aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac/handlers
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2010-12-21 23:10:22 +0100
committerReinier Zwitserloot <reinier@zwitserloot.com>2010-12-22 09:28:29 +0100
commitcbaaedf32c028adbf1e050930428d732ea7be0b3 (patch)
treec7ca21d355643aefe37dc6a8bc08baf3e693f002 /src/core/lombok/javac/handlers
parentb260648065724a73ef4ec84f8e4b17d771576822 (diff)
downloadlombok-cbaaedf32c028adbf1e050930428d732ea7be0b3.tar.gz
lombok-cbaaedf32c028adbf1e050930428d732ea7be0b3.tar.bz2
lombok-cbaaedf32c028adbf1e050930428d732ea7be0b3.zip
val x = foo; is now desugared into "@val type x = foo;" (the @val is added), for javac. Of course, this is NOT done in delombok mode.
Diffstat (limited to 'src/core/lombok/javac/handlers')
-rw-r--r--src/core/lombok/javac/handlers/HandleVal.java8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/core/lombok/javac/handlers/HandleVal.java b/src/core/lombok/javac/handlers/HandleVal.java
index 63dedc49..b21137f7 100644
--- a/src/core/lombok/javac/handlers/HandleVal.java
+++ b/src/core/lombok/javac/handlers/HandleVal.java
@@ -33,10 +33,12 @@ import org.mangosdk.spi.ProviderFor;
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.code.Type;
import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.JCAnnotation;
import com.sun.tools.javac.tree.JCTree.JCEnhancedForLoop;
import com.sun.tools.javac.tree.JCTree.JCExpression;
import com.sun.tools.javac.tree.JCTree.JCNewArray;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
+import com.sun.tools.javac.util.List;
@ProviderFor(JavacASTVisitor.class)
public class HandleVal extends JavacASTAdapter {
@@ -71,6 +73,12 @@ public class HandleVal extends JavacASTAdapter {
JavacHandlerUtil.deleteImportFromCompilationUnit(localNode, "lombok.val");
local.mods.flags |= Flags.FINAL;
+
+ if (!localNode.shouldDeleteLombokAnnotations()) {
+ JCAnnotation valAnnotation = localNode.getTreeMaker().Annotation(local.vartype, List.<JCExpression>nil());
+ local.mods.annotations = local.mods.annotations == null ? List.of(valAnnotation) : local.mods.annotations.append(valAnnotation);
+ }
+
local.vartype = JavacResolution.createJavaLangObject(localNode.getTreeMaker(), localNode.getAst());
Type type;