本文整理汇总了Java中com.intellij.codeInsight.completion.AllClassesGetter类的典型用法代码示例。如果您正苦于以下问题:Java AllClassesGetter类的具体用法?Java AllClassesGetter怎么用?Java AllClassesGetter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AllClassesGetter类属于com.intellij.codeInsight.completion包,在下文中一共展示了AllClassesGetter类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processSubTypes
import com.intellij.codeInsight.completion.AllClassesGetter; //导入依赖的package包/类
public static void processSubTypes(PsiType psiType, final PsiElement context, boolean getRawSubtypes, @NotNull final PrefixMatcher matcher, Consumer<PsiType> consumer)
{
int arrayDim = psiType.getArrayDimensions();
psiType = psiType.getDeepComponentType();
if(!(psiType instanceof PsiClassType))
{
return;
}
PsiClassType baseType = JavaCompletionUtil.originalize((PsiClassType) psiType);
PsiClassType.ClassResolveResult baseResult = baseType.resolveGenerics();
PsiClass baseClass = baseResult.getElement();
PsiSubstitutor baseSubstitutor = baseResult.getSubstitutor();
if(baseClass == null)
{
return;
}
GlobalSearchScope scope = context.getResolveScope();
Processor<PsiClass> inheritorsProcessor = createInheritorsProcessor(context, baseType, arrayDim, getRawSubtypes, consumer, baseClass, baseSubstitutor);
addContextTypeArguments(context, baseType, inheritorsProcessor);
if(baseClass.hasModifierProperty(PsiModifier.FINAL))
{
return;
}
if(matcher.getPrefix().length() > 2)
{
JBTreeTraverser<PsiClass> traverser = new JBTreeTraverser<>(c -> Arrays.asList(c.getInnerClasses()));
AllClassesGetter.processJavaClasses(matcher, context.getProject(), scope, psiClass ->
{
Iterable<PsiClass> inheritors = traverser.withRoot(psiClass).filter(c -> c.isInheritor(baseClass, true));
return ContainerUtil.process(inheritors, inheritorsProcessor);
});
}
else
{
Query<PsiClass> baseQuery = ClassInheritorsSearch.search(baseClass, scope, true, true, false);
Query<PsiClass> query = new FilteredQuery<>(baseQuery, psiClass -> !(psiClass instanceof PsiTypeParameter) && ContainerUtil.exists(JavaCompletionUtil.getAllLookupStrings(psiClass),
matcher::prefixMatches));
query.forEach(inheritorsProcessor);
}
}