use of com.intellij.psi.scope.PsiScopeProcessor in project intellij-community by JetBrains.
the class GrUnresolvedAccessChecker method doCheckContainer.
private static boolean doCheckContainer(final PsiMethod patternMethod, PsiElement container, final String name) {
final Ref<Boolean> result = new Ref<>(false);
PsiScopeProcessor processor = new GrScopeProcessorWithHints(name, ClassHint.RESOLVE_KINDS_METHOD) {
@Override
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
if (element instanceof PsiMethod && name.equals(((PsiMethod) element).getName()) && patternMethod.getParameterList().getParametersCount() == ((PsiMethod) element).getParameterList().getParametersCount() && isNotFromGroovyObject((PsiMethod) element)) {
result.set(true);
return false;
}
return true;
}
};
ResolveUtil.treeWalkUp(container, processor, true);
return result.get();
}
use of com.intellij.psi.scope.PsiScopeProcessor in project intellij-community by JetBrains.
the class GroovyFileImpl method processCachedDeclarations.
private static boolean processCachedDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, MostlySingularMultiMap<String, ResultWithContext> cache) {
for (PsiScopeProcessor each : GroovyResolverProcessor.allProcessors(processor)) {
String name = ResolveUtil.getNameHint(each);
Processor<ResultWithContext> cacheProcessor = res -> each.execute(res.getElement(), state.put(ClassHint.RESOLVE_CONTEXT, res.getFileContext()));
boolean result = name != null ? cache.processForKey(name, cacheProcessor) : cache.processAllValues(cacheProcessor);
if (!result)
return false;
}
return true;
}
use of com.intellij.psi.scope.PsiScopeProcessor in project intellij-community by JetBrains.
the class GrImportStatementImpl method processSingleStaticImport.
private boolean processSingleStaticImport(@NotNull final PsiScopeProcessor processor, @NotNull ResolveState state, @NotNull String importedName, @Nullable PsiElement lastParent, @NotNull PsiElement place) {
final GrCodeReferenceElement ref = getImportReference();
if (ref == null)
return true;
PsiClass clazz = resolveQualifier();
if (clazz == null)
return true;
state = state.put(ClassHint.RESOLVE_CONTEXT, this);
final String refName = ref.getReferenceName();
for (PsiScopeProcessor each : GroovyResolverProcessor.allProcessors(processor)) {
if (!doProcessSingleStaticImport(each, state, importedName, lastParent, place, clazz, refName))
return false;
}
return true;
}
use of com.intellij.psi.scope.PsiScopeProcessor in project intellij-community by JetBrains.
the class GrImportStatementImpl method processDeclarationsForMultipleElements.
private boolean processDeclarationsForMultipleElements(@NotNull final PsiScopeProcessor processor, @Nullable PsiElement lastParent, @NotNull PsiElement place, @NotNull ResolveState state) {
GrCodeReferenceElement ref = getImportReference();
if (ref == null)
return true;
if (isStatic()) {
final PsiElement resolved = ref.resolve();
if (resolved instanceof PsiClass) {
state = state.put(ClassHint.RESOLVE_CONTEXT, this);
final PsiClass clazz = (PsiClass) resolved;
for (final PsiScopeProcessor each : GroovyResolverProcessor.allProcessors(processor)) {
if (!clazz.processDeclarations(new DelegatingScopeProcessor(each) {
@Override
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
if (element instanceof PsiMember && ((PsiMember) element).hasModifierProperty(PsiModifier.STATIC)) {
return super.execute(element, state);
}
return true;
}
}, state, lastParent, place))
return false;
}
}
} else {
if (ResolveUtil.shouldProcessClasses(processor.getHint(ElementClassHint.KEY))) {
String qName = PsiUtil.getQualifiedReferenceText(ref);
if (qName != null) {
PsiPackage aPackage = JavaPsiFacade.getInstance(getProject()).findPackage(qName);
if (aPackage != null && !((GroovyFile) getContainingFile()).getPackageName().equals(aPackage.getQualifiedName())) {
state = state.put(ClassHint.RESOLVE_CONTEXT, this);
if (!aPackage.processDeclarations(processor, state, lastParent, place))
return false;
}
}
}
}
return true;
}
use of com.intellij.psi.scope.PsiScopeProcessor in project intellij-community by JetBrains.
the class PatternEditorContextMembersProvider method processDynamicElements.
@Override
public void processDynamicElements(@NotNull PsiType qualifierType, @NotNull final PsiScopeProcessor scopeProcessor, @NotNull final PsiElement place, @NotNull final ResolveState state) {
final PsiFile file = place.getContainingFile().getOriginalFile();
final BaseInjection injection = file.getUserData(BaseInjection.INJECTION_KEY);
Processor<PsiElement> processor = element -> element.processDeclarations(scopeProcessor, state, null, place);
if (injection == null) {
processDevContext(file, processor);
} else {
processPatternContext(injection, file, processor);
}
}
Aggregations