Skip to content

Improve cross-reference completion support - #155

Merged
msujew merged 12 commits into
mainfrom
msujew/completion-fixes
Oct 22, 2026
Merged

msujew merged 12 commits into
mainfrom
msujew/completion-fixes

Conversation

@msujew

@msujew msujew commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Improves how the completion engine determines the owner of a cross-reference at the cursor. Previously, we derived the owner from a synthetic chain built from the completion parser's rule stack. That chain had no connection to the AST that the main parser built, so scope providers that depend on the container of the owner or its containment data returned the wrong symbols (or none at all).

This change builds the owner from the node that owns the token in front of the cursor, combined with the rule calls between that token and the cross-reference. The owner is either an existing node of the AST or a new node with the container and the containment data that the main parser would give to it. This means that scope providers see the same picture as they do for a regular node.

Also simplifies a lot of the internal machinery/API in the completion system. 90% of the changes are in the generated files though. In the same vein, I've restructured the completion test language: every rule has a descriptive keyword instead of a single letter, and I've added new rules for a bunch of test cases.

@ssmifi ssmifi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice improvement, thanks. I mostly have doc/naming nits. Keep it rolling.

Comment thread server/completion_contributor.go
Comment thread parser/atn_simulator.go Outdated
Comment thread internal/languages/completion/completion_engine_test.go Outdated
Comment thread internal/atn/atn.go
Comment thread internal/atn/atn.go Outdated
Comment thread parser/atn_runtime.go
Comment thread parser/atn_simulator.go
Comment thread parser/atn_simulator_test.go Outdated
Comment thread parser/completion_parser.go Outdated
Comment thread parser/completion_parser.go Outdated
@msujew
msujew force-pushed the msujew/completion-fixes branch from 1faa7e1 to e65f8de Compare October 21, 2026 20:59
@msujew
msujew force-pushed the msujew/completion-fixes branch from e65f8de to c3061c8 Compare October 21, 2026 21:05
@msujew
msujew merged commit f47699b into main Oct 22, 2026
5 checks passed
@msujew
msujew deleted the msujew/completion-fixes branch October 22, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants