aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorBradley Lewis <22850972+BradLewis@users.noreply.github.com>2025-08-17 13:07:08 -0400
committerGitHub <noreply@github.com>2025-08-17 13:07:08 -0400
commitd62633a2c020859b169baaece4f416670f1efc66 (patch)
treee0395fedfeec8428f976b66ce6460166fb38baee /src/server
parent87693f65296e7e947d530e3274148753603434cc (diff)
parent0eea8cc8a45a23e4645e11849f4726253a6d2905 (diff)
Merge pull request #896 from BradLewis/fix/distinct-improvements
Fix/distinct improvements
Diffstat (limited to 'src/server')
-rw-r--r--src/server/collector.odin5
-rw-r--r--src/server/documentation.odin28
2 files changed, 21 insertions, 12 deletions
diff --git a/src/server/collector.odin b/src/server/collector.odin
index 4af9d7c..7f345c9 100644
--- a/src/server/collector.odin
+++ b/src/server/collector.odin
@@ -650,7 +650,6 @@ collect_symbols :: proc(collection: ^SymbolCollection, file: ast.File, uri: stri
symbol.uri = get_index_unique_string(collection, uri)
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"
@@ -667,6 +666,10 @@ collect_symbols :: proc(collection: ^SymbolCollection, file: ast.File, uri: stri
symbol.pkg = get_index_unique_string(collection, directory)
}
+ if is_distinct {
+ symbol.flags |= {.Distinct}
+ }
+
if expr.deprecated {
symbol.flags |= {.Deprecated}
}
diff --git a/src/server/documentation.odin b/src/server/documentation.odin
index c076008..c7b9f0c 100644
--- a/src/server/documentation.odin
+++ b/src/server/documentation.odin
@@ -152,6 +152,9 @@ write_signature :: proc(sb: ^strings.Builder, ast_context: ^AstContext, symbol:
#partial switch v in symbol.value {
case SymbolEnumValue:
+ if .Distinct in symbol.flags {
+ strings.write_string(sb, "distinct ")
+ }
if len(v.names) == 0 {
write_indent(sb, depth)
strings.write_string(sb, "enum {}")
@@ -189,6 +192,9 @@ write_signature :: proc(sb: ^strings.Builder, ast_context: ^AstContext, symbol:
strings.write_string(sb, "}")
return
case SymbolStructValue:
+ if .Distinct in symbol.flags {
+ strings.write_string(sb, "distinct ")
+ }
if len(v.names) == 0 {
strings.write_string(sb, "struct {}")
if symbol.comment != "" {
@@ -199,6 +205,9 @@ write_signature :: proc(sb: ^strings.Builder, ast_context: ^AstContext, symbol:
write_struct_hover(sb, ast_context, v, depth)
return
case SymbolUnionValue:
+ if .Distinct in symbol.flags {
+ strings.write_string(sb, "distinct ")
+ }
strings.write_string(sb, "union")
write_poly_list(sb, v.poly, v.poly_names)
if v.kind != .Normal {
@@ -241,6 +250,9 @@ write_signature :: proc(sb: ^strings.Builder, ast_context: ^AstContext, symbol:
write_procedure_symbol_signature(sb, v, detailed_signature = true)
return
case SymbolBitFieldValue:
+ if .Distinct in symbol.flags {
+ strings.write_string(sb, "distinct ")
+ }
strings.write_string(sb, "bit_field ")
build_string_node(v.backing_type, sb, false)
if len(v.names) == 0 {
@@ -290,19 +302,13 @@ get_short_signature :: proc(ast_context: ^AstContext, symbol: Symbol) -> string
write_short_signature :: proc(sb: ^strings.Builder, ast_context: ^AstContext, symbol: Symbol) {
pointer_prefix := repeat("^", symbol.pointers, ast_context.allocator)
+ if .Distinct in symbol.flags {
+ strings.write_string(sb, "distinct ")
+ }
#partial switch v in symbol.value {
case SymbolBasicValue:
- if .Distinct in symbol.flags {
- 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)
- }
+ strings.write_string(sb, pointer_prefix)
+ build_string_node(v.ident, sb, false)
return
case SymbolPolyTypeValue:
fmt.sbprintf(sb, "%s$", pointer_prefix)