本文整理汇总了Java中org.eclipse.jdt.core.Signature.getTypeSignatureKind方法的典型用法代码示例。如果您正苦于以下问题:Java Signature.getTypeSignatureKind方法的具体用法?Java Signature.getTypeSignatureKind怎么用?Java Signature.getTypeSignatureKind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.Signature
的用法示例。
在下文中一共展示了Signature.getTypeSignatureKind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getKind
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
private static final int getKind(int flags, char[] typeNameSig) {
if (Signature.getTypeSignatureKind(typeNameSig) == Signature.TYPE_VARIABLE_SIGNATURE) {
return VARIABLES;
}
if (Flags.isAnnotation(flags)) {
return ANNOTATIONS;
}
if (Flags.isInterface(flags)) {
return INTERFACES;
}
if (Flags.isEnum(flags)) {
return ENUMS;
}
return CLASSES;
}
示例2: isValidTypeSignature
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
private static boolean isValidTypeSignature(String sig) {
if (Signature.getTypeSignatureKind(sig) == Signature.BASE_TYPE_SIGNATURE)
return true;
else if (Signature.getTypeSignatureKind(sig) == Signature.ARRAY_TYPE_SIGNATURE)
return isValidTypeSignature(Signature.getElementType(sig));
else
return false;
}
示例3: sameParameter
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
private static boolean sameParameter(ITypeBinding type, String candidate, IType scope)
throws JavaModelException {
if (type.getDimensions() != Signature.getArrayCount(candidate)) return false;
// Normalizes types
if (type.isArray()) type = type.getElementType();
candidate = Signature.getElementType(candidate);
if ((Signature.getTypeSignatureKind(candidate) == Signature.BASE_TYPE_SIGNATURE)
!= type.isPrimitive()) {
return false;
}
if (type.isPrimitive() || type.isTypeVariable()) {
return type.getName().equals(Signature.toString(candidate));
} else {
// normalize (quick hack until binding.getJavaElement works)
candidate = Signature.getTypeErasure(candidate);
type = type.getErasure();
if (candidate.charAt(Signature.getArrayCount(candidate)) == Signature.C_RESOLVED) {
return Signature.toString(candidate).equals(Bindings.getFullyQualifiedName(type));
} else {
String[][] qualifiedCandidates = scope.resolveType(Signature.toString(candidate));
if (qualifiedCandidates == null || qualifiedCandidates.length == 0) return false;
String packageName =
type.getPackage().isUnnamed() ? "" : type.getPackage().getName(); // $NON-NLS-1$
String typeName = getTypeQualifiedName(type);
for (int i = 0; i < qualifiedCandidates.length; i++) {
String[] qualifiedCandidate = qualifiedCandidates[i];
if (qualifiedCandidate[0].equals(packageName) && qualifiedCandidate[1].equals(typeName))
return true;
}
}
}
return false;
}
示例4: isArray
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
/**
* Returns <code>true</code> if the type of the local variable is an array type.
*
* @return <code>true</code> if the receiver's type is an array, <code>false</code> if not
*/
public boolean isArray() {
if (fType == UNKNOWN
&& (fChecked & ARRAY) == 0
&& Signature.getTypeSignatureKind(signature) == Signature.ARRAY_TYPE_SIGNATURE)
fType = ARRAY;
fChecked |= ARRAY;
return fType == ARRAY;
}
示例5: isTrueSubtypeOf
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
/**
* Returns <code>true</code> if <code>subTypeSignature</code> describes a type which is a true
* sub type of the type described by <code>superTypeSignature</code>.
*
* @param subTypeSignature the potential subtype's signature
* @param superTypeSignature the potential supertype's signature
* @return <code>true</code> if the inheritance relationship holds
*/
private boolean isTrueSubtypeOf(String subTypeSignature, String superTypeSignature) {
// try cheap test first
if (subTypeSignature.equals(superTypeSignature)) return true;
if (SignatureUtil.isJavaLangObject(subTypeSignature))
return false; // Object has no super types
if (Signature.getTypeSignatureKind(subTypeSignature) != Signature.BASE_TYPE_SIGNATURE
&& SignatureUtil.isJavaLangObject(superTypeSignature)) return true;
IJavaProject project = fUnit.getJavaProject();
try {
if ((Signature.getTypeSignatureKind(subTypeSignature)
& (Signature.TYPE_VARIABLE_SIGNATURE | Signature.CLASS_TYPE_SIGNATURE))
== 0) return false;
IType subType = project.findType(SignatureUtil.stripSignatureToFQN(subTypeSignature));
if (subType == null) return false;
if ((Signature.getTypeSignatureKind(superTypeSignature)
& (Signature.TYPE_VARIABLE_SIGNATURE | Signature.CLASS_TYPE_SIGNATURE))
== 0) return false;
IType superType = project.findType(SignatureUtil.stripSignatureToFQN(superTypeSignature));
if (superType == null) return false;
ITypeHierarchy hierarchy = subType.newSupertypeHierarchy(null);
IType[] types = hierarchy.getAllSupertypes(subType);
for (int i = 0; i < types.length; i++) if (types[i].equals(superType)) return true;
} catch (JavaModelException e) {
// ignore and return false
}
return false;
}
示例6: isConcreteType
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
/**
* Returns <code>true</code> if <code>signature</code> is a concrete type signature, <code>false
* </code> if it is a type variable.
*
* @param signature the signature to check
* @param context the context inside which to resolve the type
* @return <code>true</code> if the given signature is a concrete type signature
* @throws JavaModelException if finding the type fails
*/
private boolean isConcreteType(String signature, IType context) throws JavaModelException {
// Inexpensive check for the variable type first
if (Signature.TYPE_VARIABLE_SIGNATURE == Signature.getTypeSignatureKind(signature))
return false;
// try and resolve otherwise
if (context.isBinary()) {
return fUnit.getJavaProject().findType(SignatureUtil.stripSignatureToFQN(signature))
!= null;
} else {
return context.resolveType(SignatureUtil.stripSignatureToFQN(signature)) != null;
}
}
示例7: getKind
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
private static final int getKind(int flags, char[] typeNameSig) {
if (Signature.getTypeSignatureKind(typeNameSig) == Signature.TYPE_VARIABLE_SIGNATURE) {
return VARIABLES;
}
if (Flags.isAnnotation(flags)) {
return ANNOTATIONS;
}
if (Flags.isInterface(flags)) {
return INTERFACES;
}
if (Flags.isEnum(flags)) {
return ENUMS;
}
return CLASSES;
}
示例8: parse
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
public static JsniJavaRefParamType parse(IPath source, int offset,
String paramTypeString) {
// Minimal class type signature is of form "LClassName;"
if (paramTypeString.length() < 3 || !paramTypeString.endsWith(";")) {
return null;
}
// We only consider class types (no primitives)
if (Signature.getTypeSignatureKind(paramTypeString) != Signature.CLASS_TYPE_SIGNATURE) {
return null;
}
return new JsniJavaRefParamType(source, offset, paramTypeString);
}
示例9: sameParameter
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
private static boolean sameParameter(ITypeBinding type, String candidate, IType scope) throws JavaModelException {
if (type.getDimensions() != Signature.getArrayCount(candidate)) {
return false;
}
// Normalizes types
if (type.isArray()) {
type= type.getElementType();
}
candidate= Signature.getElementType(candidate);
if ((Signature.getTypeSignatureKind(candidate) == Signature.BASE_TYPE_SIGNATURE) != type.isPrimitive()) {
return false;
}
if (type.isPrimitive() || type.isTypeVariable()) {
return type.getName().equals(Signature.toString(candidate));
} else {
// normalize (quick hack until binding.getJavaElement works)
candidate= Signature.getTypeErasure(candidate);
type= type.getErasure();
if (candidate.charAt(Signature.getArrayCount(candidate)) == Signature.C_RESOLVED) {
return Signature.toString(candidate).equals(Bindings.getFullyQualifiedName(type));
} else {
String[][] qualifiedCandidates= scope.resolveType(Signature.toString(candidate));
if (qualifiedCandidates == null || qualifiedCandidates.length == 0) {
return false;
}
String packageName= type.getPackage().isUnnamed() ? "" : type.getPackage().getName(); //$NON-NLS-1$
String typeName= getTypeQualifiedName(type);
for (int i= 0; i < qualifiedCandidates.length; i++) {
String[] qualifiedCandidate= qualifiedCandidates[i];
if ( qualifiedCandidate[0].equals(packageName) &&
qualifiedCandidate[1].equals(typeName)) {
return true;
}
}
}
}
return false;
}
示例10: appendTypeSignatureLabel
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
protected void appendTypeSignatureLabel(IJavaElement enclosingElement, String typeSig, long flags) {
int sigKind= Signature.getTypeSignatureKind(typeSig);
switch (sigKind) {
case Signature.BASE_TYPE_SIGNATURE:
fBuilder.append(Signature.toString(typeSig));
break;
case Signature.ARRAY_TYPE_SIGNATURE:
appendTypeSignatureLabel(enclosingElement, Signature.getElementType(typeSig), flags);
for (int dim= Signature.getArrayCount(typeSig); dim > 0; dim--) {
fBuilder.append('[').append(']');
}
break;
case Signature.CLASS_TYPE_SIGNATURE:
String baseType= getSimpleTypeName(enclosingElement, typeSig);
fBuilder.append(baseType);
String[] typeArguments= Signature.getTypeArguments(typeSig);
appendTypeArgumentSignaturesLabel(enclosingElement, typeArguments, flags);
break;
case Signature.TYPE_VARIABLE_SIGNATURE:
fBuilder.append(getSimpleTypeName(enclosingElement, typeSig));
break;
case Signature.WILDCARD_TYPE_SIGNATURE:
char ch= typeSig.charAt(0);
if (ch == Signature.C_STAR) { //workaround for bug 85713
fBuilder.append('?');
} else {
if (ch == Signature.C_EXTENDS) {
fBuilder.append("? extends "); //$NON-NLS-1$
appendTypeSignatureLabel(enclosingElement, typeSig.substring(1), flags);
} else if (ch == Signature.C_SUPER) {
fBuilder.append("? super "); //$NON-NLS-1$
appendTypeSignatureLabel(enclosingElement, typeSig.substring(1), flags);
}
}
break;
case Signature.CAPTURE_TYPE_SIGNATURE:
appendTypeSignatureLabel(enclosingElement, typeSig.substring(1), flags);
break;
case Signature.INTERSECTION_TYPE_SIGNATURE:
String[] typeBounds= Signature.getIntersectionTypeBounds(typeSig);
appendTypeBoundsSignaturesLabel(enclosingElement, typeBounds, flags);
break;
default:
// unknown
}
}
示例11: createClassCreationChain
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
private static void createClassCreationChain(IType baseType,
IMethod constructor, StringBuilder classCreationChain,
List<ITestDataFactory> testDataFactories) throws JavaModelException {
// add parameters
ILocalVariable[] params = constructor.getParameters();
String fullQualifiedName;
IType paramType;
if (params != null && params.length != 0) {
String typeSignature;
String comma = "";
for (ILocalVariable param : params) {
classCreationChain.append(comma);
typeSignature = param.getTypeSignature();
int typeSignatureKind = Signature
.getTypeSignatureKind(typeSignature);
String signatureSimpleName = Signature
.getSignatureSimpleName(typeSignature);
// if simple type
if (Signature.BASE_TYPE_SIGNATURE == typeSignatureKind
|| isString(signatureSimpleName)) {
if (!TYPE_VOID.equals(Signature
.getSimpleName(typeSignature))) {
classCreationChain.append(decorateValue(
JDTUtils.createInitValue(signatureSimpleName),
signatureSimpleName));
}
} else {
paramType = null;
fullQualifiedName = getFullQualifiedName(baseType, param);
try {
paramType = baseType.getJavaProject().findType(
fullQualifiedName);
} catch (JavaModelException e) {
paramType = null;
}
if (paramType != null) {
boolean creationDone = false;
// if it is a special type
for (ITestDataFactory testDataFactory : testDataFactories) {
creationDone = testDataFactory.createTypeCreation(
paramType, classCreationChain);
}
if (paramType.getFullyQualifiedName().equals(
baseType.getFullyQualifiedName())) {
classCreationChain.append("null");
} else if (!creationDone) {
createClassCreationChain(paramType,
classCreationChain, testDataFactories);
}
} else {
classCreationChain.append("null");
}
}
comma = ", ";
}
}
}
示例12: appendTypeSignatureLabel
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
protected void appendTypeSignatureLabel(
IJavaElement enclosingElement, String typeSig, long flags, StringBuilder builder) {
int sigKind = Signature.getTypeSignatureKind(typeSig);
switch (sigKind) {
case Signature.BASE_TYPE_SIGNATURE:
builder.append(Signature.toString(typeSig));
break;
case Signature.ARRAY_TYPE_SIGNATURE:
appendTypeSignatureLabel(
enclosingElement, Signature.getElementType(typeSig), flags, builder);
for (int dim = Signature.getArrayCount(typeSig); dim > 0; dim--) {
builder.append('[').append(']');
}
break;
case Signature.CLASS_TYPE_SIGNATURE:
String baseType = getSimpleTypeName(enclosingElement, typeSig);
builder.append(baseType);
String[] typeArguments = Signature.getTypeArguments(typeSig);
appendTypeArgumentSignaturesLabel(enclosingElement, typeArguments, flags, builder);
break;
case Signature.TYPE_VARIABLE_SIGNATURE:
builder.append(getSimpleTypeName(enclosingElement, typeSig));
break;
case Signature.WILDCARD_TYPE_SIGNATURE:
char ch = typeSig.charAt(0);
if (ch == Signature.C_STAR) { // workaround for bug 85713
builder.append('?');
} else {
if (ch == Signature.C_EXTENDS) {
builder.append("? extends "); // $NON-NLS-1$
appendTypeSignatureLabel(enclosingElement, typeSig.substring(1), flags, builder);
} else if (ch == Signature.C_SUPER) {
builder.append("? super "); // $NON-NLS-1$
appendTypeSignatureLabel(enclosingElement, typeSig.substring(1), flags, builder);
}
}
break;
case Signature.CAPTURE_TYPE_SIGNATURE:
appendTypeSignatureLabel(enclosingElement, typeSig.substring(1), flags, builder);
break;
case Signature.INTERSECTION_TYPE_SIGNATURE:
String[] typeBounds = Signature.getIntersectionTypeBounds(typeSig);
appendTypeBoundsSignaturesLabel(enclosingElement, typeBounds, flags, builder);
break;
default:
// unknown
}
}
示例13: createImageDescriptor
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
/**
* 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);
}
示例14: appendTypeSignatureLabel
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
protected void appendTypeSignatureLabel(
IJavaElement enclosingElement, String typeSig, long flags) {
int sigKind = Signature.getTypeSignatureKind(typeSig);
switch (sigKind) {
case Signature.BASE_TYPE_SIGNATURE:
fBuffer.append(Signature.toString(typeSig));
break;
case Signature.ARRAY_TYPE_SIGNATURE:
appendTypeSignatureLabel(enclosingElement, Signature.getElementType(typeSig), flags);
for (int dim = Signature.getArrayCount(typeSig); dim > 0; dim--) {
fBuffer.append('[').append(']');
}
break;
case Signature.CLASS_TYPE_SIGNATURE:
String baseType = getSimpleTypeName(enclosingElement, typeSig);
fBuffer.append(baseType);
String[] typeArguments = Signature.getTypeArguments(typeSig);
appendTypeArgumentSignaturesLabel(enclosingElement, typeArguments, flags);
break;
case Signature.TYPE_VARIABLE_SIGNATURE:
fBuffer.append(getSimpleTypeName(enclosingElement, typeSig));
break;
case Signature.WILDCARD_TYPE_SIGNATURE:
char ch = typeSig.charAt(0);
if (ch == Signature.C_STAR) { // workaround for bug 85713
fBuffer.append('?');
} else {
if (ch == Signature.C_EXTENDS) {
fBuffer.append("? extends "); // $NON-NLS-1$
appendTypeSignatureLabel(enclosingElement, typeSig.substring(1), flags);
} else if (ch == Signature.C_SUPER) {
fBuffer.append("? super "); // $NON-NLS-1$
appendTypeSignatureLabel(enclosingElement, typeSig.substring(1), flags);
}
}
break;
case Signature.CAPTURE_TYPE_SIGNATURE:
appendTypeSignatureLabel(enclosingElement, typeSig.substring(1), flags);
break;
case Signature.INTERSECTION_TYPE_SIGNATURE:
String[] typeBounds = Signature.getIntersectionTypeBounds(typeSig);
appendTypeBoundsSignaturesLabel(enclosingElement, typeBounds, flags);
break;
default:
// unknown
}
}
示例15: appendTypeSignatureLabel
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
protected void appendTypeSignatureLabel(IJavaElement enclosingElement, String typeSig, long flags) {
int sigKind= Signature.getTypeSignatureKind(typeSig);
switch (sigKind) {
case Signature.BASE_TYPE_SIGNATURE:
fBuffer.append(Signature.toString(typeSig));
break;
case Signature.ARRAY_TYPE_SIGNATURE:
appendTypeSignatureLabel(enclosingElement, Signature.getElementType(typeSig), flags);
for (int dim= Signature.getArrayCount(typeSig); dim > 0; dim--) {
fBuffer.append('[').append(']');
}
break;
case Signature.CLASS_TYPE_SIGNATURE:
String baseType= getSimpleTypeName(enclosingElement, typeSig);
fBuffer.append(baseType);
String[] typeArguments= Signature.getTypeArguments(typeSig);
appendTypeArgumentSignaturesLabel(enclosingElement, typeArguments, flags);
break;
case Signature.TYPE_VARIABLE_SIGNATURE:
fBuffer.append(getSimpleTypeName(enclosingElement, typeSig));
break;
case Signature.WILDCARD_TYPE_SIGNATURE:
char ch= typeSig.charAt(0);
if (ch == Signature.C_STAR) { //workaround for bug 85713
fBuffer.append('?');
} else {
if (ch == Signature.C_EXTENDS) {
fBuffer.append("? extends "); //$NON-NLS-1$
appendTypeSignatureLabel(enclosingElement, typeSig.substring(1), flags);
} else if (ch == Signature.C_SUPER) {
fBuffer.append("? super "); //$NON-NLS-1$
appendTypeSignatureLabel(enclosingElement, typeSig.substring(1), flags);
}
}
break;
case Signature.CAPTURE_TYPE_SIGNATURE:
appendTypeSignatureLabel(enclosingElement, typeSig.substring(1), flags);
break;
case Signature.INTERSECTION_TYPE_SIGNATURE:
String[] typeBounds= Signature.getIntersectionTypeBounds(typeSig);
appendTypeBoundsSignaturesLabel(enclosingElement, typeBounds, flags);
break;
default:
// unknown
}
}