Search in sources :

Example 56 with PsiAnnotation

use of com.intellij.psi.PsiAnnotation in project azure-tools-for-java by Microsoft.

the class FunctionUtils method generateConfigurations.

private static Map<String, FunctionConfiguration> generateConfigurations(final PsiMethod[] methods) throws AzureExecutionException {
    final Map<String, FunctionConfiguration> configMap = new HashMap<>();
    for (final PsiMethod method : methods) {
        final PsiAnnotation annotation = AnnotationUtil.findAnnotation(method, FunctionUtils.AZURE_FUNCTION_ANNOTATION_CLASS);
        final String functionName = AnnotationUtil.getDeclaredStringAttributeValue(annotation, "value");
        configMap.put(functionName, generateConfiguration(method));
    }
    return configMap;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) PsiMethod(com.intellij.psi.PsiMethod) FunctionConfiguration(com.microsoft.azure.toolkit.lib.legacy.function.configurations.FunctionConfiguration) PsiAnnotation(com.intellij.psi.PsiAnnotation)

Example 57 with PsiAnnotation

use of com.intellij.psi.PsiAnnotation in project intellij by bazelbuild.

the class TestSizeAnnotationMap method getTestSize.

@Nullable
public static TestSize getTestSize(PsiClass psiClass) {
    PsiModifierList psiModifierList = psiClass.getModifierList();
    if (psiModifierList == null) {
        return null;
    }
    PsiAnnotation[] annotations = psiModifierList.getAnnotations();
    TestSize testSize = getTestSize(annotations);
    if (testSize == null) {
        return null;
    }
    return testSize;
}
Also used : PsiAnnotation(com.intellij.psi.PsiAnnotation) TestSize(com.google.idea.blaze.base.dependencies.TestSize) PsiModifierList(com.intellij.psi.PsiModifierList) Nullable(javax.annotation.Nullable)

Example 58 with PsiAnnotation

use of com.intellij.psi.PsiAnnotation in project intellij by bazelbuild.

the class TestSizeAnnotationMap method getTestSize.

@Nullable
public static TestSize getTestSize(PsiMethod psiMethod) {
    PsiAnnotation[] annotations = psiMethod.getModifierList().getAnnotations();
    TestSize testSize = getTestSize(annotations);
    if (testSize != null) {
        return testSize;
    }
    return getTestSize(psiMethod.getContainingClass());
}
Also used : PsiAnnotation(com.intellij.psi.PsiAnnotation) TestSize(com.google.idea.blaze.base.dependencies.TestSize) Nullable(javax.annotation.Nullable)

Example 59 with PsiAnnotation

use of com.intellij.psi.PsiAnnotation in project qi4j-sdk by Qi4j.

the class AbstractInjectionAnnotationDeclarationOnFieldAndConstructorInspection method checkMethod.

@Override
public final ProblemDescriptor[] checkMethod(@NotNull PsiMethod method, @NotNull InspectionManager manager, boolean isOnTheFly) {
    PsiParameterList parameterList = method.getParameterList();
    PsiParameter[] parameters = parameterList.getParameters();
    if (method.isConstructor()) {
        List<ProblemDescriptor> problems = new LinkedList<ProblemDescriptor>();
        for (PsiParameter parameter : parameters) {
            PsiAnnotation annotation = getAnnotationToCheck(parameter);
            if (annotation != null) {
                ProblemDescriptor[] descriptors = verifyAnnotationDeclaredCorrectly(parameter, annotation, manager);
                if (descriptors != null) {
                    problems.addAll(asList(descriptors));
                }
            }
        }
        return problems.toArray(new ProblemDescriptor[problems.size()]);
    } else {
        List<ProblemDescriptor> problems = new LinkedList<ProblemDescriptor>();
        for (PsiParameter parameter : parameters) {
            PsiAnnotation annotationToCheck = getAnnotationToCheck(parameter);
            if (annotationToCheck != null) {
                String message = getInjectionAnnotationValidDeclarationMessage();
                AbstractFix removeAnnotationFix = createRemoveAnnotationFix(annotationToCheck);
                ProblemDescriptor problemDescriptor = manager.createProblemDescriptor(annotationToCheck, message, removeAnnotationFix, GENERIC_ERROR_OR_WARNING);
                problems.add(problemDescriptor);
            }
        }
        return problems.toArray(new ProblemDescriptor[problems.size()]);
    }
}
Also used : PsiParameter(com.intellij.psi.PsiParameter) ProblemDescriptor(com.intellij.codeInspection.ProblemDescriptor) AbstractFix(org.qi4j.ide.plugin.idea.common.inspections.AbstractFix) PsiParameterList(com.intellij.psi.PsiParameterList) PsiAnnotation(com.intellij.psi.PsiAnnotation) LinkedList(java.util.LinkedList)

Example 60 with PsiAnnotation

use of com.intellij.psi.PsiAnnotation in project qi4j-sdk by Qi4j.

the class ReplaceWithStructureAnnotation method applyFix.

public final void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
    PsiAnnotation structureAnnotation = createStructureAnnotation(project, annotation);
    annotation.replace(structureAnnotation);
}
Also used : PsiAnnotation(com.intellij.psi.PsiAnnotation)

Aggregations

PsiAnnotation (com.intellij.psi.PsiAnnotation)61 PsiModifierList (com.intellij.psi.PsiModifierList)18 PsiAnnotationMemberValue (com.intellij.psi.PsiAnnotationMemberValue)14 PsiMethod (com.intellij.psi.PsiMethod)14 NotNull (org.jetbrains.annotations.NotNull)13 Project (com.intellij.openapi.project.Project)12 PsiClass (com.intellij.psi.PsiClass)11 PsiElement (com.intellij.psi.PsiElement)9 MockProblemDescriptor (com.intellij.testFramework.MockProblemDescriptor)6 ProblemDescriptor (com.intellij.codeInspection.ProblemDescriptor)5 PsiParameter (com.intellij.psi.PsiParameter)5 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)5 Nullable (org.jetbrains.annotations.Nullable)5 PsiParameterList (com.intellij.psi.PsiParameterList)4 TestSize (com.google.idea.blaze.base.dependencies.TestSize)3 PsiJavaCodeReferenceElement (com.intellij.psi.PsiJavaCodeReferenceElement)3 PsiNameValuePair (com.intellij.psi.PsiNameValuePair)3 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 Nullable (javax.annotation.Nullable)3