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
Let me start by exploring the repository structure to understand the codebase and then figure out how to reproduce and fix the issue with LSP not providing completions for interfaces.
Assistant
Let me explore the repository structure more to understand how it's organized.
Assistant
This is a Rust project. The issue is about LSP not providing completions for interfaces. Let me find the LSP-related code.
Assistant
The
completion.rsfile is likely the key file for this issue. Let me examine it.Assistant
The open command needs to be called differently. Let me try without the file parameter format.
Assistant
Now let me look at the main LSP library file to understand how completions are triggered and processed.
Assistant
Let me see the completion function more specifically. I need to see the middle part of the file that was truncated.
Assistant
Now I understand the flow. When we have
ex.whereexis of interface typeExample, thedetect_dot_contextfunction is called. If it detects an instance context,get_instance_completionsis called. Let me look at this function more closely - it looks like it only handles structs, not interfaces.Assistant
I can see the issue now! The
get_instance_completionsfunction only handles struct fields (lines 199-211) but doesn't handle interface methods. When you have an interface type likeExample, the function:- Checks if it's a struct and gets fields - but interfaces aren't structs
- Then looks for methods with prefix
{type_id}.- this would find methods defined on the interface type
The problem is that interface methods are NOT stored with the prefix
{interface_name}.method_name. They're stored differently. Let me explore how interface definitions are structured.Assistant
Now I can see the issue clearly! The
Interfacestruct has amethodsfield that contains aHashMap<EcoString, Type>of method names to their types. But theget_instance_completionsfunction incompletion.rsonly looks for methods defined as separateDefinitionentries with the prefix{type_id}..For interfaces, the methods are stored directly in the
Interfacestruct'smethodsfield, not as separate definitions. Let me look at how interface methods are stored in the definitions map.Assistant
Now I understand the full picture. The
get_all_methodsfunction in the store shows how interface methods are retrieved. When the type is an interface, it looks up the interface definition and returns the methods frominterface.methods.Now let me check how the LSP's
get_instance_completionsworks - it only looks for definitions with the prefix{type_id}.method_name, but interface methods are stored in theInterface.methodsHashMap, not as separate definitions.Let me verify this understanding by checking how methods are registered in the definitions:
Assistant
Next command only.
Assistant
I can see that interface methods are stored in the
Interface.methodsHashMap and are NOT registered as separate definitions. Theget_instance_completionsfunction needs to be updated to also look up interface methods from the interface definition'smethodsfield.Let me look at the snapshot to see what's available for looking up interface definitions.
Assistant
Now let me look at how I can access interface information from the definitions:
Assistant
Now let me look at how other parts of the codebase access interface methods, and then I'll modify
get_instance_completionsto also handle interfaces.Assistant
Now I understand the full picture. Let me also check what parent interfaces look like and if we need to include those methods too:
Assistant
Now I understand the issue. The
get_instance_completionsfunction only handles struct fields and methods registered as separate definitions with{type_id}.method_nameprefix. But interface methods are stored in theInterface.methodsHashMap, not as separate definitions.Let me now check if there are any tests for completions to understand the expected behavior better:
Assistant
Let me look at the completion test helper and check if there are existing interface completion tests:
Assistant
let me check if there's a completion test for interfaces. Let me search for any existing completion tests that test interface methods.
Assistant
Command not found, trying again with proper escaping.
Assistant
No existing tests for interface completions. Let me check the lsp_harness to understand the test infrastructure:
Assistant
Now I have a good understanding of the test infrastructure. Let me first create a test script to reproduce the issue, then fix it.
Assistant
Good, the project builds. Now let me write a simple test to reproduce the issue:
Assistant
Let me run the existing LSP tests to understand how the test infrastructure works and confirm the issue:
Assistant
Good, tests run. Now let me write a quick test to confirm the bug exists. First, let me understand the exact character positions in the test source:
Assistant
I need to run a test to reproduce the issue. Let me try a different approach - I'll add a test directly to the existing test file temporarily and run it.
Assistant
Let me look at the
get_instance_completionsfunction again and understand exactly how to add interface method completions:Assistant
Now I understand the issue. The
get_instance_completionsfunction only handles struct fields and methods registered as separate definitions. Interface methods are stored in theInterface.methodsHashMap, not as separate definitions.Let me fix the
get_instance_completionsfunction to also include interface methods:Assistant
Now I understand the issue clearly. The
get_instance_completionsfunction handles struct fields and methods registered as separate definitions, but interface methods are stored directly inInterface.methodsHashMap, not as separate definitions. I need to add code to extract interface methods from the interface definition.Assistant
I need to modify the
get_instance_completionsfunction to also include interface methods. Let me edit the file:Assistant
Let me edit the completion.rs file to add interface method completions to the
get_instance_completionsfunction.Assistant
The
get_instance_completionsfunction needs to be modified to also include interface methods. Currently it only handles:- Struct fields
- Methods registered as separate definitions with prefix
{type_id}.
But interface methods are stored directly in the
Interface.methodsHashMap, not as separate definitions.I need to add code to:
- Check if the type_id is an interface definition
- If so, extract methods from the
Interface.methodsHashMap - Also include methods from parent interfaces
Let me implement this fix.
Assistant
Now I need to modify the
get_instance_completionsfunction to also handle interface methods. I'll add code to check if the type is an interface and extract methods from it.Let me create the fix by replacing the function.
Assistant
The edit command failed because of the way I formatted it. Let me use the heredoc syntax properly.
Assistant
The edit command is failing. Let me try using a different approach - I'll use sed or create a Python script to do the replacement.
Assistant
The function has been replaced. Now let me verify the changes and build to check for compilation errors.
Assistant
The code compiles. Now let me verify the changes look correct and run the existing tests to make sure I didn't break anything.
Assistant
The changes look good. Now let me run the existing LSP tests to make sure I haven't broken anything:
Assistant
All 469 tests pass. Now let me create a simple test script to verify that my fix actually resolves the issue described in the bug report:
Assistant
Let me run the new test to verify it passes with my fix.
Assistant
The test wasn't recognized because I added it inside another function (the warnings say "cannot test inner items"). Let me revert my test addition and add it properly at the file level.
Assistant
LSP doesn't provide completion for interfaces
Assistant
The test passes! My fix works. Now let me revert the test file changes (since I shouldn't modify tests) and run all existing tests to make sure nothing is broken.
Assistant
I reverted the test file. Now let me run all existing LSP tests to confirm my fix doesn't break anything.
Assistant
All 469 LSP tests pass. Let me also verify the fix handles edge cases like interface inheritance by reviewing the code and checking a few more tests:
Assistant
I notice there are many test failures in the suite. Let me check if these are pre-existing or caused by my change by reverting and testing:
Assistant
The test failures are pre-existing - they happen even without my changes. These are likely snapshot tests or environment-dependent tests. The important thing is that the LSP tests all pass.
Let me restore my changes:
Assistant
Good, my changes are restored. Let me verify the fix is in place and run the LSP tests again to confirm everything works.
Assistant
The fix is in place and working. Let me run the LSP tests one more time to confirm everything is good, then submit my changes.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.