diff options
| author | Bradley Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-08-11 20:06:00 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-11 20:06:00 -0400 |
| commit | 848d46e939d91c9b5067d2f5b3cc034f20b20612 (patch) | |
| tree | 4bbf44a1946cffc5bc886aa89775011805b57dbc /src/server | |
| parent | 36488812d99059c5a6f4453bf4b176461c125a7f (diff) | |
| parent | f43f8593b1b6c54104d3ff20470e5217592b5405 (diff) | |
Merge pull request #856 from BradLewis/feat/clean-completions-struct-decl
Remove functions, consts, variables and fields when in struct definitions
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/analysis.odin | 15 | ||||
| -rw-r--r-- | src/server/completion.odin | 7 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin index f18ec0b..9fb6ad0 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -4477,6 +4477,21 @@ position_in_proc_decl :: proc(position_context: ^DocumentPositionContext) -> boo return false } +position_in_struct_decl :: proc(position_context: ^DocumentPositionContext) -> bool { + if position_context.value_decl == nil { + return false + } + + if len(position_context.value_decl.values) != 1 { + return false + } + + if _, ok := position_context.value_decl.values[0].derived.(^ast.Struct_Type); ok { + return true + } + + return false +} is_lhs_comp_lit :: proc(position_context: ^DocumentPositionContext) -> bool { if position_context.position <= position_context.comp_lit.open.offset { diff --git a/src/server/completion.odin b/src/server/completion.odin index d1a630a..3921958 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -236,6 +236,13 @@ convert_completion_results :: proc( continue } + if position_in_struct_decl(position_context) { + to_skip: bit_set[SymbolType] = {.Function, .Variable, .Constant, .Field} + if result.symbol.type in to_skip { + continue + } + } + if result.snippet.insert != "" { item := CompletionItem { label = result.symbol.name, |