當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。