aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-06-29 19:50:55 -0400
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-06-29 19:50:55 -0400
commitf6a16912a968d4afc527b6784694085cd857626e (patch)
treed408fdbbcbba30629a44349d71a4ccd342bd3e4f /src/server
parentc9af6de66b4ab64ed65a9ea118db9036f4ea414d (diff)
Mark collected distinct symbols as distinct and improve hover information
Diffstat (limited to 'src/server')
-rw-r--r--src/server/collector.odin3
-rw-r--r--src/server/documentation.odin9
2 files changed, 9 insertions, 3 deletions
diff --git a/src/server/collector.odin b/src/server/collector.odin
index c59a46c..5888326 100644
--- a/src/server/collector.odin
+++ b/src/server/collector.odin
@@ -469,10 +469,12 @@ collect_symbols :: proc(collection: ^SymbolCollection, file: ast.File, uri: stri
col_expr = helper.type
}
}
+ is_distinct := false
if dist, ok := col_expr.derived.(^ast.Distinct_Type); ok {
if dist.type != nil {
col_expr = dist.type
+ is_distinct = true
}
}
@@ -612,6 +614,7 @@ collect_symbols :: proc(collection: ^SymbolCollection, file: ast.File, uri: stri
symbol.doc = get_doc(expr.docs, collection.allocator)
comment := get_file_comment(file, symbol.range.start.line + 1)
symbol.comment = strings.clone(get_comment(comment), collection.allocator)
+ symbol.flags |= {.Distinct}
if expr.builtin || strings.contains(uri, "builtin.odin") {
symbol.pkg = "$builtin"
diff --git a/src/server/documentation.odin b/src/server/documentation.odin
index b50a18d..3be174f 100644
--- a/src/server/documentation.odin
+++ b/src/server/documentation.odin
@@ -84,15 +84,18 @@ get_short_signature :: proc(ast_context: ^AstContext, symbol: Symbol) -> string
is_variable := symbol.type == .Variable
pointer_prefix := repeat("^", symbol.pointers, context.temp_allocator)
-
-
#partial switch v in symbol.value {
case SymbolBasicValue:
sb := strings.builder_make(ast_context.allocator)
if symbol.type_name != "" {
write_symbol_type_information(ast_context, &sb, symbol, pointer_prefix)
} else if .Distinct in symbol.flags {
- fmt.sbprintf(&sb, "%s%s", pointer_prefix, symbol.name)
+ if symbol.type == .Keyword {
+ strings.write_string(&sb, "distinct ")
+ build_string_node(v.ident, &sb, false)
+ } else {
+ fmt.sbprintf(&sb, "%s%s", pointer_prefix, symbol.name)
+ }
} else {
strings.write_string(&sb, pointer_prefix)
build_string_node(v.ident, &sb, false)