use of org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference in project lombok by rzwitserloot.
the class EclipseHandlerUtil method cloneSelfType.
public static TypeReference cloneSelfType(EclipseNode context, ASTNode source) {
int pS = source == null ? 0 : source.sourceStart, pE = source == null ? 0 : source.sourceEnd;
long p = (long) pS << 32 | pE;
EclipseNode type = context;
TypeReference result = null;
while (type != null && type.getKind() != Kind.TYPE) type = type.up();
if (type != null && type.get() instanceof TypeDeclaration) {
TypeDeclaration typeDecl = (TypeDeclaration) type.get();
if (typeDecl.typeParameters != null && typeDecl.typeParameters.length > 0) {
TypeReference[] refs = new TypeReference[typeDecl.typeParameters.length];
int idx = 0;
for (TypeParameter param : typeDecl.typeParameters) {
TypeReference typeRef = new SingleTypeReference(param.name, (long) param.sourceStart << 32 | param.sourceEnd);
if (source != null)
setGeneratedBy(typeRef, source);
refs[idx++] = typeRef;
}
result = new ParameterizedSingleTypeReference(typeDecl.name, refs, 0, p);
} else {
result = new SingleTypeReference(((TypeDeclaration) type.get()).name, p);
}
}
if (result != null && source != null)
setGeneratedBy(result, source);
return result;
}
use of org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference in project lombok by rzwitserloot.
the class EclipseHandlerUtil method namePlusTypeParamsToTypeReference.
public static TypeReference namePlusTypeParamsToTypeReference(char[] typeName, TypeParameter[] params, long p) {
if (params != null && params.length > 0) {
TypeReference[] refs = new TypeReference[params.length];
int idx = 0;
for (TypeParameter param : params) {
TypeReference typeRef = new SingleTypeReference(param.name, p);
refs[idx++] = typeRef;
}
return new ParameterizedSingleTypeReference(typeName, refs, 0, p);
}
return new SingleTypeReference(typeName, p);
}
Aggregations