stalb commented on code in PR #1716:
URL: https://github.com/apache/groovy/pull/1716#discussion_r857152026
##########
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:
_SimpleGroovyRootDoc.classNamedExact_ is used at several other places in
this class.
Thus I can't exclude that the same problem occurs elsewhere.
Perhaps it would be better to change the method itself.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]