kwin commented on code in PR #2060:
URL: https://github.com/apache/maven-resolver/pull/2060#discussion_r3804398855


##########
maven-resolver-tools/src/main/java/org/eclipse/aether/tools/ConfigurationCollectorDoclet.java:
##########
@@ -757,11 +772,39 @@ private String getConfigurationType(DocTreePath path, 
Map<String, UnknownBlockTa
                         configurationTypePath, "No valid {@link ...} reference 
found in @" + typeTag.getTagName()));
 
         String type = getType(configurationTypePath, linkTree);
+        String javadocUrl = resolveReferencedType(configurationTypePath, 
linkTree.getReference())
+                .filter(typeElement ->
+                        
!typeElement.getQualifiedName().toString().startsWith("java."))
+                .map(ConfigurationCollectorDoclet::getJavadocUrl)
+                .orElse("");
         String javaLangPackage = "java.lang.";
         if (type.startsWith(javaLangPackage)) {
             type = type.substring(javaLangPackage.length());
         }
-        return type;
+        return new ConfigurationType(type, javadocUrl);
+    }
+
+    private String getConfigurationKey(VariableElement field) {
+        if (field == null || !(field.getConstantValue() instanceof String 
key)) {
+            return null;
+        }
+        if (mode == Mode.MAVEN) {
+            return getAnnotation(field, MAVEN_CONFIG_ANNOTATION) != null ? key 
: null;
+        }
+        DocCommentTree docComment = docTrees.getDocCommentTree(field);
+        return docComment != null && 
collectBlockTags(docComment).containsKey("configurationSource") ? key : null;
+    }
+
+    private static String getJavadocUrl(TypeElement type) {
+        Element enclosing = type;
+        while (!(enclosing instanceof PackageElement)) {
+            enclosing = enclosing.getEnclosingElement();
+        }
+        String packageName = ((PackageElement) 
enclosing).getQualifiedName().toString();
+        String qualifiedName = type.getQualifiedName().toString();
+        String className = packageName.isEmpty() ? qualifiedName : 
qualifiedName.substring(packageName.length() + 1);
+        String packagePath = packageName.replace('.', '/');
+        return "apidocs/" + (packagePath.isEmpty() ? "" : packagePath + "/") + 
className + ".html";

Review Comment:
   The prefix should be configurable.



##########
maven-resolver-tools/src/main/java/org/eclipse/aether/tools/ConfigurationCollectorDoclet.java:
##########
@@ -757,11 +772,39 @@ private String getConfigurationType(DocTreePath path, 
Map<String, UnknownBlockTa
                         configurationTypePath, "No valid {@link ...} reference 
found in @" + typeTag.getTagName()));
 
         String type = getType(configurationTypePath, linkTree);
+        String javadocUrl = resolveReferencedType(configurationTypePath, 
linkTree.getReference())
+                .filter(typeElement ->
+                        
!typeElement.getQualifiedName().toString().startsWith("java."))
+                .map(ConfigurationCollectorDoclet::getJavadocUrl)
+                .orElse("");
         String javaLangPackage = "java.lang.";
         if (type.startsWith(javaLangPackage)) {
             type = type.substring(javaLangPackage.length());
         }
-        return type;
+        return new ConfigurationType(type, javadocUrl);
+    }
+
+    private String getConfigurationKey(VariableElement field) {
+        if (field == null || !(field.getConstantValue() instanceof String 
key)) {
+            return null;
+        }
+        if (mode == Mode.MAVEN) {
+            return getAnnotation(field, MAVEN_CONFIG_ANNOTATION) != null ? key 
: null;
+        }
+        DocCommentTree docComment = docTrees.getDocCommentTree(field);
+        return docComment != null && 
collectBlockTags(docComment).containsKey("configurationSource") ? key : null;
+    }
+
+    private static String getJavadocUrl(TypeElement type) {

Review Comment:
   Please use 
https://github.com/apache/maven-plugin-tools/blob/master/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/javadoc/JavadocLinkGenerator.java.
 The format of deep links (e.g. method references) differs depending on the 
javadoc version.



##########
maven-resolver-tools/src/main/java/org/eclipse/aether/tools/ConfigurationCollectorDoclet.java:
##########
@@ -757,11 +772,39 @@ private String getConfigurationType(DocTreePath path, 
Map<String, UnknownBlockTa
                         configurationTypePath, "No valid {@link ...} reference 
found in @" + typeTag.getTagName()));
 
         String type = getType(configurationTypePath, linkTree);
+        String javadocUrl = resolveReferencedType(configurationTypePath, 
linkTree.getReference())
+                .filter(typeElement ->
+                        
!typeElement.getQualifiedName().toString().startsWith("java."))
+                .map(ConfigurationCollectorDoclet::getJavadocUrl)
+                .orElse("");
         String javaLangPackage = "java.lang.";
         if (type.startsWith(javaLangPackage)) {
             type = type.substring(javaLangPackage.length());
         }
-        return type;
+        return new ConfigurationType(type, javadocUrl);
+    }
+
+    private String getConfigurationKey(VariableElement field) {
+        if (field == null || !(field.getConstantValue() instanceof String 
key)) {
+            return null;
+        }
+        if (mode == Mode.MAVEN) {
+            return getAnnotation(field, MAVEN_CONFIG_ANNOTATION) != null ? key 
: null;
+        }
+        DocCommentTree docComment = docTrees.getDocCommentTree(field);
+        return docComment != null && 
collectBlockTags(docComment).containsKey("configurationSource") ? key : null;
+    }
+
+    private static String getJavadocUrl(TypeElement type) {

Review Comment:
   Please support all types of links (not only to types, but also to elements 
(constructors, method, fields)). Also there needs to be some basic validation 
as this may also refer to types not contained in the Javadoc (e.g. transitive 
dependencies or JRE built in packages/types/elements). Also the module name 
potentially needs to be considered.



-- 
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]

Reply via email to