netbeans
netbeans copied to clipboard
Find usages does not find any Usages
Apache NetBeans version
Apache NetBeans 15
What happened
When trying to Find Usages, no Usages are found. When clicking "Refresh the refactoring data" (to repeat Find Usages), the dialog with "The original element being refactored is not available. It was deleted or significantly changed. Usages cannot be collected." appears. The method I finding usages is overloaded. Seems like problem with particular class/file, other classes works fine. Cleaning, closing/opening doesn't help.
How to reproduce
Click "Find Usages" on method. No usages are found.
Did this work correctly in an earlier version?
Apache NetBeans 14
Operating System
Linux, Debian 11
JDK
OpenJDK 64-Bit Server VM (build 11.0.15+10-post-Debian-1, mixed mode, sharing), OpenJDK
Apache NetBeans packaging
Apache NetBeans binary zip
Anything else
No response
Are you willing to submit a pull request?
No
Code of Conduct
Yes
please provide a minimal reproducer.
Also check if there is no exception reported in the Notification window. There are some unfortunate cases when an exception happens in Javac, that would silently cancel the find usage operation.
import java.util.stream.IntStream;
import java.util.stream.Stream;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class DOM {
public static Stream<Node> selectTags(final Node node) {
return selectTags(node.getChildNodes());
}
public static Stream<Node> selectTags(final NodeList nodeList) {
return IntStream.range(0, nodeList.getLength())
.mapToObj(nodeList::item);
}
}
Try to Find Usages on selectTags(final NodeList nodeList); It gives me "no occurrences". No exception is thrown. There are following messages in messages.log:
INFO [org.netbeans.api.java.source.TreePathHandle]: Cannot resolve: TreePathHandle[delegate:TreeDelegate[kind:METHOD, enclosingElement:ElementHandle[kind=METHOD; sigs=ru.justnews.nbtest.DOM selectTags (LNodeList;)Ljava/util/stream/Stream; ], file:/home/paul/work/personal/nbtest/src/main/java/ru/justnews/nbtest/DOM.java@a0d2834e:68abb08a]]
INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=METHOD; sigs=ru.justnews.nbtest.DOM selectTags (LNodeList;)Ljava/util/stream/Stream; ]
Btw, when trying to refactor method name the following error appears:
Error: The original element being refactored is not available. It was deleted or significantly changed. Usages cannot be collected.
upd: more log
Curiouser and curiouser. I was UNABLE to reproduce case on fresh installation and start digging. On failing installation (notebook), I have a number of project opened. When I close all projects except with failed case, all start works fine. When I open particular project (not related to that failed), I cannot find usages any more. The culprit project is java fx stab. Having this project opened prevents Find Usages in side project. I dunno, how can I attach zip with projects here.
I confirm the same bug in NB15. It doesn't happen always, but quite often. It can not find usages or for example interface method implementations as well. As per usages I noticed that when you select Scope: Current Project & Dependencies - it can find usages, whereas with only Current Project scope usages could not be found. Need to add that after some actions (not sure which exactly: mostly trying Find Usages with different scopes, nothing else) or simply after some time - it started working fine (like now for me: it didn't work so I started googling for this issue and found this post, and then later after some time - it works fine again).