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


Java CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER属性代码示例

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


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

示例1: appendMethodNameReplacement

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

示例2: appendMethodNameReplacement

/**
 * Appends everything up to the method name including the opening parenthesis.
 *
 * <p>In case of {@link org.eclipse.jdt.core.CompletionProposal#METHOD_REF_WITH_CASTED_RECEIVER}
 * it add cast.
 *
 * @param buffer the string buffer
 * @since 3.4
 */
protected void appendMethodNameReplacement(StringBuffer buffer) {
  if (fProposal.getKind() == CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER) {
    String coreCompletion = String.valueOf(fProposal.getCompletion());
    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));
  }

  if (fProposal.getKind() != CompletionProposal.CONSTRUCTOR_INVOCATION)
    buffer.append(fProposal.getName());

  FormatterPrefs prefs = getFormatterPrefs();
  if (prefs.beforeOpeningParen) buffer.append(SPACE);
  buffer.append(LPAREN);
}
 
开发者ID:eclipse,项目名称:che,代码行数:30,代码来源:JavaMethodCompletionProposal.java

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

示例4: getPrefixCompletionStart

@Override
public int getPrefixCompletionStart(IDocument document, int completionOffset) {
  if (fProposal.getKind() == CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER) {
    return fProposal.getTokenStart();
  } else if (fProposal.getKind() == CompletionProposal.CONSTRUCTOR_INVOCATION)
    return fProposal.getRequiredProposals()[0].getReplaceStart();
  return super.getPrefixCompletionStart(document, completionOffset);
}
 
开发者ID:eclipse,项目名称:che,代码行数:8,代码来源:JavaMethodCompletionProposal.java

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

示例6: updateDescription

/**
 * Updates the description fields of the item.
 *
 * @param proposal
 * @param item
 */
