Search in sources :

Example 16 with PsiModifierList

use of com.intellij.psi.PsiModifierList in project intellij-community by JetBrains.

the class GrTypeDefinitionRangeHandler method getDeclarationRange.

@NotNull
@Override
public TextRange getDeclarationRange(@NotNull GrTypeDefinition aClass) {
    if (aClass instanceof GrAnonymousClassDefinition) {
        GrNewExpression call = (GrNewExpression) aClass.getParent();
        int startOffset = call.getTextRange().getStartOffset();
        int endOffset = call.getArgumentList().getTextRange().getEndOffset();
        return new TextRange(startOffset, endOffset);
    } else {
        final PsiModifierList modifierList = aClass.getModifierList();
        int startOffset = modifierList == null ? aClass.getTextRange().getStartOffset() : modifierList.getTextRange().getStartOffset();
        final GrImplementsClause implementsList = aClass.getImplementsClause();
        int endOffset = implementsList == null ? aClass.getTextRange().getEndOffset() : implementsList.getTextRange().getEndOffset();
        return new TextRange(startOffset, endOffset);
    }
}
Also used : GrNewExpression(org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrNewExpression) GrImplementsClause(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrImplementsClause) GrAnonymousClassDefinition(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrAnonymousClassDefinition) TextRange(com.intellij.openapi.util.TextRange) PsiModifierList(com.intellij.psi.PsiModifierList) NotNull(org.jetbrains.annotations.NotNull)

Example 17 with PsiModifierList

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

the class JavaScriptInterfaceDetector method isJavaScriptAnnotated.

private static boolean isJavaScriptAnnotated(PsiClass clz) {
    while (clz != null) {
        PsiModifierList modifierList = clz.getModifierList();
        if (modifierList != null && modifierList.findAnnotation(JAVASCRIPT_INTERFACE_CLS) != null) {
            return true;
        }
        for (PsiMethod method : clz.getMethods()) {
            if (method.getModifierList().findAnnotation(JAVASCRIPT_INTERFACE_CLS) != null) {
                return true;
            }
        }
        clz = clz.getSuperClass();
    }
    return false;
}
Also used : PsiMethod(com.intellij.psi.PsiMethod) PsiModifierList(com.intellij.psi.PsiModifierList)

Example 18 with PsiModifierList

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

the class AndroidLayoutXmlTagNameProvider method isDeclarationDeprecated.

private static boolean isDeclarationDeprecated(@Nullable PsiElement declaration) {
    if (!(declaration instanceof PsiClass)) {
        return false;
    }
    final PsiClass aClass = (PsiClass) declaration;
    final PsiModifierList modifierList = aClass.getModifierList();
    if (modifierList == null) {
        return false;
    }
    return modifierList.findAnnotation("java.lang.Deprecated") != null;
}
Also used : PsiClass(com.intellij.psi.PsiClass) PsiModifierList(com.intellij.psi.PsiModifierList)

Example 19 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)

Example 20 with PsiModifierList

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

the class AndroidActivityAliasCompletionContributor method fillCompletionVariants.

@Override
public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) {
    if (parameters.getCompletionType() != CompletionType.BASIC) {
        return;
    }
    final Editor editor = parameters.getEditor();
    LaunchOptionConfigurableContext context = editor.getUserData(LaunchOptionConfigurableContext.KEY);
    if (context == null) {
        return;
    }
    final Module module = context.getModule();
    if (module == null) {
        return;
    }
    final AndroidFacet facet = AndroidFacet.getInstance(module);
    if (facet == null) {
        return;
    }
    final String prefix = parameters.getEditor().getDocument().getText().substring(0, parameters.getOffset());
    result = result.withPrefixMatcher(prefix);
    final PsiClass activityClass = JavaPsiFacade.getInstance(module.getProject()).findClass(AndroidUtils.ACTIVITY_BASE_CLASS_NAME, module.getModuleWithDependenciesAndLibrariesScope(false));
    if (activityClass != null) {
        final CompletionResultSet finalResult = result;
        ClassInheritorsSearch.search(activityClass, module.getModuleWithDependenciesScope(), true, true, false).forEach(new Processor<PsiClass>() {

            @Override
            public boolean process(PsiClass psiClass) {
                final PsiModifierList modifierList = psiClass.getModifierList();
                if (modifierList != null && modifierList.hasModifierProperty(PsiModifier.PUBLIC) && !modifierList.hasModifierProperty(PsiModifier.ABSTRACT)) {
                    final String qName = psiClass.getQualifiedName();
                    if (qName != null && qName.length() > 0) {
                        finalResult.addElement(JavaLookupElementBuilder.forClass(psiClass, qName));
                    }
                }
                return true;
            }
        });
    }
    final Set<String> aliases = collectActivityAliases(facet);
    if (aliases.size() > 0) {
        for (String alias : aliases) {
            LookupElementBuilder element = LookupElementBuilder.create(alias);
            final String shortName = StringUtilRt.getShortName(alias);
            if (!shortName.equals(alias)) {
                element = element.withLookupString(shortName);
            }
            result.addElement(element);
        }
    }
    result.stopHere();
}
Also used : LaunchOptionConfigurableContext(com.android.tools.idea.run.editor.LaunchOptionConfigurableContext) PsiClass(com.intellij.psi.PsiClass) LookupElementBuilder(com.intellij.codeInsight.lookup.LookupElementBuilder) Editor(com.intellij.openapi.editor.Editor) Module(com.intellij.openapi.module.Module) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) PsiModifierList(com.intellij.psi.PsiModifierList)

Aggregations

PsiModifierList (com.intellij.psi.PsiModifierList)21 PsiClass (com.intellij.psi.PsiClass)6 PsiAnnotation (com.intellij.psi.PsiAnnotation)4 PsiElement (com.intellij.psi.PsiElement)4 PsiModifierListOwner (com.intellij.psi.PsiModifierListOwner)3 NotNull (org.jetbrains.annotations.NotNull)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 TextRange (com.intellij.openapi.util.TextRange)1 JavaPsiFacade (com.intellij.psi.JavaPsiFacade)1