• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java LookupElementWeigher类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.codeInsight.lookup.LookupElementWeigher的典型用法代码示例。如果您正苦于以下问题:Java LookupElementWeigher类的具体用法?Java LookupElementWeigher怎么用?Java LookupElementWeigher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LookupElementWeigher类属于com.intellij.codeInsight.lookup包,在下文中一共展示了LookupElementWeigher类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: updateResult

import com.intellij.codeInsight.lookup.LookupElementWeigher; //导入依赖的package包/类
@NotNull
private CompletionResultSet updateResult(CompletionParameters params, @NotNull CompletionResultSet result) {
    CompletionResultSet completionResultSet = result;
    CompletionSorter completionSorter =
            CompletionSorter.defaultSorter(params, completionResultSet.getPrefixMatcher())
                    .weighBefore("priority", new LookupElementWeigher("GraphQLWeight") {
                        @NotNull
                        @Override
                        public Comparable weigh(@NotNull LookupElement element) {
                            return new LookupElementComparator(element);
                        }
                    });
    completionResultSet = completionResultSet.withRelevanceSorter(completionSorter);
    return completionResultSet;
}
 
开发者ID:jimkyndemeyer,项目名称:js-graphql-intellij-plugin,代码行数:16,代码来源:JSGraphQLCompletionContributor.java


示例2: recursiveSorter

