You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2020/05/22 03:59:38 UTC
[groovy] branch master updated: GROOVY-9568: groovydoc: don't try
to find ctors from methods (closes #1251)
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new bb9f69b GROOVY-9568: groovydoc: don't try to find ctors from methods (closes #1251)
bb9f69b is described below
commit bb9f69ba058f782c27e9642c51c2605bc58dd280
Author: Mikko Värri <vm...@linuxbox.fi>
AuthorDate: Fri May 22 02:18:15 2020 +0300
GROOVY-9568: groovydoc: don't try to find ctors from methods (closes #1251)
---
.../java/org/apache/groovy/antlr/GroovydocVisitor.java | 9 +--------
.../groovy/tools/groovydoc/GroovyDocToolTest.java | 16 ++++++++++++++++
.../testfiles/GroovyClassWithMultipleInterfaces.groovy | 1 +
3 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/subprojects/groovy-groovydoc/src/main/java/org/apache/groovy/antlr/GroovydocVisitor.java b/subprojects/groovy-groovydoc/src/main/java/org/apache/groovy/antlr/GroovydocVisitor.java
index a89b7e7..c51689f 100644
--- a/subprojects/groovy-groovydoc/src/main/java/org/apache/groovy/antlr/GroovydocVisitor.java
+++ b/subprojects/groovy-groovydoc/src/main/java/org/apache/groovy/antlr/GroovydocVisitor.java
@@ -139,14 +139,7 @@ public class GroovydocVisitor extends ClassCodeVisitorSupport {
classDocs.put(currentClassDoc.getFullPathName(), currentClassDoc);
super.visitClass(node);
SimpleGroovyClassDoc parent = currentClassDoc;
- boolean explicitCons = false;
- for (GroovyMethodDoc meth : currentClassDoc.methods()) {
- if (meth instanceof SimpleGroovyConstructorDoc) {
- explicitCons = true;
- break;
- }
- }
- if (!explicitCons) {
+ if (currentClassDoc.constructors().length == 0) {
// add default no-arg constructor
SimpleGroovyConstructorDoc cons = new SimpleGroovyConstructorDoc(name, currentClassDoc);
cons.setPublic(true);
diff --git a/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/GroovyDocToolTest.java b/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/GroovyDocToolTest.java
index 979cea0..ed5b64c 100644
--- a/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/GroovyDocToolTest.java
+++ b/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/GroovyDocToolTest.java
@@ -1027,6 +1027,22 @@ public class GroovyDocToolTest extends GroovyTestCase {
assertTrue("The Java method comment should contain links", javaMethodComment.find());
}
+ public void testPrivateDefaultConstructor() throws Exception {
+ final String base = "org/codehaus/groovy/tools/groovydoc/testfiles";
+ htmlTool.add(Arrays.asList(
+ base + "/GroovyClassWithMultipleInterfaces.groovy"
+ ));
+
+ final MockOutputTool output = new MockOutputTool();
+ htmlTool.renderToOutput(output, MOCK_DIR);
+
+ final String groovydoc = output.getText(MOCK_DIR + "/" + base + "/GroovyClassWithMultipleInterfaces.html");
+
+ final Matcher matcher = Pattern.compile(Pattern.quote("GroovyClassWithMultipleInterfaces()")).matcher(groovydoc);
+
+ assertFalse("Private ctor should not be listed", matcher.find());
+ }
+
public void testScript() throws Exception {
List<String> srcList = new ArrayList<String>();
srcList.add("org/codehaus/groovy/tools/groovydoc/testfiles/Script.groovy");
diff --git a/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/testfiles/GroovyClassWithMultipleInterfaces.groovy b/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/testfiles/GroovyClassWithMultipleInterfaces.groovy
index c9dad7a..41946fd 100644
--- a/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/testfiles/GroovyClassWithMultipleInterfaces.groovy
+++ b/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/testfiles/GroovyClassWithMultipleInterfaces.groovy
@@ -19,4 +19,5 @@
package org.codehaus.groovy.tools.groovydoc.testfiles
abstract class GroovyClassWithMultipleInterfaces implements GroovyInterface1, JavaInterface1, Runnable {
+ private GroovyClassWithMultipleInterfaces() {}
}