GROOVY-7366: Stubs do not include static imports
diff --git a/src/main/org/codehaus/groovy/tools/javac/JavaStubGenerator.java b/src/main/org/codehaus/groovy/tools/javac/JavaStubGenerator.java
index 122f486..f625d44 100644
--- a/src/main/org/codehaus/groovy/tools/javac/JavaStubGenerator.java
+++ b/src/main/org/codehaus/groovy/tools/javac/JavaStubGenerator.java
@@ -910,6 +910,14 @@
imports.addAll(Arrays.asList(ResolveVisitor.DEFAULT_IMPORTS));
+ for (Map.Entry<String, ImportNode> entry : moduleNode.getStaticImports().entrySet()) {
+ imports.add("static "+entry.getValue().getType().getName()+"."+entry.getKey());
+ }
+
+ for (Map.Entry<String, ImportNode> entry : moduleNode.getStaticStarImports().entrySet()) {
+ imports.add("static "+entry.getValue().getType().getName()+".");
+ }
+
for (String imp : imports) {
String s = new StringBuilder()
.append("import ")
diff --git a/src/test/org/codehaus/groovy/tools/stubgenerator/Groovy7366Bug.groovy b/src/test/org/codehaus/groovy/tools/stubgenerator/Groovy7366Bug.groovy
new file mode 100644
index 0000000..67c3891
--- /dev/null
+++ b/src/test/org/codehaus/groovy/tools/stubgenerator/Groovy7366Bug.groovy
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2003-2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.groovy.tools.stubgenerator
+
+class Groovy7366Bug extends StringSourcesStubTestCase {
+
+ Map<String, String> provideSources() {
+ [
+ 'Constants.java': '''
+ package test;
+ public interface Constants {
+ String C1 = "c1";
+ }
+ ''',
+ 'MyAnnotation.java': '''
+ package test;
+ public @interface MyAnnotation {
+ String value();
+ }
+ ''',
+
+ 'Test.groovy': '''
+ package test
+ import static test.Constants.C1
+ @MyAnnotation(C1)
+ class Test {
+ def test
+ Test(test) {
+ this.test = test
+ }
+ }
+ ''',
+ 'Hello.java': '''
+ package test;
+ public class Hello {
+ public static void main(String[] args) {
+ System.out.println(new Test("hello").getTest());
+ }
+ }
+ '''
+ ]
+ }
+
+ void verifyStubs() {
+
+ }
+}
\ No newline at end of file
diff --git a/src/test/org/codehaus/groovy/tools/stubgenerator/Groovy7366BugVariant.groovy b/src/test/org/codehaus/groovy/tools/stubgenerator/Groovy7366BugVariant.groovy
new file mode 100644
index 0000000..de7d373
--- /dev/null
+++ b/src/test/org/codehaus/groovy/tools/stubgenerator/Groovy7366BugVariant.groovy
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2003-2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.codehaus.groovy.tools.stubgenerator
+
+class Groovy7366BugVariant extends StringSourcesStubTestCase {
+
+ Map<String, String> provideSources() {
+ [
+ 'Constants.java': '''
+ package test;
+ public interface Constants {
+ String C1 = "c1";
+ }
+ ''',
+ 'MyAnnotation.java': '''
+ package test;
+ public @interface MyAnnotation {
+ String value();
+ }
+ ''',
+
+ 'Test.groovy': '''
+ package test
+ import static test.Constants.*
+ @MyAnnotation(C1)
+ class Test {
+ def test
+ Test(test) {
+ this.test = test
+ }
+ }
+ ''',
+ 'Hello.java': '''
+ package test;
+ public class Hello {
+ public static void main(String[] args) {
+ System.out.println(new Test("hello").getTest());
+ }
+ }
+ '''
+ ]
+ }
+
+ void verifyStubs() {
+
+ }
+}
\ No newline at end of file