From cd5cb7f3987641843016ceb28b6718abec6f993c Mon Sep 17 00:00:00 2001 From: Josef Ludvicek Date: Fri, 7 Oct 2016 13:56:09 +0200 Subject: Potential solution for issue #1164 * copy Jbds* to Rhds* and replace jbdevstudio to devstudio --- .../lombok/installer/eclipse/RhdsLocation.java | 45 ++++++++++++++ .../installer/eclipse/RhdsLocationProvider.java | 69 +++++++++++++++++++++ src/installer/lombok/installer/eclipse/rhds.png | Bin 0 -> 5768 bytes 3 files changed, 114 insertions(+) create mode 100644 src/installer/lombok/installer/eclipse/RhdsLocation.java create mode 100644 src/installer/lombok/installer/eclipse/RhdsLocationProvider.java create mode 100644 src/installer/lombok/installer/eclipse/rhds.png (limited to 'src') diff --git a/src/installer/lombok/installer/eclipse/RhdsLocation.java b/src/installer/lombok/installer/eclipse/RhdsLocation.java new file mode 100644 index 00000000..dbe1812c --- /dev/null +++ b/src/installer/lombok/installer/eclipse/RhdsLocation.java @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2013 The Project Lombok Authors. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package lombok.installer.eclipse; + +import java.io.File; +import java.net.URL; + +import lombok.installer.CorruptedIdeLocationException; + +public class RhdsLocation extends EclipseLocation { + public RhdsLocation(String nameOfLocation, File pathToEclipseIni) throws CorruptedIdeLocationException { + super(nameOfLocation, pathToEclipseIni); + } + + @Override public URL getIdeIcon() { + return RhdsLocation.class.getResource("rhds.png"); + } + + @Override protected String getIniFileName() { + return "devstudio.ini"; + } + + @Override protected String getTypeName() { + return "Red Hat JBoss Developer Studio"; + } +} diff --git a/src/installer/lombok/installer/eclipse/RhdsLocationProvider.java b/src/installer/lombok/installer/eclipse/RhdsLocationProvider.java new file mode 100644 index 00000000..008cbf86 --- /dev/null +++ b/src/installer/lombok/installer/eclipse/RhdsLocationProvider.java @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2013 The Project Lombok Authors. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package lombok.installer.eclipse; + +import java.io.File; +import java.util.Arrays; +import java.util.List; +import java.util.regex.Pattern; + +import lombok.installer.CorruptedIdeLocationException; +import lombok.installer.IdeLocation; +import lombok.installer.IdeLocationProvider; +import lombok.installer.IdeFinder.OS; + +import org.mangosdk.spi.ProviderFor; + +@ProviderFor(IdeLocationProvider.class) +public class RhdsLocationProvider extends EclipseLocationProvider { + @Override protected List getEclipseExecutableNames() { + return Arrays.asList("devstudio.app", "devstudio.exe", "devstudioc.exe", "devstudio"); + } + + @Override protected String getIniName() { + return "devstudio.ini"; + } + + @Override protected IdeLocation makeLocation(String name, File ini) throws CorruptedIdeLocationException { + return new JbdsLocation(name, ini); + } + + @Override protected String getMacAppName() { + return "devstudio.app"; + } + + @Override protected String getUnixAppName() { + return "devstudio"; + } + + @Override public Pattern getLocationSelectors(OS os) { + switch (os) { + case MAC_OS_X: + return Pattern.compile("^(devstudio|devstudio\\.ini|devstudio\\.app)$", Pattern.CASE_INSENSITIVE); + case WINDOWS: + return Pattern.compile("^(devstudioc?\\.exe|devstudio\\.ini)$", Pattern.CASE_INSENSITIVE); + default: + case UNIX: + return Pattern.compile("^(devstudio|devstudio\\.ini)$", Pattern.CASE_INSENSITIVE); + } + } +} diff --git a/src/installer/lombok/installer/eclipse/rhds.png b/src/installer/lombok/installer/eclipse/rhds.png new file mode 100644 index 00000000..bd0f534d Binary files /dev/null and b/src/installer/lombok/installer/eclipse/rhds.png differ -- cgit From d97ac8b196e0ed538fab48c5adae0286755797c5 Mon Sep 17 00:00:00 2001 From: Josef Ludvicek Date: Thu, 13 Oct 2016 17:50:42 +0200 Subject: [close #1164] Add finder for RHDS >=10 * add forgotten finder for RHDS * use correct location in RhdsLocationProvider --- .../lombok/installer/eclipse/RhdsFinder.java | 70 +++++++++++++++++++++ .../installer/eclipse/RhdsLocationProvider.java | 2 +- src/installer/lombok/installer/eclipse/rhds.png | Bin 5768 -> 3470 bytes 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 src/installer/lombok/installer/eclipse/RhdsFinder.java (limited to 'src') diff --git a/src/installer/lombok/installer/eclipse/RhdsFinder.java b/src/installer/lombok/installer/eclipse/RhdsFinder.java new file mode 100644 index 00000000..5e639fa5 --- /dev/null +++ b/src/installer/lombok/installer/eclipse/RhdsFinder.java @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2013 The Project Lombok Authors. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package lombok.installer.eclipse; + +import java.util.Arrays; +import java.util.List; + +import lombok.installer.CorruptedIdeLocationException; +import lombok.installer.IdeFinder; +import lombok.installer.IdeLocation; + +import org.mangosdk.spi.ProviderFor; + +/** + * RHDS (Red Hat JBoss Developer Studio) is an eclipse variant. + * Other than different executable names, it's the same as eclipse, as far as lombok support goes. + */ +@ProviderFor(IdeFinder.class) +public class RhdsFinder extends EclipseFinder { + @Override protected IdeLocation createLocation(String guess) throws CorruptedIdeLocationException { + return new RhdsLocationProvider().create0(guess); + } + + @Override protected String getDirName() { + return "studio"; + } + + @Override protected String getMacExecutableName() { + return "devstudio.app"; + } + + @Override protected String getUnixExecutableName() { + return "devstudio"; + } + + @Override protected String getWindowsExecutableName() { + return "devstudio.exe"; + } + + @Override protected List getSourceDirsOnWindows() { + return Arrays.asList("\\", "\\Program Files", "\\Program Files (x86)", System.getProperty("user.home", ".")); + } + + @Override protected List getSourceDirsOnMac() { + return Arrays.asList("/Applications", System.getProperty("user.home", ".")); + } + + @Override protected List getSourceDirsOnUnix() { + return Arrays.asList(System.getProperty("user.home", ".")); + } +} diff --git a/src/installer/lombok/installer/eclipse/RhdsLocationProvider.java b/src/installer/lombok/installer/eclipse/RhdsLocationProvider.java index 008cbf86..fabddba2 100644 --- a/src/installer/lombok/installer/eclipse/RhdsLocationProvider.java +++ b/src/installer/lombok/installer/eclipse/RhdsLocationProvider.java @@ -44,7 +44,7 @@ public class RhdsLocationProvider extends EclipseLocationProvider { } @Override protected IdeLocation makeLocation(String name, File ini) throws CorruptedIdeLocationException { - return new JbdsLocation(name, ini); + return new RhdsLocation(name, ini); } @Override protected String getMacAppName() { diff --git a/src/installer/lombok/installer/eclipse/rhds.png b/src/installer/lombok/installer/eclipse/rhds.png index bd0f534d..ca7738e6 100644 Binary files a/src/installer/lombok/installer/eclipse/rhds.png and b/src/installer/lombok/installer/eclipse/rhds.png differ -- cgit From 0f0cb68eac20c6f02b77c1fade88cdad8b7d85a2 Mon Sep 17 00:00:00 2001 From: Bulgakov Alexander Date: Thu, 22 Sep 2016 14:48:41 +0300 Subject: added supporting for @val variables inside lambdas. --- AUTHORS | 1 + src/core/lombok/javac/JavacAST.java | 35 ++++++++++++++++++++-- .../resource/after-delombok/ValFinal.java | 5 ++++ .../resource/after-delombok/ValInLambda.java | 18 +++++++++++ test/transform/resource/after-ecj/ValFinal.java | 9 ++++++ test/transform/resource/after-ecj/ValInLambda.java | 21 +++++++++++++ test/transform/resource/before/ValFinal.java | 6 ++++ test/transform/resource/before/ValInLambda.java | 21 +++++++++++++ 8 files changed, 113 insertions(+), 3 deletions(-) create mode 100644 test/transform/resource/after-delombok/ValFinal.java create mode 100644 test/transform/resource/after-delombok/ValInLambda.java create mode 100644 test/transform/resource/after-ecj/ValFinal.java create mode 100644 test/transform/resource/after-ecj/ValInLambda.java create mode 100644 test/transform/resource/before/ValFinal.java create mode 100644 test/transform/resource/before/ValInLambda.java (limited to 'src') diff --git a/AUTHORS b/AUTHORS index 46902ad4..a9339bd2 100644 --- a/AUTHORS +++ b/AUTHORS @@ -19,5 +19,6 @@ Szymon Pacanowski Taiki Sugawara Thomas Darimont Yun Zhi Lin +Bulgakov Alexander By adding your name to this list, you grant full and irrevocable copyright and patent indemnity to Project Lombok and all use of Project Lombok, and you certify that you have the right to do so for all commits you add to Project Lombok. diff --git a/src/core/lombok/javac/JavacAST.java b/src/core/lombok/javac/JavacAST.java index da61361d..3130e7a5 100644 --- a/src/core/lombok/javac/JavacAST.java +++ b/src/core/lombok/javac/JavacAST.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2015 The Project Lombok Authors. + * Copyright (C) 2009-2016 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,6 +28,8 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import javax.annotation.processing.Messager; import javax.tools.Diagnostic; @@ -315,7 +317,6 @@ public class JavacAST extends AST { // @Foo int x, y; is handled in javac by putting the same annotation node on 2 JCVariableDecls. return null; } - return putInMap(new JavacNode(this, annotation, null, Kind.ANNOTATION)); } @@ -333,12 +334,40 @@ public class JavacAST extends AST { if (statement instanceof JCClassDecl) return buildType((JCClassDecl)statement); if (statement instanceof JCVariableDecl) return buildLocalVar((JCVariableDecl)statement, Kind.LOCAL); if (statement instanceof JCTry) return buildTry((JCTry) statement); - + if (statement.getClass().getSimpleName().equals("JCLambda")) return buildLambda(statement); if (setAndGetAsHandled(statement)) return null; return drill(statement); } + private JavacNode buildLambda(JCTree jcTree) { + return buildStatementOrExpression(getBody(jcTree)); + } + + private JCTree getBody(JCTree jcTree) { + try { + return (JCTree) getBodyMethod(jcTree.getClass()).invoke(jcTree); + } catch (Exception e) { + throw Javac.sneakyThrow(e); + } + } + + private final static ConcurrentMap, Method> getBodyMethods = new ConcurrentHashMap, Method>(); + + private Method getBodyMethod(Class c) { + Method m = getBodyMethods.get(c); + if (m != null) { + return m; + } + try { + m = c.getMethod("getBody"); + } catch (NoSuchMethodException e) { + throw Javac.sneakyThrow(e); + } + getBodyMethods.putIfAbsent(c, m); + return getBodyMethods.get(c); + } + private JavacNode drill(JCTree statement) { try { List childNodes = new ArrayList(); diff --git a/test/transform/resource/after-delombok/ValFinal.java b/test/transform/resource/after-delombok/ValFinal.java new file mode 100644 index 00000000..d35ca713 --- /dev/null +++ b/test/transform/resource/after-delombok/ValFinal.java @@ -0,0 +1,5 @@ +public class ValFinal { + public void test() { + final int x = 10; + } +} \ No newline at end of file diff --git a/test/transform/resource/after-delombok/ValInLambda.java b/test/transform/resource/after-delombok/ValInLambda.java new file mode 100644 index 00000000..7ce1e1b4 --- /dev/null +++ b/test/transform/resource/after-delombok/ValInLambda.java @@ -0,0 +1,18 @@ +// version 8: +class ValInLambda { + Runnable foo = (Runnable) () -> { + final int i = 1; + }; + + public void easyLambda() { + Runnable foo = (Runnable) () -> { + final int i = 1; + }; + } + + public void easyIntersectionLambda() { + Runnable foo = (Runnable) () -> { + final int i = 1; + }; + } +} diff --git a/test/transform/resource/after-ecj/ValFinal.java b/test/transform/resource/after-ecj/ValFinal.java new file mode 100644 index 00000000..d7cf9cb7 --- /dev/null +++ b/test/transform/resource/after-ecj/ValFinal.java @@ -0,0 +1,9 @@ +import lombok.val; +public class ValFinal { + public ValFinal() { + super(); + } + public void test() { + final @val int x = 10; + } +} diff --git a/test/transform/resource/after-ecj/ValInLambda.java b/test/transform/resource/after-ecj/ValInLambda.java new file mode 100644 index 00000000..7669789b --- /dev/null +++ b/test/transform/resource/after-ecj/ValInLambda.java @@ -0,0 +1,21 @@ +// version 8: + +import lombok.val; +class ValInLambda { + Runnable foo = (Runnable) () -> { + final @val int i = 1; +}; + ValInLambda() { + super(); + } + public void easyLambda() { + Runnable foo = (Runnable) () -> { + final @val int i = 1; +}; + } + public void easyIntersectionLambda() { + Runnable foo = (Runnable) () -> { + final @val int i = 1; +}; + } +} diff --git a/test/transform/resource/before/ValFinal.java b/test/transform/resource/before/ValFinal.java new file mode 100644 index 00000000..3c5af366 --- /dev/null +++ b/test/transform/resource/before/ValFinal.java @@ -0,0 +1,6 @@ +import lombok.val; +public class ValFinal { + public void test() { + final val x = 10; + } +} \ No newline at end of file diff --git a/test/transform/resource/before/ValInLambda.java b/test/transform/resource/before/ValInLambda.java new file mode 100644 index 00000000..2c2a5942 --- /dev/null +++ b/test/transform/resource/before/ValInLambda.java @@ -0,0 +1,21 @@ +// version 8: + +import lombok.val; + +class ValInLambda { + Runnable foo = (Runnable) () -> { + val i = 1; + }; + + public void easyLambda() { + Runnable foo = (Runnable) () -> { + val i = 1; + }; + } + + public void easyIntersectionLambda() { + Runnable foo = (Runnable) () -> { + val i = 1; + }; + } +} -- cgit From 2f210869f3ad6608cfa1aa8b8beb12c2f4bb9c35 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Mon, 17 Oct 2016 22:24:04 +0200 Subject: Make fieldsOfASTClasses thread safe --- src/core/lombok/core/AST.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/core/lombok/core/AST.java b/src/core/lombok/core/AST.java index e6efe058..2d5e5352 100644 --- a/src/core/lombok/core/AST.java +++ b/src/core/lombok/core/AST.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2013 The Project Lombok Authors. + * Copyright (C) 2009-2016 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -21,7 +21,7 @@ */ package lombok.core; -import static lombok.Lombok.*; +import static lombok.Lombok.sneakyThrow; import java.lang.reflect.Array; import java.lang.reflect.Field; @@ -31,10 +31,11 @@ import java.lang.reflect.Type; import java.net.URI; import java.util.ArrayList; import java.util.Collection; -import java.util.HashMap; import java.util.IdentityHashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import lombok.core.configuration.ConfigurationKey; import lombok.core.debug.HistogramTracker; @@ -209,11 +210,11 @@ public abstract class AST, L extends LombokNode, } } - private static Map, Collection> fieldsOfASTClasses = new HashMap, Collection>(); + private static final ConcurrentMap, Collection> fieldsOfASTClasses = new ConcurrentHashMap, Collection>(); /** Returns FieldAccess objects for the stated class. Each field that contains objects of the kind returned by * {@link #getStatementTypes()}, either directly or inside of an array or java.util.collection (or array-of-arrays, - * or collection-of-collections, etcetera), is returned. + * or collection-of-collections, et cetera), is returned. */ protected Collection fieldsOf(Class c) { Collection fields = fieldsOfASTClasses.get(c); @@ -221,8 +222,8 @@ public abstract class AST, L extends LombokNode, fields = new ArrayList(); getFields(c, fields); - fieldsOfASTClasses.put(c, fields); - return fields; + fieldsOfASTClasses.putIfAbsent(c, fields); + return fieldsOfASTClasses.get(c); } private void getFields(Class c, Collection fields) { -- cgit From 49f0bc1c3ede3c81754568af22fcdbbe8f4b5a8f Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Mon, 17 Oct 2016 23:03:32 +0200 Subject: Cleanup --- AUTHORS | 2 +- doc/changelog.markdown | 1 + src/core/lombok/core/AST.java | 17 +++++++++-------- src/core/lombok/eclipse/EclipseAST.java | 6 +++--- src/core/lombok/javac/JavacAST.java | 7 +++---- 5 files changed, 17 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/AUTHORS b/AUTHORS index a9339bd2..aaa6b258 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,5 +1,6 @@ Lombok contributors in alphabetical order: +Bulgakov Alexander Christian Sterzl DaveLaw Dawid Rusin @@ -19,6 +20,5 @@ Szymon Pacanowski Taiki Sugawara Thomas Darimont Yun Zhi Lin -Bulgakov Alexander By adding your name to this list, you grant full and irrevocable copyright and patent indemnity to Project Lombok and all use of Project Lombok, and you certify that you have the right to do so for all commits you add to Project Lombok. diff --git a/doc/changelog.markdown b/doc/changelog.markdown index 0ee812e7..89df8709 100644 --- a/doc/changelog.markdown +++ b/doc/changelog.markdown @@ -3,6 +3,7 @@ Lombok Changelog ### v1.16.11 "Edgy Guinea Pig" * v1.16.10 is the latest release +* BUGFIX: `val` in lambda expressions now work as expected [Issue #911](https://github.com/rzwitserloot/lombok/issues/911) * PLATFORM: Red Hat JBoss Developer Studio is now correctly identified by the installer [Issue #1164](https://github.com/rzwitserloot/lombok/issues/1164) * BUGFIX: delombok: for-loops with initializers that are not local variables would be generated incorrectly [Issue #1076](https://github.com/rzwitserloot/lombok/issues/1076) diff --git a/src/core/lombok/core/AST.java b/src/core/lombok/core/AST.java index 2d5e5352..1142018f 100644 --- a/src/core/lombok/core/AST.java +++ b/src/core/lombok/core/AST.java @@ -62,12 +62,18 @@ public abstract class AST, L extends LombokNode, Map identityDetector = new IdentityHashMap(); private Map nodeMap = new IdentityHashMap(); private boolean changed = false; + + // The supertypes which are considered AST Node children. Usually, the Statement, and the Expression, + // though some platforms (such as Eclipse) group these under one common supertype. + private final Collection> statementTypes; + private static final HistogramTracker configTracker = System.getProperty("lombok.timeConfig") == null ? null : new HistogramTracker("lombok.config"); - protected AST(String fileName, String packageDeclaration, ImportList imports) { + protected AST(String fileName, String packageDeclaration, ImportList imports, Collection> statementTypes) { this.fileName = fileName == null ? "(unknown).java" : fileName; this.packageDeclaration = packageDeclaration; this.imports = imports; + this.statementTypes = statementTypes; } /** @@ -262,13 +268,8 @@ public abstract class AST, L extends LombokNode, return Object.class; } - /** - * The supertypes which are considered AST Node children. Usually, the Statement, and the Expression, - * though some platforms (such as Eclipse) group these under one common supertype. */ - protected abstract Collection> getStatementTypes(); - - protected boolean shouldDrill(Class parentType, Class childType, String fieldName) { - for (Class statementType : getStatementTypes()) { + private boolean shouldDrill(Class parentType, Class childType, String fieldName) { + for (Class statementType : statementTypes) { if (statementType.isAssignableFrom(childType)) return true; } diff --git a/src/core/lombok/eclipse/EclipseAST.java b/src/core/lombok/eclipse/EclipseAST.java index 6741b33a..dc2c9843 100644 --- a/src/core/lombok/eclipse/EclipseAST.java +++ b/src/core/lombok/eclipse/EclipseAST.java @@ -62,7 +62,7 @@ public class EclipseAST extends AST { * @param ast The compilation unit, which serves as the top level node in the tree to be built. */ public EclipseAST(CompilationUnitDeclaration ast) { - super(toFileName(ast), packageDeclaration(ast), new EclipseImportList(ast)); + super(toFileName(ast), packageDeclaration(ast), new EclipseImportList(ast), statementTypes()); this.compilationUnitDeclaration = ast; setTop(buildCompilationUnit(ast)); this.completeParse = isComplete(ast); @@ -477,9 +477,9 @@ public class EclipseAST extends AST { return putInMap(new EclipseNode(this, statement, childNodes, Kind.STATEMENT)); } - /** For Eclipse, only Statement counts, as Expression is a subclass of it, even though this isn't + /* For Eclipse, only Statement counts, as Expression is a subclass of it, even though this isn't * entirely correct according to the JLS spec (only some expressions can be used as statements, not all of them). */ - @Override protected Collection> getStatementTypes() { + private static Collection> statementTypes() { return Collections.>singleton(Statement.class); } diff --git a/src/core/lombok/javac/JavacAST.java b/src/core/lombok/javac/JavacAST.java index 3130e7a5..106a29ae 100644 --- a/src/core/lombok/javac/JavacAST.java +++ b/src/core/lombok/javac/JavacAST.java @@ -81,7 +81,7 @@ public class JavacAST extends AST { * @param top The compilation unit, which serves as the top level node in the tree to be built. */ public JavacAST(Messager messager, Context context, JCCompilationUnit top) { - super(sourceName(top), PackageName.getPackageName(top), new JavacImportList(top)); + super(sourceName(top), PackageName.getPackageName(top), new JavacImportList(top), statementTypes()); setTop(buildCompilationUnit(top)); this.context = context; this.messager = messager; @@ -383,9 +383,8 @@ public class JavacAST extends AST { } } - /** For javac, both JCExpression and JCStatement are considered as valid children types. */ - @Override - protected Collection> getStatementTypes() { + /* For javac, both JCExpression and JCStatement are considered as valid children types. */ + private static Collection> statementTypes() { Collection> collection = new ArrayList>(3); collection.add(JCStatement.class); collection.add(JCExpression.class); -- cgit