Skip to content

Conversation

@micahscopes
Copy link
Collaborator

builds on #1175

Add a generic items_in_scope API to HIR that collects all visible items
in a given scope across the specified name domains. This follows the same
pattern as available_traits_in_scope and properly handles:
- Named imports
- Glob imports
- Unnamed/prelude imports
- Direct child items
- Parent scope items (recursively)

Add ScopeId::items_in_scope() as a convenient traversal-like method.

Rewrite completion handler to:
- Find the most specific scope at cursor position
- Use items_in_scope to get properly scoped completions
- Convert NameRes items to appropriate CompletionItem kinds

This fixes completion showing random unrelated symbols and provides
context-aware suggestions that respect lexical scope.
- Set insert_text, insert_text_format, and insert_text_mode to prevent
  unwanted text replacement and indentation issues
- Detect when completion is triggered by '.' for future member access
  implementation
- Add TODO for member completion (needs proper public API for type members)

This fixes the issue where completion would replace existing text and
add extra indentation.
Use top_mod.target_at() instead of reference_at() + target_at() so that
rename works when cursor is on a definition name, not just references.
- Add textDocument/implementation handler for traits and trait methods
  - On traits: navigates to all impl Trait blocks
  - On trait methods: navigates to all implementations of that method

- Fix trait method rename to also rename implementations
  - When renaming a trait method, all corresponding method definitions
    in impl blocks are also renamed
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