mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-13 20:15:09 +00:00
Fixed some bugs in copyType(), and now the static constructor is generated without any raw generics warnings - it is effectively done.
This commit is contained in:
1 parent
8bbdcec6fa
commit
e85ef24b4d
2 files changed
+37
-17
No files matched your search
@@ -106,17 +106,17 @@ public class Eclipse {
|
||||
return out;
|
||||
}
|
||||
|
||||
public static TypeReference[] copyTypes(TypeReference[] refs) {
|
||||
if ( refs == null ) return null;
|
||||
TypeReference[] outs = new TypeReference[refs.length];
|
||||
int idx = 0;
|
||||
for ( TypeReference ref : refs ) {
|
||||
outs[idx++] = copyType(ref);
|
||||
}
|
||||
return outs;
|
||||
}
|
||||
|
||||
public static TypeReference copyType(TypeReference ref) {
|
||||
if ( ref instanceof QualifiedTypeReference ) {
|
||||
QualifiedTypeReference iRef = (QualifiedTypeReference) ref;
|
||||
return new QualifiedTypeReference(iRef.tokens, iRef.sourcePositions);
|
||||
}
|
||||
|
||||
if ( ref instanceof ArrayQualifiedTypeReference ) {
|
||||
ArrayQualifiedTypeReference iRef = (ArrayQualifiedTypeReference) ref;
|
||||
return new ArrayQualifiedTypeReference(iRef.tokens, iRef.dimensions(), iRef.sourcePositions);
|
||||
}
|
||||
|
||||
if ( ref instanceof ParameterizedQualifiedTypeReference ) {
|
||||
ParameterizedQualifiedTypeReference iRef = (ParameterizedQualifiedTypeReference) ref;
|
||||
TypeReference[][] args = null;
|
||||
@@ -138,14 +138,14 @@ public class Eclipse {
|
||||
return new ParameterizedQualifiedTypeReference(iRef.tokens, args, iRef.dimensions(), iRef.sourcePositions);
|
||||
}
|
||||
|
||||
if ( ref instanceof SingleTypeReference ) {
|
||||
SingleTypeReference iRef = (SingleTypeReference) ref;
|
||||
return new SingleTypeReference(iRef.token, (long)iRef.sourceStart << 32 | iRef.sourceEnd);
|
||||
if ( ref instanceof ArrayQualifiedTypeReference ) {
|
||||
ArrayQualifiedTypeReference iRef = (ArrayQualifiedTypeReference) ref;
|
||||
return new ArrayQualifiedTypeReference(iRef.tokens, iRef.dimensions(), iRef.sourcePositions);
|
||||
}
|
||||
|
||||
if ( ref instanceof ArrayTypeReference ) {
|
||||
ArrayTypeReference iRef = (ArrayTypeReference) ref;
|
||||
return new ArrayTypeReference(iRef.token, iRef.dimensions(), (long)iRef.sourceStart << 32 | iRef.sourceEnd);
|
||||
if ( ref instanceof QualifiedTypeReference ) {
|
||||
QualifiedTypeReference iRef = (QualifiedTypeReference) ref;
|
||||
return new QualifiedTypeReference(iRef.tokens, iRef.sourcePositions);
|
||||
}
|
||||
|
||||
if ( ref instanceof ParameterizedSingleTypeReference ) {
|
||||
@@ -162,10 +162,20 @@ public class Eclipse {
|
||||
return new ParameterizedSingleTypeReference(iRef.token, args, iRef.dimensions(), (long)iRef.sourceStart << 32 | iRef.sourceEnd);
|
||||
}
|
||||
|
||||
if ( ref instanceof ArrayTypeReference ) {
|
||||
ArrayTypeReference iRef = (ArrayTypeReference) ref;
|
||||
return new ArrayTypeReference(iRef.token, iRef.dimensions(), (long)iRef.sourceStart << 32 | iRef.sourceEnd);
|
||||
}
|
||||
|
||||
if ( ref instanceof Wildcard ) {
|
||||
return new Wildcard(((Wildcard)ref).kind);
|
||||
}
|
||||
|
||||
if ( ref instanceof SingleTypeReference ) {
|
||||
SingleTypeReference iRef = (SingleTypeReference) ref;
|
||||
return new SingleTypeReference(iRef.token, (long)iRef.sourceStart << 32 | iRef.sourceEnd);
|
||||
}
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.eclipse.jdt.internal.compiler.ast.MessageSend;
|
||||
import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
|
||||
import org.eclipse.jdt.internal.compiler.ast.NullLiteral;
|
||||
import org.eclipse.jdt.internal.compiler.ast.OperatorIds;
|
||||
import org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference;
|
||||
import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference;
|
||||
import org.eclipse.jdt.internal.compiler.ast.ReturnStatement;
|
||||
import org.eclipse.jdt.internal.compiler.ast.SingleNameReference;
|
||||
@@ -47,6 +48,7 @@ import org.eclipse.jdt.internal.compiler.ast.StringLiteral;
|
||||
import org.eclipse.jdt.internal.compiler.ast.ThisReference;
|
||||
import org.eclipse.jdt.internal.compiler.ast.TrueLiteral;
|
||||
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
|
||||
import org.eclipse.jdt.internal.compiler.ast.TypeParameter;
|
||||
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
|
||||
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
|
||||
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
|
||||
@@ -188,7 +190,15 @@ public class HandleData implements EclipseAnnotationHandler<Data> {
|
||||
((CompilationUnitDeclaration) type.top().get()).compilationResult);
|
||||
|
||||
constructor.modifiers = PKG.toModifier(AccessLevel.PUBLIC) | Modifier.STATIC;
|
||||
constructor.returnType = new SingleTypeReference(((TypeDeclaration)type.get()).name, p);
|
||||
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 ) {
|
||||
refs[idx++] = new SingleTypeReference(param.name, 0);
|
||||
}
|
||||
constructor.returnType = new ParameterizedSingleTypeReference(typeDecl.name, refs, 0, p);
|
||||
} else constructor.returnType = new SingleTypeReference(((TypeDeclaration)type.get()).name, p);
|
||||
constructor.annotations = null;
|
||||
constructor.selector = name.toCharArray();
|
||||
constructor.thrownExceptions = null;
|
||||
|
||||
Reference in new issue
Block a user