Skip to content

Commit 1c7dd66

Browse files
committed
1 parent 298e4be commit 1c7dd66

File tree

2,107 files changed

+1259336
-74
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,107 files changed

+1259336
-74
lines changed

base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/basic/EnumerationTests.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ public void testEnum13() {
658658
"}\n" +
659659
"\n" +
660660
"class A {\n" +
661-
" public enum C2{\n" +
661+
" enum C2{\n" +
662662
" TEST_C2\n" +
663663
" }\n" +
664664
"}\n",
@@ -699,6 +699,26 @@ public void testEnum13() {
699699
//@formatter:on
700700

701701
runConformTest(sources);
702+
703+
checkGCUDeclaration("A.groovy",
704+
"package be.flow;\n" +
705+
"public enum C1 {\n" +
706+
" TEST_C1,\n" +
707+
" private @groovy.transform.Generated C1() {\n" +
708+
" }\n" +
709+
"}\n" +
710+
"public class A {\n" +
711+
" public static enum C2 {\n" +
712+
" TEST_C2,\n" +
713+
" private @groovy.transform.Generated C2() {\n" +
714+
" }\n" +
715+
" }\n" +
716+
" public @groovy.transform.Generated A() {\n" +
717+
" }\n" +
718+
"}");
719+
720+
checkDisassemblyFor("be/flow/A$C2.class",
721+
"public static final enum be.flow.A$C2 implements ");
702722
}
703723

704724
@Test
@@ -914,6 +934,9 @@ public void testAbstractMethodWithinEnum1() {
914934
" }\n" +
915935
" public abstract int foo();\n" +
916936
"}");
937+
938+
checkDisassemblyFor("Good.class", "public abstract enum Good ");
939+
checkDisassemblyFor("Good$1.class", "\nfinal enum Good$1 {\n ");
917940
}
918941

919942
@Test

