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 the codebase.
Assistant
Now let me understand how interfaces are structured. Let me look at the syntax definitions.
Assistant
Now let me understand how interface methods are stored. Let me look at how definitions are built.
Assistant
Let me look at how the snapshot exposes definitions and how
get_instance_completionsis called.Assistant
Let me look at how interfaces store methods. I want to understand whether interface methods are stored as separate
Valuedefinitions or only in the interface'smethodsmap. Let me look at the registration code.Assistant
Interface methods ARE stored as
Definition::Valueentries with the qualified name{module_id}.{interface_name}.{method_name}. Let me look at how the method type (especiallyself) is constructed.Assistant
The key insight: interface methods have their
selfparameter STRIPPED from the type. Let me look at how struct/enum impl methods are registered to compare.Assistant
Let me look at the existing tests for completion to understand the testing approach.
Assistant
Let me look at the dispatch logic in
lib.rsaround line 1100.Assistant
Now let me reproduce the issue. Let me check the CLI completions handler to see if I can test more easily.
Assistant
That's CLI shell completions, not LSP. Let me look at the test harness and write a reproduction test.
Assistant
Let me build the project first to confirm it compiles, then create a reproduction test.
Assistant
Now let me create a temporary reproduction test based on the existing test patterns.
Assistant
The test files are declared explicitly with
[[test]]entries. So mytmp_repro.rswon't be picked up automatically because it's not declared. But Cargo does pick up tests intests/directory automatically if they're not declared... Actually, no. When[[test]]sections are declared, Cargo still auto-discovers tests in thetests/directory unlessautotests = false. Let me check the[package]section.Actually, when you have
[[test]]entries with explicit paths, Cargo still auto-discovers other test files intests/. The explicit[[test]]entries just add extra ones (or override). Let me just try running it.Actually, I should add a
[[test]]entry, or maybe Cargo auto-discovers. Let me just try running it.Assistant
Auto-discovery is disabled. Let me add a temporary
[[test]]entry to run my repro, then remove it later.Assistant
I've reproduced the issue — the interface method
exampleis not in completions (empty labels). Now let me check whether interface methods can be static (withoutself).Assistant
Interface methods are all functions. The question is whether they always have
self. Let me look at the interface method parsing and any validation that requiresself.Assistant
Let me check whether interface methods must have a
selfreceiver by looking at the checker validation.Assistant
The interface
methodsmap stores signatures with the receiver stripped. Let me check theAnalysisSnapshotto see what store methods are available (e.g.get_interface,parent_interfaces_of).Assistant
Let me look at the prelude for interfaces to understand the stdlib case mentioned in the issue.
Assistant
The prelude is in Go, not Lisette. Let me check the prelude.rs and stdlib typedefs for interfaces. The issue mentions "from either stdlib or user-defined". Let me look at the stdlib typedefs which are
.d.lisfiles (Go interop typedefs). Let me check those for interfaces.Assistant
Interesting — these stdlib interface methods don't have a
selfparameter! Let me check how interface parent embedding works and whether stdlib interfaces useimplparents.Assistant
Let me look at how interface embedding (
implparents) is used in stdlib typedefs.Assistant
Let me check the docs for interface embedding syntax (impl parents).
Assistant
Lisette interfaces support embedding via
impl Reader. Let me look at the Type API for getting qualified names of parents.Assistant
Let me look at the
Symboltype to understand how to use it.Assistant
Let me check how
Symbolis used withstrip_prefixin the existing code — whether it derefs to str.Assistant
Symbolderefs tostr. Now I understand the structure. Let me check the lsp crate's dependencies to know what's available.Assistant
rustc-hashis available. Let me check thetype_namehelper to confirm interface types resolve to their qualified name.Assistant
My analysis is confirmed. Now let me apply the fix to
get_instance_completions. Let me open the file at the relevant section.Assistant
Now let me build to verify it compiles.
Assistant
Now let me run my reproduction test.
Assistant
The fix works for user-defined interfaces. Now let me test edge cases: interface embedding (parents), stdlib interfaces, and methods without
self.Assistant
The 3 failures were due to wrong cursor positions in my test (off-by-one line/column). The stdlib and basic interface cases passed. Let me fix the test positions.
Assistant
Wait, the sed for the struct one (
6, 3->6, 4) also matched the without_self one (5, 3->6, 4)? No, I did5, 3->6, 4first (without_self), then6, 3->6, 4(struct). But the struct one was originally6, 3. After the first sed changed5, 3to6, 4, the struct6, 3is still there. Then the third sed6, 3->6, 4changes it. But wait — now without_self is at6, 4and struct is at6, 4. That's fine since they're different tests/functions.Wait, but actually there's a conflict: the without_self test now uses
(6, 4)and the struct test uses(6, 4). That's fine, they're separate tests.Let me re-verify the without_self line. The
d.is on line 6. (6, 4):d.columns: space=0,space=1,d=2,.=3,cursor=4. Correct.Let me rerun.
Assistant
All edge cases pass:
- User-defined interface with
self→example✓ - Go-interop interface without
self→Info,Name,IsDir✓ - Interface with embedded parents →
read,write(inherited) ✓ - stdlib interface (
io.Reader) →Read✓ - Struct still works →
x,y,dist✓
Now let me run the full existing LSP test suite to ensure nothing broke.
- User-defined interface with
Assistant
All 469 LSP tests pass. Let me also check if there are snapshot/spec tests related to completion that I should run.
Assistant
These are unrelated UI diagnostic snapshots. My change only affects the LSP completion logic. Let me run the broader
testspackage suite to be safe.Assistant
There are 1513 failures in the suite test. Let me check if these are pre-existing (not caused by my change) since the suite is about emit/Go compilation.
Assistant
These failures are about Go emit formatting (missing tabs, space before
()) — clearly environmental (Go toolchain), not related to my LSP change. Let me confirm Go is the issue.Assistant
go: command not found— Go isn't installed, causing all the emit/format snapshot failures. These are pre-existing environmental issues unrelated to my LSP-only change. Let me confirm by stashing my change and running the same failing test.Assistant
Confirmed: the suite failures are pre-existing and environmental (Go not installed) — they fail identically on the clean tree (stashed). My change only touches
crates/lsp/src/completion.rs. The stashed run created.snap.newfiles that I must clean up, along with my temp test file and Cargo.toml entry.Assistant
The find command with
-deleteand-print— the count was 0, meaning the-print -deleteorder may not have printed. Let me verify no .snap.new files remain.Assistant
The
.snap.newfiles weren't deleted. Let me remove them properly.Assistant
Now let me revert the
tests/Cargo.tomlchange (remove my temporary[[test]]entry).Assistant
Now only
crates/lsp/src/completion.rsis modified. Let me review the final diff.Assistant
The diff is clean. Let me do a final verification: re-add my repro test temporarily, run both the repro and the full LSP suite, then clean up.
Assistant
All 5 edge cases pass. Now let me run the full LSP test suite one final time.
Assistant
All 469 LSP tests pass plus my 5 edge cases. Now let me clean up the temporary test file and Cargo.toml entry.
Assistant
The working tree is clean except for my intended change. Let me do a final build to confirm everything compiles.
Assistant
Let me run clippy fully to ensure no new warnings were introduced.
Assistant
No clippy warnings. Everything is clean. Let me do a final verification of the complete state.
Assistant
Let me be thorough and test a couple more edge cases: generic interfaces and interfaces with type args, to ensure no panic in
get_qualified_name.Assistant
The generic interface works. Let me check what the second test returned.
Assistant
That's a test position error again (
d.is on line 9, I used line 8). Let me fix and re-run.Assistant
Both pass — generic interfaces and structs satisfying interfaces work, with no panics. Now let me clean up the temporary test files.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.