当前位置: 首页>>代码示例>>Java>>正文


Java AllClassesGetter类代码示例

本文整理汇总了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);
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:48,代码来源:CodeInsightUtil.java


注:本文中的com.intellij.codeInsight.completion.AllClassesGetter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。