Search in sources :

Example 41 with PsiModifierList

use of com.intellij.psi.PsiModifierList in project google-cloud-intellij by GoogleCloudPlatform.

the class RestSignatureInspectionTest method initializePsiMethod.

private void initializePsiMethod(String methodName, String httpMethodValue, String pathValue) {
    PsiAnnotationMemberValue mockAnnotationMemberValue1 = mock(PsiAnnotationMemberValue.class);
    when(mockAnnotationMemberValue1.getText()).thenReturn(httpMethodValue);
    PsiAnnotationMemberValue mockAnnotationMemberValue2 = mock(PsiAnnotationMemberValue.class);
    when(mockAnnotationMemberValue2.getText()).thenReturn(pathValue);
    PsiAnnotation mockAnnotation = mock(PsiAnnotation.class);
    when(mockAnnotation.getQualifiedName()).thenReturn(GctConstants.APP_ENGINE_ANNOTATION_API_METHOD);
    when(mockAnnotation.findAttributeValue("httpMethod")).thenReturn(mockAnnotationMemberValue1);
    when(mockAnnotation.findAttributeValue("path")).thenReturn(mockAnnotationMemberValue2);
    PsiAnnotation[] mockAnnotationsArray = { mockAnnotation };
    PsiModifierList mockModifierList = mock(PsiModifierList.class);
    when(mockModifierList.getAnnotations()).thenReturn(mockAnnotationsArray);
    mockPsiMethod = mock(PsiMethod.class);
    when(mockPsiMethod.getModifierList()).thenReturn(mockModifierList);
    when(mockPsiMethod.getName()).thenReturn(methodName);
    when(mockPsiMethod.getContainingClass()).thenReturn(mockPsiClass);
    PsiParameterList mockParameterList = mock(PsiParameterList.class);
    when(mockParameterList.getParameters()).thenReturn(new PsiParameter[0]);
    when(mockPsiMethod.getParameterList()).thenReturn(mockParameterList);
}
Also used : PsiMethod(com.intellij.psi.PsiMethod) PsiParameterList(com.intellij.psi.PsiParameterList) PsiAnnotation(com.intellij.psi.PsiAnnotation) PsiAnnotationMemberValue(com.intellij.psi.PsiAnnotationMemberValue) PsiModifierList(com.intellij.psi.PsiModifierList)

Example 42 with PsiModifierList

use of com.intellij.psi.PsiModifierList 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 43 with PsiModifierList

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

the class GuiceImplicitUsageProvider method isImplicitUsage.

@Override
public boolean isImplicitUsage(PsiElement element) {
    if (!(element instanceof PsiMethod)) {
        return false;
    }
    PsiMethod method = (PsiMethod) element;
    if (method.hasModifierProperty(PsiModifier.PRIVATE)) {
        return false;
    }
    PsiModifierList modifiers = method.getModifierList();
    return IMPLICIT_METHOD_USAGE_ANNOTATIONS.stream().anyMatch(s -> modifiers.findAnnotation(s) != null);
}
Also used : PsiMethod(com.intellij.psi.PsiMethod) PsiModifierList(com.intellij.psi.PsiModifierList)

Aggregations

PsiModifierList (com.intellij.psi.PsiModifierList)43 PsiAnnotation (com.intellij.psi.PsiAnnotation)18 PsiClass (com.intellij.psi.PsiClass)13 PsiMethod (com.intellij.psi.PsiMethod)12 PsiAnnotationMemberValue (com.intellij.psi.PsiAnnotationMemberValue)6 PsiElement (com.intellij.psi.PsiElement)6 NotNull (org.jetbrains.annotations.NotNull)6 Project (com.intellij.openapi.project.Project)5 Module (com.intellij.openapi.module.Module)3 PsiModifierListOwner (com.intellij.psi.PsiModifierListOwner)3 PsiParameter (com.intellij.psi.PsiParameter)3 Test (org.junit.Test)3 ProblemDescriptor (com.intellij.codeInspection.ProblemDescriptor)2 ClassFilter (com.intellij.ide.util.ClassFilter)2 TreeClassChooser (com.intellij.ide.util.TreeClassChooser)2 Document (com.intellij.openapi.editor.Document)2 JavaPsiFacade (com.intellij.psi.JavaPsiFacade)2 PsiFile (com.intellij.psi.PsiFile)2 PsiMember (com.intellij.psi.PsiMember)2 PsiNameValuePair (com.intellij.psi.PsiNameValuePair)2