mbien commented on code in PR #8425: URL: https://github.com/apache/netbeans/pull/8425#discussion_r2206010852
########## java/java.editor.base/src/org/netbeans/modules/java/editor/base/imports/UnusedImports.java: ########## @@ -133,6 +142,23 @@ private void handleJavadoc(TreePath classMember) { public Map<ImportTree, TreePath/*ImportTree*/> getUnusedImports() { Map<ImportTree, TreePath> ret = new HashMap<>(import2Highlight); ret.keySet().removeAll(usageCounts.keySet()); + for (Iterator<ModuleElement> it = usedModules.iterator(); it.hasNext(); ) { + ModuleElement primary = it.next(); + ImportTree imp = primaryModule2Import.get(primary); + + if (imp != null) { + it.remove(); Review Comment: this getter as side effects. Calling it multiple times will give different results. should it copy `unusedModules` before use? Map is likely small so it shouldn't be noticeable. Makes it safer to debug and avoids problems in future even if it is only called once now. -- 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: notifications-unsubscr...@netbeans.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org For additional commands, e-mail: notifications-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists