Update JavaIndex when a file without its project is opened - #9622
JaroslavTulach wants to merge 1 commit into
Conversation
|
lahodaj
left a comment
There was a problem hiding this comment.
So, I dag deep(er), a this is what I've found:
starting from a clean userdir:
- I go to Tools/Plugins and manually enable "Developing NetBeans" (we'll get to this later)
- then I open
ide/projectui/src/org/netbeans/modules/project/ui/ProjectsRootNode.java. There's indexing happening. No errors - then I restart the IDE
- there are errors in
ProjectsRootNode.java
The reason for this behavior is that there is:
https://github.com/apache/netbeans/blob/master/java/java.source.base/src/org/netbeans/modules/java/source/classpath/SourcePathCheck.java
which registers "unknown" roots. But, it uses !JavaIndex.hasSourceCache(url,false) (
This is what the patch here helps with; but it would be IMO hopefully cleaner to use !JavaIndex.hasSourceCache(url,true) instead.
This is, of course, only partial solution - and maybe, for your case, this partial solution is OK, then please go ahead with the false -> true change.
The limitations is that there needs to exist a project for the file (the very next line is FileOwnerQuery.getOwner(url.toURI()) != null). Hence:
- if I don't go the Tools/Plugins and don't enable apisupport, there's no project for the file, and everything is red. For me, at least. Because this is a projectless source root now.
- if I copy e.g.
openide.util.lookup/srcinto a directory (without the project metadata), and open a file from this directory, I still see the errors. There no project and hence no index created bySourcePathCheck.
|
Thanks for review @lahodaj and yes, you are right steps to reproduce were not exact enough. Steps to ReproduceLet's reproduce with 915296a. This time without ergonomics.
The errors are there with 915296a. FixWith a867080 the errors are gone, exactly as @lahodaj predicted:
Yes, that's perfectly fine limitation. Let's fix the ergnomics misbehavior in some other PR. Thanks for your suggestion. a867080 is much cleaner fix than c3f98c6 even it does basically the same (as we discussed yesterday), but c3f98c6 is too brute force. |
815a85a to
a867080
Compare
refreshIndex when a file without project is openedJavaIndex when a file without its project is opened


ProjectsRootNodeI found following error:ProjectsRootNodeeven there shall be noneIndexforide/projectui/srcand then it cannot find co-located filesnetbeans/java/java.source.base/src/org/netbeans/modules/java/source/classpath/SourcePath.java
Line 47 in 1336aa1
-J-DSourcePath.no.source.filter=trueit all works correctly