From fea931509e1bad0979eeca55e541db556ca5249c Mon Sep 17 00:00:00 2001 From: Eric Milles Date: Mon, 9 Aug 2021 12:14:44 -0500 Subject: [PATCH] GROOVY-10121 --- .../tests/xform/AnnotationCollectorTests.java | 37 +++++++++++++++---- .../AnnotationCollectorTransform.java | 2 +- .../AnnotationCollectorTransform.java | 2 +- .../AnnotationCollectorTransform.java | 2 +- 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/AnnotationCollectorTests.java b/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/AnnotationCollectorTests.java index 8915968e55..247cca4637 100644 --- a/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/AnnotationCollectorTests.java +++ b/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/AnnotationCollectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2020 the original author or authors. + * Copyright 2009-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,17 +33,17 @@ public void testAnnotationCollector1() { " String id\n" + " String hidden = '456'\n" + " \n" + - " static void main(String[] args) {\n" + + " static main(args) {\n" + " print(new Type(id:'123'))\n" + " }\n" + - "}", + "}\n", "Alias.groovy", "import groovy.transform.*\n" + "@AnnotationCollector\n" + "@EqualsAndHashCode\n" + "@ToString\n" + - "@interface Alias { }", + "@interface Alias { }\n", }; //@formatter:on @@ -60,23 +60,44 @@ public void testAnnotationCollector2() { " String id\n" + " String hidden = '456'\n" + " \n" + - " static void main(String[] args) {\n" + + " static main(args) {\n" + " print(new Type(id:'123'))\n" + " }\n" + - "}", + "}\n", "Alias.groovy", "import groovy.transform.*\n" + "@AnnotationCollector([EqualsAndHashCode, ToString])\n" + - "@interface Alias { }", + "@interface Alias { }\n", }; //@formatter:on runConformTest(sources, "Type(123)"); } - @Test + @Test // GROOVY-10121 public void testAnnotationCollector3() { + //@formatter:off + String[] sources = { + "Main.groovy", + "class Main {\n" + + " static main(args) {\n" + + " print(Alias.classes*.name)\n" + + " }\n" + + "}\n", + + "Alias.groovy", + "import groovy.transform.*\n" + + "@AnnotationCollector()\n" + + "@interface Alias { }\n", + }; + //@formatter:on + + runConformTest(sources, "[Alias$CollectorHelper]"); + } + + @Test + public void testAnnotationCollector4() { //@formatter:off String[] sources = { "Book.groovy", diff --git a/base/org.codehaus.groovy25/src/org/codehaus/groovy/transform/AnnotationCollectorTransform.java b/base/org.codehaus.groovy25/src/org/codehaus/groovy/transform/AnnotationCollectorTransform.java index b644a06afe..ac0a894210 100644 --- a/base/org.codehaus.groovy25/src/org/codehaus/groovy/transform/AnnotationCollectorTransform.java +++ b/base/org.codehaus.groovy25/src/org/codehaus/groovy/transform/AnnotationCollectorTransform.java @@ -124,7 +124,7 @@ public void transformClass(ClassNode cn) { // force no interfaces implemented helper.setInterfaces(ClassNode.EMPTY_ARRAY); } else { - helper = new InnerClassNode(cn.getPlainNodeReference(), cn.getName() + "$CollectorHelper", + helper = new InnerClassNode(cn/*GRECLIPSE edit -- GROOVY-10121 .getPlainNodeReference()*/, cn.getName() + "$CollectorHelper", ACC_PUBLIC | ACC_STATIC | ACC_FINAL, ClassHelper.OBJECT_TYPE.getPlainNodeReference()); cn.getModule().addClass(helper); helper.addAnnotation(new AnnotationNode(COMPILESTATIC_CLASSNODE)); diff --git a/base/org.codehaus.groovy30/src/org/codehaus/groovy/transform/AnnotationCollectorTransform.java b/base/org.codehaus.groovy30/src/org/codehaus/groovy/transform/AnnotationCollectorTransform.java index fa11d7482d..e7f3d19995 100644 --- a/base/org.codehaus.groovy30/src/org/codehaus/groovy/transform/AnnotationCollectorTransform.java +++ b/base/org.codehaus.groovy30/src/org/codehaus/groovy/transform/AnnotationCollectorTransform.java @@ -123,7 +123,7 @@ public void transformClass(ClassNode cn) { // force no interfaces implemented helper.setInterfaces(ClassNode.EMPTY_ARRAY); } else { - helper = new InnerClassNode(cn.getPlainNodeReference(), cn.getName() + "$CollectorHelper", + helper = new InnerClassNode(cn/*GRECLIPSE edit -- GROOVY-10121 .getPlainNodeReference()*/, cn.getName() + "$CollectorHelper", ACC_PUBLIC | ACC_STATIC | ACC_FINAL, ClassHelper.OBJECT_TYPE.getPlainNodeReference()); cn.getModule().addClass(helper); helper.addAnnotation(new AnnotationNode(COMPILESTATIC_CLASSNODE)); diff --git a/base/org.codehaus.groovy40/src/org/codehaus/groovy/transform/AnnotationCollectorTransform.java b/base/org.codehaus.groovy40/src/org/codehaus/groovy/transform/AnnotationCollectorTransform.java index fa11d7482d..e7f3d19995 100644 --- a/base/org.codehaus.groovy40/src/org/codehaus/groovy/transform/AnnotationCollectorTransform.java +++ b/base/org.codehaus.groovy40/src/org/codehaus/groovy/transform/AnnotationCollectorTransform.java @@ -123,7 +123,7 @@ public void transformClass(ClassNode cn) { // force no interfaces implemented helper.setInterfaces(ClassNode.EMPTY_ARRAY); } else { - helper = new InnerClassNode(cn.getPlainNodeReference(), cn.getName() + "$CollectorHelper", + helper = new InnerClassNode(cn/*GRECLIPSE edit -- GROOVY-10121 .getPlainNodeReference()*/, cn.getName() + "$CollectorHelper", ACC_PUBLIC | ACC_STATIC | ACC_FINAL, ClassHelper.OBJECT_TYPE.getPlainNodeReference()); cn.getModule().addClass(helper); helper.addAnnotation(new AnnotationNode(COMPILESTATIC_CLASSNODE));