netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

Fix invalid element references during completion resolution using ElementHandle which has additional text edits

Open Achal1607 opened this issue 2 months ago • 0 comments

Fixes crashes and incorrect behavior when resolving completion items across different javac contexts.

When completion items are created, they capture Element references from the initial javac context. Later, when the LSP client calls completionItem/resolve to fetch additionalTextEdits, a new javac context may be used (especially if the file was modified). The old Element instances are invalid in the new context, causing Assertion Error rootPackage missing!; currModule: java.base.

So, store ElementHandles instead of stale Elements when creating completion items.

Thanks @lahodaj for helping out.

Achal1607 avatar Nov 12 '25 08:11 Achal1607