本文整理汇总了Java中org.eclipse.jdt.core.Signature.toCharArray方法的典型用法代码示例。如果您正苦于以下问题:Java Signature.toCharArray方法的具体用法?Java Signature.toCharArray怎么用?Java Signature.toCharArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.Signature
的用法示例。
在下文中一共展示了Signature.toCharArray方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeSortString
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
@Override
protected String computeSortString() {
/*
* Lexicographical sort order:
* 1) by relevance (done by the proposal sorter)
* 2) by method name
* 3) by parameter count
* 4) by parameter type names
*/
char[] name = fProposal.getName();
char[] parameterList =
Signature.toCharArray(fProposal.getSignature(), null, null, false, false);
int parameterCount =
Signature.getParameterCount(fProposal.getSignature())
% 10; // we don't care about insane methods with >9 parameters
StringBuffer buf = new StringBuffer(name.length + 2 + parameterList.length);
buf.append(name);
buf.append('\0'); // separator
buf.append(parameterCount);
buf.append(parameterList);
return buf.toString();
}
示例2: appendTypeParameterList
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
/**
* Appends the type parameter list to <code>buffer</code>.
*
* @param buffer the buffer to append to
* @param typeProposal the type proposal
* @return the modified <code>buffer</code>
*/
private StringBuilder appendTypeParameterList(StringBuilder buffer, CompletionProposal typeProposal) {
// TODO remove once https://bugs.eclipse.org/bugs/show_bug.cgi?id=85293
// gets fixed.
char[] signature= SignatureUtil.fix83600(typeProposal.getSignature());
char[][] typeParameters= Signature.getTypeArguments(signature);
for (int i= 0; i < typeParameters.length; i++) {
char[] param= typeParameters[i];
typeParameters[i]= Signature.toCharArray(param);
}
return appendParameterSignature(buffer, typeParameters, null);
}
示例3: addType
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
private void addType(char[] typeNameSig, int flags, int relevance) {
int kind= getKind(flags, typeNameSig);
if (!isKind(kind)) {
return;
}
String fullName= new String(Signature.toCharArray(Signature.getTypeErasure(typeNameSig)));
if (NameMatcher.isSimilarName(fName, Signature.getSimpleName(fullName))) {
addResult(new SimilarElement(kind, fullName, relevance));
}
}
示例4: getMemberTypeAsString
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
public static String getMemberTypeAsString(IField f) {
if(f == null) return null;
try {
String typeName = new String(Signature.toCharArray(f.getTypeSignature().toCharArray()));
return resolveType(f.getDeclaringType(), typeName);
} catch (JavaModelException e) {
e.printStackTrace();
}
return null;
}
示例5: appendTypeParameterList
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
/**
* Appends the type parameter list to <code>buffer</code>.
*
* @param buffer the buffer to append to
* @param typeProposal the type proposal
* @return the modified <code>buffer</code>
* @since 3.2
*/
private StyledString appendTypeParameterList(
StyledString buffer, CompletionProposal typeProposal) {
// TODO remove once https://bugs.eclipse.org/bugs/show_bug.cgi?id=85293
// gets fixed.
char[] signature = SignatureUtil.fix83600(typeProposal.getSignature());
char[][] typeParameters = Signature.getTypeArguments(signature);
for (int i = 0; i < typeParameters.length; i++) {
char[] param = typeParameters[i];
typeParameters[i] = Signature.toCharArray(param);
}
return appendParameterSignature(buffer, typeParameters, null);
}
示例6: getDeclaringType
import org.eclipse.jdt.core.Signature; //导入方法依赖的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;
}
}
示例7: getParameterTypes
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
private String[] getParameterTypes() {
char[] signature = SignatureUtil.fix83600(fProposal.getSignature());
char[][] types = Signature.getParameterTypes(signature);
String[] ret = new String[types.length];
for (int i = 0; i < types.length; i++) {
ret[i] = new String(Signature.toCharArray(types[i]));
}
return ret;
}
示例8: addType
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
private void addType(char[] typeNameSig, int flags, int relevance) {
int kind = getKind(flags, typeNameSig);
if (!isKind(kind)) {
return;
}
String fullName = new String(Signature.toCharArray(Signature.getTypeErasure(typeNameSig)));
if (TypeFilter.isFiltered(fullName)) {
return;
}
if (NameMatcher.isSimilarName(fName, Signature.getSimpleName(fullName))) {
addResult(new SimilarElement(kind, fullName, relevance));
}
}
示例9: createJavadocTypeProposalLabel
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
private void createJavadocTypeProposalLabel(CompletionProposal typeProposal, CompletionItem item) {
char[] fullName= Signature.toCharArray(typeProposal.getSignature());
createJavadocTypeProposalLabel(fullName, item);
}
示例10: resolveTypeAsString
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
public static String resolveTypeAsString(IType type, String typeName) {
if(type == null || typeName == null) return null;
typeName = new String(Signature.toCharArray(typeName.toCharArray()));
return resolveType(type, typeName);
}
示例11: createJavadocTypeProposalLabel
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
StyledString createJavadocTypeProposalLabel(CompletionProposal typeProposal) {
char[] fullName = Signature.toCharArray(typeProposal.getSignature());
return createJavadocTypeProposalLabel(fullName);
}
示例12: getAnnotationMemberValue
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
public static Object getAnnotationMemberValue(
JavaElement parent, MemberValuePair memberValuePair, Object binaryValue) {
if (binaryValue instanceof Constant) {
return getAnnotationMemberValue(memberValuePair, (Constant) binaryValue);
} else if (binaryValue instanceof IBinaryAnnotation) {
memberValuePair.valueKind = IMemberValuePair.K_ANNOTATION;
return getAnnotation(
parent, (IBinaryAnnotation) binaryValue, memberValuePair.getMemberName());
} else if (binaryValue instanceof ClassSignature) {
memberValuePair.valueKind = IMemberValuePair.K_CLASS;
char[] className =
Signature.toCharArray(
CharOperation.replaceOnCopy(((ClassSignature) binaryValue).getTypeName(), '/', '.'));
return new String(className);
} else if (binaryValue instanceof EnumConstantSignature) {
memberValuePair.valueKind = IMemberValuePair.K_QUALIFIED_NAME;
EnumConstantSignature enumConstant = (EnumConstantSignature) binaryValue;
char[] enumName =
Signature.toCharArray(CharOperation.replaceOnCopy(enumConstant.getTypeName(), '/', '.'));
char[] qualifiedName =
CharOperation.concat(enumName, enumConstant.getEnumConstantName(), '.');
return new String(qualifiedName);
} else if (binaryValue instanceof Object[]) {
memberValuePair.valueKind = -1; // modified below by the first call to getMemberValue(...)
Object[] binaryValues = (Object[]) binaryValue;
int length = binaryValues.length;
Object[] values = new Object[length];
for (int i = 0; i < length; i++) {
int previousValueKind = memberValuePair.valueKind;
Object value = getAnnotationMemberValue(parent, memberValuePair, binaryValues[i]);
if (previousValueKind != -1 && memberValuePair.valueKind != previousValueKind) {
// values are heterogeneous, value kind is thus unknown
memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
}
if (value instanceof Annotation) {
Annotation annotation = (Annotation) value;
for (int j = 0; j < i; j++) {
if (annotation.equals(values[j])) {
annotation.occurrenceCount++;
}
}
}
values[i] = value;
}
if (memberValuePair.valueKind == -1) memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
return values;
} else {
memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
return null;
}
}
示例13: createTypeProposalLabel
import org.eclipse.jdt.core.Signature; //导入方法依赖的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<E></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));
}
示例14: createTypeProposalLabel
import org.eclipse.jdt.core.Signature; //导入方法依赖的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<E></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);
}