[
https://issues.apache.org/jira/browse/GROOVY-10593?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17531146#comment-17531146
]
ASF GitHub Bot commented on GROOVY-10593:
-----------------------------------------
paulk-asert commented on code in PR #1716:
URL: https://github.com/apache/groovy/pull/1716#discussion_r863679483
##########
subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java:
##########
@@ -682,11 +686,24 @@ private static boolean isPrimitiveType(String name) {
private GroovyClassDoc resolveInternalClassDocFromImport(GroovyRootDoc
rootDoc, String baseName) {
if (isPrimitiveType(baseName)) return null;
for (String importName : importedClassesAndPackages) {
- if (importName.endsWith("/" + baseName)) {
- GroovyClassDoc doc =
((SimpleGroovyRootDoc)rootDoc).classNamedExact(importName);
- if (doc != null) return doc;
+ String targetClassName = null;
+ if (aliases.containsKey(baseName)) {
+ targetClassName = aliases.get(baseName);
+ } else if (importName.endsWith("/" + baseName)) {
+ targetClassName = importName;
} else if (importName.endsWith("/*")) {
- GroovyClassDoc doc =
((SimpleGroovyRootDoc)rootDoc).classNamedExact(importName.substring(0,
importName.length() - 2) + baseName);
+ targetClassName = importName.substring(0, importName.length()
- 1) + baseName;
+ }
+ // need this for correct resolution of static imports
+ if (targetClassName != null){
+ GroovyClassDoc doc = null;
+ Optional<Name> name = new
JavaParser().parseName(targetClassName.replace('/','.')).getResult();
+ String staticPart = "";
+ while (doc == null && name.isPresent()) {
+ doc =
((SimpleGroovyRootDoc)rootDoc).classNamedExact(name.get().asString().replace('.','/')+staticPart);
+ staticPart = "."+name.get().getIdentifier()+staticPart;
+ name = name.get().getQualifier();
+ }
Review Comment:
I had a look at the other places which call that method. I am unsure if any
are affected in the same way, so I've merged as is and we can always refine
later if we find a case.
> Groovydoc links to wrong type
> -----------------------------
>
> Key: GROOVY-10593
> URL: https://issues.apache.org/jira/browse/GROOVY-10593
> Project: Groovy
> Issue Type: Bug
> Components: GroovyDoc
> Affects Versions: 3.0.4, 3.0.5, 3.0.6, 3.0.7, 3.0.8, 3.0.9, 3.0.10, 4.0.0,
> 4.0.1
> Reporter: Stephane Talbot
> Priority: Major
> Time Spent: 20m
> Remaining Estimate: 0h
>
> When I generate groovydoc for the following classes:
> {code:title=a/List.java}
> package a;
> public interface List {}
> {code}
>
> {code:title=b/Test.groovy}
> package b
> import a.List
> public interface Test extends List {}
> {code}
> Then in the documentation of the Test interface, the _List_ interface is
> linked with *java.util.List* instead of {*}a.List{*}.
> It was working as expected until Groovy 3.0.4
--
This message was sent by Atlassian Jira
(v8.20.7#820007)