@Override public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) { processor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, this); PsiElement[] decls = getDeclaredElements(); for (PsiElement decl : decls) { if (decl != lastParent) { if (!processor.execute(decl, state)) return false; } else { final ElementClassHint hint = processor.getHint(ElementClassHint.KEY); if (lastParent instanceof PsiClass) { if (hint == null || hint.shouldProcess(ElementClassHint.DeclarationKind.CLASS)) { if (!processor.execute(lastParent, state)) return false; } } } } return true; }
@Override public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) { ElementClassHint classHint = processor.getHint(ElementClassHint.KEY); if (classHint == null || classHint.shouldProcess(ElementClassHint.DeclarationKind.CLASS)) { final NameHint nameHint = processor.getHint(NameHint.KEY); final String name = nameHint != null ? nameHint.getName(state) : null; //"pseudo-imports" if (name != null) { PsiClass imported = myPseudoImports.get(name); if (imported != null) { if (!processor.execute(imported, state)) return false; } } else { for (PsiClass aClass : myPseudoImports.values()) { if (!processor.execute(aClass, state)) return false; } } if (myContext == null) { if (!JavaResolveUtil.processImplicitlyImportedPackages(processor, state, place, getManager())) return false; } } return true; }
private static boolean processDeclarationsInMethodLike(@NotNull final PsiElement element, @NotNull final PsiScopeProcessor processor, @NotNull final ResolveState state, @NotNull final PsiElement place, final boolean fromBody, @Nullable final PsiTypeParameterList typeParameterList, @NotNull final PsiParameterList parameterList) { processor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, element); if (typeParameterList != null) { final ElementClassHint hint = processor.getHint(ElementClassHint.KEY); if (hint == null || hint.shouldProcess(ElementClassHint.DeclarationKind.CLASS)) { if (!typeParameterList.processDeclarations(processor, state, null, place)) return false; } } if (fromBody) { final PsiParameter[] parameters = parameterList.getParameters(); for (PsiParameter parameter : parameters) { if (!processor.execute(parameter, state)) return false; } } return true; }
public static boolean processDeclarationsInResourceList(@NotNull final PsiResourceList resourceList, @NotNull final PsiScopeProcessor processor, @NotNull final ResolveState state, final PsiElement lastParent) { final ElementClassHint hint = processor.getHint(ElementClassHint.KEY); if (hint != null && !hint.shouldProcess(ElementClassHint.DeclarationKind.VARIABLE)) return true; final List<PsiResourceVariable> resources = resourceList.getResourceVariables(); @SuppressWarnings({"SuspiciousMethodCalls"}) final int lastIdx = lastParent instanceof PsiResourceVariable ? resources.indexOf(lastParent) : resources.size(); for (int i = 0; i < lastIdx; i++) { if (!processor.execute(resources.get(i), state)) return false; } return true; }
@Override public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) { processor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, this); final ElementClassHint classHint = processor.getHint(ElementClassHint.KEY); if(classHint == null || classHint.shouldProcess(ElementClassHint.DeclarationKind.CLASS)) { final PsiClass[] classes = getClasses(); for(PsiClass aClass : classes) { if(!processor.execute(aClass, state)) { return false; } } } return true; }
public static boolean processDeclarationsInResourceList(@NotNull final PsiResourceList resourceList, @NotNull final PsiScopeProcessor processor, @NotNull final ResolveState state, final PsiElement lastParent) { final ElementClassHint hint = processor.getHint(ElementClassHint.KEY); if(hint != null && !hint.shouldProcess(ElementClassHint.DeclarationKind.VARIABLE)) { return true; } for(PsiResourceListElement resource : resourceList) { if(resource == lastParent) { break; } if(resource instanceof PsiResourceVariable && !processor.execute(resource, state)) { return false; } } return true; }
@Override public <T> T getHint(@NotNull Key<T> hintKey) { if(hintKey == ElementClassHint.KEY) { //noinspection unchecked return (T) this; } if(hintKey == JavaCompletionHints.NAME_FILTER) { //noinspection unchecked return (T) myMatcher; } return super.getHint(hintKey); }
@Override public void handleEmptyContext(PsiScopeProcessor processor, PsiElement position) { final ElementClassHint hint = processor.getHint(ElementClassHint.KEY); if(position == null) { return; } if(hint == null || hint.shouldProcess(ElementClassHint.DeclarationKind.PACKAGE) || hint.shouldProcess(ElementClassHint.DeclarationKind.CLASS)) { final List<PsiElement> cachedPackages = getDefaultPackages(position.getProject()); for(final PsiElement psiPackage : cachedPackages) { if(!processor.execute(psiPackage, ResolveState.initial())) { return; } } } }
@Override public <T> T getHint(@NotNull Key<T> hintKey) { if (hintKey == ElementClassHint.KEY) { return (T)this; } return super.getHint(hintKey); }
@Override public <T> T getHint(@NotNull Key<T> hintKey) { if (hintKey == ElementClassHint.KEY) { return (T)this; } if (hintKey == NameHint.KEY && myNameHint != null) { return (T)this; } return null; }
@Override public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) { processor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, this); final ElementClassHint classHint = processor.getHint(ElementClassHint.KEY); if (classHint == null || classHint.shouldProcess(ElementClassHint.DeclarationKind.CLASS)) { final PsiClass[] classes = getClasses(); for (PsiClass aClass : classes) { if (!processor.execute(aClass, state)) return false; } } return true; }
@Override public <T> T getHint(@NotNull Key<T> hintKey) { if (hintKey == ElementClassHint.KEY) { //noinspection unchecked return (T)this; } return null; }
@Override public <T> T getHint(@NotNull Key<T> hintKey) { if (hintKey == ElementClassHint.KEY) { //noinspection unchecked return (T)this; } return super.getHint(hintKey); }
@Override public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) { processor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, this); if (lastParent == null) { // Parent element should not see our vars return true; } Couple<Set<String>> pair = buildMaps(); boolean conflict = pair == null; final Set<String> classesSet = conflict ? null : pair.getFirst(); final Set<String> variablesSet = conflict ? null : pair.getSecond(); final NameHint hint = processor.getHint(NameHint.KEY); if (hint != null && !conflict) { final ElementClassHint elementClassHint = processor.getHint(ElementClassHint.KEY); final String name = hint.getName(state); if ((elementClassHint == null || elementClassHint.shouldProcess(ElementClassHint.DeclarationKind.CLASS)) && classesSet.contains(name)) { return PsiScopesUtil.walkChildrenScopes(this, processor, state, lastParent, place); } if ((elementClassHint == null || elementClassHint.shouldProcess(ElementClassHint.DeclarationKind.VARIABLE)) && variablesSet.contains(name)) { return PsiScopesUtil.walkChildrenScopes(this, processor, state, lastParent, place); } } else { return PsiScopesUtil.walkChildrenScopes(this, processor, state, lastParent, place); } return true; }
public static boolean processDeclarationsInResourceList(@NotNull final PsiResourceList resourceList, @NotNull final PsiScopeProcessor processor, @NotNull final ResolveState state, final PsiElement lastParent) { final ElementClassHint hint = processor.getHint(ElementClassHint.KEY); if (hint != null && !hint.shouldProcess(ElementClassHint.DeclarationKind.VARIABLE)) return true; for (PsiResourceListElement resource : resourceList) { if (resource == lastParent) break; if (resource instanceof PsiResourceVariable && !processor.execute(resource, state)) return false; } return true; }
@Override public <T> T getHint(@NotNull Key<T> hintKey) { if (hintKey == ElementClassHint.KEY) { //noinspection unchecked return (T)this; } if (hintKey == JavaCompletionHints.NAME_FILTER) { //noinspection unchecked return (T)myMatcher; } return super.getHint(hintKey); }
@Override public void handleEmptyContext(PsiScopeProcessor processor, PsiElement position) { final ElementClassHint hint = processor.getHint(ElementClassHint.KEY); if (position == null) return; if (hint == null || hint.shouldProcess(ElementClassHint.DeclarationKind.PACKAGE) || hint.shouldProcess(ElementClassHint.DeclarationKind.CLASS)) { final List<PsiElement> cachedPackages = getDefaultPackages(position.getProject()); for (final PsiElement psiPackage : cachedPackages) { if (!processor.execute(psiPackage, ResolveState.initial())) return; } } }
@Override @SuppressWarnings({"unchecked"}) public <T> T getHint(@NotNull Key<T> hintKey) { if (NameHint.KEY == hintKey && myName != null) { return (T)this; } if ((ClassHint.KEY == hintKey || ElementClassHint.KEY == hintKey) && myResolveTargetKinds != null) { return (T)this; } return null; }
@Override public <T> T getHint(@NotNull Key<T> hintKey) { if ((NameHint.KEY == hintKey && myNameHint != null) || ClassHint.KEY == hintKey || ElementClassHint.KEY == hintKey) { //noinspection unchecked return (T) this; } return null; }
public <T> T getHint(@NotNull Key<T> hintKey) { if (hintKey == ElementClassHint.KEY) { return (T)this; } if (hintKey == NameHint.KEY && myNameHint != null) { return (T)this; } return null; }
@Override public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) { processor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, this); if (lastParent == null) { // Parent element should not see our vars return true; } Pair<Set<String>, Set<String>> pair = buildMaps(); boolean conflict = pair == null; final Set<String> classesSet = conflict ? null : pair.getFirst(); final Set<String> variablesSet = conflict ? null : pair.getSecond(); final NameHint hint = processor.getHint(NameHint.KEY); if (hint != null && !conflict) { final ElementClassHint elementClassHint = processor.getHint(ElementClassHint.KEY); final String name = hint.getName(state); if ((elementClassHint == null || elementClassHint.shouldProcess(ElementClassHint.DeclarationKind.CLASS)) && classesSet.contains(name)) { return PsiScopesUtil.walkChildrenScopes(this, processor, state, lastParent, place); } if ((elementClassHint == null || elementClassHint.shouldProcess(ElementClassHint.DeclarationKind.VARIABLE)) && variablesSet.contains(name)) { return PsiScopesUtil.walkChildrenScopes(this, processor, state, lastParent, place); } } else { return PsiScopesUtil.walkChildrenScopes(this, processor, state, lastParent, place); } return true; }
@Override public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) { if (isEnum()) { String name = getName(); if (name != null) { try { final NameHint nameHint = processor.getHint(NameHint.KEY); final ElementClassHint classHint = processor.getHint(ElementClassHint.KEY); if (nameHint == null || VALUES_METHOD.equals(nameHint.getName(state))) { if (classHint == null || classHint.shouldProcess(ElementClassHint.DeclarationKind.METHOD)) { if (!processor.execute(getValuesMethod(), ResolveState.initial())) return false; } } if (nameHint == null || VALUE_OF_METHOD.equals(nameHint.getName(state))) { if (classHint == null || classHint.shouldProcess(ElementClassHint.DeclarationKind.METHOD)) { if (!processor.execute(getValueOfMethod(), ResolveState.initial())) return false; } } } catch (IncorrectOperationException e) { LOG.error(e); } } } return PsiClassImplUtil.processDeclarationsInClass(this, processor, state, null, lastParent, place, PsiUtil.getLanguageLevel(place), false); }
@SuppressWarnings({"unchecked"}) public <T> T getHint(@NotNull Key<T> hintKey) { if ((NameHint.KEY == hintKey && myName != null) || ClassHint.KEY == hintKey || ElementClassHint.KEY == hintKey) { return (T)this; } return null; }
private boolean processImpl(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) { processor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, this); if(lastParent == null) { // Parent element should not see our vars return true; } Pair<Set<String>, Set<String>> pair = buildMaps(); boolean conflict = pair == null; final Set<String> classesSet = conflict ? null : pair.getFirst(); final Set<String> variablesSet = conflict ? null : pair.getSecond(); final NameHint hint = processor.getHint(NameHint.KEY); if(hint != null && !conflict) { final ElementClassHint elementClassHint = processor.getHint(ElementClassHint.KEY); final String name = hint.getName(state); if((elementClassHint == null || elementClassHint.shouldProcess(ElementClassHint.DeclarationKind.CLASS)) && classesSet.contains(name)) { return PsiScopesUtil.walkChildrenScopes(this, processor, state, lastParent, place); } if((elementClassHint == null || elementClassHint.shouldProcess(ElementClassHint.DeclarationKind.VARIABLE)) && variablesSet.contains(name)) { return PsiScopesUtil.walkChildrenScopes(this, processor, state, lastParent, place); } } else { return PsiScopesUtil.walkChildrenScopes(this, processor, state, lastParent, place); } return true; }
@Override public <T> T getHint(@NotNull Key<T> hintKey) { if(hintKey == ElementClassHint.KEY) { return (T) this; } return super.getHint(hintKey); }