ISSUE DESCRIPTION LSP doesn't provide completion for interfaces Lisette version: 0.2.11…
- User
ISSUE DESCRIPTION
LSP doesn't provide completion for interfaces Lisette version: 0.2.11 IDE: VSCode and Zed
The LSP isn't providing completions for interfaces from either stdlib or user-defined.
interface Example { fn example(self, name: string) -> string } fn example_call(ex: Example) -> string { ex. }Interface
No new interfaces are introduced.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /lisette, current file: none) bash-$
- Assistant
I'll start by exploring the repository structure to understand what we're working with. Let's first look at the directory.
- Assistant
Let me explore the repository structure more to understand what kind of project this is.
- Assistant
Let me explore the crates directory to find the LSP-related code.
- Assistant
The LSP crate is at
crates/lsp. Let me look at it more closely. - Assistant
Let me look at the LSP source files.
- Assistant
The issue is about LSP not providing completions for interfaces. Let me look at the completion.rs file to understand how completions work.
- Assistant
Now let me look at the
type_namefunction used in the completion code: - Assistant
Let me search for type_name in the lsp crate
- Assistant
Let me look at the
type_namefunction inanalysis.rs: - Assistant
Now let me look at how the LSP handles dot access completions. I need to see the lib.rs where completions are triggered:
- Assistant
Let me look at the full completion method in lib.rs:
- Assistant
Let me see the completion method:
- Assistant
Let me understand how the type system handles interfaces. Let me look at the syntax types and how interfaces are defined:
- Assistant
Let me look at the definition structure to understand how interfaces are stored:
- Assistant
Now I understand the issue better. Let me look at how interface methods are stored and accessed. The
Interfacetype has methods, but theget_instance_completionsfunction only looks atStructdefinitions and iterates definitions for methods. Let me check how interface methods are registered as definitions. - Assistant
Let me look at the
Typedefinition to understand how interface types are represented: - Assistant
Let me look at the Type enum to see how interface types are represented.
- Assistant
Let me look at how interface methods are stored in the definitions. Let me check the semantics store:
- Assistant
Now I understand the issue. Let me look at how interface methods are stored vs struct methods.
- Assistant
Now I need to understand how interface methods work. The issue is that when a variable has an interface type, the LSP should show the interface's methods as completions when the user types
.after the variable.Let me look at
get_instance_completionsmore carefully. It currently:- Gets struct fields for struct types
- Finds methods defined as
Type.methoddefinitions
The problem is that for interfaces, methods are stored differently - they're part of the interface definition itself, not as separate
Type.methoddefinitions.Let me look at the semantics to understand how interface methods are represented.
- Assistant
Let me look at the interface_methods function more carefully.
- Assistant
Let me look at the
get_interfacefunction and understand how interface methods are stored. - Assistant
Now I understand the core issue. Let me examine the flow more carefully. Let me look at how the
detect_dot_contextfunction handles the case when the expression has an interface type: - Assistant
Let me see the
is_type_definitionmethod: - Assistant
Now let me understand how interface methods are registered as definitions. Let me check the inference code for interfaces:
- Assistant
Now let me look at how definitions are collected. Let me find where interface definitions are registered:
- Assistant
Let me look at how interface definitions are registered, particularly the methods:
- Assistant
Now I can see that interface methods ARE registered as
Definition::Valueentries with qualified names likemodule.Example.example. So theget_instance_completionsshould theoretically find them. Let me checkis_instance_methodmore carefully and understand the type of theselfparameter: - Assistant
Let me search for where interface methods are registered:
- Assistant
Let me look at the
populate_interfacefunction more carefully: - Assistant
Now I understand the core problem. The interface methods are registered as
Definition::Valueentries with theselfparameter stripped from the type. So whenget_instance_completionscallsis_instance_methodon these methods, it fails because the first parameter is no longer the interface type.Let me verify this by also checking the
AnalysisSnapshotto understand how definitions are accessed: - Assistant
Now I need to understand how definitions are stored. Let me look at
SemanticResult: - Assistant
Now I have a clear picture. The issue is:
- Interface methods are stored as
Definition::Valueentries with theselfparameter stripped from the type get_instance_completionschecksis_instance_method(definition.ty(), type_id)which looks for the receiver type as the first parameter- Since interface methods have
selfstripped, this check fails and no interface methods are returned
Let me also check how the
Interface.methodsmap is populated: - Interface methods are stored as
- Assistant
Now I understand the full picture. The problem is:
- Interface methods are stored in
Interface.methodsHashMap withselfstripped - They're also registered as
Definition::Valueentries withselfstripped is_instance_methodchecks if the first parameter matches the receiver type, but sinceselfis stripped, this check fails
I need to modify
get_instance_completionsto handle interface types. Let me also checkType::get_qualified_id: - Interface methods are stored in
- Assistant
Let me look at how interface methods are stored compared to struct methods:
- Assistant
Now I have a clear understanding of the problem. Let me trace through the flow:
- When typing
ex.whereex: Example(interface),detect_dot_contextgets the type and returnsDotContext::Instance("module.Example") get_instance_completions("module.Example", ...)is called- It iterates all definitions looking for
module.Example.*methods - It finds
module.Example.examplewhich is aValuedefinition - BUT
is_instance_method()fails because interface methods haveselfstripped from their type during registration
The fix is: in
get_instance_completions, we need to also handleInterfacedefinitions by looking at their methods map directly.Let me first look at the existing tests:
- When typing
- Assistant
Let me check if there are any LSP-specific tests:
- Assistant
Let me check if there are any existing tests for interface completions:
- Assistant
Let me look at the relevant tests for interfaces and see if there's one for completions on interfaces:
- Assistant
Now let me also look at how the
Snapshotprovides access to definitions from all modules: - Assistant
Let me look at how the definitions map works - what are the keys?
- Assistant
Let me look at the Module struct to see how definitions are stored.
- Assistant
Let me look at the Module struct.
- Assistant
Let me find the Module definition.
- Assistant
Now I have a full understanding of the issue. Let me trace through the completion code path:
detect_dot_contextcorrectly identifies the interface type and returnsDotContext::Instance("module.Example")get_instance_completionsis called- For interface definitions,
methodsis stored in theInterface.methodsHashMap - Interface methods are ALSO registered as
Definition::Valueentries with qualified names likemodule.Example.example, but withselfstripped from the type - The
is_instance_methodcheck fails because the first parameter is no longer the interface type (it was stripped)
The fix is to add handling for interfaces in
get_instance_completions. Let me implement this: - Assistant
Now let me implement the fix. I need to modify
get_instance_completionsto handle interfaces. The key change is to also check forInterfacedefinitions and include their methods: - Assistant
Now I understand the full picture. The issue is that interface methods are stored in the
Interface.methodsHashMap AND asDefinition::Valueentries, but both haveselfstripped from their type. Whenget_instance_completionsiteratesDefinition::Valueentries, theis_instance_methodcheck fails because the first parameter is no longer the receiver type.The fix is to add handling for
Interfacedefinitions inget_instance_completions- directly reading methods from theInterface.methodsHashMap. - Assistant
Now I understand the full issue. Let me implement the fix. I need to add handling for
Interfacedefinitions inget_instance_completions- directly reading methods from theInterface.methodsHashMap and recursively collecting from parent interfaces: - Assistant
Now let me apply the fix to the actual file. Let me replace the
get_instance_completionsfunction: - Assistant
Good, the edit was applied. Now I need to add the necessary imports. Let me check if
rustc_hashandecoware available: - Assistant
Let me check the dependencies for the LSP crate:
- Assistant
Now I need to check if
ecowis available as a dependency. Let me check: - Assistant
The
ecowcrate is a workspace dependency but not directly in the LSP crate. Let me check howEcoStringis accessed in other files: - Assistant
I need to check if
ecowis accessible through the syntax crate: - Assistant
Good,
EcoStringis re-exported fromsyntax. Let me update the code to usesyntax::EcoString: - Assistant
Now let me verify the code compiles. First, let me check that the definitions map key type matches what we're using. Let me check the
Symboltype: - Assistant
Let me check if
Symbolimplements indexing with&str: - Assistant
Good,
SymbolimplementsBorrow<str>so thesnapshot.definitions().get(parent_id)call should work. Now let me build the project to verify it compiles: - Assistant
The code compiles. Now let me run the existing LSP tests to make sure we didn't break anything:
- Assistant
No tests ran because the LSP crate has
test = falsein its Cargo.toml. The tests are in/lisette/tests/lsp.rs. Let me run those: - Assistant
All 469 tests pass. Now let me also look at the specific interface-related tests to see if any test completions:
- Assistant
Good, no existing interface completion tests. Let me now also check if there's a related issue with the
detect_dot_contextfunction. When the type is an interface, the flow should work. Let me verify the full file is correct: - Assistant
The code looks good. Now let me also check the
detect_dot_contextfunction for the edge case where the expression before the dot is a type-level identifier (likeExample.method). Currentlyis_type_definition()excludesInterface: - Assistant
Now let me also make sure the
detect_dot_contextfunction correctly handles the case when the expression before the dot has an interface type. Let me look at howexpression.get_type()works for interface-typed variables: - Assistant
Let me check how
expression.get_type()returns the type for an identifier: - Assistant
Now I need to also check if the
detect_dot_contextfunction correctly handles the case when the variable has an interface type. Let me verify the full flow works by running the tests: - Assistant
All 469 tests pass. Now let me also think about edge cases. Let me check if there's a potential issue with the
detect_dot_contextfunction when the expression before the dot has an interface type. The flow is:memberis empty → continues past the!member.is_empty()check- Checks if the identifier is a type →
is_type_definition()returns false for interfaces, so this doesn't match - Calls
expression.get_type()→ returns the interface's nominal type type_name(&ty)extracts the qualified name → returnsDotContext::Instance("module.Example")
This should work correctly. Let me now verify the complete fix by looking at the final file:
- Assistant
Let me also run the full test suite to make sure nothing else breaks:
- Assistant
All 469 tests pass. Let me also run any other tests that might be relevant:
- Assistant
There are failures in the broader test suite. Let me check if these are pre-existing failures (not related to my changes):
- Assistant
The LSP tests all pass. The failures in the broader test suite are in the
testspackage which seems to have snapshot/golden tests. Let me check if those failures are pre-existing by checking the diff and the tests themselves. - Assistant
Let me check if these failures are pre-existing or related to my changes:
- Assistant
Let me verify these failures are pre-existing by checking if they exist before my change:
- Assistant
The failures are pre-existing - they exist even without my changes. Let me restore my changes:
- Assistant
Good - the failures are pre-existing snapshot test failures unrelated to my change. They exist without my changes. Let me verify the final diff:
- Assistant
The fix looks good. But I need to also consider visibility - I should check that interface methods respect the
same_moduleflag. Let me update the code to check the interface definition's visibility: - Assistant
I see there's a duplicate comment block. Let me fix that:
- Assistant
Let me also check if the
definition @binding compiles properly with the match pattern: - Assistant
Good, it compiles. Let me run the LSP tests again:
- Assistant
All 469 tests pass. Let me now verify the final diff:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →