From cbaaedf32c028adbf1e050930428d732ea7be0b3 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Tue, 21 Dec 2010 23:10:22 +0100 Subject: 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. --- src/core/lombok/javac/handlers/HandleVal.java | 8 ++++++++ 1 file changed, 8 insertions(+) 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.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; -- cgit