use of com.intellij.psi.scope.NameHint in project intellij-community by JetBrains.
the class GroovyShellCodeFragment method processVariables.
private boolean processVariables(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state) {
ElementClassHint classHint = processor.getHint(ElementClassHint.KEY);
if (!ResolveUtil.shouldProcessMethods(classHint) && !ResolveUtil.shouldProcessProperties(classHint)) {
return true;
}
NameHint nameHint = processor.getHint(NameHint.KEY);
String name = nameHint != null ? nameHint.getName(state) : null;
if (name != null) {
final PsiVariable var = myVariables.get(name);
if (var != null) {
if (processor.execute(var, state)) {
return false;
}
}
} else {
for (PsiVariable var : myVariables.values()) {
if (!processor.execute(var, state)) {
return false;
}
}
}
return true;
}
use of com.intellij.psi.scope.NameHint in project intellij-community by JetBrains.
the class GroovyShellCodeFragment method processTypeDefinitions.
private boolean processTypeDefinitions(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state) {
ElementClassHint classHint = processor.getHint(ElementClassHint.KEY);
if (!ResolveUtil.shouldProcessClasses(classHint)) {
return true;
}
NameHint nameHint = processor.getHint(NameHint.KEY);
String name = nameHint != null ? nameHint.getName(state) : null;
if (name != null) {
final GrTypeDefinition definition = myTypeDefinitions.get(name);
if (definition != null) {
if (processor.execute(definition, state)) {
return false;
}
}
} else {
for (GrTypeDefinition definition : myTypeDefinitions.values()) {
if (!processor.execute(definition, state)) {
return false;
}
}
}
return true;
}
use of com.intellij.psi.scope.NameHint in project intellij-community by JetBrains.
the class PsiClassImplUtil method processDeclarationsInClass.
private static boolean processDeclarationsInClass(@NotNull PsiClass aClass, @NotNull final PsiScopeProcessor processor, @NotNull ResolveState state, @Nullable Set<PsiClass> visited, PsiElement last, @NotNull PsiElement place, @NotNull LanguageLevel languageLevel, boolean isRaw, @NotNull GlobalSearchScope resolveScope) {
if (last instanceof PsiTypeParameterList || last instanceof PsiModifierList && aClass.getModifierList() == last) {
return true;
}
if (visited != null && visited.contains(aClass))
return true;
PsiSubstitutor substitutor = state.get(PsiSubstitutor.KEY);
isRaw = isRaw || PsiUtil.isRawSubstitutor(aClass, substitutor);
final NameHint nameHint = processor.getHint(NameHint.KEY);
if (nameHint != null) {
String name = nameHint.getName(state);
return processCachedMembersByName(aClass, processor, state, visited, last, place, isRaw, substitutor, getValues(aClass).getValue(aClass).get(resolveScope), name, languageLevel);
}
return processDeclarationsInClassNotCached(aClass, processor, state, visited, last, place, isRaw, languageLevel, resolveScope);
}
use of com.intellij.psi.scope.NameHint in project intellij-community by JetBrains.
the class PsiClassImplUtil method processDeclarationsInClassNotCached.
private static boolean processDeclarationsInClassNotCached(@NotNull PsiClass aClass, @NotNull final PsiScopeProcessor processor, @NotNull final ResolveState state, @Nullable Set<PsiClass> visited, final PsiElement last, @NotNull final PsiElement place, final boolean isRaw, @NotNull final LanguageLevel languageLevel, @NotNull final GlobalSearchScope resolveScope) {
if (visited == null)
visited = new THashSet<>();
if (!visited.add(aClass))
return true;
processor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, aClass);
final ElementClassHint classHint = processor.getHint(ElementClassHint.KEY);
final NameHint nameHint = processor.getHint(NameHint.KEY);
if (classHint == null || classHint.shouldProcess(ElementClassHint.DeclarationKind.FIELD)) {
if (nameHint != null) {
final PsiField fieldByName = aClass.findFieldByName(nameHint.getName(state), false);
if (fieldByName != null && !processor.execute(fieldByName, state))
return false;
} else {
final PsiField[] fields = aClass.getFields();
for (final PsiField field : fields) {
if (!processor.execute(field, state))
return false;
}
}
}
PsiElementFactory factory = JavaPsiFacade.getInstance(aClass.getProject()).getElementFactory();
if (classHint == null || classHint.shouldProcess(ElementClassHint.DeclarationKind.METHOD)) {
PsiSubstitutor baseSubstitutor = state.get(PsiSubstitutor.KEY);
final PsiMethod[] methods = nameHint != null ? aClass.findMethodsByName(nameHint.getName(state), false) : aClass.getMethods();
for (final PsiMethod method : methods) {
PsiSubstitutor finalSubstitutor = checkRaw(isRaw, factory, method, baseSubstitutor);
ResolveState methodState = finalSubstitutor == baseSubstitutor ? state : state.put(PsiSubstitutor.KEY, finalSubstitutor);
if (!processor.execute(method, methodState))
return false;
}
}
if (classHint == null || classHint.shouldProcess(ElementClassHint.DeclarationKind.CLASS)) {
if (last != null && last.getContext() == aClass) {
// Parameters
final PsiTypeParameterList list = aClass.getTypeParameterList();
if (list != null && !list.processDeclarations(processor, ResolveState.initial(), last, place))
return false;
}
if (!(last instanceof PsiReferenceList) && !(last instanceof PsiModifierList)) {
// Inners
if (nameHint != null) {
final PsiClass inner = aClass.findInnerClassByName(nameHint.getName(state), false);
if (inner != null) {
if (!processor.execute(inner, state))
return false;
}
} else {
final PsiClass[] inners = aClass.getInnerClasses();
for (final PsiClass inner : inners) {
if (!processor.execute(inner, state))
return false;
}
}
}
}
if (last instanceof PsiReferenceList)
return true;
final Set<PsiClass> visited1 = visited;
return processSuperTypes(aClass, state.get(PsiSubstitutor.KEY), factory, languageLevel, resolveScope, (superClass, finalSubstitutor) -> processDeclarationsInClass(superClass, processor, state.put(PsiSubstitutor.KEY, finalSubstitutor), visited1, last, place, languageLevel, isRaw, resolveScope));
}
use of com.intellij.psi.scope.NameHint in project intellij-community by JetBrains.
the class GroovyCodeFragment method processSingleImports.
private boolean processSingleImports(PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, PsiElement place, Boolean processStatic) {
if (processStatic == null)
return processSingleImports(processor, state, lastParent, place, false) && processSingleImports(processor, state, lastParent, place, true);
NameHint nameHint = processor.getHint(NameHint.KEY);
String name = nameHint != null ? nameHint.getName(state) : null;
if (name != null) {
final GrImportStatement anImport = myPseudoImports.get(name);
if (anImport != null && processStatic == anImport.isStatic()) {
if (!anImport.processDeclarations(processor, state, lastParent, place)) {
return false;
}
}
} else {
for (GrImportStatement anImport : myPseudoImports.values()) {
if (processStatic != anImport.isStatic())
continue;
if (!anImport.processDeclarations(processor, state, lastParent, place)) {
return false;
}
}
}
return true;
}
Aggregations