Skip to content

Type inference for id member expressions in completion - #18

Merged
cushycush merged 1 commit into
mainfrom
feat/id-type-inference
Apr 17, 2026
Merged

Type inference for id member expressions in completion#18
cushycush merged 1 commit into
mainfrom
feat/id-type-inference

Conversation

@cushycush

@cushycush cushycush commented Apr 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • Typing root. where id: root resolves to a concrete type now offers that type's properties (plus inherited ones via the prototype chain) instead of the generic property list.
  • Works during active editing even when the file is temporarily invalid: a textual brace-balance fallback resolves the enclosing type when tree-sitter error-recovers past the ui_object_definition.
  • Unknown identifiers (foo. where foo isn't an id) fall back to the generic property list, so existing behavior is preserved.

Test plan

  • go test -race ./...
  • Added tests covering id index builder (happy + non-id bindings), identifierBeforeDot token extraction, end-to-end completion after <id>., and fallback when the identifier isn't a known id.
  • Verify in editor: Rectangle { id: root; width: root.| } — completion shows Rectangle+Item properties, not just the generic set.

Closes

Last item on the v1.6.0 follow-on roadmap (document links and cross-file go-to-def shipped in #16 / #17).

Typing `root.` where `id: root` resolves to a specific type now offers
that type's properties (including inherited ones via the prototype
chain) instead of the generic property list.

Implementation:
* buildIDTypeIndex walks ui_binding nodes named "id" and records the
  id → enclosing type. It prefers a ui_object_definition ancestor and
  falls back to a textual brace-balance scan when the parser error-
  recovers — which happens in the common case where `.` has no member
  after it yet.
* The ContextProperty branch of Completion consults the index when the
  identifier before `.` matches an id, and returns typePropertyCompletions
  in that case. Unknown identifiers fall back to generic properties so
  existing behavior is unchanged.
@cushycush
cushycush merged commit 481a7b5 into main Apr 17, 2026
3 checks passed
@cushycush
cushycush deleted the feat/id-type-inference branch April 17, 2026 04:02
cushycush added a commit that referenced this pull request Apr 17, 2026
…nt links

The three features shipped in #16, #17, and #18 weren't reflected in the
README. Updates the completions list, broadens the Go to Definition
entry, and adds a Document Links entry.
cushycush added a commit that referenced this pull request Apr 17, 2026
…nt links (#19)

The three features shipped in #16, #17, and #18 weren't reflected in the
README. Updates the completions list, broadens the Go to Definition
entry, and adds a Document Links entry.
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.

1 participant