本文整理汇总了Java中org.eclipse.jdt.core.CompletionProposal.getDeclarationSignature方法的典型用法代码示例。如果您正苦于以下问题:Java CompletionProposal.getDeclarationSignature方法的具体用法?Java CompletionProposal.getDeclarationSignature怎么用?Java CompletionProposal.getDeclarationSignature使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.CompletionProposal
的用法示例。
在下文中一共展示了CompletionProposal.getDeclarationSignature方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAnonymousTypeLabel
import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
private void createAnonymousTypeLabel(CompletionProposal proposal, CompletionItem item) {
char[] declaringTypeSignature= proposal.getDeclarationSignature();
declaringTypeSignature= Signature.getTypeErasure(declaringTypeSignature);
String name = new String(Signature.getSignatureSimpleName(declaringTypeSignature));
item.setInsertText(name);
StringBuilder buf= new StringBuilder();
buf.append(name);
buf.append('(');
appendUnboundedParameterList(buf, proposal);
buf.append(')');
buf.append(" "); //$NON-NLS-1$
buf.append("Anonymous Inner Type"); //TODO: consider externalization
item.setLabel(buf.toString());
if (proposal.getRequiredProposals() != null) {
char[] signatureQualifier= Signature.getSignatureQualifier(declaringTypeSignature);
if (signatureQualifier.length > 0) {
item.setDetail(String.valueOf(signatureQualifier));
}
}
setDeclarationSignature(item, String.valueOf(declaringTypeSignature));
}
示例2: createAnonymousTypeLabel
import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
StyledString createAnonymousTypeLabel(CompletionProposal proposal) {
char[] declaringTypeSignature = proposal.getDeclarationSignature();
declaringTypeSignature = Signature.getTypeErasure(declaringTypeSignature);
StyledString buffer = new StyledString();
buffer.append(Signature.getSignatureSimpleName(declaringTypeSignature));
buffer.append('(');
appendUnboundedParameterList(buffer, proposal);
buffer.append(')');
buffer.append(" "); // $NON-NLS-1$
buffer.append(JavaTextMessages.ResultCollector_anonymous_type);
if (proposal.getRequiredProposals() != null) {
char[] signatureQualifier = Signature.getSignatureQualifier(declaringTypeSignature);
if (signatureQualifier.length > 0) {
buffer.append(JavaElementLabels.CONCAT_STRING, StyledString.QUALIFIER_STYLER);
buffer.append(signatureQualifier, StyledString.QUALIFIER_STYLER);
}
}
return Strings.markJavaElementLabelLTR(buffer);
}
示例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);
}
示例4: extractDeclaringTypeFQN
import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
/**
* Extracts the fully qualified name of the declaring type of a method
* reference.
*
* @param methodProposal a proposed method
* @return the qualified name of the declaring type
*/
private String extractDeclaringTypeFQN(CompletionProposal methodProposal) {
char[] declaringTypeSignature= methodProposal.getDeclarationSignature();
// special methods may not have a declaring type: methods defined on arrays etc.
// TODO remove when bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=84690 gets fixed
if (declaringTypeSignature == null)
{
return OBJECT;
}
return SignatureUtil.stripSignatureToFQN(String.valueOf(declaringTypeSignature));
}
示例5: createLabelWithTypeAndDeclaration
import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
private void createLabelWithTypeAndDeclaration(CompletionProposal proposal, CompletionItem item) {
char[] name= proposal.getCompletion();
if (!isThisPrefix(name)) {
name= proposal.getName();
}
StringBuilder buf= new StringBuilder();
buf.append(name);
item.setInsertText(buf.toString());
char[] typeName= Signature.getSignatureSimpleName(proposal.getSignature());
if (typeName.length > 0) {
buf.append(VAR_TYPE_SEPARATOR);
buf.append(typeName);
}
item.setLabel(buf.toString());
char[] declaration= proposal.getDeclarationSignature();
if (declaration != null) {
setDeclarationSignature(item, String.valueOf(declaration));
StringBuilder declBuf = new StringBuilder();
declaration= Signature.getSignatureSimpleName(declaration);
if (declaration.length > 0) {
if (proposal.getRequiredProposals() != null) {
String declaringType= extractDeclaringTypeFQN(proposal);
String qualifier= Signature.getQualifier(declaringType);
if (qualifier.length() > 0) {
declBuf.append(qualifier);
declBuf.append('.');
}
}
declBuf.append(declaration);
item.setDetail(declBuf.toString());
}
}
setName(item,String.valueOf(name));
}
示例6: extractDeclaringTypeFQN
import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
/**
* Extracts the fully qualified name of the declaring type of a method reference.
*
* @param methodProposal a proposed method
* @return the qualified name of the declaring type
*/
private String extractDeclaringTypeFQN(CompletionProposal methodProposal) {
char[] declaringTypeSignature = methodProposal.getDeclarationSignature();
// special methods may not have a declaring type: methods defined on arrays etc.
// TODO remove when bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=84690 gets fixed
if (declaringTypeSignature == null) return "java.lang.Object"; // $NON-NLS-1$
return SignatureUtil.stripSignatureToFQN(String.valueOf(declaringTypeSignature));
}
示例7: createLabelWithTypeAndDeclaration
import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
StyledString createLabelWithTypeAndDeclaration(CompletionProposal proposal) {
char[] name = proposal.getCompletion();
if (!isThisPrefix(name)) name = proposal.getName();
StyledString buf = new StyledString();
buf.append(name);
char[] typeName = Signature.getSignatureSimpleName(proposal.getSignature());
if (typeName.length > 0) {
buf.append(VAR_TYPE_SEPARATOR);
buf.append(typeName);
}
char[] declaration = proposal.getDeclarationSignature();
if (declaration != null) {
declaration = Signature.getSignatureSimpleName(declaration);
if (declaration.length > 0) {
buf.append(QUALIFIER_SEPARATOR, StyledString.QUALIFIER_STYLER);
if (proposal.getRequiredProposals() != null) {
String declaringType = extractDeclaringTypeFQN(proposal);
String qualifier = Signature.getQualifier(declaringType);
if (qualifier.length() > 0) {
buf.append(qualifier, StyledString.QUALIFIER_STYLER);
buf.append('.', StyledString.QUALIFIER_STYLER);
}
}
buf.append(declaration, StyledString.QUALIFIER_STYLER);
}
}
return Strings.markJavaElementLabelLTR(buf);
}
示例8: getDeclaringType
import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
/**
* 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;
}
}
示例9: 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;
}