Skip to content

Commit

Permalink
GROOVY-10121
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Aug 9, 2021
1 parent 01cc9ac commit fea9315
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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

Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit fea9315

Please sign in to comment.