Search in sources :

Example 11 with PsiModifierList

use of com.intellij.psi.PsiModifierList in project Intellij-Plugin by getgauge.

the class HookUtilTest method TestIsHookWhenNonHookAnnotation.

@Test
public void TestIsHookWhenNonHookAnnotation() throws Exception {
    PsiMethod method = mock(PsiMethod.class);
    PsiModifierList list = mock(PsiModifierList.class);
    PsiAnnotation annotation = mock(PsiAnnotation.class);
    when(annotation.getQualifiedName()).thenReturn("Unequal");
    when(list.getAnnotations()).thenReturn(new PsiAnnotation[] { annotation });
    when(method.getModifierList()).thenReturn(list);
    assertFalse(HookUtil.isHook(method));
}
Also used : PsiMethod(com.intellij.psi.PsiMethod) PsiAnnotation(com.intellij.psi.PsiAnnotation) PsiModifierList(com.intellij.psi.PsiModifierList) Test(org.junit.Test)

Example 12 with PsiModifierList

use of com.intellij.psi.PsiModifierList in project Intellij-Plugin by getgauge.

the class HookUtilTest method TestIsHook.

@Test
public void TestIsHook() throws Exception {
    PsiMethod method = mock(PsiMethod.class);
    PsiModifierList list = mock(PsiModifierList.class);
    PsiAnnotation annotation = mock(PsiAnnotation.class);
    when(annotation.getQualifiedName()).thenReturn(BeforeStep.class.getCanonicalName());
    when(list.getAnnotations()).thenReturn(new PsiAnnotation[] { annotation });
    when(method.getModifierList()).thenReturn(list);
    assertTrue(HookUtil.isHook(method));
}
Also used : BeforeStep(com.thoughtworks.gauge.BeforeStep) PsiMethod(com.intellij.psi.PsiMethod) PsiAnnotation(com.intellij.psi.PsiAnnotation) PsiModifierList(com.intellij.psi.PsiModifierList) Test(org.junit.Test)

Example 13 with PsiModifierList

use of com.intellij.psi.PsiModifierList in project smali by JesusFreke.

the class SmalideaClassDef method getAccessFlags.

@Override
public int getAccessFlags() {
    PsiModifierList modifierList = psiClass.getModifierList();
    int flags = 0;
    if (modifierList == null) {
        return flags;
    }
    if (modifierList.hasModifierProperty("public")) {
        flags |= AccessFlags.PUBLIC.getValue();
    }
    if (modifierList.hasModifierProperty("final")) {
        flags |= AccessFlags.FINAL.getValue();
    }
    if (modifierList.hasModifierProperty("abstract")) {
        flags |= AccessFlags.ABSTRACT.getValue();
    }
    if (psiClass.isInterface()) {
        flags |= AccessFlags.INTERFACE.getValue();
    }
    if (psiClass.isEnum()) {
        flags |= AccessFlags.ENUM.getValue();
    }
    if (psiClass.isAnnotationType()) {
        flags |= AccessFlags.ANNOTATION.getValue();
    }
    return flags;
}
Also used : PsiModifierList(com.intellij.psi.PsiModifierList)

Example 14 with PsiModifierList

use of com.intellij.psi.PsiModifierList in project smali by JesusFreke.

the class SmalideaField method getAccessFlags.

@Override
public int getAccessFlags() {
    if (psiField instanceof SmaliField) {
        return ((SmaliField) psiField).getModifierList().getAccessFlags();
    } else {
        int flags = 0;
        PsiModifierList modifierList = psiField.getModifierList();
        if (modifierList == null) {
            return flags;
        }
        if (modifierList.hasModifierProperty("public")) {
            flags |= AccessFlags.PUBLIC.getValue();
        } else if (modifierList.hasModifierProperty("protected")) {
            flags |= AccessFlags.PROTECTED.getValue();
        } else if (modifierList.hasModifierProperty("private")) {
            flags |= AccessFlags.PRIVATE.getValue();
        }
        if (modifierList.hasModifierProperty("static")) {
            flags |= AccessFlags.STATIC.getValue();
        }
        if (modifierList.hasModifierProperty("final")) {
            flags |= AccessFlags.FINAL.getValue();
        }
        if (modifierList.hasModifierProperty("volatile")) {
            flags |= AccessFlags.VOLATILE.getValue();
        }
        return flags;
    }
}
Also used : SmaliField(org.jf.smalidea.psi.impl.SmaliField) PsiModifierList(com.intellij.psi.PsiModifierList)

Example 15 with PsiModifierList

use of com.intellij.psi.PsiModifierList in project android by JetBrains.

the class PsiCFGField method parseModifiers.

private void parseModifiers() {
    PsiModifierList modifierList = mPsiFieldRef.getModifierList();
    modifierBits = Modifier.ParseModifierList(modifierList);
}
Also used : PsiModifierList(com.intellij.psi.PsiModifierList)

Aggregations

PsiModifierList (com.intellij.psi.PsiModifierList)24 PsiAnnotation (com.intellij.psi.PsiAnnotation)6 PsiClass (com.intellij.psi.PsiClass)6 PsiElement (com.intellij.psi.PsiElement)4 PsiMethod (com.intellij.psi.PsiMethod)4 PsiModifierListOwner (com.intellij.psi.PsiModifierListOwner)3 NotNull (org.jetbrains.annotations.NotNull)3 Test (org.junit.Test)3 Module (com.intellij.openapi.module.Module)2 Project (com.intellij.openapi.project.Project)2 PsiMember (com.intellij.psi.PsiMember)2 LaunchOptionConfigurableContext (com.android.tools.idea.run.editor.LaunchOptionConfigurableContext)1 AddAnnotationFix (com.intellij.codeInsight.intention.AddAnnotationFix)1 LookupElementBuilder (com.intellij.codeInsight.lookup.LookupElementBuilder)1 LookupImpl (com.intellij.codeInsight.lookup.impl.LookupImpl)1 ProblemDescriptor (com.intellij.codeInspection.ProblemDescriptor)1 ClassFilter (com.intellij.ide.util.ClassFilter)1 TreeClassChooser (com.intellij.ide.util.TreeClassChooser)1 Document (com.intellij.openapi.editor.Document)1 Editor (com.intellij.openapi.editor.Editor)1