Skip to content

Commit

Permalink
Update the Groovy plugin to 4.0.0-alpha-2
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Dec 22, 2020
1 parent 49a0d4d commit 0e195d3
Show file tree
Hide file tree
Showing 179 changed files with 112,817 additions and 119 deletions.
4 changes: 4 additions & 0 deletions Site-org.codehaus.groovy.eclipse/site.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
<category name="org.codehaus.groovy.compilers"/>
</feature>

<feature id="org.codehaus.groovy40.feature" url="features/org.codehaus.groovy40.feature_4.0.0.qualifier.jar" version="4.0.0.qualifier">
<category name="org.codehaus.groovy.compilers"/>
</feature>

<feature id="org.codehaus.groovy.m2eclipse.feature" url="features/org.codehaus.groovy.m2eclipse.feature_4.0.0.qualifier.jar" version="4.0.0.qualifier">
<category name="org.codehaus.groovy.m2eclipse"/>
</feature>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ private void addJUnitAndSpock(final IPath projectPath) throws Exception {
if (isAtLeastGroovy(30)) {
jUnitVersion = 5;
spockCorePath = "lib/spock-core-2.0-M4-groovy-3.0.jar";
if (isAtLeastGroovy(40)) {
System.setProperty("spock.iKnowWhatImDoing.disableGroovyVersionCheck", "true");
}
} else {
spockCorePath = "lib/spock-core-1.3-groovy-2.5.jar";
}
Expand All @@ -114,7 +117,6 @@ private void addJUnitAndSpock(final IPath projectPath) throws Exception {

// check whether these are identical (in everything except name!)
private static void compareClassNodes(final ClassNode jcn, final ClassNode cn, final int d) {
System.out.println("Comparing ClassNodes\njcn=" + jcn.toString() + "\n cn=" + cn.toString());
assertEquals(cn.isGenericsPlaceHolder(), jcn.isGenericsPlaceHolder());

GenericsType[] cnGenerics = cn.getGenericsTypes();
Expand All @@ -129,8 +131,7 @@ private static void compareClassNodes(final ClassNode jcn, final ClassNode cn, f
}
assertNotNull(jcnGenerics);
assertEquals(cnGenerics.length, jcnGenerics.length);
for (int i = 0; i < cnGenerics.length; i++) {
System.out.println("Comparing generics types information, index #" + i);
for (int i = 0, n = cnGenerics.length; i < n; i += 1) {
compareGenericsTypes(jcnGenerics[i], cnGenerics[i], d + 1);
}
}
Expand All @@ -147,12 +148,10 @@ private static void compareGenericsTypes(final GenericsType jgt, final GenericsT
}

private static void compareType(final ClassNode jcn, final ClassNode cn, final int d) {
System.out.println("Compare type of GenericsType: jcn=" + jcn + " cn=" + cn);
compareClassNodes(jcn, cn, d + 1);
}

private static void compareLowerBound(final ClassNode jcn, final ClassNode cn, final int d) {
System.out.println("Comparing lower bound");
if (jcn == null) {
assertNull(cn);
} else {
Expand All @@ -162,7 +161,6 @@ private static void compareLowerBound(final ClassNode jcn, final ClassNode cn, f
}

private static void compareUpperBounds(final ClassNode[] jcnlist, final ClassNode[] cnlist, final int d) {
System.out.println("Comparing upper bounds: jcn=" + Arrays.toString(jcnlist) + " cn=" + Arrays.toString(cnlist));
if (cnlist == null) {
if (jcnlist != null) {
fail("Should be null but is " + Arrays.toString(jcnlist));
Expand Down Expand Up @@ -2411,9 +2409,6 @@ public void testSimpleTaskMarkerInSingleLineComment() throws Exception {
fullBuild(paths[0]);

Problem[] rootProblems = env.getProblemsFor(pathToA);
for (int i = 0; i < rootProblems.length; i += 1) {
System.out.println(i + " " + rootProblems[i] + "[" + rootProblems[i].getMessage() + "]" + rootProblems[i].getEnd());
}
// positions should be from the first character of the tag to the character after the last in the text
expectingSpecificProblemFor(pathToA, new Problem("A", toTask("todo", "nothing"), pathToA, 24, 36, -1, IMarker.SEVERITY_ERROR));
}
Expand Down Expand Up @@ -2459,9 +2454,6 @@ public void testSimpleTaskMarkerInSingleLineCommentEndOfClassCaseInsensitive() t
fullBuild(paths[0]);

Problem[] rootProblems = env.getProblemsFor(pathToA);
for (int i = 0; i < rootProblems.length; i += 1) {
System.out.println(i + " " + rootProblems[i] + "[" + rootProblems[i].getMessage() + "]" + rootProblems[i].getEnd());
}
expectingSpecificProblemFor(pathToA, new Problem("A", toTask("todo", "nothing"), pathToA, 24, 36, -1, IMarker.SEVERITY_ERROR));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package org.eclipse.jdt.core.groovy.tests.search;

import static org.eclipse.jdt.groovy.core.tests.GroovyBundle.isAtLeastGroovy;

import org.junit.Test;

/**
Expand Down Expand Up @@ -62,7 +64,11 @@ public void testSyntheticAccessors2() {
" }\n" +
"}\n";

assertUnknown(contents, "isBar");
if (!isAtLeastGroovy(40)) {
assertUnknown(contents, "isBar");
} else {
assertKnown(contents, "isBar", "Foo");
}
assertKnown(contents, "getBar", "Foo");
assertKnown(contents, "setBar", "Foo");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ protected String[] getDefaultClassPaths() {
String[] cps = super.getDefaultClassPaths();
String[] newcps = Arrays.copyOf(cps, cps.length + 2);

String[] groovyVersions = {"3.0.7-indy", "2.5.14-indy"};
String[] groovyVersions = {"4.0.0", "3.0.7-indy", "2.5.14-indy"};
String[] ivyVersions = {"2.5.0", "2.4.0"};
try {
URL groovyJar = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.eclipse.jdt.groovy.core.tests.basic;

import static org.eclipse.jdt.groovy.core.tests.GroovyBundle.isAtLeastGroovy;
import static org.eclipse.jdt.groovy.core.tests.GroovyBundle.isParrotParser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
Expand Down Expand Up @@ -5256,24 +5257,28 @@ public void testJDKClasses() {
public void testVisibility() {
//@formatter:off
String[] sources = {
"p/First.groovy",
"p/Foo.groovy",
"package p;\n" +
"import q.Second;\n" +
"public class First {\n" +
"import q.Bar;\n" +
"public class Foo {\n" +
" public static void main(String[] argv) {\n" +
" new First().getIt();\n" +
" new Foo().getIt();\n" +
" print \"success\"\n" +
" }\n" +
" public Second getIt() { return null;}\n" +
" public Bar getIt() { return null;}\n" +
"}\n",

"q/Second.java",
"q/Bar.java",
"package q;\n" +
"class Second {}\n",
"class Bar {}\n",
};
//@formatter:on

runConformTest(sources, "success");
if (!isAtLeastGroovy(40)) {
runConformTest(sources, "success");
} else {
runConformTest(sources, "", "java.lang.IllegalAccessError: failed to access class q.Bar from class p.Foo");
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2500,16 +2500,17 @@ public void testCompileStatic9007or9043_enumConstToPrivate1() {
};
//@formatter:on

runConformTest(sources, "", "groovy.lang.MissingPropertyException: No such property: name for class: E");
/* TODO: https://issues.apache.org/jira/browse/GROOVY-9093
runNegativeTest(sources,
"----------\n" +
"1. ERROR in Main.groovy (at line 6)\n" +
"\tE.ONE.name\n" +
"\t^^^^^\n" +
"Groovy:Access to E#name is forbidden @ line 6, column 3.\n" +
"----------\n");
*/
if (!isAtLeastGroovy(40)) {
runConformTest(sources, "", "groovy.lang.MissingPropertyException: No such property: name for class: E");
} else {
runNegativeTest(sources,
"----------\n" +
"1. ERROR in Main.groovy (at line 6)\n" +
"\tprint E.ONE.name\n" +
"\t ^^^^^\n" +
"Groovy:Access to E#name is forbidden\n" +
"----------\n");
}
}

@Test
Expand All @@ -2528,16 +2529,17 @@ public void testCompileStatic9007or9043_enumConstToPrivate2() {
};
//@formatter:on

runConformTest(sources, "", "groovy.lang.MissingPropertyException: No such property: ordinal for class: E");
/* TODO: https://issues.apache.org/jira/browse/GROOVY-9093
runNegativeTest(sources,
"----------\n" +
"1. ERROR in Main.groovy (at line 6)\n" +
"\tE.ONE.ordinal\n" +
"\t^^^^^\n" +
"Groovy:Access to E#ordinal is forbidden @ line 6, column 3.\n" +
"----------\n");
*/
if (!isAtLeastGroovy(40)) {
runConformTest(sources, "", "groovy.lang.MissingPropertyException: No such property: ordinal for class: E");
} else {
runNegativeTest(sources,
"----------\n" +
"1. ERROR in Main.groovy (at line 6)\n" +
"\tprint E.ONE.ordinal\n" +
"\t ^^^^^\n" +
"Groovy:Access to E#ordinal is forbidden\n" +
"----------\n");
}
}

@Test
Expand Down Expand Up @@ -3054,16 +3056,17 @@ public void testCompileStatic9043_subToPackage2() {
};
//@formatter:on

runConformTest(sources, "");
/* TODO: https://issues.apache.org/jira/browse/GROOVY-9093
runNegativeTest(sources,
"----------\n" +
"1. ERROR in q\\More.groovy (at line 5)\n" +
"\tprint VALUE\n" +
"\t ^^^^^\n" +
"Groovy:Access to q.More#VALUE is forbidden @ line 5, column 11.\n" +
"----------\n");
*/
if (!isAtLeastGroovy(40)) {
runConformTest(sources, "");
} else {
runNegativeTest(sources,
"----------\n" +
"1. ERROR in q\\More.groovy (at line 5)\n" +
"\tprint VALUE\n" +
"\t ^^^^^\n" +
"Groovy:Access to q.More#VALUE is forbidden\n" +
"----------\n");
}
}

@Test
Expand Down Expand Up @@ -3205,16 +3208,17 @@ public void testCompileStatic9043_subToPrivate2() {
};
//@formatter:on

runConformTest(sources, "");
/* TODO: https://issues.apache.org/jira/browse/GROOVY-9093
runNegativeTest(sources,
"----------\n" +
"1. ERROR in q\\More.groovy (at line 5)\n" +
"\tprint VALUE\n" +
"\t ^^^^^\n" +
"Groovy:Access to q.More#VALUE is forbidden @ line 5, column 11.\n" +
"----------\n");
*/
if (!isAtLeastGroovy(40)) {
runConformTest(sources, "");
} else {
runNegativeTest(sources,
"----------\n" +
"1. ERROR in q\\More.groovy (at line 5)\n" +
"\tprint VALUE\n" +
"\t ^^^^^\n" +
"Groovy:Access to q.More#VALUE is forbidden\n" +
"----------\n");
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public final class TypeCheckedTests extends GroovyCompilerTestSuite {
public void testTypeChecked1() {
//@formatter:off
String[] sources = {
"Foo.groovy",
"Main.groovy",
"import groovy.transform.TypeChecked\n"+
"@TypeChecked\n"+
"void method(String message) {\n"+
Expand All @@ -40,12 +40,12 @@ public void testTypeChecked1() {

runNegativeTest(sources,
"----------\n" +
"1. ERROR in Foo.groovy (at line 4)\n" +
"1. ERROR in Main.groovy (at line 4)\n" +
"\tif (rareCondition) {\n" +
"\t ^^^^^^^^^^^^^\n" +
"Groovy:[Static type checking] - The variable [rareCondition] is undeclared.\n" +
"----------\n" +
"2. ERROR in Foo.groovy (at line 5)\n" +
"2. ERROR in Main.groovy (at line 5)\n" +
"\tprintln \"Did you spot the error in this ${message.toUppercase()}?\"\n" +
"\t ^^^^^^^^^^^^^^^^^^^^^\n" +
"Groovy:[Static type checking] - Cannot find matching method java.lang.String#toUppercase()." +
Expand All @@ -57,7 +57,7 @@ public void testTypeChecked1() {
public void testTypeChecked2() {
//@formatter:off
String[] sources = {
"Foo.groovy",
"Main.groovy",
"import groovy.transform.TypeChecked\n" +
"@TypeChecked\n" +
"void method(String message) {\n" +
Expand All @@ -70,7 +70,7 @@ public void testTypeChecked2() {

runNegativeTest(sources,
"----------\n" +
"1. ERROR in Foo.groovy (at line 6)\n" +
"1. ERROR in Main.groovy (at line 6)\n" +
"\tls.add(\'abc\')\n" +
"\t^^^^^^^^^^^^^\n" +
"Groovy:[Static type checking] - Cannot find matching method java.util.ArrayList#add(java.lang.String). Please check if the declared type is correct and if the method exists.\n" +
Expand All @@ -81,7 +81,7 @@ public void testTypeChecked2() {
public void testTypeChecked3() {
//@formatter:off
String[] sources = {
"Foo.groovy",
"Main.groovy",
"interface I {\n" +
"}\n" +
"enum E implements I {\n" +
Expand All @@ -103,9 +103,9 @@ public void testTypeChecked3() {
public void testTypeChecked4() {
//@formatter:off
String[] sources = {
"Foo.groovy",
"Main.groovy",
"@groovy.transform.TypeChecked\n" +
"class Foo {" +
"class Main {" +
" def method() {\n" +
" Set<java.beans.BeanInfo> defs = []\n" +
" defs*.additionalBeanInfo\n" +
Expand All @@ -121,9 +121,9 @@ public void testTypeChecked4() {
public void testTypeChecked5() {
//@formatter:off
String[] sources = {
"Foo.groovy",
"Main.groovy",
"@groovy.transform.TypeChecked\n" +
"class Foo {" +
"class Main {" +
" static def method() {\n" + // static method alters type checking
" Set<java.beans.BeanInfo> defs = []\n" +
" defs*.additionalBeanInfo\n" +
Expand All @@ -139,9 +139,9 @@ public void testTypeChecked5() {
public void testTypeChecked6() {
//@formatter:off
String[] sources = {
"Foo.groovy",
"Main.groovy",
"@groovy.transform.TypeChecked\n" +
"class Foo {\n" +
"class Main {\n" +
" private Closure<String> normalizer\n" +
" String normalize(String s) {\n" +
" normalizer(s)" +
Expand All @@ -157,7 +157,7 @@ public void testTypeChecked6() {
public void testTypeChecked7() {
//@formatter:off
String[] sources = {
"Foo.groovy",
"Main.groovy",
"class C {\n" +
" C(String s, Comparable<List<Integer>> c) {\n" +
" }\n" +
Expand All @@ -177,7 +177,7 @@ public void testTypeChecked7() {
public void testTypeChecked8() {
//@formatter:off
String[] sources = {
"Foo.groovy",
"Main.groovy",
"import groovy.transform.stc.*\n" +
"class C {\n" +
" C(String s, @ClosureParams(value=SimpleType, options='java.util.List') Closure<Integer> c) {\n" +
Expand All @@ -198,7 +198,7 @@ public void testTypeChecked8() {
public void testTypeChecked9() {
//@formatter:off
String[] sources = {
"Foo.groovy",
"Main.groovy",
"class C {\n" +
" static m(String s, Comparable<List<Integer>> c) {\n" +
" }\n" +
Expand Down Expand Up @@ -486,7 +486,7 @@ public void testTypeChecked9762() {
runConformTest(sources, "[123]");
}

@Test
@Test // see GROOVY-9783 for Groovy 4
public void testTypeChecked9803() {
//@formatter:off
String[] sources = {
Expand Down
Loading

0 comments on commit 0e195d3

Please sign in to comment.