Skip to content

Conversation

@lahodaj
Copy link
Contributor

@lahodaj lahodaj commented Feb 18, 2025

While looking into:
oracle/javavscode#375

it turned out there's this problem with ClassIndex: when the ClassIndex is created for a ClasspathInfo, it sets up delegate queries, one per (translated) root included in the ClasspathInfo. 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 of ClassIndex is 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 ClassIndex is usually not queried before indexing is finished
b) the ClasspathInfos are thrown away relatively commonly.

Inside the VS Code extension(s), the index query may happen much sooner, and the ClasspathInfo is apparently not throw away so easily. We could workaround by refreshing the ClasspathInfos 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 ClassIndexManager when a delegate does not exist for a root, and the existing code should then ensure the ClassIndex is refreshed when indexing finishes.

The listener is weak, and I did some experiments, and it seems it is being freed reasonably.

…assIndex is rebuilt when the index is created.
@lahodaj lahodaj added Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) LSP [ci] enable Language Server Protocol tests VSCode Extension labels Feb 18, 2025
@lahodaj lahodaj added this to the NB26 milestone Feb 18, 2025
@lahodaj lahodaj requested review from dbalek and sdedic February 18, 2025 09:25
Copy link
Contributor

@tzezula tzezula left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@lahodaj lahodaj merged commit bb4a594 into apache:master Feb 25, 2025
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) LSP [ci] enable Language Server Protocol tests VSCode Extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants