refreshIndex when a file without project is opened - #9622
JaroslavTulach wants to merge 2 commits 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.

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