diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2013-03-24 19:14:10 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2013-05-23 21:25:30 +0200 |
commit | 4152eee126bcb6a0403d3e7a79fe336944031268 (patch) | |
tree | a255c5d4815752ca2a31c1e9eba7dd1a888b2f34 /src/core/lombok | |
parent | ffb3527daa05c966f40cccb3bbd93133b5775c7b (diff) | |
download | lombok-4152eee126bcb6a0403d3e7a79fe336944031268.tar.gz lombok-4152eee126bcb6a0403d3e7a79fe336944031268.tar.bz2 lombok-4152eee126bcb6a0403d3e7a79fe336944031268.zip |
Added a method to obtain latest java language spec supported by host
platform and implemented it for javac BUT NOT FOR ECJ!
Diffstat (limited to 'src/core/lombok')
-rw-r--r-- | src/core/lombok/core/AST.java | 8 | ||||
-rw-r--r-- | src/core/lombok/core/LombokNode.java | 9 | ||||
-rw-r--r-- | src/core/lombok/javac/JavacAST.java | 4 |
3 files changed, 21 insertions, 0 deletions
diff --git a/src/core/lombok/core/AST.java b/src/core/lombok/core/AST.java index 644d9449..a2279efe 100644 --- a/src/core/lombok/core/AST.java +++ b/src/core/lombok/core/AST.java @@ -146,6 +146,14 @@ public abstract class AST<A extends AST<A, L, N>, L extends LombokNode<A, L, N>, return nodeMap.get(node); } + /** + * Returns the latest version of the java language specification supported by the host compiler. + * For example, if compiling with javac v1.7, this returns {@code 7}. + */ + public int getLatestJavaSpecSupported() { + return 6; + } + @SuppressWarnings({"unchecked", "rawtypes"}) L replaceNewWithExistingOld(Map<N, L> oldNodes, L newNode) { L oldNode = oldNodes.get(newNode.get()); diff --git a/src/core/lombok/core/LombokNode.java b/src/core/lombok/core/LombokNode.java index 588adc55..aa161a8d 100644 --- a/src/core/lombok/core/LombokNode.java +++ b/src/core/lombok/core/LombokNode.java @@ -181,6 +181,15 @@ public abstract class LombokNode<A extends AST<A, L, N>, L extends LombokNode<A, } /** + * Convenient shortcut to the owning ast object's getLatestJavaSpecSupported method. + * + * @see AST#getLatestJavaSpecSupported() + */ + public int getLatestJavaSpecSupported() { + return ast.getLatestJavaSpecSupported(); + } + + /** * Convenient shortcut to the owning ast object's top method. * * @see AST#top() diff --git a/src/core/lombok/javac/JavacAST.java b/src/core/lombok/javac/JavacAST.java index 93ea9754..9e15516e 100644 --- a/src/core/lombok/javac/JavacAST.java +++ b/src/core/lombok/javac/JavacAST.java @@ -113,6 +113,10 @@ public class JavacAST extends AST<JavacAST, JavacNode, JCTree> { for (JavacNode child : node.down()) child.traverse(visitor); } + @Override public int getLatestJavaSpecSupported() { + return Javac.getJavaCompilerVersion(); + } + /** @return A Name object generated for the proper name table belonging to this AST. */ public Name toName(String name) { return elements.getName(name); |