import com.intellij.codeInsight.lookup.LookupElementWeigher; //导入依赖的package包/类
@Nullable
@RequiredReadAction
private static LookupElementWeigher recursiveSorter(CompletionParameters completionParameters, CompletionResultSet result)
{
	PsiElement position = completionParameters.getPosition();


	Set<PsiElement> elements = new THashSet<>();

	PsiElement argumentListOwner = PsiTreeUtil.getContextOfType(position, CSharpCallArgumentListOwner.class, DotNetVariable.class);
	if(argumentListOwner instanceof CSharpMethodCallExpressionImpl)
	{
		ContainerUtil.addIfNotNull(elements, ((CSharpMethodCallExpressionImpl) argumentListOwner).resolveToCallable());
	}
	else if(argumentListOwner instanceof DotNetVariable)
	{
		elements.add(argumentListOwner);
	}

	List<CSharpForeachStatementImpl> foreachStatements = SyntaxTraverser.psiApi().parents(position).filter(CSharpForeachStatementImpl.class).addAllTo(new ArrayList<>());
	for(CSharpForeachStatementImpl foreachStatement : foreachStatements)
	{
		DotNetExpression iterableExpression = foreachStatement.getIterableExpression();
		if(iterableExpression instanceof CSharpReferenceExpression)
		{
			ContainerUtil.addIfNotNull(elements, ((CSharpReferenceExpression) iterableExpression).resolve());
		}
	}

	if(!elements.isEmpty())
	{
		return new CSharpRecursiveGuardWeigher(elements);
	}
	return null;
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:36,代码来源:CSharpCompletionSorting.java


示例3: modifyResultSet

import com.intellij.codeInsight.lookup.LookupElementWeigher; //导入依赖的package包/类
@RequiredReadAction
public static CompletionResultSet modifyResultSet(CompletionParameters completionParameters, CompletionResultSet result)
{
	CompletionSorter sorter = CompletionSorter.defaultSorter(completionParameters, result.getPrefixMatcher());
	List<LookupElementWeigher> afterStats = new ArrayList<>();

	afterStats.add(new KindSorter());
	ContainerUtil.addIfNotNull(afterStats, recursiveSorter(completionParameters, result));

	List<LookupElementWeigher> afterProximity = new ArrayList<>();

	List<ExpectedTypeInfo> expectedTypeRefs = ExpectedTypeVisitor.findExpectedTypeRefs(completionParameters.getPosition());
	if(expectedTypeRefs.isEmpty())
	{
		expectedTypeRefs = ExpectedTypeVisitor.findExpectedTypeRefs(completionParameters.getPosition().getParent());
	}

	if(!expectedTypeRefs.isEmpty())
	{
		afterProximity.add(new ExpectedNameSorter(expectedTypeRefs));
		afterProximity.add(new PreferShorter(expectedTypeRefs));
	}

	afterProximity.add(new NotImportedSorter());

	sorter = sorter.weighAfter("stats", afterStats.toArray(new LookupElementWeigher[afterStats.size()]));
	sorter = sorter.weighAfter("proximity", afterProximity.toArray(new LookupElementWeigher[afterProximity.size()]));
	result = result.withRelevanceSorter(sorter);
	return result;
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:31,代码来源:CSharpCompletionSorting.java


示例4: recursion

import com.intellij.codeInsight.lookup.LookupElementWeigher; //导入依赖的package包/类
@Nullable
private static LookupElementWeigher recursion(CompletionParameters parameters, final ExpectedTypeInfo[] expectedInfos)
{
	final PsiElement position = parameters.getPosition();
	final PsiMethodCallExpression expression = PsiTreeUtil.getParentOfType(position, PsiMethodCallExpression.class, true, PsiClass.class);
	final PsiReferenceExpression reference = expression != null ? expression.getMethodExpression() : PsiTreeUtil.getParentOfType(position, PsiReferenceExpression.class);
	if(reference == null)
	{
		return null;
	}

	return new RecursionWeigher(position, parameters.getCompletionType(), reference, expression, expectedInfos);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:14,代码来源:JavaCompletionSorting.java


示例5: addJavaSorting

import com.intellij.codeInsight.lookup.LookupElementWeigher; //导入依赖的package包/类
public static CompletionResultSet addJavaSorting(final CompletionParameters parameters, CompletionResultSet result)
{
	PsiElement position = parameters.getPosition();
	ExpectedTypeInfo[] expectedTypes = getExpectedTypesWithDfa(parameters, position);
	CompletionType type = parameters.getCompletionType();
	boolean smart = type == CompletionType.SMART;
	boolean afterNew = JavaSmartCompletionContributor.AFTER_NEW.accepts(position);

	List<LookupElementWeigher> afterProximity = new ArrayList<>();
	afterProximity.add(new PreferContainingSameWords(expectedTypes));
	afterProximity.add(new PreferShorter(expectedTypes));

	CompletionSorter sorter = CompletionSorter.defaultSorter(parameters, result.getPrefixMatcher());
	if(!smart && afterNew)
	{
		sorter = sorter.weighBefore("liftShorter", new PreferExpected(true, expectedTypes, position));
	}
	else if(PsiTreeUtil.getParentOfType(position, PsiReferenceList.class) == null)
	{
		sorter = ((CompletionSorterImpl) sorter).withClassifier("liftShorterClasses", true, new LiftShorterClasses(position));
	}
	if(smart)
	{
		sorter = sorter.weighAfter("priority", new PreferDefaultTypeWeigher(expectedTypes, parameters));
	}

	final PreferMostUsedWeigher preferMostUsedWeigher = PreferMostUsedWeigher.create(position);
	List<LookupElementWeigher> afterStats = ContainerUtil.newArrayList();
	afterStats.add(new PreferByKindWeigher(type, position, expectedTypes));
	if(!smart)
	{
		if(preferMostUsedWeigher == null)
		{
			ContainerUtil.addIfNotNull(afterStats, preferStatics(position, expectedTypes));
		}
		if(!afterNew)
		{
			afterStats.add(new PreferExpected(false, expectedTypes, position));
		}
	}
	if(preferMostUsedWeigher != null)
	{
		afterStats.add(preferMostUsedWeigher);
		ContainerUtil.addIfNotNull(afterStats, preferStatics(position, expectedTypes));
	}
	ContainerUtil.addIfNotNull(afterStats, recursion(parameters, expectedTypes));
	afterStats.add(new PreferSimilarlyEnding(expectedTypes));
	if(ContainerUtil.or(expectedTypes, info -> !info.getType().equals(PsiType.VOID)))
	{
		afterStats.add(new PreferNonGeneric());
	}
	Collections.addAll(afterStats, new PreferAccessible(position), new PreferSimple());

	sorter = sorter.weighAfter("stats", afterStats.toArray(new LookupElementWeigher[afterStats.size()]));
	sorter = sorter.weighAfter("proximity", afterProximity.toArray(new LookupElementWeigher[afterProximity.size()]));
	return result.withRelevanceSorter(sorter);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:58,代码来源:JavaCompletionSorting.java


示例6: preferStatics

import com.intellij.codeInsight.lookup.LookupElementWeigher; //导入依赖的package包/类
@Nullable
private static LookupElementWeigher preferStatics(PsiElement position, final ExpectedTypeInfo[] infos)
{
	if(PsiTreeUtil.getParentOfType(position, PsiDocComment.class) != null)
	{
		return null;
	}
	if(position.getParent() instanceof PsiReferenceExpression)
	{
		final PsiReferenceExpression refExpr = (PsiReferenceExpression) position.getParent();
		final PsiElement qualifier = refExpr.getQualifier();
		if(qualifier == null)
		{
			return null;
		}
		if(!(qualifier instanceof PsiJavaCodeReferenceElement) || !(((PsiJavaCodeReferenceElement) qualifier).resolve() instanceof PsiClass))
		{
			return null;
		}
	}

	return new LookupElementWeigher("statics")
	{
		@NotNull
		@Override
		public Comparable weigh(@NotNull LookupElement element)
		{
			final Object o = element.getObject();
			if(o instanceof PsiKeyword)
			{
				return -3;
			}
			if(!(o instanceof PsiMember) || element.getUserData(JavaGenerateMemberCompletionContributor.GENERATE_ELEMENT) != null)
			{
				return 0;
			}

			if(((PsiMember) o).hasModifierProperty(PsiModifier.STATIC) && !hasNonVoid(infos))
			{
				if(o instanceof PsiMethod)
				{
					return -5;
				}
				if(o instanceof PsiField)
				{
					return -4;
				}
			}

			if(o instanceof PsiClass)
			{
				return -3;
			}

			//instance method or field
			return -5;
		}
	};
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:60,代码来源:JavaCompletionSorting.java


示例7: weighBefore

import com.intellij.codeInsight.lookup.LookupElementWeigher; //导入依赖的package包/类
public abstract CompletionSorter weighBefore(@NotNull String beforeId, LookupElementWeigher... weighers); 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:2,代码来源:CompletionSorter.java


示例8: weighAfter

import com.intellij.codeInsight.lookup.LookupElementWeigher; //导入依赖的package包/类
public abstract CompletionSorter weighAfter(@NotNull String afterId, LookupElementWeigher... weighers); 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:2,代码来源:CompletionSorter.java


示例9: weigh

import com.intellij.codeInsight.lookup.LookupElementWeigher; //导入依赖的package包/类
public abstract CompletionSorter weigh(LookupElementWeigher weigher); 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:2,代码来源:CompletionSorter.java


示例10: weighBefore

import com.intellij.codeInsight.lookup.LookupElementWeigher; //导入依赖的package包/类
public abstract CompletionSorter weighBefore(@Nonnull String beforeId, LookupElementWeigher... weighers); 
开发者ID:consulo,项目名称:consulo,代码行数:2,代码来源:CompletionSorter.java


示例11: weighAfter

import com.intellij.codeInsight.lookup.LookupElementWeigher; //导入依赖的package包/类
public abstract CompletionSorter weighAfter(@Nonnull String afterId, LookupElementWeigher... weighers); 
开发者ID:consulo,项目名称:consulo,代码行数:2,代码来源:CompletionSorter.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LocalVariableConversion类代码示例发布时间:2022-05-23
下一篇:
Java XAxisRenderer类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap