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


Java CompletionProposal.getSignature方法代码示例

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


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

示例1: translateToCompletion

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
private AutocompleteResponse.Completion translateToCompletion(CompletionProposal proposal)
{
	AutocompleteResponse.Completion.Builder builder = AutocompleteResponse.Completion.newBuilder()
			.setKind(AutocompleteResponse.Completion.CompletionKind.valueOf(proposal.getKind()))
			.setIsConstructor(proposal.isConstructor())
			.setCompletionText(String.copyValueOf(proposal.getCompletion()))
			.setFlags(proposal.getFlags())
			.setRelevance(proposal.getRelevance())
			.setReplaceStart(proposal.getReplaceStart())
			.setReplaceEnd(proposal.getReplaceEnd());

	char[] sig = proposal.getSignature();
	
	if (sig != null)
	{
		if (proposal.getKind() == CompletionProposal.METHOD_REF || proposal.getKind() == CompletionProposal.JAVADOC_METHOD_REF)
			builder.setSignature(new String(Signature.toCharArray(sig, proposal.getName(), null, false, true)));
		else
			builder.setSignature(new String(Signature.toCharArray(sig)));
	}
	char[] name = proposal.getName();
	if (name == null)
		builder.setName(builder.getCompletionText());
	else
		builder.setName(String.copyValueOf(name));		
	return builder.build();
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:28,代码来源:JavaParser.java

示例2: createProposal

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
@Override
protected ICompletionProposal createProposal(CompletionProposal javaProposal) {
  char[] signature = javaProposal.getSignature();
  String replacementText = null;
  int relevanceAdjustment = 0;

  if (javaProposal.getKind() != CompletionProposal.METHOD_REF) {
    return null;
  }

  if (Signature.getParameterCount(signature) != 0) {
    // Only zero-arg methods are allowed
    return null;
  }

  String returnType = String.valueOf(Signature.getReturnType(signature));
  if (Signature.SIG_VOID.equals(returnType)) {
    // Methods with void return type are not allowed
    return null;
  }

  relevanceAdjustment += getRelevanceAdjustmentForMyTypeAndDeclarationType(
      returnType, javaProposal.getDeclarationSignature());
  replacementText = String.valueOf(javaProposal.getName());

  IJavaCompletionProposal jdtCompletionProposal = JavaContentAssistUtilities.getJavaCompletionProposal(
      javaProposal, getContext(), getJavaProject());
  ReplacementCompletionProposal proposal = ReplacementCompletionProposal.fromExistingCompletionProposal(
      replacementText, getReplaceOffset(), getReplaceLength(),
      jdtCompletionProposal);

  if (relevanceAdjustment != 0) {
    proposal.setRelevance(proposal.getRelevance() + relevanceAdjustment);
  }

  return proposal;
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:38,代码来源:JavaElExpressionProposalComputer.java

示例3: createJavaCompletionProposal

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
@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,代码行数:33,代码来源:SimpleJavaProposalCollector.java

示例4: resolveJavaElement

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
private IJavaElement resolveJavaElement(IJavaProject project, CompletionProposal proposal) throws JavaModelException {
	char[] signature= proposal.getSignature();
	String typeName= SignatureUtil.stripSignatureToFQN(String.valueOf(signature));
	return project.findType(typeName);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:6,代码来源:CompletionProposalReplacementProvider.java

示例5: appendImportProposal

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
private StringBuilder appendImportProposal(StringBuilder buffer, CompletionProposal proposal, int coreKind) {
	int proposalKind= proposal.getKind();
	String qualifiedTypeName= null;
	char[] qualifiedType= null;
	if (proposalKind == CompletionProposal.TYPE_IMPORT) {
		qualifiedType= proposal.getSignature();
		qualifiedTypeName= String.valueOf(Signature.toCharArray(qualifiedType));
	} else if (proposalKind == CompletionProposal.METHOD_IMPORT || proposalKind == CompletionProposal.FIELD_IMPORT) {
		qualifiedType= Signature.getTypeErasure(proposal.getDeclarationSignature());
		qualifiedTypeName= String.valueOf(Signature.toCharArray(qualifiedType));
	} else {
		/*
		 * In 3.3 we only support the above import proposals, see
		 * CompletionProposal#getRequiredProposals()
		 */
		Assert.isTrue(false);
	}

	/* Add imports if the preference is on. */
	if (importRewrite != null) {
		if (proposalKind == CompletionProposal.TYPE_IMPORT) {
			String simpleType= importRewrite.addImport(qualifiedTypeName, null);
			if (coreKind == CompletionProposal.METHOD_REF) {
				buffer.append(simpleType);
				buffer.append(COMMA);
				return buffer;
			}
		} else {
			String res= importRewrite.addStaticImport(qualifiedTypeName, String.valueOf(proposal.getName()), proposalKind == CompletionProposal.FIELD_IMPORT, null);
			int dot= res.lastIndexOf('.');
			if (dot != -1) {
				buffer.append(importRewrite.addImport(res.substring(0, dot), null));
				buffer.append('.');
				return buffer;
			}
		}
		return buffer;
	}

	// Case where we don't have an import rewrite (see allowAddingImports)

	if (compilationUnit != null && isImplicitImport(Signature.getQualifier(qualifiedTypeName), compilationUnit)) {
		/* No imports for implicit imports. */

		if (proposal.getKind() == CompletionProposal.TYPE_IMPORT && coreKind == CompletionProposal.FIELD_REF) {
			return buffer;
		}
		qualifiedTypeName= String.valueOf(Signature.getSignatureSimpleName(qualifiedType));
	}
	buffer.append(qualifiedTypeName);
	buffer.append('.');
	return buffer;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:54,代码来源:CompletionProposalReplacementProvider.java

示例6: createTypeProposalLabel

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
/**
 * Updates a display label for a given type proposal. The display label
 * consists of:
 * <ul>
 *   <li>the simple type name (erased when the context is in javadoc)</li>
 *   <li>the package name</li>
 * </ul>
 * <p>
 * Examples:
 * A proposal for the generic type <code>java.util.List&lt;E&gt;</code>, the display label
 * is: <code>List<E> - java.util</code>.
 * </p>
 *
 * @param typeProposal the method proposal to display
 * @param item the completion to update
 */
private void createTypeProposalLabel(CompletionProposal typeProposal, CompletionItem item) {
	char[] signature;
	if (fContext != null && fContext.isInJavadoc()) {
		signature= Signature.getTypeErasure(typeProposal.getSignature());
	} else {
		signature= typeProposal.getSignature();
	}
	char[] fullName= Signature.toCharArray(signature);
	createTypeProposalLabel(fullName, item);
	setDeclarationSignature(item, String.valueOf(signature));
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:28,代码来源:CompletionProposalDescriptionProvider.java

示例7: createTypeProposalLabel

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
/**
 * Creates a display label for a given type proposal. The display label consists of:
 *
 * <ul>
 *   <li>the simple type name (erased when the context is in javadoc)
 *   <li>the package name
 * </ul>
 *
 * <p>Examples: A proposal for the generic type <code>java.util.List&lt;E&gt;</code>, the display
 * label is: <code>List<E> - java.util</code>.
 *
 * @param typeProposal the method proposal to display
 * @return the display label for the given type proposal
 */
StyledString createTypeProposalLabel(CompletionProposal typeProposal) {
  char[] signature;
  if (fContext != null && fContext.isInJavadoc())
    signature = Signature.getTypeErasure(typeProposal.getSignature());
  else signature = typeProposal.getSignature();
  char[] fullName = Signature.toCharArray(signature);
  return createTypeProposalLabel(fullName);
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:CompletionProposalLabelProvider.java

示例8: getFullyQualifiedTypeName

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
/**
 * Gets the fully qualified type name from a java completion proposal for
 * {@link CompletionProposal#TYPE_REF}.
 * 
 * @param javaProposal the java type reference completion proposal generated
 *          by a code complete
 * @return the fully qualified type name
 */
public static String getFullyQualifiedTypeName(CompletionProposal javaProposal) {
  char[] signature = javaProposal.getSignature();
  return String.valueOf(Signature.toCharArray(signature));
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:13,代码来源:JavaContentAssistUtilities.java


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