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


Java CompletionProposal.METHOD_REF属性代码示例

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


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

示例1: createParameterList

/**
 * 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,代码行数:34,代码来源:CompletionProposalDescriptionProvider.java

示例2: createParameterList

/**
 * 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>
 *
 * @param proposal the proposal to create the parameter list for
 * @return the list of comma-separated parameters suitable for display
 */
public String createParameterList(CompletionProposal proposal) {
  String paramList;
  int kind = proposal.getKind();
  switch (kind) {
    case CompletionProposal.METHOD_REF:
    case CompletionProposal.CONSTRUCTOR_INVOCATION:
      paramList = appendUnboundedParameterList(new StyledString(), proposal).getString();
      return Strings.markJavaElementLabelLTR(paramList);
    case CompletionProposal.TYPE_REF:
    case CompletionProposal.JAVADOC_TYPE_REF:
      paramList = appendTypeParameterList(new StyledString(), proposal).getString();
      return Strings.markJavaElementLabelLTR(paramList);
    case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
    case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION:
      paramList = appendUnboundedParameterList(new StyledString(), proposal).getString();
      return Strings.markJavaElementLabelLTR(paramList);
    default:
      Assert.isLegal(false);
      return null; // dummy
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:35,代码来源:CompletionProposalLabelProvider.java

示例3: isSupportingRequiredProposals

/**
 * 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,代码行数:22,代码来源:AbstractJavaCompletionProposal.java

示例4: ignoreAll

private void ignoreAll() {
  int[] ignoredKinds = new int[] {
      CompletionProposal.ANONYMOUS_CLASS_DECLARATION,
      CompletionProposal.FIELD_REF, CompletionProposal.KEYWORD,
      CompletionProposal.LABEL_REF, CompletionProposal.LOCAL_VARIABLE_REF,
      CompletionProposal.METHOD_REF, CompletionProposal.METHOD_DECLARATION,
      CompletionProposal.PACKAGE_REF, CompletionProposal.TYPE_REF,
      CompletionProposal.VARIABLE_DECLARATION,
      CompletionProposal.POTENTIAL_METHOD_DECLARATION,
      CompletionProposal.METHOD_NAME_REFERENCE,
      CompletionProposal.ANNOTATION_ATTRIBUTE_REF,
      CompletionProposal.JAVADOC_FIELD_REF,
      CompletionProposal.JAVADOC_METHOD_REF,
      CompletionProposal.JAVADOC_TYPE_REF,
      CompletionProposal.JAVADOC_VALUE_REF,
      CompletionProposal.JAVADOC_PARAM_REF,
      CompletionProposal.JAVADOC_BLOCK_TAG,
      CompletionProposal.JAVADOC_INLINE_TAG, CompletionProposal.FIELD_IMPORT,
      CompletionProposal.METHOD_IMPORT, CompletionProposal.TYPE_IMPORT};

  for (int kind : ignoredKinds) {
    setIgnored(kind, true);
  }
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:24,代码来源:ProposalGeneratingCompletionRequestor.java

示例5: computeProposals

public void computeProposals(List<ICompletionProposal> proposals)
    throws UiBinderException {
  IEvaluationContext evalContext = createEvaluationContext();

  try {
    // Get proposals for instance methods and static methods by treating the
    // Java type as an instance.
    // Since the type does not necessarily have to have a zero-arg
    // constructor, we use a local variable in the completion request below
    JavaElExpressionCompletionRequestor requestor = new JavaElExpressionCompletionRequestor(
        CompletionProposal.METHOD_REF);
    String snippet = javaType.getFullyQualifiedName('.') + " tmpVar; tmpVar."
        + getEnteredText();
    evalContext.codeComplete(snippet, snippet.length(), requestor);
    proposals.addAll(requestor.getProposals());

  } catch (JavaModelException e) {
    throw new UiBinderException(e);
  }
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:20,代码来源:JavaElExpressionProposalComputer.java

示例6: createReplaceString

private String createReplaceString() {
  switch (wrappedProposal.getKind()) {
    case CompletionProposal.PACKAGE_REF:
      return computePackageCompletion();
    case CompletionProposal.TYPE_REF:
      return computeTypeCompletion();
    case CompletionProposal.FIELD_REF:
      return computeFieldCompletion();
    case CompletionProposal.METHOD_REF:
      if (wrappedProposal.isConstructor()) {
        return computeCtorCompletion();
      } else {
        return computeMethodCompletion();
      }
    default:
      return "";
  }
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:18,代码来源:JsniCompletionProposal.java

示例7: createJavaCompletionProposal

@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,代码行数:18,代码来源:JsniCompletionProposalCollector.java

示例8: createMethodProposalDescription

/**
 * 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,代码行数:34,代码来源:CompletionProposalDescriptionProvider.java

示例9: computeSortText

/**
 * 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,代码行数:34,代码来源:SortTextHelper.java

示例10: isSupportingRequiredProposals

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,代码行数:8,代码来源:CompletionProposalReplacementProvider.java

示例11: computeRelevance

/**
 * 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,代码行数:38,代码来源:CompletionProposalCollector.java

示例12: getDeclaringType

/**
 * Returns the type signature of the declaring type of a <code>CompletionProposal</code>, or
 * <code>null</code> for proposals that do not have a declaring type. The return value is
 * <em>not</em> <code>null</code> for proposals of the following kinds:
 *
 * <ul>
 *   <li>METHOD_DECLARATION
 *   <li>METHOD_NAME_REFERENCE
 *   <li>METHOD_REF
 *   <li>ANNOTATION_ATTRIBUTE_REF
 *   <li>POTENTIAL_METHOD_DECLARATION
 *   <li>ANONYMOUS_CLASS_DECLARATION
 *   <li>FIELD_REF
 *   <li>PACKAGE_REF (returns the package, but no type)
 *   <li>TYPE_REF
 * </ul>
 *
 * @param proposal the completion proposal to get the declaring type for
 * @return the type signature of the declaring type, or <code>null</code> if there is none
 * @see org.eclipse.jdt.core.Signature#toCharArray(char[])
 */
protected final char[] getDeclaringType(CompletionProposal proposal) {
  switch (proposal.getKind()) {
    case CompletionProposal.METHOD_DECLARATION:
    case CompletionProposal.METHOD_NAME_REFERENCE:
    case CompletionProposal.JAVADOC_METHOD_REF:
    case CompletionProposal.METHOD_REF:
    case CompletionProposal.CONSTRUCTOR_INVOCATION:
    case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION:
    case CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER:
    case CompletionProposal.ANNOTATION_ATTRIBUTE_REF:
    case CompletionProposal.POTENTIAL_METHOD_DECLARATION:
    case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
    case CompletionProposal.FIELD_REF:
    case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER:
    case CompletionProposal.JAVADOC_FIELD_REF:
    case CompletionProposal.JAVADOC_VALUE_REF:
      char[] declaration = proposal.getDeclarationSignature();
      // special methods may not have a declaring type: methods defined on arrays etc.
      // Currently known: class literals don't have a declaring type - use Object
      if (declaration == null) return "java.lang.Object".toCharArray(); // $NON-NLS-1$
      return Signature.toCharArray(declaration);
    case CompletionProposal.PACKAGE_REF:
      return proposal.getDeclarationSignature();
    case CompletionProposal.JAVADOC_TYPE_REF:
    case CompletionProposal.TYPE_REF:
      return Signature.toCharArray(proposal.getSignature());
    case CompletionProposal.LOCAL_VARIABLE_REF:
    case CompletionProposal.VARIABLE_DECLARATION:
    case CompletionProposal.KEYWORD:
    case CompletionProposal.LABEL_REF:
    case CompletionProposal.JAVADOC_BLOCK_TAG:
    case CompletionProposal.JAVADOC_INLINE_TAG:
    case CompletionProposal.JAVADOC_PARAM_REF:
      return null;
    default:
      Assert.isTrue(false);
      return null;
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:60,代码来源:CompletionProposalCollector.java

示例13: computeRelevance

protected int computeRelevance() {
  final int baseRelevance = fProposal.getRelevance() * 16;
  switch (fProposal.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,代码行数:30,代码来源:LazyJavaCompletionProposal.java

示例14: createJavaCompletionProposal

@Override
protected IJavaCompletionProposal createJavaCompletionProposal(
		CompletionProposal proposal) {
	if (collectMethods) {
		if (CompletionProposal.METHOD_REF == proposal.getKind()
				&& Flags.isPublic(proposal.getFlags())) {
			char[] sig = proposal.getSignature();
			char[] declSig = proposal.getDeclarationSignature();
			// collect methods suitable for action methods ignoring Object
			// methods
			if (sig != null && declSig != null
					&& ACTION_METHOD_SIGNATURE.equals(String.valueOf(sig))
					&& !OBJECT_SIGNATURE.equals(String.valueOf(declSig))) {
				return new SimpleJavaCompletionProposal(proposal,
						getInvocationContext(), getImage(getLabelProvider()
								.createImageDescriptor(proposal)));
			}
		}
	} else {
		// collect packages and classes suitable for actions
		if ((CompletionProposal.PACKAGE_REF == proposal.getKind() || CompletionProposal.TYPE_REF == proposal
				.getKind())
				&& !Flags.isAbstract(proposal.getFlags())
				&& !Flags.isInterface(proposal.getFlags())
				&& !Flags.isEnum(proposal.getFlags())) {
			return new SimpleJavaCompletionProposal(proposal,
					getInvocationContext(), getImage(getLabelProvider()
							.createImageDescriptor(proposal)));
		}
	}
	return null;
}
 
开发者ID:aleksandr-m,项目名称:strutsclipse,代码行数:32,代码来源:SimpleJavaProposalCollector.java

示例15: createJavaCompletionProposal

@Override
protected IJavaCompletionProposal createJavaCompletionProposal(CompletionProposal proposal) {
  switch (proposal.getKind()) {
    case CompletionProposal.METHOD_REF:
    case CompletionProposal.CONSTRUCTOR_INVOCATION:
    case CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER:
      return createMethodReferenceProposal(proposal);
    case CompletionProposal.TYPE_REF:
      return createTypeProposal(proposal);
    default:
      return super.createJavaCompletionProposal(proposal);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:13,代码来源:FillArgumentNamesCompletionProposalCollector.java


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