aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-08-17 11:20:13 -0400
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-08-17 11:27:56 -0400
commit34e42985f2bee18a9abf2d936070ba38d3fc5fa9 (patch)
tree7e7efd3369b381271b061eca19fb217cf1c01350
parentaa4287a6c8bc06278db0abd5f7db902cf52af200 (diff)
Provide documentation for generic symbols
-rw-r--r--src/server/documentation.odin17
-rw-r--r--tests/completions_test.odin28
2 files changed, 37 insertions, 8 deletions
diff --git a/src/server/documentation.odin b/src/server/documentation.odin
index a0922fd..c076008 100644
--- a/src/server/documentation.odin
+++ b/src/server/documentation.odin
@@ -331,7 +331,7 @@ write_short_signature :: proc(sb: ^strings.Builder, ast_context: ^AstContext, sy
fmt.sbprintf(sb, "%smap[", pointer_prefix)
build_string_node(v.key, sb, false)
strings.write_string(sb, "]")
- write_node(ast_context, sb, v.value, "", short_signature = true)
+ write_node(sb, ast_context, v.value, "", short_signature = true)
return
case SymbolProcedureValue:
write_procedure_symbol_signature(sb, v, detailed_signature = true)
@@ -370,21 +370,21 @@ write_short_signature :: proc(sb: ^strings.Builder, ast_context: ^AstContext, sy
return
case SymbolMultiPointerValue:
fmt.sbprintf(sb, "%s[^]", pointer_prefix)
- write_node(ast_context, sb, v.expr, "", short_signature = true)
+ write_node(sb, ast_context, v.expr, "", short_signature = true)
return
case SymbolDynamicArrayValue:
fmt.sbprintf(sb, "%s[dynamic]", pointer_prefix)
- write_node(ast_context, sb, v.expr, "", short_signature = true)
+ write_node(sb, ast_context, v.expr, "", short_signature = true)
return
case SymbolSliceValue:
fmt.sbprintf(sb, "%s[]", pointer_prefix)
- write_node(ast_context, sb, v.expr, "", short_signature = true)
+ write_node(sb, ast_context, v.expr, "", short_signature = true)
return
case SymbolFixedArrayValue:
fmt.sbprintf(sb, "%s[", pointer_prefix)
build_string_node(v.len, sb, false)
strings.write_string(sb, "]")
- write_node(ast_context, sb, v.expr, "", short_signature = true)
+ write_node(sb, ast_context, v.expr, "", short_signature = true)
return
case SymbolMatrixValue:
fmt.sbprintf(sb, "%smatrix[", pointer_prefix)
@@ -409,6 +409,9 @@ write_short_signature :: proc(sb: ^strings.Builder, ast_context: ^AstContext, sy
strings.write_string(sb, "int")
}
return
+ case SymbolGenericValue:
+ build_string_node(v.expr, sb, false)
+ return
}
return
@@ -574,7 +577,7 @@ write_struct_hover :: proc(sb: ^strings.Builder, ast_context: ^AstContext, v: Sy
name_len += len(using_prefix)
}
fmt.sbprintf(sb, "%s:%*s", v.names[i], longestNameLen - name_len + 1, "")
- write_node(ast_context, sb, v.types[i], v.names[i], depth + 1)
+ write_node(sb, ast_context, v.types[i], v.names[i], depth + 1)
if bit_size, ok := v.bit_sizes[i]; ok {
fmt.sbprintf(sb, "%*s| ", longest_type_len - len(type_names[i]) + 1, "")
build_string_node(bit_size, sb, false)
@@ -632,8 +635,8 @@ write_union_kind :: proc(sb: ^strings.Builder, kind: ast.Union_Type_Kind) {
}
write_node :: proc(
- ast_context: ^AstContext,
sb: ^strings.Builder,
+ ast_context: ^AstContext,
node: ^ast.Node,
name: string,
depth := 0,
diff --git a/tests/completions_test.odin b/tests/completions_test.odin
index 339b195..0b2bc5f 100644
--- a/tests/completions_test.odin
+++ b/tests/completions_test.odin
@@ -3421,7 +3421,6 @@ ast_complete_ptr_using :: proc(t: ^testing.T) {
`,
}
- // TODO: add "{..}" to the struct in this example to match the others
test.expect_completion_docs(t, &source, "", {`A.b: ^test.B`, `A.a: ^struct {..}`, `A.foo: int`, `A.f: int`})
}
@@ -4389,3 +4388,30 @@ ast_completion_enum_map_value_global :: proc(t: ^testing.T) {
test.expect_completion_docs(t, &source, "", {"A", "B", "C"})
}
+
+@(test)
+ast_completion_basic_type_other_pkg :: proc(t: ^testing.T) {
+ packages := make([dynamic]test.Package, context.temp_allocator)
+
+ append(
+ &packages,
+ test.Package {
+ pkg = "my_package",
+ source = `package my_package
+ foo: int
+ `,
+ },
+ )
+ source := test.Source {
+ main = `package test
+ import "my_package"
+
+ foo :: proc() {
+ my_package.f{*}
+ }
+ `,
+ packages = packages[:],
+ }
+
+ test.expect_completion_docs(t, &source, "", {"my_package.foo: int"})
+}