本文整理了Java中org.eclipse.jdt.core.Signature.getElementType()
方法的一些代码示例,展示了Signature.getElementType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Signature.getElementType()
方法的具体详情如下:
包路径:org.eclipse.jdt.core.Signature
类名称:Signature
方法名:getElementType
[英]Returns the type signature without any array nesting.
For example:
getElementType("[[I") --> "I".
[中]返回没有任何数组嵌套的类型签名。
例如:
getElementType("[[I") --> "I".
代码示例来源:origin: org.eclipse/org.eclipse.jst.j2ee
/**
* This method is intended for internal use only. Checks to see if the passed type name
* is of a primitive type. This method does not accept null. It will not return null.
* @see Signature#getElementType(java.lang.String)
*
* @param typeName
* @return boolean is type Primitive?
*/
private boolean isPrimitiveType(String typeName) {
char first = Signature.getElementType(typeName).charAt(0);
return (first != Signature.C_RESOLVED && first != Signature.C_UNRESOLVED);
}
代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui
private static boolean hasPrimitiveType(IField field) throws JavaModelException {
String signature= field.getTypeSignature();
char first= Signature.getElementType(signature).charAt(0);
return (first != Signature.C_RESOLVED && first != Signature.C_UNRESOLVED);
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui
private static boolean hasPrimitiveType(IField field) throws JavaModelException {
String signature= field.getTypeSignature();
char first= Signature.getElementType(signature).charAt(0);
return (first != Signature.C_RESOLVED && first != Signature.C_UNRESOLVED);
}
代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core
/**
* Returns the type signature without any array nesting.
* <p>
* For example:
* <pre>
* <code>
* getElementType("[[I") --> "I".
* </code>
* </pre>
* </p>
*
* @param typeSignature the type signature
* @return the type signature without arrays
* @exception IllegalArgumentException if the signature is not syntactically
* correct
*/
public static String getElementType(String typeSignature) throws IllegalArgumentException {
char[] signature = typeSignature.toCharArray();
char[] elementType = getElementType(signature);
return signature == elementType ? typeSignature : new String(elementType);
}
/**
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui
private static boolean hasPrimitiveType(IField field) throws JavaModelException {
String signature= field.getTypeSignature();
char first= Signature.getElementType(signature).charAt(0);
return (first != Signature.C_RESOLVED && first != Signature.C_UNRESOLVED);
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core
/**
* Returns the type signature without any array nesting.
* <p>
* For example:
* <pre>
* <code>
* getElementType("[[I") --> "I".
* </code>
* </pre>
* </p>
*
* @param typeSignature the type signature
* @return the type signature without arrays
* @exception IllegalArgumentException if the signature is not syntactically
* correct
*/
public static String getElementType(String typeSignature) throws IllegalArgumentException {
char[] signature = typeSignature.toCharArray();
char[] elementType = getElementType(signature);
return signature == elementType ? typeSignature : new String(elementType);
}
/**
代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core
/**
* Returns the type signature without any array nesting.
* <p>
* For example:
* <pre>
* <code>
* getElementType("[[I") --> "I".
* </code>
* </pre>
* </p>
*
* @param typeSignature the type signature
* @return the type signature without arrays
* @exception IllegalArgumentException if the signature is not syntactically
* correct
*/
public static String getElementType(String typeSignature) throws IllegalArgumentException {
char[] signature = typeSignature.toCharArray();
char[] elementType = getElementType(signature);
return signature == elementType ? typeSignature : new String(elementType);
}
/**
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core
/**
* Returns the type signature without any array nesting.
* <p>
* For example:
* <pre>
* <code>
* getElementType("[[I") --> "I".
* </code>
* </pre>
* </p>
*
* @param typeSignature the type signature
* @return the type signature without arrays
* @exception IllegalArgumentException if the signature is not syntactically
* correct
*/
public static String getElementType(String typeSignature) throws IllegalArgumentException {
char[] signature = typeSignature.toCharArray();
char[] elementType = getElementType(signature);
return signature == elementType ? typeSignature : new String(elementType);
}
/**
代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.jdt.core
/**
* Returns the type signature without any array nesting.
* <p>
* For example:
* <pre>
* <code>
* getElementType("[[I") --> "I".
* </code>
* </pre>
* </p>
*
* @param typeSignature the type signature
* @return the type signature without arrays
* @exception IllegalArgumentException if the signature is not syntactically
* correct
*/
public static String getElementType(String typeSignature) throws IllegalArgumentException {
char[] signature = typeSignature.toCharArray();
char[] elementType = getElementType(signature);
return signature == elementType ? typeSignature : new String(elementType);
}
/**
代码示例来源:origin: trylimits/Eclipse-Postfix-Code-Completion
/**
* Returns the type signature without any array nesting.
* <p>
* For example:
* <pre>
* <code>
* getElementType("[[I") --> "I".
* </code>
* </pre>
* </p>
*
* @param typeSignature the type signature
* @return the type signature without arrays
* @exception IllegalArgumentException if the signature is not syntactically
* correct
*/
public static String getElementType(String typeSignature) throws IllegalArgumentException {
char[] signature = typeSignature.toCharArray();
char[] elementType = getElementType(signature);
return signature == elementType ? typeSignature : new String(elementType);
}
/**
代码示例来源: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
/**
* Returns the fully qualified type name of the given signature, with any
* type parameters and arrays erased.
*
* @param signature the signature
* @return the fully qualified type name of the signature
*/
public static String stripSignatureToFQN(String signature) throws IllegalArgumentException {
signature= Signature.getTypeErasure(signature);
signature= Signature.getElementType(signature);
return Signature.toString(signature);
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core.manipulation
/**
* Returns the fully qualified type name of the given signature, with any
* type parameters and arrays erased.
*
* @param signature the signature
* @return the fully qualified type name of the signature
* @throws IllegalArgumentException if the signature is syntactically incorrect
*/
public static String stripSignatureToFQN(String signature) throws IllegalArgumentException {
signature= Signature.getTypeErasure(signature);
signature= Signature.getElementType(signature);
return Signature.toString(signature);
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui
/**
* Returns the fully qualified type name of the given signature, with any
* type parameters and arrays erased.
*
* @param signature the signature
* @return the fully qualified type name of the signature
* @throws IllegalArgumentException if the signature is syntactically incorrect
*/
public static String stripSignatureToFQN(String signature) throws IllegalArgumentException {
signature= Signature.getTypeErasure(signature);
signature= Signature.getElementType(signature);
return Signature.toString(signature);
}
代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui
/**
* Returns the type names of all member type bounds, as they would be
* appear when referenced in the current compilation unit.
*
* @return type names of all member type bounds
*/
public String[] getMemberTypeNames() {
String[] signatures= getMemberTypeSignatures();
String[] names= new String[signatures.length];
for (int i= 0; i < signatures.length; i++) {
String sig= signatures[i];
String local= (String) fLocalTypes.get(Signature.getElementType(sig));
int dim= Signature.getArrayCount(sig);
if (local != null && dim > 0) {
StringBuffer array= new StringBuffer(local);
for (int j= 0; j < dim; j++)
array.append("[]"); //$NON-NLS-1$
local= array.toString();
}
if (local != null)
names[i]= local;
else
names[i]= Signature.getSimpleName(Signature.getSignatureSimpleName(sig));
}
return names;
}
代码示例来源:origin: org.eclipse.recommenders.completion.rcp/calls
public ProposalMatcher(CompletionProposal proposal) {
jSignature = getSignature(proposal);
jName = valueOf(proposal.getName());
jParams = getParameterTypes(jSignature);
for (int i = 0; i < jParams.length; i++) {
String param = getTypeErasure(jParams[i]);
String paramBaseType = getElementType(param);
param = param.replace('.', '/');
param = StringUtils.removeEnd(param, ";");
if (isWildcardCapture(paramBaseType) || isTypeParameter(paramBaseType)) {
int dimensions = getArrayCount(param);
param = StringUtils.repeat('[', dimensions) + "Ljava/lang/Object";
}
jParams[i] = param;
}
}
代码示例来源:origin: io.sarl/io.sarl.eclipse
private String resolve(IMethod operation, String typename) throws JavaModelException {
if (Signature.C_UNRESOLVED == Signature.getElementType(typename).charAt(0)) {
final ICompilationUnit unit = operation.getCompilationUnit();
if (unit != null) {
final String post = "." + Signature.toString(typename); //$NON-NLS-1$
for (final IImportDeclaration decl : unit.getImports()) {
if (decl.getElementName().endsWith(post)) {
return decl.getElementName();
}
}
}
}
return Signature.toString(typename);
}
代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui
private static List createParameterInfoList(IMethod method) {
try {
String[] typeNames= method.getParameterTypes();
String[] oldNames= method.getParameterNames();
List result= new ArrayList(typeNames.length);
for (int i= 0; i < oldNames.length; i++){
ParameterInfo parameterInfo;
if (i == oldNames.length - 1 && Flags.isVarargs(method.getFlags())) {
String varargSignature= typeNames[i];
int arrayCount= Signature.getArrayCount(varargSignature);
String baseSignature= Signature.getElementType(varargSignature);
if (arrayCount > 1)
baseSignature= Signature.createArraySignature(baseSignature, arrayCount - 1);
parameterInfo= new ParameterInfo(Signature.toString(baseSignature) + ParameterInfo.ELLIPSIS, oldNames[i], i);
} else {
parameterInfo= new ParameterInfo(Signature.toString(typeNames[i]), oldNames[i], i);
}
result.add(parameterInfo);
}
return result;
} catch(JavaModelException e) {
JavaPlugin.log(e);
return new ArrayList(0);
}
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui
return new String[] {Signature.createArraySignature(Signature.getElementType(signature), Signature.getArrayCount(signature) - 1)};
} else if (fUnit != null && (isIterable() || isCollection())) {
if (fMemberTypes == null) {
内容来源于网络,如有侵权,请联系作者删除!