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


Java CompletionProposal.getKind方法代码示例

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


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

示例1: createParameterList

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
/**
 * Creates and returns a parameter list of the given method or type proposal suitable for
 * display. The list does not include parentheses. The lower bound of parameter types is
 * returned.
 * <p>
 * Examples:
 *
 * <pre>
 *   &quot;void method(int i, String s)&quot; -&gt; &quot;int i, String s&quot;
 *   &quot;? extends Number method(java.lang.String s, ? super Number n)&quot; -&gt; &quot;String s, Number n&quot;
 * </pre>
 *
 * </p>
 *
 * @param proposal the proposal to create the parameter list for
 * @return the list of comma-separated parameters suitable for display
 */
public StringBuilder createParameterList(CompletionProposal proposal) {
	int kind= proposal.getKind();
	switch (kind) {
	case CompletionProposal.METHOD_REF:
	case CompletionProposal.CONSTRUCTOR_INVOCATION:
		return appendUnboundedParameterList(new StringBuilder(), proposal);
	case CompletionProposal.TYPE_REF:
	case CompletionProposal.JAVADOC_TYPE_REF:
		return appendTypeParameterList(new StringBuilder(), proposal);
	case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
	case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION:
		return appendUnboundedParameterList(new StringBuilder(), proposal);
	default:
		Assert.isLegal(false);
		return null; // dummy
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:35,代码来源:CompletionProposalDescriptionProvider.java

示例2: appendMethodNameReplacement

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
private void appendMethodNameReplacement(StringBuilder buffer, CompletionProposal proposal) {
	if (proposal.getKind() == CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER) {
		String coreCompletion = String.valueOf(proposal.getCompletion());
		if (client.isCompletionSnippetsSupported()) {
			coreCompletion = CompletionUtils.sanitizeCompletion(coreCompletion);
		}
		//			String lineDelimiter = TextUtilities.getDefaultLineDelimiter(getTextViewer().getDocument());
		//			String replacement= CodeFormatterUtil.format(CodeFormatter.K_EXPRESSION, coreCompletion, 0, lineDelimiter, fInvocationContext.getProject());
		//			buffer.append(replacement.substring(0, replacement.lastIndexOf('.') + 1));
		buffer.append(coreCompletion);
	}

	if (proposal.getKind() != CompletionProposal.CONSTRUCTOR_INVOCATION) {
		String str = new String(proposal.getName());
		if (client.isCompletionSnippetsSupported()) {
			str = CompletionUtils.sanitizeCompletion(str);
		}
		buffer.append(str);
	}

}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:22,代码来源:CompletionProposalReplacementProvider.java

示例3: createProposal

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
protected ICompletionProposal createProposal(CompletionProposal javaProposal) {
  String completion = String.valueOf(javaProposal.getCompletion());
  int kind = javaProposal.getKind();
  if (kind == CompletionProposal.TYPE_REF) {
    // Make sure it is fully qualified
    completion = JavaContentAssistUtilities.getFullyQualifiedTypeName(javaProposal);
  }

  if (forceFullyQualifiedFieldNames
      && (kind == CompletionProposal.FIELD_IMPORT || kind == CompletionProposal.FIELD_REF)) {
    char[] decSig = javaProposal.getDeclarationSignature();
    if (decSig != null && decSig.length > 2) {
      // declaration signatures for objects are like Ljava.lang.String;, so lop off first
      // and last chars
      completion = new String(decSig, 1, decSig.length - 2) + "."
          + new String(javaProposal.getCompletion());
      completion = completion.replace('$', '.');
    }
  }

  ICompletionProposal jdtCompletionProposal = JavaContentAssistUtilities.getJavaCompletionProposal(
      javaProposal, context, javaProject);
  return ReplacementCompletionProposal.fromExistingCompletionProposal(completion,
      replaceOffset, replaceLength, jdtCompletionProposal);
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:26,代码来源:ProposalGeneratingCompletionRequestor.java

示例4: createJavaCompletionProposal

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
@Override
protected IJavaCompletionProposal createJavaCompletionProposal(
    CompletionProposal proposal) {
  IJavaCompletionProposal defaultProposal = super.createJavaCompletionProposal(proposal);

  // For members of inner classes, there's a bug in the JDT which results in
  // the declaration signature of the proposal missing the outer classes, so
  // we have to manually set the signature instead.
  if (proposal.getKind() == CompletionProposal.METHOD_REF
      || proposal.getKind() == CompletionProposal.FIELD_REF) {
    char[] typeSignature = Signature.createTypeSignature(qualifiedTypeName,
        true).toCharArray();
    proposal.setDeclarationSignature(typeSignature);
  }

  return JsniCompletionProposal.create(defaultProposal, proposal,
      getCompilationUnit().getJavaProject(), refOffset, refLength);
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:19,代码来源:JsniCompletionProposalCollector.java

示例5: isSupportingRequiredProposals

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
/**
 * Tells whether required proposals are supported by this proposal.
 *
 * @return <code>true</code> if required proposals are supported by this proposal
 * @see org.eclipse.jdt.core.CompletionProposal#getRequiredProposals()
 * @since 3.3
 */
protected boolean isSupportingRequiredProposals() {
  if (fInvocationContext == null) return false;

  ProposalInfo proposalInfo = getProposalInfo();
  if (!(proposalInfo instanceof MemberProposalInfo
      || proposalInfo instanceof AnonymousTypeProposalInfo)) return false;

  CompletionProposal proposal = ((MemberProposalInfo) proposalInfo).fProposal;
  return proposal != null
      && (proposal.getKind() == CompletionProposal.METHOD_REF
          || proposal.getKind() == CompletionProposal.FIELD_REF
          || proposal.getKind() == CompletionProposal.TYPE_REF
          || proposal.getKind() == CompletionProposal.CONSTRUCTOR_INVOCATION
          || proposal.getKind() == CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION);
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:AbstractJavaCompletionProposal.java

示例6: createMethodProposalDescription

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
/**
 * Creates and returns the method signature suitable for display.
 *
 * @param proposal
 *            the proposal to create the description for
 * @return the string of method signature suitable for display
 */
public StringBuilder createMethodProposalDescription(CompletionProposal proposal) {
	int kind = proposal.getKind();
	StringBuilder description = new StringBuilder();
	switch (kind) {
		case CompletionProposal.METHOD_REF:
		case CompletionProposal.METHOD_NAME_REFERENCE:
		case CompletionProposal.POTENTIAL_METHOD_DECLARATION:
		case CompletionProposal.CONSTRUCTOR_INVOCATION:

			// method name
			description.append(proposal.getName());

			// parameters
			description.append('(');
			appendUnboundedParameterList(description, proposal);
			description.append(')');

			// return type
			if (!proposal.isConstructor()) {
				// TODO remove SignatureUtil.fix83600 call when bugs are fixed
				char[] returnType = createTypeDisplayName(SignatureUtil.getUpperBound(Signature.getReturnType(SignatureUtil.fix83600(proposal.getSignature()))));
				description.append(RETURN_TYPE_SEPARATOR);
				description.append(returnType);
			}
	}
	return description; // dummy
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:35,代码来源:CompletionProposalDescriptionProvider.java

示例7: accept

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
@Override
public void accept(CompletionProposal proposal) {
	if (!isIgnored(proposal.getKind())) {
		if (proposal.getKind() == CompletionProposal.POTENTIAL_METHOD_DECLARATION) {
			acceptPotentialMethodDeclaration(proposal);
		} else {
			if (proposal.getKind() == CompletionProposal.PACKAGE_REF && unit.getParent() != null && String.valueOf(proposal.getCompletion()).equals(unit.getParent().getElementName())) {
				// Hacky way to boost relevance of current package, for package completions, until
				// https://bugs.eclipse.org/518140 is fixed
				proposal.setRelevance(proposal.getRelevance() + 1);
			}
			proposals.add(proposal);
		}
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:16,代码来源:CompletionProposalRequestor.java

示例8: 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

示例9: isSupportingRequiredProposals

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
private boolean isSupportingRequiredProposals(CompletionProposal proposal) {
	return proposal != null
			&& (proposal.getKind() == CompletionProposal.METHOD_REF
			|| proposal.getKind() == CompletionProposal.FIELD_REF
			|| proposal.getKind() == CompletionProposal.TYPE_REF
					|| proposal.getKind() == CompletionProposal.CONSTRUCTOR_INVOCATION || proposal.getKind() == CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION
					|| proposal.getKind() == CompletionProposal.ANONYMOUS_CLASS_DECLARATION);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:9,代码来源:CompletionProposalReplacementProvider.java

示例10: hasArgumentList

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
protected boolean hasArgumentList(CompletionProposal proposal) {
	if (CompletionProposal.METHOD_NAME_REFERENCE == proposal.getKind()) {
		return false;
	}
	char[] completion= proposal.getCompletion();
	return !isInJavadoc() && completion.length > 0 && completion[completion.length - 1] == RPAREN;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:8,代码来源:CompletionProposalReplacementProvider.java

示例11: appendReplacementString

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
private void appendReplacementString(StringBuilder buffer, CompletionProposal proposal) {
	if (!hasArgumentList(proposal)) {
		String str = proposal.getKind() == CompletionProposal.TYPE_REF ? computeJavaTypeReplacementString(proposal) : String.valueOf(proposal.getCompletion());
		if (client.isCompletionSnippetsSupported()) {
			str = CompletionUtils.sanitizeCompletion(str);
		}
		buffer.append(str);
		return;
	}

	// we're inserting a method plus the argument list - respect formatter preferences
	appendMethodNameReplacement(buffer, proposal);
	final boolean addParen  = client.isCompletionSnippetsSupported();
	if(addParen) {
		buffer.append(LPAREN);
	}

	if (hasParameters(proposal)) {
		appendGuessingCompletion(buffer, proposal);
	}

	if(addParen){
		buffer.append(RPAREN);
		// add semicolons only if there are parentheses
		if (canAutomaticallyAppendSemicolon(proposal)) {
			buffer.append(SEMICOLON);
		}
	}
	if(proposal.getKind() == CompletionProposal.METHOD_DECLARATION){
		appendBody(buffer);
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:33,代码来源:CompletionProposalReplacementProvider.java

示例12: accept

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
@Override
public void accept(CompletionProposal proposal) {
	if (!isIgnored(proposal.getKind())) {
		if (proposal.getKind() == CompletionProposal.PACKAGE_REF && unit.getParent() != null && String.valueOf(proposal.getCompletion()).equals(unit.getParent().getElementName())) {
			// Hacky way to boost relevance of current package, for package completions, until
			// https://bugs.eclipse.org/518140 is fixed
			proposal.setRelevance(proposal.getRelevance() + 1);
		}
		proposals.add(proposal);
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:12,代码来源:SignatureHelpRequestor.java

示例13: accept

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 *
 * <p>Subclasses may replace, but usually should not need to. Consider replacing {@linkplain
 * #createJavaCompletionProposal(org.eclipse.jdt.core.CompletionProposal)
 * createJavaCompletionProposal} instead.
 */
@Override
public void accept(CompletionProposal proposal) {
  long start = DEBUG ? System.currentTimeMillis() : 0;
  try {
    if (isFiltered(proposal)) return;

    if (proposal.getKind() == CompletionProposal.POTENTIAL_METHOD_DECLARATION) {
      acceptPotentialMethodDeclaration(proposal);
    } else {
      IJavaCompletionProposal javaProposal = createJavaCompletionProposal(proposal);
      if (javaProposal != null) {
        fJavaProposals.add(javaProposal);
        if (proposal.getKind() == CompletionProposal.KEYWORD) fKeywords.add(javaProposal);
      }
    }
  } catch (IllegalArgumentException e) {
    // all signature processing method may throw IAEs
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=84657
    // don't abort, but log and show all the valid proposals
    JavaPlugin.log(
        new Status(
            IStatus.ERROR,
            JavaPlugin.getPluginId(),
            IStatus.OK,
            "Exception when processing proposal for: " + String.valueOf(proposal.getCompletion()),
            e)); // $NON-NLS-1$
  }

  if (DEBUG) fUITime += System.currentTimeMillis() - start;
}
 
开发者ID:eclipse,项目名称:che,代码行数:38,代码来源:CompletionProposalCollector.java

示例14: 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

示例15: create

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
/**
 * Return proposals only for references to a package, type, field, method or
 * constructor (and nothing else).
 */
public static IJavaCompletionProposal create(
    IJavaCompletionProposal jdtProposal, CompletionProposal wrappedProposal,
    IJavaProject javaProject, int replaceOffset, int replaceLength) {
  switch (wrappedProposal.getKind()) {
    case CompletionProposal.PACKAGE_REF:
    case CompletionProposal.TYPE_REF:
    case CompletionProposal.FIELD_REF:
    case CompletionProposal.METHOD_REF:
      return new JsniCompletionProposal(jdtProposal, wrappedProposal,
          javaProject, replaceOffset, replaceLength);
    default:
      return null;
  }
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:19,代码来源:JsniCompletionProposal.java


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