lahodaj commented on code in PR #9005:
URL: https://github.com/apache/netbeans/pull/9005#discussion_r2571523533


##########
java/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionCollector.java:
##########
@@ -558,16 +559,21 @@ public Completion 
createOverrideMethodItem(CompilationInfo info, ExecutableEleme
                     .textEdit(new TextEdit(substitutionOffset, 
substitutionOffset, EMPTY))
                     .additionalTextEdits(() -> 
modify2TextEdits(JavaSource.forFileObject(info.getFileObject()), wc -> {
                             wc.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED);
+                            ExecutableElement currentElem = 
elemHandle.resolve(wc);
+                            if (currentElem == null) {
+                                //cannot resolve?
+                                return ;
+                            }
                             TreePath tp = 
wc.getTreeUtilities().pathFor(substitutionOffset);
                             if (implement) {
-                                
GeneratorUtils.generateAbstractMethodImplementation(wc, tp, elem, 
substitutionOffset);
+                                
GeneratorUtils.generateAbstractMethodImplementation(wc, tp, currentElem, 
substitutionOffset);
                             } else {
-                                GeneratorUtils.generateMethodOverride(wc, tp, 
elem, substitutionOffset);
+                                GeneratorUtils.generateMethodOverride(wc, tp, 
currentElem, substitutionOffset);
                             }
                         }));
-            ElementHandle<ExecutableElement> handle = 
SUPPORTED_ELEMENT_KINDS.contains(elem.getKind().name()) ? 
ElementHandle.create(elem) : null;
-            if (handle != null) {
-                builder.documentation(getDocumentation(doc, offset, handle));
+            
+            if (SUPPORTED_ELEMENT_KINDS.contains(elem.getKind().name())) {

Review Comment:
   I think the `SUPPORTED_ELEMENT_KINDS` check here does not serve any function 
anymore. I believe the point here was to not call `ElementHandle.create` with 
an unsupported `ElementKind`, but: a) I think all kinds that can occur here are 
supported; b) we have already created the `ElementHandle` by this point, so if 
that would not work, it would have failed already. I think I would suggest to 
simply delete the condition here.



##########
java/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionCollector.java:
##########
@@ -558,16 +559,21 @@ public Completion 
createOverrideMethodItem(CompilationInfo info, ExecutableEleme
                     .textEdit(new TextEdit(substitutionOffset, 
substitutionOffset, EMPTY))
                     .additionalTextEdits(() -> 
modify2TextEdits(JavaSource.forFileObject(info.getFileObject()), wc -> {
                             wc.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED);
+                            ExecutableElement currentElem = 
elemHandle.resolve(wc);
+                            if (currentElem == null) {
+                                //cannot resolve?

Review Comment:
   Nit - maybe remove this comment, as other places don't have it either. (Or 
add logging to this and other places.)



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