use of com.intellij.psi.impl.source.resolve.SymbolCollectingProcessor.ResultWithContext 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.impl.source.resolve.SymbolCollectingProcessor.ResultWithContext in project intellij-community by JetBrains.
the class GroovyFileImpl method buildDeclarationCache.
@NotNull
private MostlySingularMultiMap<String, ResultWithContext> buildDeclarationCache() {
MostlySingularMultiMap<String, ResultWithContext> results = new MostlySingularMultiMap<>();
processDeclarationsNoGuess(new BaseScopeProcessor() {
@Override
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
if (element instanceof PsiNamedElement) {
PsiElement context = state.get(ClassHint.RESOLVE_CONTEXT);
String name = getDeclarationName((PsiNamedElement) element, context);
if (name != null) {
results.add(name, new ResultWithContext((PsiNamedElement) element, context));
}
}
return true;
}
private String getDeclarationName(@NotNull PsiNamedElement element, @Nullable PsiElement context) {
String name = context instanceof GrImportStatement ? ((GrImportStatement) context).getImportedName() : null;
return name != null ? name : element.getName();
}
}, ResolveState.initial(), null, this);
return results;
}
Aggregations