If a ClassIndex ignores a root due to missing index, make sure the ClassIndex is rebuilt when the index is created. #8255
+54
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While looking into:
oracle/javavscode#375
it turned out there's this problem with
ClassIndex: when theClassIndexis created for aClasspathInfo, it sets up delegate queries, one per (translated) root included in theClasspathInfo. If a delegate query does not exist for a given root, it is ignored. The delegate may not exist if the root has not been indexed yet. The problem is, this given instance ofClassIndexis not refreshed when the root is indexed, and the delegate exists. Which may mean the index won't reply with answers for the root, basically forever.I think this does not manifest much in the NetBeans IDE, as:
a) the
ClassIndexis usually not queried before indexing is finishedb) the
ClasspathInfos are thrown away relatively commonly.Inside the VS Code extension(s), the index query may happen much sooner, and the
ClasspathInfois apparently not throw away so easily. We could workaround by refreshing theClasspathInfos at the end of an indexing, or something like that, but it feels like a hack to me.The proposal here is to add a listener to
ClassIndexManagerwhen a delegate does not exist for a root, and the existing code should then ensure theClassIndexis refreshed when indexing finishes.The listener is weak, and I did some experiments, and it seems it is being freed reasonably.