public void updateDescription(CompletionProposal proposal, CompletionItem item) {
	switch (proposal.getKind()) {
		case CompletionProposal.METHOD_NAME_REFERENCE:
		case CompletionProposal.METHOD_REF:
		case CompletionProposal.CONSTRUCTOR_INVOCATION:
		case CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER:
		case CompletionProposal.POTENTIAL_METHOD_DECLARATION:
			if (fContext != null && fContext.isInJavadoc()) {
				createJavadocMethodProposalLabel(proposal, item);
				break;
			}
			createMethodProposalLabel(proposal, item);
			break;
		case CompletionProposal.METHOD_DECLARATION:
			createOverrideMethodProposalLabel(proposal, item);
			break;
		case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
		case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION:
			createAnonymousTypeLabel(proposal, item);
			break;
		case CompletionProposal.TYPE_REF:
			createTypeProposalLabel(proposal, item);
			break;
		case CompletionProposal.JAVADOC_TYPE_REF:
			createJavadocTypeProposalLabel(proposal, item);
			break;
		case CompletionProposal.JAVADOC_FIELD_REF:
		case CompletionProposal.JAVADOC_VALUE_REF:
		case CompletionProposal.JAVADOC_BLOCK_TAG:
		case CompletionProposal.JAVADOC_INLINE_TAG:
		case CompletionProposal.JAVADOC_PARAM_REF:
			createJavadocSimpleProposalLabel(proposal, item);
			break;
		case CompletionProposal.JAVADOC_METHOD_REF:
			createJavadocMethodProposalLabel(proposal, item);
			break;
		case CompletionProposal.PACKAGE_REF:
		case CompletionProposal.MODULE_DECLARATION:
		case CompletionProposal.MODULE_REF:
			createPackageProposalLabel(proposal, item);
			break;
		case CompletionProposal.ANNOTATION_ATTRIBUTE_REF:
		case CompletionProposal.FIELD_REF:
		case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER:
			createLabelWithTypeAndDeclaration(proposal, item);
			break;
		case CompletionProposal.LOCAL_VARIABLE_REF:
		case CompletionProposal.VARIABLE_DECLARATION:
			createSimpleLabelWithType(proposal, item);
			break;
		case CompletionProposal.KEYWORD:
		case CompletionProposal.LABEL_REF:
			item.setLabel(createSimpleLabel(proposal).toString());
			break;
		default:
			JavaLanguageServerPlugin.logInfo(new String(proposal.getName()) + " is of type " + getProposal(proposal));
			Assert.isTrue(false);
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:65,代码来源:CompletionProposalDescriptionProvider.java

示例7: mapKind

private CompletionItemKind mapKind(final int kind) {
	switch (kind) {
	case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION:
	case CompletionProposal.CONSTRUCTOR_INVOCATION:
		return CompletionItemKind.Constructor;
	case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
	case CompletionProposal.TYPE_REF:
		return CompletionItemKind.Class;
	case CompletionProposal.FIELD_IMPORT:
	case CompletionProposal.METHOD_IMPORT:
	case CompletionProposal.METHOD_NAME_REFERENCE:
	case CompletionProposal.PACKAGE_REF:
	case CompletionProposal.TYPE_IMPORT:
		return CompletionItemKind.Module;
	case CompletionProposal.FIELD_REF:
	case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER:
		return CompletionItemKind.Field;
	case CompletionProposal.KEYWORD:
		return CompletionItemKind.Keyword;
	case CompletionProposal.LABEL_REF:
		return CompletionItemKind.Reference;
	case CompletionProposal.LOCAL_VARIABLE_REF:
	case CompletionProposal.VARIABLE_DECLARATION:
		return CompletionItemKind.Variable;
	case CompletionProposal.METHOD_DECLARATION:
	case CompletionProposal.METHOD_REF:
	case CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER:
	case CompletionProposal.POTENTIAL_METHOD_DECLARATION:
		return CompletionItemKind.Function;
		//text
	case CompletionProposal.ANNOTATION_ATTRIBUTE_REF:
	case CompletionProposal.JAVADOC_BLOCK_TAG:
	case CompletionProposal.JAVADOC_FIELD_REF:
	case CompletionProposal.JAVADOC_INLINE_TAG:
	case CompletionProposal.JAVADOC_METHOD_REF:
	case CompletionProposal.JAVADOC_PARAM_REF:
	case CompletionProposal.JAVADOC_TYPE_REF:
	case CompletionProposal.JAVADOC_VALUE_REF:
	default:
		return CompletionItemKind.Text;
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:42,代码来源:CompletionProposalRequestor.java

示例8: createStyledLabel

/**
 * Creates a display label with styles for a given <code>CompletionProposal</code>.
 *
 * @param proposal the completion proposal to create the display label for
 * @return the display label for <code>proposal</code>
 * @since 3.4
 */
public StyledString createStyledLabel(CompletionProposal proposal) {
  switch (proposal.getKind()) {
    case CompletionProposal.METHOD_NAME_REFERENCE:
    case CompletionProposal.METHOD_REF:
    case CompletionProposal.CONSTRUCTOR_INVOCATION:
    case CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER:
    case CompletionProposal.POTENTIAL_METHOD_DECLARATION:
      if (fContext != null && fContext.isInJavadoc())
        return createJavadocMethodProposalLabel(proposal);
      return createMethodProposalLabel(proposal);
    case CompletionProposal.METHOD_DECLARATION:
      return createOverrideMethodProposalLabel(proposal);
    case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
    case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION:
      return createAnonymousTypeLabel(proposal);
    case CompletionProposal.TYPE_REF:
      return createTypeProposalLabel(proposal);
    case CompletionProposal.JAVADOC_TYPE_REF:
      return createJavadocTypeProposalLabel(proposal);
    case CompletionProposal.JAVADOC_FIELD_REF:
    case CompletionProposal.JAVADOC_VALUE_REF:
    case CompletionProposal.JAVADOC_BLOCK_TAG:
    case CompletionProposal.JAVADOC_INLINE_TAG:
    case CompletionProposal.JAVADOC_PARAM_REF:
      return createJavadocSimpleProposalLabel(proposal);
    case CompletionProposal.JAVADOC_METHOD_REF:
      return createJavadocMethodProposalLabel(proposal);
    case CompletionProposal.PACKAGE_REF:
      return createPackageProposalLabel(proposal);
    case CompletionProposal.ANNOTATION_ATTRIBUTE_REF:
    case CompletionProposal.FIELD_REF:
    case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER:
      return createLabelWithTypeAndDeclaration(proposal);
    case CompletionProposal.LOCAL_VARIABLE_REF:
    case CompletionProposal.VARIABLE_DECLARATION:
      return createSimpleLabelWithType(proposal);
    case CompletionProposal.KEYWORD:
    case CompletionProposal.LABEL_REF:
      return createSimpleLabel(proposal);
    default:
      Assert.isTrue(false);
      return null;
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:51,代码来源:CompletionProposalLabelProvider.java

示例9: createImageDescriptor

/**
 * Creates and returns a decorated image descriptor for a completion proposal.
 *
 * @param proposal the proposal for which to create an image descriptor
 * @return the created image descriptor, or <code>null</code> if no image is available
 */
public ImageDescriptor createImageDescriptor(CompletionProposal proposal) {
  final int flags = proposal.getFlags();

  ImageDescriptor descriptor;
  switch (proposal.getKind()) {
    case CompletionProposal.METHOD_DECLARATION:
    case CompletionProposal.METHOD_NAME_REFERENCE:
    case CompletionProposal.METHOD_REF:
    case CompletionProposal.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.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION:
      descriptor = JavaElementImageProvider.getMethodImageDescriptor(false, flags);
      break;
    case CompletionProposal.TYPE_REF:
      switch (Signature.getTypeSignatureKind(proposal.getSignature())) {
        case Signature.CLASS_TYPE_SIGNATURE:
          descriptor =
              JavaElementImageProvider.getTypeImageDescriptor(false, false, flags, false);
          break;
        case Signature.TYPE_VARIABLE_SIGNATURE:
          descriptor = JavaPluginImages.DESC_OBJS_TYPEVARIABLE;
          break;
        default:
          descriptor = null;
      }
      break;
    case CompletionProposal.FIELD_REF:
    case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER:
      descriptor = JavaElementImageProvider.getFieldImageDescriptor(false, flags);
      break;
    case CompletionProposal.LOCAL_VARIABLE_REF:
    case CompletionProposal.VARIABLE_DECLARATION:
      descriptor = JavaPluginImages.DESC_OBJS_LOCAL_VARIABLE;
      break;
    case CompletionProposal.PACKAGE_REF:
      descriptor = JavaPluginImages.DESC_OBJS_PACKAGE;
      break;
    case CompletionProposal.KEYWORD:
    case CompletionProposal.LABEL_REF:
      descriptor = null;
      break;
    case CompletionProposal.JAVADOC_METHOD_REF:
    case CompletionProposal.JAVADOC_TYPE_REF:
    case CompletionProposal.JAVADOC_FIELD_REF:
    case CompletionProposal.JAVADOC_VALUE_REF:
    case CompletionProposal.JAVADOC_BLOCK_TAG:
    case CompletionProposal.JAVADOC_INLINE_TAG:
    case CompletionProposal.JAVADOC_PARAM_REF:
      descriptor = JavaPluginImages.DESC_OBJS_JAVADOCTAG;
      break;
    default:
      descriptor = null;
      Assert.isTrue(false);
  }

  if (descriptor == null) return null;
  return decorateImageDescriptor(descriptor, proposal);
}
 
开发者ID:eclipse,项目名称:che,代码行数:67,代码来源:CompletionProposalLabelProvider.java

示例10: createJavaCompletionProposal

/**
 * Creates a new java completion proposal from a core proposal. This may involve computing the
 * display label and setting up some context.
 *
 * <p>This method is called for every proposal that will be displayed to the user, which may be
 * hundreds. Implementations should therefore defer as much work as possible: Labels should be
 * computed lazily to leverage virtual table usage, and any information only needed when
 * <em>applying</em> a proposal should not be computed yet.
 *
 * <p>Implementations may return <code>null</code> if a proposal should not be included in the
 * list presented to the user.
 *
 * <p>Subclasses may extend or replace this method.
 *
 * @param proposal the core completion proposal to create a UI proposal for
 * @return the created java completion proposal, or <code>null</code> if no proposal should be
 *     displayed
 */
protected IJavaCompletionProposal createJavaCompletionProposal(CompletionProposal proposal) {
  switch (proposal.getKind()) {
    case CompletionProposal.KEYWORD:
      return createKeywordProposal(proposal);
    case CompletionProposal.PACKAGE_REF:
      return createPackageProposal(proposal);
    case CompletionProposal.TYPE_REF:
      return createTypeProposal(proposal);
    case CompletionProposal.JAVADOC_TYPE_REF:
      return createJavadocLinkTypeProposal(proposal);
    case CompletionProposal.FIELD_REF:
    case CompletionProposal.JAVADOC_FIELD_REF:
    case CompletionProposal.JAVADOC_VALUE_REF:
      return createFieldProposal(proposal);
    case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER:
      return createFieldWithCastedReceiverProposal(proposal);
    case CompletionProposal.METHOD_REF:
    case CompletionProposal.CONSTRUCTOR_INVOCATION:
    case CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER:
    case CompletionProposal.METHOD_NAME_REFERENCE:
    case CompletionProposal.JAVADOC_METHOD_REF:
      return createMethodReferenceProposal(proposal);
    case CompletionProposal.METHOD_DECLARATION:
      return createMethodDeclarationProposal(proposal);
    case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION:
      return createAnonymousTypeProposal(proposal, getInvocationContext());
    case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
      return createAnonymousTypeProposal(proposal, null);
    case CompletionProposal.LABEL_REF:
      return createLabelProposal(proposal);
    case CompletionProposal.LOCAL_VARIABLE_REF:
    case CompletionProposal.VARIABLE_DECLARATION:
      return createLocalVariableProposal(proposal);
    case CompletionProposal.ANNOTATION_ATTRIBUTE_REF:
      return createAnnotationAttributeReferenceProposal(proposal);
    case CompletionProposal.JAVADOC_BLOCK_TAG:
    case CompletionProposal.JAVADOC_PARAM_REF:
      return createJavadocSimpleProposal(proposal);
    case CompletionProposal.JAVADOC_INLINE_TAG:
      return createJavadocInlineTagProposal(proposal);
    case CompletionProposal.POTENTIAL_METHOD_DECLARATION:
    default:
      return null;
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:63,代码来源:CompletionProposalCollector.java

示例11: isPrefix

@Override
protected boolean isPrefix(String prefix, String string) {
  if (fProposal.getKind() == CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER && prefix != null)
    prefix = prefix.substring(fProposal.getReceiverEnd() - fProposal.getReceiverStart() + 1);
  return super.isPrefix(prefix, string);
}
 
开发者ID:eclipse,项目名称:che,代码行数:6,代码来源:JavaMethodCompletionProposal.java


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