aboutsummaryrefslogtreecommitdiff
path: root/src/lombok/eclipse
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@tipit.to>2009-06-23 19:13:03 +0200
committerReinier Zwitserloot <reinier@tipit.to>2009-06-23 19:13:03 +0200
commite85ef24b4d99f922f77439d9ba5e0e27717f2d31 (patch)
tree577c4693074cd289fe9103f4bec836fd2974ad35 /src/lombok/eclipse
parent8bbdcec6fad6edf8f335f9e0c6899fddc56e07c1 (diff)
downloadlombok-e85ef24b4d99f922f77439d9ba5e0e27717f2d31.tar.gz
lombok-e85ef24b4d99f922f77439d9ba5e0e27717f2d31.tar.bz2
lombok-e85ef24b4d99f922f77439d9ba5e0e27717f2d31.zip
Fixed some bugs in copyType(), and now the static constructor is generated without any raw generics warnings - it is effectively done.
Diffstat (limited to 'src/lombok/eclipse')
-rw-r--r--src/lombok/eclipse/Eclipse.java42
-rw-r--r--src/lombok/eclipse/handlers/HandleData.java12
2 files changed, 37 insertions, 17 deletions
diff --git a/src/lombok/eclipse/Eclipse.java b/src/lombok/eclipse/Eclipse.java
index e717e491..67622e47 100644
--- a/src/lombok/eclipse/Eclipse.java
+++ b/src/lombok/eclipse/Eclipse.java
@@ -106,17 +106,17 @@ public class Eclipse {
return out;
}
- 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);
+ 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 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;
}
diff --git a/src/lombok/eclipse/handlers/HandleData.java b/src/lombok/eclipse/handlers/HandleData.java
index 27757e7d..65072ab1 100644
--- a/src/lombok/eclipse/handlers/HandleData.java
+++ b/src/lombok/eclipse/handlers/HandleData.java
@@ -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;