本文整理了Java中org.eclipse.jdt.core.Signature.getTypeSignatureKind()
方法的一些代码示例,展示了Signature.getTypeSignatureKind()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Signature.getTypeSignatureKind()
方法的具体详情如下:
包路径:org.eclipse.jdt.core.Signature
类名称:Signature
方法名:getTypeSignatureKind
[英]Returns the kind of type signature encoded by the given string.
[中]返回由给定字符串编码的类型签名的类型。
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui
/**
* 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;
}
代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui
/**
* 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;
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui
/**
* 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;
}
代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core
/**
* Returns the kind of type signature encoded by the given string.
*
* @param typeSignature the type signature string
* @return the kind of type signature; one of the kind constants:
* {@link #ARRAY_TYPE_SIGNATURE}, {@link #CLASS_TYPE_SIGNATURE},
* {@link #BASE_TYPE_SIGNATURE}, or {@link #TYPE_VARIABLE_SIGNATURE},
* or (since 3.1) {@link #WILDCARD_TYPE_SIGNATURE} or {@link #CAPTURE_TYPE_SIGNATURE}
* or (since 3.7) {@link #INTERSECTION_TYPE_SIGNATURE}
* @exception IllegalArgumentException if this is not a type signature
* @since 3.0
*/
public static int getTypeSignatureKind(String typeSignature) {
return getTypeSignatureKind(typeSignature.toCharArray());
}
/**
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core
/**
* Returns the kind of type signature encoded by the given string.
*
* @param typeSignature the type signature string
* @return the kind of type signature; one of the kind constants:
* {@link #ARRAY_TYPE_SIGNATURE}, {@link #CLASS_TYPE_SIGNATURE},
* {@link #BASE_TYPE_SIGNATURE}, or {@link #TYPE_VARIABLE_SIGNATURE},
* or (since 3.1) {@link #WILDCARD_TYPE_SIGNATURE} or {@link #CAPTURE_TYPE_SIGNATURE}
* or (since 3.7) {@link #INTERSECTION_TYPE_SIGNATURE}
* @exception IllegalArgumentException if this is not a type signature
* @since 3.0
*/
public static int getTypeSignatureKind(String typeSignature) {
return getTypeSignatureKind(typeSignature.toCharArray());
}
/**
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core
/**
* Returns the kind of type signature encoded by the given string.
*
* @param typeSignature the type signature string
* @return the kind of type signature; one of the kind constants:
* {@link #ARRAY_TYPE_SIGNATURE}, {@link #CLASS_TYPE_SIGNATURE},
* {@link #BASE_TYPE_SIGNATURE}, or {@link #TYPE_VARIABLE_SIGNATURE},
* or (since 3.1) {@link #WILDCARD_TYPE_SIGNATURE} or {@link #CAPTURE_TYPE_SIGNATURE}
* or (since 3.7) {@link #INTERSECTION_TYPE_SIGNATURE}
* @exception IllegalArgumentException if this is not a type signature
* @since 3.0
*/
public static int getTypeSignatureKind(String typeSignature) {
return getTypeSignatureKind(typeSignature.toCharArray());
}
/**
代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core
/**
* Returns the kind of type signature encoded by the given string.
*
* @param typeSignature the type signature string
* @return the kind of type signature; one of the kind constants:
* {@link #ARRAY_TYPE_SIGNATURE}, {@link #CLASS_TYPE_SIGNATURE},
* {@link #BASE_TYPE_SIGNATURE}, or {@link #TYPE_VARIABLE_SIGNATURE},
* or (since 3.1) {@link #WILDCARD_TYPE_SIGNATURE} or {@link #CAPTURE_TYPE_SIGNATURE}
* or (since 3.7) {@link #INTERSECTION_TYPE_SIGNATURE}
* @exception IllegalArgumentException if this is not a type signature
* @since 3.0
*/
public static int getTypeSignatureKind(String typeSignature) {
return getTypeSignatureKind(typeSignature.toCharArray());
}
/**
代码示例来源:origin: trylimits/Eclipse-Postfix-Code-Completion
/**
* Returns the kind of type signature encoded by the given string.
*
* @param typeSignature the type signature string
* @return the kind of type signature; one of the kind constants:
* {@link #ARRAY_TYPE_SIGNATURE}, {@link #CLASS_TYPE_SIGNATURE},
* {@link #BASE_TYPE_SIGNATURE}, or {@link #TYPE_VARIABLE_SIGNATURE},
* or (since 3.1) {@link #WILDCARD_TYPE_SIGNATURE} or {@link #CAPTURE_TYPE_SIGNATURE}
* or (since 3.7) {@link #INTERSECTION_TYPE_SIGNATURE}
* @exception IllegalArgumentException if this is not a type signature
* @since 3.0
*/
public static int getTypeSignatureKind(String typeSignature) {
return getTypeSignatureKind(typeSignature.toCharArray());
}
/**
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui
/**
* Checks whether the given type signature is from a primitive type.
*
* @param typeSignature the type signature string to check
* @return <code>true</code> if the type is a primitive type, <code> false</code> otherwise
* @throws JavaModelException if this element does not exist or if an exception occurs while
* accessing its corresponding resource.
* @since 3.7
*/
public static boolean isPrimitive(String typeSignature) throws JavaModelException {
return Signature.getTypeSignatureKind(Signature.getElementType(typeSignature)) == Signature.BASE_TYPE_SIGNATURE;
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core.manipulation
/**
* Checks whether the given type signature is from a primitive type.
*
* @param typeSignature the type signature string to check
* @return <code>true</code> if the type is a primitive type, <code> false</code> otherwise
* @throws JavaModelException if this element does not exist or if an exception occurs while
* accessing its corresponding resource.
* @since 3.7
*/
public static boolean isPrimitive(String typeSignature) throws JavaModelException {
return Signature.getTypeSignatureKind(Signature.getElementType(typeSignature)) == Signature.BASE_TYPE_SIGNATURE;
}
代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui
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;
}
代码示例来源:origin: eclipse/eclipse.jdt.ls
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;
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui
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;
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui
private static final int getKind(int flags, char[] typeNameSig) {
if (Signature.getTypeSignatureKind(typeNameSig) == Signature.TYPE_VARIABLE_SIGNATURE) {
return TypeKinds.VARIABLES;
}
if (Flags.isAnnotation(flags)) {
return TypeKinds.ANNOTATIONS;
}
if (Flags.isInterface(flags)) {
return TypeKinds.INTERFACES;
}
if (Flags.isEnum(flags)) {
return TypeKinds.ENUMS;
}
return TypeKinds.CLASSES;
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui
@Override
protected void addHyperlinks(List<IHyperlink> hyperlinksCollector, IRegion wordRegion, SelectionDispatchAction openAction, IJavaElement element, boolean qualify, JavaEditor editor) {
try {
if (element.getElementType() == IJavaElement.FIELD || element.getElementType() == IJavaElement.LOCAL_VARIABLE) {
String typeSignature= getTypeSignature(element);
if (!JavaModelUtil.isPrimitive(typeSignature) && SelectionConverter.canOperateOn(editor)) {
if (Signature.getTypeSignatureKind(typeSignature) == Signature.INTERSECTION_TYPE_SIGNATURE) {
String[] bounds= Signature.getIntersectionTypeBounds(typeSignature);
qualify|= bounds.length >= 2;
for (int i= 0; i < bounds.length; i++) {
hyperlinksCollector.add(new JavaElementDeclaredTypeHyperlink(wordRegion, openAction, element, bounds[i], qualify));
}
} else {
hyperlinksCollector.add(new JavaElementDeclaredTypeHyperlink(wordRegion, openAction, element, qualify));
}
}
}
} catch (JavaModelException e) {
JavaPlugin.log(e);
}
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui
@Override
protected void addHyperlinks(List<IHyperlink> hyperlinksCollector, IRegion wordRegion, SelectionDispatchAction openAction, IJavaElement element, boolean qualify, JavaEditor editor) {
try {
if (element.getElementType() == IJavaElement.FIELD || element.getElementType() == IJavaElement.LOCAL_VARIABLE) {
String typeSignature= getTypeSignature(element);
if (!JavaModelUtil.isPrimitive(typeSignature) && SelectionConverter.canOperateOn(editor)) {
if (Signature.getTypeSignatureKind(typeSignature) == Signature.INTERSECTION_TYPE_SIGNATURE) {
String[] bounds= Signature.getIntersectionTypeBounds(typeSignature);
qualify|= bounds.length >= 2;
for (int i= 0; i < bounds.length; i++) {
hyperlinksCollector.add(new JavaElementDeclaredTypeHyperlink(wordRegion, openAction, element, bounds[i], qualify));
}
} else {
hyperlinksCollector.add(new JavaElementDeclaredTypeHyperlink(wordRegion, openAction, element, qualify));
}
}
}
} catch (JavaModelException e) {
JavaPlugin.log(e);
}
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui
/**
* 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;
}
}
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui
/**
* 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;
}
}
}
代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui
/**
* 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
* @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;
}
}
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui
@Override
public void open() {
try {
String returnTypeSignature= fMethod.getReturnType();
int kind= Signature.getTypeSignatureKind(returnTypeSignature);
if (kind == Signature.ARRAY_TYPE_SIGNATURE) {
returnTypeSignature= Signature.getElementType(returnTypeSignature);
} else if (kind == Signature.CLASS_TYPE_SIGNATURE) {
returnTypeSignature= Signature.getTypeErasure(returnTypeSignature);
}
String returnType= Signature.toString(returnTypeSignature);
String[][] resolvedType= fMethod.getDeclaringType().resolveType(returnType);
if (resolvedType == null || resolvedType.length == 0) {
openMethodAndShowErrorInStatusLine();
return;
}
String typeName= JavaModelUtil.concatenateName(resolvedType[0][0], resolvedType[0][1]);
IType type= fMethod.getJavaProject().findType(typeName, (IProgressMonitor)null);
if (type != null) {
fOpenAction.run(new StructuredSelection(type));
return;
}
openMethodAndShowErrorInStatusLine();
} catch (JavaModelException e) {
JavaPlugin.log(e);
return;
}
}
内容来源于网络,如有侵权,请联系作者删除!