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


Java CompletionProposal.getRelevance方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.CompletionProposal.getRelevance方法的典型用法代码示例。如果您正苦于以下问题:Java CompletionProposal.getRelevance方法的具体用法?Java CompletionProposal.getRelevance怎么用?Java CompletionProposal.getRelevance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.CompletionProposal的用法示例。


在下文中一共展示了CompletionProposal.getRelevance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: acceptPotentialMethodDeclaration

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
private void acceptPotentialMethodDeclaration(CompletionProposal proposal) {
	try {
		IJavaElement enclosingElement = null;
		if (response.getContext().isExtended()) {
			enclosingElement = response.getContext().getEnclosingElement();
		} else if (unit != null) {
			// kept for backward compatibility: CU is not reconciled at this moment, information is missing (bug 70005)
			enclosingElement = unit.getElementAt(proposal.getCompletionLocation() + 1);
		}
		if (enclosingElement == null) {
			return;
		}
		IType type = (IType) enclosingElement.getAncestor(IJavaElement.TYPE);
		if (type != null) {
			String prefix = String.valueOf(proposal.getName());
			int completionStart = proposal.getReplaceStart();
			int completionEnd = proposal.getReplaceEnd();
			int relevance = proposal.getRelevance() + 6;

			GetterSetterCompletionProposal.evaluateProposals(type, prefix, completionStart, completionEnd - completionStart, relevance, proposals);
		}
	} catch (CoreException e) {
		JavaLanguageServerPlugin.logException("Accept potential method declaration failed for completion ", e);
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:26,代码来源:CompletionProposalRequestor.java

示例2: computeSortText

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
/**
 * Computes the relevance for a given <code>CompletionProposal</code>.
 *
 * @param proposal the proposal to compute the relevance for
 * @return the relevance for <code>proposal</code>
 */
public static String computeSortText(CompletionProposal proposal) {
	final int baseRelevance= proposal.getRelevance() * 16;
	switch (proposal.getKind()) {
	case CompletionProposal.LABEL_REF:
		return convertRelevance( baseRelevance + 1);
	case CompletionProposal.KEYWORD:
		return convertRelevance(baseRelevance + 2);
	case CompletionProposal.TYPE_REF:
	case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
	case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION:
		return convertRelevance(baseRelevance + 3);
	case CompletionProposal.METHOD_REF:
	case CompletionProposal.CONSTRUCTOR_INVOCATION:
	case CompletionProposal.METHOD_NAME_REFERENCE:
	case CompletionProposal.METHOD_DECLARATION:
	case CompletionProposal.ANNOTATION_ATTRIBUTE_REF:
	case CompletionProposal.POTENTIAL_METHOD_DECLARATION:
		return convertRelevance(baseRelevance + 4);
	case CompletionProposal.FIELD_REF:
		return convertRelevance(baseRelevance + 5);
	case CompletionProposal.LOCAL_VARIABLE_REF:
	case CompletionProposal.VARIABLE_DECLARATION:
		return convertRelevance(baseRelevance + 6);
	case CompletionProposal.PACKAGE_REF://intentional fall-through
	default:
		return convertRelevance(baseRelevance);
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:35,代码来源:SortTextHelper.java

示例3: computeRelevance

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
/**
 * Computes the relevance for a given <code>CompletionProposal</code>.
 *
 * <p>Subclasses may replace, but usually should not need to.
 *
 * @param proposal the proposal to compute the relevance for
 * @return the relevance for <code>proposal</code>
 */
protected int computeRelevance(CompletionProposal proposal) {
  final int baseRelevance = proposal.getRelevance() * 16;
  switch (proposal.getKind()) {
    case CompletionProposal.PACKAGE_REF:
      return baseRelevance + 0;
    case CompletionProposal.LABEL_REF:
      return baseRelevance + 1;
    case CompletionProposal.KEYWORD:
      return baseRelevance + 2;
    case CompletionProposal.TYPE_REF:
    case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
    case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION:
      return baseRelevance + 3;
    case CompletionProposal.METHOD_REF:
    case CompletionProposal.CONSTRUCTOR_INVOCATION:
    case CompletionProposal.METHOD_NAME_REFERENCE:
    case CompletionProposal.METHOD_DECLARATION:
    case CompletionProposal.ANNOTATION_ATTRIBUTE_REF:
      return baseRelevance + 4;
    case CompletionProposal.POTENTIAL_METHOD_DECLARATION:
      return baseRelevance + 4 /* + 99 */;
    case CompletionProposal.FIELD_REF:
      return baseRelevance + 5;
    case CompletionProposal.LOCAL_VARIABLE_REF:
    case CompletionProposal.VARIABLE_DECLARATION:
      return baseRelevance + 6;
    default:
      return baseRelevance;
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:39,代码来源:CompletionProposalCollector.java

示例4: SimpleJavaCompletionProposal

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
public SimpleJavaCompletionProposal(CompletionProposal proposal,
		JavaContentAssistInvocationContext context, Image img) {
	if (CompletionProposal.METHOD_REF == proposal.getKind()) {
		this.replacementString = String.valueOf(proposal.getName());
	} else {
		this.replacementString = String.valueOf(proposal.getCompletion());
	}
	this.displayString = context.getLabelProvider().createLabel(proposal);
	this.relevance = proposal.getRelevance();
	this.image = img;
}
 
开发者ID:aleksandr-m,项目名称:strutsclipse,代码行数:12,代码来源:SimpleJavaCompletionProposal.java


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