mbien commented on code in PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#discussion_r1678152730


##########
java/java.hints/src/org/netbeans/modules/java/hints/infrastructure/JavaErrorProvider.java:
##########
@@ -200,25 +202,55 @@ private static List<CodeAction> 
convertFixes(ErrorDescription err, Consumer<Exce
             }
         }
 
-        List<Fix> fixes = sortFixes(lfl.getFixes());
+        List<Fix> baseFixes = lfl.getFixes();
+
+        baseFixes = sortFixes(baseFixes);
+
+        List<Pair<Fix, Boolean>> fixesAndSubfixes = new ArrayList<>(); // true 
if main fix
+
+        for (Fix f : baseFixes){
+            fixesAndSubfixes.add(Pair.of(f, true));
+
+            try {
+                Class<?> controller = 
Class.forName("org.netbeans.modules.editor.hints.HintsControllerImpl",
+                                                    false,
+                                                    
ErrorDescription.class.getClassLoader());
+                Method getSubfixes = 
controller.getDeclaredMethod("getSubfixes", Fix.class);

Review Comment:
   if it is decided that the reflection bits stay I would recommend the 
following:
    - move all relfective setup code into static initializer, log exception + 
descriptive msg, e.g "implementation changed, update needed"
    - also add a short comment that that this is the most convenient way to 
access the method without having to change module dependencies or complicate 
things further
    - inside the loop I would call a utility method, which simply returns 
`getSubfixes.invoke(null, f))` and deals with the reflective invocation 
exception there (maybe log an return empty iterable)
    
   this would move the `Class.forName` out of inner loops and help future 
maintainers to fix it it again once things start failing



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