dbalek commented on code in PR #8858:
URL: https://github.com/apache/netbeans/pull/8858#discussion_r2382116604


##########
java/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionCollector.java:
##########
@@ -162,6 +166,38 @@ public static Supplier<String> getDocumentation(Document 
doc, int offset, Elemen
                     @Override
                     public Future<String> create(CompilationInfo 
compilationInfo, Element element, Callable<Boolean> cancel) {
                         ElementJavadoc doc = 
ElementJavadoc.create(compilationInfo, element, cancel);
+                        if (doc.getGotoSourceAction() == null && doc.getURL() 
== null) {
+                            // try to attach sources
+                            final TypeElement te = 
compilationInfo.getElementUtilities().outermostTypeElement(element);
+                            final ClasspathInfo cpInfo = 
compilationInfo.getClasspathInfo();
+                            final ClassPath cp = 
ClassPathSupport.createProxyClassPath(
+                                
cpInfo.getClassPath(ClasspathInfo.PathKind.BOOT),
+                                
cpInfo.getClassPath(ClasspathInfo.PathKind.COMPILE),
+                                
cpInfo.getClassPath(ClasspathInfo.PathKind.SOURCE));
+                            final FileObject resource = 
cp.findResource(te.getQualifiedName().toString().replace('.', '/') + ".class");
+                            if (resource != null) {
+                                final FileObject root = 
cp.findOwnerRoot(resource);
+                                if (root != null) {
+                                    CompletableFuture<String> future = new 
CompletableFuture<>();
+                                    try {
+                                        
SourceJavadocAttacher.attachSources(root.toURL(), new 
SourceJavadocAttacher.AttachmentListener() {

Review Comment:
   The whole computation is performed asynchronously in the 
`TextDocumentServiceImpl.WORKER` thread.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to