diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-11-06 23:02:03 -0500 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-11-06 23:02:48 -0500 |
| commit | f7c57f83d686d6dfc01d82ccc0528be7ecfb331f (patch) | |
| tree | b58f7fb2d19633827b8920ec6e86602207418702 /src | |
| parent | e466dde8a720fe8c9653aed200190dcfeb0d640e (diff) | |
Don't include package for union selector completions if the package has being 'using'ed
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/analysis.odin | 10 | ||||
| -rw-r--r-- | src/server/completion.odin | 3 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 4a1980c..2dfed25 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -3267,6 +3267,16 @@ get_using_packages :: proc(ast_context: ^AstContext) -> []string { return usings } +// Returns whether the provided package is being used with a `using` statement +is_using_package :: proc(ast_context: ^AstContext, pkg: string) -> bool { + for u in ast_context.usings { + if strings.compare(pkg, u.pkg_name) == 0 { + return true + } + } + return false +} + get_symbol_pkg_name :: proc(ast_context: ^AstContext, symbol: ^Symbol) -> string { return get_pkg_name(ast_context, symbol.pkg) } diff --git a/src/server/completion.odin b/src/server/completion.odin index 2d249bd..44916d7 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -934,7 +934,8 @@ get_selector_completion :: proc( if symbol.pkg == ast_context.document_package || base == "runtime" || base == "$builtin" || - is_selector { + is_selector || + is_using_package(ast_context, symbol.pkg) { item.label = fmt.aprintf( "(%v%v)", repeat("^", symbol.pointers, context.temp_allocator), |