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.
codeinterface Example { fn example(self, name: string) -> string } fn example_call(ex: Example) -> string { ex. }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 the codebase and then locate the relevant LSP completion code.
Assistant
Let me look for LSP-related files.
Assistant
There's a dedicated LSP crate. Let me look at the completion.rs file since the issue is about completions for interfaces.
Assistant
right
<tool_call> <function=bash_terminal> <parameter=command> cat /lisette/crates/lsp/src/completion.rs </tool_call>
Assistant
Let me use the correct syntax for the open command.
Assistant
Let me explore how interfaces are defined and how their methods are stored in the definitions.
Assistant
Let me look at how interfaces are structured and how their methods are stored:
Assistant
Let me understand better how interface methods are stored versus how struct methods are stored. Let me check the LSP tests to understand the expected behavior:
Assistant
Let me search for any existing interface-related completion tests and understand how interface methods are stored:
Assistant
Now let me look at how methods are stored for interfaces in the semantics/analysis phase. The issue is that
get_instance_completionsonly looks for methods stored as separate definitions with a prefix like{type_id}.. Let me check if interface methods are stored the same way:Assistant
Let me look at the
get_all_methodsfunction in the store.rs to understand how interface methods are looked up:Assistant
Now I can see the issue. The
get_all_methodsfunction in the store handles interfaces by callingself.get_interface(&qualified_name)and returning the interface's methods. However, the LSP completion code inget_instance_completionsonly looks for methods by scanning definitions that have a{type_id}.prefix in their qualified name. Interface methods are stored directly in the interface definition'smethodshash map, not as separate definitions.Let me look at the full
get_instance_completionsfunction and understand what I need to change:Assistant
command <tool_call>continue=true
Assistant
Let me check the snapshot structure to understand how to access interface methods:
Assistant
Now I understand the issue. The
get_instance_completionsfunction only looks for:- Struct fields (when definition body is
Struct) - Methods stored as separate definitions with prefix
{type_id}.
However, interface methods are stored directly inside the
Interfacestruct'smethodsHashMap field, not as separate definitions. Let me verify this by looking at an interface test:- Struct fields (when definition body is
Assistant
The command didn't find an exact match for "interface Example" in lsp.rs. Let me search for any interface completion tests. )Let me search for tests that might be testing interface method completions:
<tool_call> <function=bash_terminal> <parameter=command> grep -B5 -A20 "stress_interface_multiple_methods" /lisette/tests/lsp.rs </tool_call>
Assistant
Let me search for tests that might be testing interface method completions.
Assistant
Now I understand the issue. The
get_instance_completionsfunction only handles struct fields and methods stored as separate definitions with prefix{type_id}., but it doesn't handle interface methods that are stored directly in theInterface.methodsHashMap.Let me first create a test script to reproduce the issue:
Assistant
Let me look at the lsp_harness.rs to understand how to create a test.
Assistant
Let me now write a test to confirm the issue and then fix it. First, let me check the existing test infrastructure:
Assistant
Now let me look at how the analysis module works and how the completions are triggered:
Assistant
Now let me look at where completions are handled in the lib.rs:
Assistant
Now I understand the issue. Looking at
get_instance_completions, it only handles:- Struct fields from
DefinitionBody::Struct - Methods stored as separate definitions with
{type_id}.prefix
But interface methods are stored directly in the
Interface.methodsHashMap, not as separate definitions. I need to add support for interface methods inget_instance_completions.Let me first create a simple test to reproduce the issue:
- Struct fields from
Assistant
Let me create a temporary test script to reproduce the issue with interface completions.
Assistant
Let me look at how I can access interface definitions from the snapshot:
Assistant
Let me look at how
get_interfaceworks:Assistant
Now I understand the structure. The interface methods are stored in
DefinitionBody::Interface { definition }wheredefinitionis anInterfacestruct containing amethods: HashMap<EcoString, Type>field.The issue is that
get_instance_completionsonly looks atStructfields and methods stored as separate definitions. It doesn't check forInterfacetypes and their methods.Let me now fix the
get_instance_completionsfunction in/lisette/crates/lsp/src/completion.rs:Assistant
Now I can see the issue clearly. The
get_instance_completionsfunction:- Gets struct fields from
DefinitionBody::Struct - Gets methods by iterating through all definitions and checking for the
{type_id}.prefix pattern
But it never checks for interface methods stored in
DefinitionBody::Interface. Let me add that:- Gets struct fields from
Assistant
Oh right, I need to use the edit command properly. Let me replace the get_instance_completions function.
Assistant
The edit command had issues with bash escaping. The file got corrupted. Let me revert and try again with a different approach.
Assistant
Let me verify the changes were applied correctly by examining the file.
Assistant
I see there's a duplicate
items\n}after the function. Let me fix that.Assistant
Let me use sed to do the replacement more carefully:
Assistant
I'll use Python to do the replacement properly:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.