本文整理汇总了Java中org.eclipse.jdt.core.Signature.createTypeSignature方法的典型用法代码示例。如果您正苦于以下问题:Java Signature.createTypeSignature方法的具体用法?Java Signature.createTypeSignature怎么用?Java Signature.createTypeSignature使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.Signature
的用法示例。
在下文中一共展示了Signature.createTypeSignature方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reset
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
/**
* Resets the completion requester.
*
* @param unit the compilation unit, may be <code>null</code>.
*/
private void reset(ICompilationUnit unit) {
fUnit = unit;
fLocalVariables.clear();
fFields.clear();
fLocalTypes.clear();
if (fUnit != null) {
try {
IType[] cuTypes = fUnit.getAllTypes();
for (int i = 0; i < cuTypes.length; i++) {
String fqn = cuTypes[i].getFullyQualifiedName();
String sig = Signature.createTypeSignature(fqn, true);
fLocalTypes.put(sig, cuTypes[i].getElementName());
}
} catch (JavaModelException e) {
// ignore
}
}
fError = false;
}
示例2: resolveParameterTypes
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
private String[] resolveParameterTypes(IMethod method) {
final String[] oldParameterTypes = method.getParameterTypes();
final String[] newparams = new String[oldParameterTypes.length];
final String[] possibleOldSigs = new String[4];
possibleOldSigs[0] = Signature.createTypeSignature(fOldType.getElementName(), false);
possibleOldSigs[1] = Signature.createTypeSignature(fOldType.getElementName(), true);
possibleOldSigs[2] = Signature.createTypeSignature(fOldType.getFullyQualifiedName(), false);
possibleOldSigs[3] = Signature.createTypeSignature(fOldType.getFullyQualifiedName(), true);
final String[] possibleNewSigs = new String[4];
possibleNewSigs[0] = Signature.createTypeSignature(fNewType.getElementName(), false);
possibleNewSigs[1] = Signature.createTypeSignature(fNewType.getElementName(), true);
possibleNewSigs[2] = Signature.createTypeSignature(fNewType.getFullyQualifiedName(), false);
possibleNewSigs[3] = Signature.createTypeSignature(fNewType.getFullyQualifiedName(), true);
// Textually replace all occurrences
// This handles stuff like Map<SomeClass, some.package.SomeClass>
for (int i = 0; i < oldParameterTypes.length; i++) {
newparams[i] = oldParameterTypes[i];
for (int j = 0; j < possibleOldSigs.length; j++) {
newparams[i] = replaceAll(newparams[i], possibleOldSigs[j], possibleNewSigs[j]);
}
}
return newparams;
}
示例3: computePairedMethod
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
/**
* Computes the paired method enclosed in the paired type contained within the
* given <code>typeContainer</code>.
*
* @param typeContainer the container for the current type and paired type
* @param method a method that will be used to form a signature used during
* the lookup
* @return the paired method, or null if one could not be found
* @throws RemoteServiceException
* @throws JavaModelException
*/
private static IMethod computePairedMethod(TypeContainer typeContainer,
IMethod method) throws RemoteServiceException, JavaModelException {
String[] paramTypeNames = null;
if (typeContainer.isSync()) {
paramTypeNames = RemoteServiceUtilities.computeAsyncParameterTypes(method);
} else {
paramTypeNames = RemoteServiceUtilities.computeSyncParameterTypes(method);
}
// We have qualified parameter type names, but need qualified parameter
// type signatures
String[] paramTypeSigs = new String[paramTypeNames.length];
for (int i = 0; i < paramTypeNames.length; i++) {
paramTypeSigs[i] = Signature.createTypeSignature(paramTypeNames[i], true);
}
IType pairedType = typeContainer.getPairedType();
return JavaModelSearch.findMethodInHierarchy(
pairedType.newSupertypeHierarchy(new NullProgressMonitor()),
pairedType, method.getElementName(), paramTypeSigs);
}
示例4: subTypeToInheritedType
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
/**
* Returns a type variable mapping from a subclass to a superclass.
*
* @param type
* the type representing the subclass class
* @return a type variable mapping. The mapping entries consist of simple
* type variable names.
* @throws JavaModelException
* if the signature of one of the types involved could not be
* retrieved
*/
public static TypeVariableMaplet[] subTypeToInheritedType(final IType type, IType implementedInterface)
throws JavaModelException {
Assert.isNotNull(type);
final ITypeParameter[] domain = type.getTypeParameters();
if (domain.length > 0) {
String fullyQualifiedParameterizedName = implementedInterface.getFullyQualifiedParameterizedName();
// RK: strip off bounds if present. Otherwise, createTypeSignature()
// won't work.
fullyQualifiedParameterizedName = stripBoundsFromFullyQualifiedParameterizedName(
fullyQualifiedParameterizedName);
String signature = null;
try {
signature = Signature.createTypeSignature(fullyQualifiedParameterizedName,
implementedInterface.isResolved());
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Could not create type signature for: "
+ implementedInterface.getFullyQualifiedParameterizedName(), e);
}
if (signature != null) {
final String[] range = getVariableSignatures(signature);
if (range.length > 0)
return parametersToSignatures(domain, range, true);
}
}
return new TypeVariableMaplet[0];
}
开发者ID:ponder-lab,项目名称:Migrate-Skeletal-Implementation-to-Interface-Refactoring,代码行数:42,代码来源:TypeVariableUtil.java
示例5: qualifySignature
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
/**
* Returns the qualified signature corresponding to <code>signature</code>.
*
* @param signature the signature to qualify
* @param context the type inside which an unqualified type will be resolved to find the
* qualifier, or <code>null</code> if no context is available
* @return the qualified signature
*/
public static String qualifySignature(final String signature, final IType context) {
if (context == null) return signature;
String qualifier = Signature.getSignatureQualifier(signature);
if (qualifier.length() > 0) return signature;
String elementType = Signature.getElementType(signature);
String erasure = Signature.getTypeErasure(elementType);
String simpleName = Signature.getSignatureSimpleName(erasure);
String genericSimpleName = Signature.getSignatureSimpleName(elementType);
int dim = Signature.getArrayCount(signature);
try {
String[][] strings = context.resolveType(simpleName);
if (strings != null && strings.length > 0) qualifier = strings[0][0];
} catch (JavaModelException e) {
// ignore - not found
}
if (qualifier.length() == 0) return signature;
String qualifiedType = Signature.toQualifiedName(new String[] {qualifier, genericSimpleName});
String qualifiedSignature = Signature.createTypeSignature(qualifiedType, true);
String newSignature = Signature.createArraySignature(qualifiedSignature, dim);
return newSignature;
}
示例6: createAsyncCallbackParameter
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
/**
* Creates a GWT RPC async callback parameter declaration based on the sync
* method return type.
*
* @param ast {@link AST} associated with the destination compilation unit
* @param syncReturnType the sync method return type
* @param callbackParameterName name of the callback parameter
* @param imports {@link ImportsRewrite} for the destination compilation unit
* @return callback paramter declaration
*/
@SuppressWarnings("unchecked")
public static SingleVariableDeclaration createAsyncCallbackParameter(AST ast,
Type syncReturnType, String callbackParameterName, ImportRewrite imports) {
ITypeBinding syncReturnTypeBinding = syncReturnType.resolveBinding();
SingleVariableDeclaration parameter = ast.newSingleVariableDeclaration();
String gwtCallbackTypeSig = Signature.createTypeSignature(
RemoteServiceUtilities.ASYNCCALLBACK_QUALIFIED_NAME, true);
Type gwtCallbackType = imports.addImportFromSignature(gwtCallbackTypeSig,
ast);
if (syncReturnTypeBinding.isPrimitive()) {
String wrapperName = JavaASTUtils.getWrapperTypeName(syncReturnTypeBinding.getName());
String wrapperTypeSig = Signature.createTypeSignature(wrapperName, true);
syncReturnType = imports.addImportFromSignature(wrapperTypeSig, ast);
} else {
syncReturnType = JavaASTUtils.normalizeTypeAndAddImport(ast,
syncReturnType, imports);
}
ParameterizedType type = ast.newParameterizedType(gwtCallbackType);
List<Type> typeArgs = type.typeArguments();
typeArgs.add(syncReturnType);
parameter.setType(type);
parameter.setName(ast.newSimpleName(callbackParameterName));
return parameter;
}
示例7: resolveTypeSignature
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
/**
* Returns the resolved type signature for the given signature in the given
* method, or <code>null</code> if unable to resolve.
*
* @param method method containing the type signature
* @param typeSignature the type signature to resolve
* @return the resolved type signature
* @throws JavaModelException
*/
private static String resolveTypeSignature(IMethod method, String typeSignature) throws JavaModelException {
int count = Signature.getArrayCount(typeSignature);
String elementTypeSignature = Signature.getElementType(typeSignature);
if (elementTypeSignature.length() == 1) {
// no need to resolve primitive types
return typeSignature;
}
String elementTypeName = Signature.toString(elementTypeSignature);
IType type = method.getDeclaringType();
String[][] resolvedElementTypeNames = type.resolveType(elementTypeName);
if (resolvedElementTypeNames == null || resolvedElementTypeNames.length != 1) {
// check if type parameter
ITypeParameter typeParameter = method.getTypeParameter(elementTypeName);
if (!typeParameter.exists()) {
typeParameter = type.getTypeParameter(elementTypeName);
}
if (typeParameter.exists()) {
String[] bounds = typeParameter.getBounds();
if (bounds.length == 0) {
return "Ljava/lang/Object;"; //$NON-NLS-1$
}
String bound = Signature.createTypeSignature(bounds[0], false);
return Signature.createArraySignature(resolveTypeSignature(method, bound), count);
}
// the type name cannot be resolved
return null;
}
String[] types = resolvedElementTypeNames[0];
types[1] = types[1].replace('.', '$');
String resolvedElementTypeName = Signature.toQualifiedName(types);
String resolvedElementTypeSignature = "";
if(types[0].equals("")) {
resolvedElementTypeName = resolvedElementTypeName.substring(1);
resolvedElementTypeSignature = Signature.createTypeSignature(resolvedElementTypeName, true);
}
else {
resolvedElementTypeSignature = Signature.createTypeSignature(resolvedElementTypeName, true).replace('.', '/');
}
return Signature.createArraySignature(resolvedElementTypeSignature, count);
}
示例8: VoidType
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
protected VoidType(TypeEnvironment environment) {
super(environment, Signature.createTypeSignature("void", true)); // $NON-NLS-1$
}