aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac/handlers/HandleData.java
diff options
context:
space:
mode:
authorRobbert Jan Grootjans <grootjans@gmail.com>2012-05-22 00:24:59 +0200
committerRobbert Jan Grootjans <grootjans@gmail.com>2012-05-22 00:24:59 +0200
commita6a8e4c5554ff000bbac43f4f7f530f661e036d2 (patch)
tree49d516b6e6e5a2478841b8465341e31572b6ed0a /src/core/lombok/javac/handlers/HandleData.java
parent68ca15986728c4d0fdf10a98761693ff6623f18f (diff)
downloadlombok-a6a8e4c5554ff000bbac43f4f7f530f661e036d2.tar.gz
lombok-a6a8e4c5554ff000bbac43f4f7f530f661e036d2.tar.bz2
lombok-a6a8e4c5554ff000bbac43f4f7f530f661e036d2.zip
Javac implementation of @ExtensionMethod.
Casual tests show that it is working. Taken from lombok-pg.
Diffstat (limited to 'src/core/lombok/javac/handlers/HandleData.java')
-rw-r--r--src/core/lombok/javac/handlers/HandleData.java11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/core/lombok/javac/handlers/HandleData.java b/src/core/lombok/javac/handlers/HandleData.java
index bec98960..62183a15 100644
--- a/src/core/lombok/javac/handlers/HandleData.java
+++ b/src/core/lombok/javac/handlers/HandleData.java
@@ -21,7 +21,7 @@
*/
package lombok.javac.handlers;
-import static lombok.javac.handlers.JavacHandlerUtil.deleteAnnotationIfNeccessary;
+import static lombok.javac.handlers.JavacHandlerUtil.*;
import lombok.AccessLevel;
import lombok.Data;
import lombok.core.AnnotationValues;
@@ -30,9 +30,7 @@ import lombok.javac.JavacNode;
import org.mangosdk.spi.ProviderFor;
-import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
-import com.sun.tools.javac.tree.JCTree.JCClassDecl;
/**
* Handles the {@code lombok.Data} annotation for javac.
@@ -42,12 +40,9 @@ public class HandleData extends JavacAnnotationHandler<Data> {
@Override public void handle(AnnotationValues<Data> annotation, JCAnnotation ast, JavacNode annotationNode) {
deleteAnnotationIfNeccessary(annotationNode, Data.class);
JavacNode typeNode = annotationNode.up();
- JCClassDecl typeDecl = null;
- if (typeNode.get() instanceof JCClassDecl) typeDecl = (JCClassDecl)typeNode.get();
- long flags = typeDecl == null ? 0 : typeDecl.mods.flags;
- boolean notAClass = (flags & (Flags.INTERFACE | Flags.ENUM | Flags.ANNOTATION)) != 0;
+ boolean notAClass = !isClass(typeNode);
- if (typeDecl == null || notAClass) {
+ if (notAClass) {
annotationNode.addError("@Data is only supported on a class.");
return;
}