Search in sources :

Example 6 with NameHint

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

the class GdkMethodHolder method processMethods.

public boolean processMethods(PsiScopeProcessor processor, @NotNull ResolveState state, PsiType qualifierType, Project project) {
    if (qualifierType == null)
        return true;
    NameHint nameHint = processor.getHint(NameHint.KEY);
    String name = nameHint == null ? null : nameHint.getName(state);
    final MultiMap<String, PsiMethod> map = name != null ? myOriginalMethodsByNameAndType.get(name) : myOriginalMethodByType.getValue();
    if (map.isEmpty()) {
        return true;
    }
    for (String superType : ResolveUtil.getAllSuperTypes(qualifierType, project)) {
        for (PsiMethod method : map.get(superType)) {
            String info = GdkMethodUtil.generateOriginInfo(method);
            GrGdkMethod gdk = GrGdkMethodImpl.createGdkMethod(method, myStatic, info);
            if (!processor.execute(gdk, state)) {
                return false;
            }
        }
    }
    return true;
}
Also used : GrGdkMethod(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrGdkMethod) NameHint(com.intellij.psi.scope.NameHint)

Example 7 with NameHint

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

the class GroovyFileImpl method processDeclarationsNoGuess.

private boolean processDeclarationsNoGuess(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, @Nullable PsiElement lastParent, @NotNull PsiElement place) {
    ElementClassHint classHint = processor.getHint(ElementClassHint.KEY);
    if (myContext != null) {
        if (ResolveUtil.shouldProcessProperties(classHint)) {
            if (!processChildrenScopes(processor, state, lastParent, place))
                return false;
        }
        return true;
    }
    boolean processClasses = ResolveUtil.shouldProcessClasses(classHint);
    GrImportStatement[] importStatements = getImportStatements();
    if (!processImports(processor, state, lastParent, place, importStatements, ImportKind.ALIAS, false))
        return false;
    GroovyScriptClass scriptClass = getScriptClass();
    if (scriptClass != null && StringUtil.isJavaIdentifier(scriptClass.getName())) {
        if (!(lastParent instanceof GrTypeDefinition)) {
            if (!ResolveUtil.processClassDeclarations(scriptClass, processor, state, lastParent, place))
                return false;
        }
        if (processClasses) {
            if (!ResolveUtil.processElement(processor, scriptClass, state))
                return false;
        }
    }
    if (processClasses) {
        for (GrTypeDefinition definition : getTypeDefinitions()) {
            if (!ResolveUtil.processElement(processor, definition, state))
                return false;
        }
    }
    if (ResolveUtil.shouldProcessProperties(classHint)) {
        if (!processChildrenScopes(processor, state, lastParent, place))
            return false;
    }
    if (!processImports(processor, state, lastParent, place, importStatements, ImportKind.ALIAS, true))
        return false;
    if (!processImports(processor, state, lastParent, place, importStatements, ImportKind.SIMPLE, null))
        return false;
    if (!processDeclarationsInPackage(processor, state, lastParent, place))
        return false;
    if (!processImports(processor, state, lastParent, place, importStatements, ImportKind.ON_DEMAND, null))
        return false;
    if (!ImplicitImportsKt.processImplicitImports(processor, state, lastParent, place, this))
        return false;
    if (ResolveUtil.shouldProcessPackages(classHint)) {
        NameHint nameHint = processor.getHint(NameHint.KEY);
        String expectedName = nameHint != null ? nameHint.getName(state) : null;
        final JavaPsiFacade facade = JavaPsiFacade.getInstance(getProject());
        if (expectedName != null) {
            final PsiPackage pkg = facade.findPackage(expectedName);
            if (pkg != null && !processor.execute(pkg, state)) {
                return false;
            }
        } else {
            PsiPackage defaultPackage = facade.findPackage("");
            if (defaultPackage != null) {
                for (PsiPackage subPackage : defaultPackage.getSubPackages(getResolveScope())) {
                    if (!ResolveUtil.processElement(processor, subPackage, state))
                        return false;
                }
            }
        }
    }
    if (ResolveUtil.shouldProcessProperties(classHint)) {
        if (lastParent != null && !(lastParent instanceof GrTypeDefinition) && scriptClass != null) {
            if (!ResolveUtil.processElement(processor, getSyntheticArgsParameter(), state))
                return false;
        }
    }
    return true;
}
Also used : GroovyScriptClass(org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass) GrTypeDefinition(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition) ElementClassHint(com.intellij.psi.scope.ElementClassHint) NameHint(com.intellij.psi.scope.NameHint) GrImportStatement(org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement)

Example 8 with NameHint

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

the class GrEnumTypeDefinitionImpl method processDeclarations.

@Override
public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, @Nullable PsiElement lastParent, @NotNull PsiElement place) {
    if (ResolveUtil.shouldProcessMethods(processor.getHint(ElementClassHint.KEY))) {
        final NameHint nameHint = processor.getHint(NameHint.KEY);
        final String name = nameHint == null ? null : nameHint.getName(state);
        for (PsiMethod method : getDefEnumMethods()) {
            if (name == null || name.equals(method.getName())) {
                if (!processor.execute(method, state))
                    return false;
            }
        }
    }
    return super.processDeclarations(processor, state, lastParent, place);
}
Also used : NameHint(com.intellij.psi.scope.NameHint)

Example 9 with NameHint

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

the class GrImportStatementImpl method processDeclarationsForSingleElement.

private boolean processDeclarationsForSingleElement(@NotNull PsiScopeProcessor processor, @Nullable PsiElement lastParent, @NotNull PsiElement place, @NotNull ResolveState state) {
    String name = getImportedName();
    if (name == null)
        return true;
    if (isStatic()) {
        return processSingleStaticImport(processor, state, name, lastParent, place);
    }
    NameHint nameHint = processor.getHint(NameHint.KEY);
    if (nameHint == null || name.equals(nameHint.getName(state))) {
        return processSingleClassImport(processor, state);
    }
    return true;
}
Also used : NameHint(com.intellij.psi.scope.NameHint)

Example 10 with NameHint

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

the class ResolveUtil method processElement.

public static boolean processElement(@NotNull PsiScopeProcessor processor, @NotNull PsiNamedElement namedElement, @NotNull ResolveState state) {
    NameHint nameHint = processor.getHint(NameHint.KEY);
    String name = nameHint == null ? null : nameHint.getName(state);
    if (name == null || name.equals(namedElement.getName())) {
        return processor.execute(namedElement, state);
    }
    return true;
}
Also used : NameHint(com.intellij.psi.scope.NameHint)

Aggregations

NameHint (com.intellij.psi.scope.NameHint)16 ElementClassHint (com.intellij.psi.scope.ElementClassHint)10 THashSet (gnu.trove.THashSet)2 GrTypeDefinition (org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition)2 GrImportStatement (org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement)2 PsiDataBindingResourceItem (com.android.tools.idea.res.PsiDataBindingResourceItem)1 Module (com.intellij.openapi.module.Module)1 LanguageLevel (com.intellij.pom.java.LanguageLevel)1 CandidateInfo (com.intellij.psi.infos.CandidateInfo)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 IElementType (com.intellij.psi.tree.IElementType)1 Set (java.util.Set)1 GrModifierList (org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList)1 GrAnnotation (org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation)1 GrReferenceList (org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrReferenceList)1 GrTypeDefinitionBody (org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinitionBody)1 GrGdkMethod (org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrGdkMethod)1 GrCodeReferenceElement (org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement)1 GroovyScriptClass (org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass)1