use of com.intellij.psi.scope.processor.FilterScopeProcessor in project intellij-community by JetBrains.
the class PsiMethodReferenceExpressionImpl method processVariants.
@Override
public void processVariants(@NotNull final PsiScopeProcessor processor) {
final FilterScopeProcessor proc = new FilterScopeProcessor(ElementClassFilter.METHOD, processor);
PsiScopesUtil.resolveAndWalk(proc, this, null, true);
}
use of com.intellij.psi.scope.processor.FilterScopeProcessor in project intellij-community by JetBrains.
the class PsiImplUtil method getReferenceVariantsByFilter.
@NotNull
public static Object[] getReferenceVariantsByFilter(@NotNull PsiJavaCodeReferenceElement reference, @NotNull ElementFilter filter) {
FilterScopeProcessor processor = new FilterScopeProcessor(filter);
PsiScopesUtil.resolveAndWalk(processor, reference, null, true);
return processor.getResults().toArray();
}
use of com.intellij.psi.scope.processor.FilterScopeProcessor in project intellij-community by JetBrains.
the class PsiJavaCodeReferenceElementImpl method processVariants.
@Override
public void processVariants(@NotNull final PsiScopeProcessor processor) {
final OrFilter filter = new OrFilter();
if (isInCode() && !(getParent() instanceof PsiImportStatement) && !(getParent() instanceof PsiReferenceList)) {
filter.addFilter(new AndFilter(ElementClassFilter.METHOD, new NotFilter(new ConstructorFilter())));
filter.addFilter(ElementClassFilter.VARIABLE);
}
switch(getKind(getContainingFile())) {
case CLASS_OR_PACKAGE_NAME_KIND:
filter.addFilter(ElementClassFilter.CLASS);
filter.addFilter(ElementClassFilter.PACKAGE_FILTER);
break;
case CLASS_NAME_KIND:
filter.addFilter(ElementClassFilter.CLASS);
if (isQualified()) {
filter.addFilter(ElementClassFilter.PACKAGE_FILTER);
}
break;
case PACKAGE_NAME_KIND:
filter.addFilter(ElementClassFilter.PACKAGE_FILTER);
break;
case CLASS_FQ_NAME_KIND:
case CLASS_FQ_OR_PACKAGE_NAME_KIND:
filter.addFilter(ElementClassFilter.PACKAGE_FILTER);
if (isQualified()) {
filter.addFilter(ElementClassFilter.CLASS);
}
break;
case CLASS_IN_QUALIFIED_NEW_KIND:
final PsiElement parent = getParent();
if (parent instanceof PsiNewExpression) {
PsiExpression qualifier = ((PsiNewExpression) parent).getQualifier();
assert qualifier != null : parent;
PsiType type = qualifier.getType();
PsiClass aClass = PsiUtil.resolveClassInType(type);
if (aClass != null) {
aClass.processDeclarations(new FilterScopeProcessor(new AndFilter(ElementClassFilter.CLASS, new ModifierFilter(PsiModifier.STATIC, false)), processor), ResolveState.initial(), null, this);
}
}
return;
default:
throw new RuntimeException("Unknown reference type");
}
final FilterScopeProcessor proc = new FilterScopeProcessor(filter, processor);
PsiScopesUtil.resolveAndWalk(proc, this, null, true);
}
use of com.intellij.psi.scope.processor.FilterScopeProcessor in project intellij-community by JetBrains.
the class PsiImportStaticReferenceElementImpl method processVariants.
@Override
public void processVariants(@NotNull PsiScopeProcessor processor) {
FilterScopeProcessor proc = new FilterScopeProcessor(new ClassFilter(PsiModifierListOwner.class), processor);
PsiScopesUtil.resolveAndWalk(proc, this, null, true);
}
use of com.intellij.psi.scope.processor.FilterScopeProcessor in project intellij-community by JetBrains.
the class MembersGetter method processMembers.
public void processMembers(final Consumer<LookupElement> results, @Nullable final PsiClass where, final boolean acceptMethods, final boolean searchInheritors) {
if (where == null || isPrimitiveClass(where))
return;
final boolean searchFactoryMethods = searchInheritors && !CommonClassNames.JAVA_LANG_OBJECT.equals(where.getQualifiedName()) && !isPrimitiveClass(where);
final Project project = myPlace.getProject();
final GlobalSearchScope scope = myPlace.getResolveScope();
final PsiClassType baseType = JavaPsiFacade.getElementFactory(project).createType(where);
Consumer<PsiType> consumer = psiType -> {
PsiClass psiClass = PsiUtil.resolveClassInType(psiType);
if (psiClass == null) {
return;
}
psiClass = CompletionUtil.getOriginalOrSelf(psiClass);
if (mayProcessMembers(psiClass)) {
final FilterScopeProcessor<PsiElement> declProcessor = new FilterScopeProcessor<>(TrueFilter.INSTANCE);
psiClass.processDeclarations(declProcessor, ResolveState.initial(), null, myPlace);
doProcessMembers(acceptMethods, results, psiType == baseType, declProcessor.getResults());
String name = psiClass.getName();
if (name != null && searchFactoryMethods) {
Collection<PsiMember> factoryMethods = JavaStaticMemberTypeIndex.getInstance().getStaticMembers(name, project, scope);
doProcessMembers(acceptMethods, results, false, factoryMethods);
}
}
};
consumer.consume(baseType);
if (searchInheritors && !CommonClassNames.JAVA_LANG_OBJECT.equals(where.getQualifiedName())) {
CodeInsightUtil.processSubTypes(baseType, myPlace, true, PrefixMatcher.ALWAYS_TRUE, consumer);
}
}
Aggregations