base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/basic/GroovyCompilerTestSuite.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public abstract class GroovyCompilerTestSuite {
7777
protected static final long JDK14 = (58L << 16) + ClassFileConstants.MINOR_VERSION_0;
7878
protected static final long JDK15 = (59L << 16) + ClassFileConstants.MINOR_VERSION_0;
7979
protected static final long JDK16 = (60L << 16) + ClassFileConstants.MINOR_VERSION_0;
80-
protected static final long JDK17 = (60L << 17) + ClassFileConstants.MINOR_VERSION_0;
80+
protected static final long JDK17 = (61L << 16) + ClassFileConstants.MINOR_VERSION_0;
8181

8282
@Parameters(name = "Java {1}")
8383
public static Iterable<Object[]> params() {
@@ -170,8 +170,12 @@ public String getName() {
170170

171171
@Override
172172
protected INameEnvironment getNameEnvironment(final String[] testFiles, final String[] classPaths) {
173-
this.classpaths = (classPaths == null ? getDefaultClassPaths() : classPaths);
174-
return new InMemoryNameEnvironment(testFiles, getClassLibs(false));
173+
return getNameEnvironment(testFiles, classPaths, null);
174+
}
175+
176+
protected INameEnvironment getNameEnvironment(final String[] testFiles, final String[] classPaths, final Map<String, String> options) {
177+
this.classpaths = (classPaths != null ? classPaths : getDefaultClassPaths());
178+
return new InMemoryNameEnvironment(testFiles, getClassLibs(false, options));
175179
}
176180

177181
private String resolve(final URL jarRef) throws IOException {

base/org.codehaus.groovy25/src/org/codehaus/groovy/antlr/AntlrParserPlugin.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -795,8 +795,8 @@ protected Expression anonymousInnerClassDef(AST node) {
795795
ClassNode outerClass = getClassOrScript(oldNode);
796796
String innerClassName = outerClass.getName() + "$" + (anonymousClassCount(outerClass) + 1);
797797
if (enumConstantBeingDef) {
798-
classNode = new EnumConstantClassNode(outerClass, innerClassName, Opcodes.ACC_PUBLIC, ClassHelper.OBJECT_TYPE);
799-
} else {
798+
classNode = new EnumConstantClassNode(outerClass, innerClassName, Opcodes.ACC_ENUM | Opcodes.ACC_FINAL, ClassHelper.OBJECT_TYPE);
799+
} else { // GRECLIPSE edit ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
800800
classNode = new InnerClassNode(outerClass, innerClassName, Opcodes.ACC_PUBLIC, ClassHelper.OBJECT_TYPE);
801801
}
802802
((InnerClassNode) classNode).setAnonymous(true);
@@ -1035,8 +1035,9 @@ protected void enumConstantDef(AST node) {
10351035
// we have to handle an enum constant with a class overriding
10361036
// a method in which case we need to configure the inner class
10371037
innerClass.setSuperClass(classNode.getPlainNodeReference());
1038+
/* GRECLIPSE edit
10381039
innerClass.setModifiers(classNode.getModifiers() | Opcodes.ACC_FINAL);
1039-
// GRECLIPSE add
1040+
*/
10401041
innerClass.setNameStart(nameStart);
10411042
innerClass.setNameEnd(nameEnd - 1);
10421043
// GRECLIPSE end

base/org.codehaus.groovy30/src/org/apache/groovy/parser/antlr4/AstBuilder.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1451,7 +1451,9 @@ public ClassNode visitClassDeclaration(ClassDeclarationContext ctx) {
14511451
this.hackMixins(classNode);
14521452

14531453
} else if (isEnum) {
1454+
/* GRECLIPSE edit -- EnumHelper#makeEnumNode does this
14541455
classNode.setModifiers(classNode.getModifiers() | Opcodes.ACC_ENUM | Opcodes.ACC_FINAL);
1456+
*/
14551457
classNode.setInterfaces(this.visitTypeList(ctx.is));
14561458
this.initUsingGenerics(classNode);
14571459

@@ -3657,7 +3659,7 @@ public InnerClassNode visitAnonymousInnerClassDeclaration(AnonymousInnerClassDec
36573659

36583660
InnerClassNode anonymousInnerClass;
36593661
if (1 == ctx.t) { // anonymous enum
3660-
anonymousInnerClass = new EnumConstantClassNode(outerClass, innerClassName, superClass.getModifiers() | Opcodes.ACC_FINAL, superClass.getPlainNodeReference());
3662+
anonymousInnerClass = new EnumConstantClassNode(outerClass, innerClassName, Opcodes.ACC_ENUM | Opcodes.ACC_FINAL, superClass.getPlainNodeReference());
36613663
// and remove the final modifier from classNode to allow the sub class
36623664
superClass.setModifiers(superClass.getModifiers() & ~Opcodes.ACC_FINAL);
36633665
} else { // anonymous inner class

base/org.codehaus.groovy30/src/org/codehaus/groovy/antlr/AntlrParserPlugin.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -882,8 +882,8 @@ protected Expression anonymousInnerClassDef(AST node) {
882882
ClassNode outerClass = getClassOrScript(oldNode);
883883
String innerClassName = outerClass.getName() + "$" + (anonymousClassCount(outerClass) + 1);
884884
if (enumConstantBeingDef) {
885-
classNode = new EnumConstantClassNode(outerClass, innerClassName, Opcodes.ACC_PUBLIC, ClassHelper.OBJECT_TYPE);
886-
} else {
885+
classNode = new EnumConstantClassNode(outerClass, innerClassName, Opcodes.ACC_ENUM | Opcodes.ACC_FINAL, ClassHelper.OBJECT_TYPE);
886+
} else { // GRECLIPSE edit ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
887887
classNode = new InnerClassNode(outerClass, innerClassName, Opcodes.ACC_PUBLIC, ClassHelper.OBJECT_TYPE);
888888
}
889889
((InnerClassNode) classNode).setAnonymous(true);
@@ -1123,8 +1123,9 @@ protected void enumConstantDef(AST node) {
11231123
// we have to handle an enum constant with a class overriding
11241124
// a method in which case we need to configure the inner class
11251125
innerClass.setSuperClass(classNode.getPlainNodeReference());
1126+
/* GRECLIPSE edit
11261127
innerClass.setModifiers(classNode.getModifiers() | Opcodes.ACC_FINAL);
1127-
// GRECLIPSE add
1128+
*/
11281129
innerClass.setNameStart(nameStart);
11291130
innerClass.setNameEnd(nameEnd - 1);
11301131
// GRECLIPSE end
-2.32 KB
Binary file not shown.

base/org.codehaus.groovy40/src/org/apache/groovy/parser/antlr4/AstBuilder.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,8 +1515,7 @@ public ClassNode visitClassDeclaration(final ClassDeclarationContext ctx) {
15151515

15161516
if ((isAnnotation || isEnum) && (isSealed || isNonSealed)) {
15171517
ModifierNode mn = isSealed ? sealedModifierNodeOptional.get() : nonSealedModifierNodeOptional.get();
1518-
throw createParsingFailedException("modifier `" + mn.getText() + "` is not allowed for " +
1519-
(isEnum ? "enum" : "annotation definition"), mn);
1518+
throw createParsingFailedException("modifier `" + mn.getText() + "` is not allowed for " + (isEnum ? "enum" : "annotation definition"), mn);
15201519
}
15211520

15221521
boolean hasPermits = asBoolean(ctx.PERMITS());
@@ -1613,7 +1612,9 @@ public ClassNode visitClassDeclaration(final ClassDeclarationContext ctx) {
16131612
this.hackMixins(classNode);
16141613

16151614
} else if (isEnum) {
1615+
/* GRECLIPSE edit -- EnumHelper#makeEnumNode does this
16161616
classNode.setModifiers(classNode.getModifiers() | Opcodes.ACC_ENUM | Opcodes.ACC_FINAL);
1617+
*/
16171618
classNode.setInterfaces(this.visitTypeList(ctx.is));
16181619
this.initUsingGenerics(classNode);
16191620

@@ -3829,7 +3830,7 @@ public InnerClassNode visitAnonymousInnerClassDeclaration(final AnonymousInnerCl
38293830

38303831
InnerClassNode anonymousInnerClass;
38313832
if (1 == ctx.t) { // anonymous enum
3832-
anonymousInnerClass = new EnumConstantClassNode(outerClass, innerClassName, superClass.getModifiers() | Opcodes.ACC_FINAL, superClass.getPlainNodeReference());
3833+
anonymousInnerClass = new EnumConstantClassNode(outerClass, innerClassName, Opcodes.ACC_ENUM | Opcodes.ACC_FINAL, superClass.getPlainNodeReference());
38333834
// and remove the final modifier from classNode to allow the sub class
38343835
superClass.setModifiers(superClass.getModifiers() & ~Opcodes.ACC_FINAL);
38353836
} else { // anonymous inner class

base/org.codehaus.groovy40/src/org/codehaus/groovy/antlr/AntlrParserPlugin.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -882,8 +882,8 @@ protected Expression anonymousInnerClassDef(AST node) {
882882
ClassNode outerClass = getClassOrScript(oldNode);
883883
String innerClassName = outerClass.getName() + "$" + (anonymousClassCount(outerClass) + 1);
884884
if (enumConstantBeingDef) {
885-
classNode = new EnumConstantClassNode(outerClass, innerClassName, Opcodes.ACC_PUBLIC, ClassHelper.OBJECT_TYPE);
886-
} else {
885+
classNode = new EnumConstantClassNode(outerClass, innerClassName, Opcodes.ACC_ENUM | Opcodes.ACC_FINAL, ClassHelper.OBJECT_TYPE);
886+
} else { // GRECLIPSE edit ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
887887
classNode = new InnerClassNode(outerClass, innerClassName, Opcodes.ACC_PUBLIC, ClassHelper.OBJECT_TYPE);
888888
}
889889
((InnerClassNode) classNode).setAnonymous(true);
@@ -1123,8 +1123,9 @@ protected void enumConstantDef(AST node) {
11231123
// we have to handle an enum constant with a class overriding
11241124
// a method in which case we need to configure the inner class
11251125
innerClass.setSuperClass(classNode.getPlainNodeReference());
1126+
/* GRECLIPSE edit
11261127
innerClass.setModifiers(classNode.getModifiers() | Opcodes.ACC_FINAL);
1127-
// GRECLIPSE add
1128+
*/
11281129
innerClass.setNameStart(nameStart);
11291130
innerClass.setNameEnd(nameEnd - 1);
11301131
// GRECLIPSE end

base/org.eclipse.jdt.groovy.core/src/org/codehaus/jdt/groovy/internal/compiler/ast/GroovyCompilationUnitDeclaration.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,7 @@ private void createTypeDeclarations(ModuleNode moduleNode) {
11431143
}
11441144

11451145
boolean isEnum = classNode.isEnum();
1146-
configureSuperClass(typeDeclaration, classNode.getSuperClass(), isEnum, isTrait(classNode));
1146+
if (!isEnum && !isTrait(classNode)) configureSuperClass(typeDeclaration, classNode.getSuperClass());
11471147
configureSuperInterfaces(typeDeclaration, classNode);
11481148
typeDeclaration.fields = createFieldDeclarations(classNode, isEnum);
11491149
typeDeclaration.methods = createConstructorAndMethodDeclarations(classNode, isEnum, typeDeclaration);
@@ -1546,15 +1546,9 @@ private AbstractMethodDeclaration createMethodDeclaration(ClassNode classNode, M
15461546

15471547
//----------------------------------------------------------------------
15481548

1549-
private void configureSuperClass(TypeDeclaration typeDeclaration, ClassNode superclass, boolean isEnum, boolean isTrait) {
1550-
if ((isEnum && superclass.getName().equals("java.lang.Enum")) || isTrait) {
1551-
// Don't wire it in, JDT will do it
1552-
typeDeclaration.superclass = null;
1553-
} else {
1554-
// If the start position is 0 the superclass wasn't actually declared, it was added by Groovy
1555-
if (!(superclass.getStart() == 0 && superclass.equals(ClassHelper.OBJECT_TYPE))) {
1556-
typeDeclaration.superclass = createTypeReferenceForClassNode(superclass);
1557-
}
1549+
private void configureSuperClass(TypeDeclaration typeDeclaration, ClassNode superclass) {
1550+
if (!(superclass.getStart() == 0 && superclass.equals(ClassHelper.OBJECT_TYPE))) {
1551+
typeDeclaration.superclass = createTypeReferenceForClassNode(superclass);
15581552
}
15591553
}
15601554

docs/Getting-Started-with-Groovy-Eclipse-Source-Code.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ This minimal project set should be open in your workspace:
167167
* org.eclipse.jdt.groovy.core.tests.builder
168168
* org.eclipse.jdt.groovy.core.tests.compiler
169169

170-
Note: Only one JDT patch should be imported (`org.eclipse.jdt.core`, `org.eclipse.jdt.core.tests.builder`, `org.eclipse.jdt.core.tests.compiler`) and it should be matched to the target platform of your workspace. For example, the patch in the `/e421` folder is for Eclipse 4.21 (2021-09).
170+
Note: Only one JDT patch should be imported (`org.eclipse.jdt.core`, `org.eclipse.jdt.core.tests.builder`, `org.eclipse.jdt.core.tests.compiler`) and it should be matched to the target platform of your workspace. For example, the patch in the `/e422` folder is for Eclipse 4.22 (2021-12).
171171

172172

173173
## Test with Eclipse
@@ -185,14 +185,15 @@ For manual testing and debugging, right-click on the org.codehaus.groovy.eclipse
185185

186186
[Download and install Maven](https://maven.apache.org/).
187187

188-
From the root directory of the repository, execute the following command to build Groovy-Eclipse for Eclipse 4.21 (2021-09).
188+
From the root directory of the repository, execute the following command to build Groovy-Eclipse for Eclipse 4.22 (2021-12).
189189

190190
```
191-
mvn -Pe4.21 clean install
191+
mvn -Pe4.22 clean install
192192
```
193193

194-
Replace e4.21 with a different option to build it for another Eclipse version:
194+
Replace e4.22 with a different option to build it for another Eclipse version:
195195

196+
* e4.21
196197
* e4.20
197198
* e4.19
198199
* e4.18

0 commit comments

Comments
 (0)