aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/server')
-rw-r--r--src/server/analysis.odin16
-rw-r--r--src/server/completion.odin4
-rw-r--r--src/server/hover.odin14
-rw-r--r--src/server/symbol.odin2
4 files changed, 27 insertions, 9 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index f25250b..5659839 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -2328,7 +2328,6 @@ get_using_packages :: proc(ast_context: ^AstContext) -> []string {
}
get_symbol_pkg_name :: proc(ast_context: ^AstContext, symbol: Symbol) -> string {
-
name := path.base(symbol.pkg, false, context.temp_allocator)
for imp in ast_context.imports {
@@ -3822,7 +3821,6 @@ append_variable_full_name :: proc(
get_signature :: proc(
ast_context: ^AstContext,
- ident: ast.Any_Node,
symbol: Symbol,
was_variable := false,
short_signature := false,
@@ -3889,6 +3887,16 @@ get_signature :: proc(
builder := strings.builder_make(ast_context.allocator)
if is_variable {
append_variable_full_name(&builder, ast_context, symbol, pointer_prefix)
+ } else if symbol.type_name != "" {
+ if symbol.type_pkg == "" {
+ fmt.sbprintf(&builder, "%s%s :: ", pointer_prefix, symbol.type_name)
+ } else {
+ // TODO: make this function just take a string
+ symbol := symbol
+ symbol.pkg = symbol.type_pkg
+ pkg_name := get_symbol_pkg_name(ast_context, symbol)
+ fmt.sbprintf(&builder, "%s%s.%s :: ", pointer_prefix, pkg_name, symbol.type_name)
+ }
}
longestNameLen := 0
for name in v.names {
@@ -3896,6 +3904,10 @@ get_signature :: proc(
longestNameLen = len(name)
}
}
+ if len(v.names) == 0 {
+ strings.write_string(&builder, "struct {}")
+ return strings.to_string(builder)
+ }
strings.write_string(&builder, "struct {\n")
for i in 0 ..< len(v.names) {
strings.write_string(&builder, "\t")
diff --git a/src/server/completion.odin b/src/server/completion.odin
index b76a2c5..30e7ac6 100644
--- a/src/server/completion.odin
+++ b/src/server/completion.odin
@@ -1290,7 +1290,7 @@ get_identifier_completion :: proc(
ident.name = k
if symbol, ok := resolve_type_identifier(ast_context, ident^); ok {
- symbol.signature = get_signature(ast_context, ident, symbol, short_signature=true)
+ symbol.signature = get_signature(ast_context, symbol, short_signature=true)
build_procedure_symbol_signature(&symbol)
@@ -1331,7 +1331,7 @@ get_identifier_completion :: proc(
ident.name = k
if symbol, ok := resolve_type_identifier(ast_context, ident^); ok {
- symbol.signature = get_signature(ast_context, ident, symbol, short_signature=true)
+ symbol.signature = get_signature(ast_context, symbol, short_signature=true)
build_procedure_symbol_signature(&symbol)
diff --git a/src/server/hover.odin b/src/server/hover.odin
index 3c602c1..89b75eb 100644
--- a/src/server/hover.odin
+++ b/src/server/hover.odin
@@ -125,9 +125,11 @@ get_hover_information :: proc(document: ^Document, position: common.Position) ->
&ast_context,
position_context.value_decl.names[0],
); ok {
+ symbol.type_name = symbol.name
+ symbol.type_pkg = symbol.pkg
symbol.pkg = struct_symbol.name
symbol.name = identifier.name
- symbol.signature = get_signature(&ast_context, field.type.derived, symbol)
+ symbol.signature = get_signature(&ast_context, symbol)
hover.contents = write_hover_content(&ast_context, symbol)
return hover, true, true
}
@@ -188,7 +190,7 @@ get_hover_information :: proc(document: ^Document, position: common.Position) ->
if position_in_node(base, position_context.position) {
if resolved, ok := resolve_type_identifier(&ast_context, ident); ok {
- resolved.signature = get_signature(&ast_context, &ident, resolved)
+ resolved.signature = get_signature(&ast_context, resolved)
resolved.name = ident.name
if resolved.type == .Variable {
@@ -237,9 +239,11 @@ get_hover_information :: proc(document: ^Document, position: common.Position) ->
for name, i in v.names {
if name == field {
if symbol, ok := resolve_type_expression(&ast_context, v.types[i]); ok {
+ symbol.type_name = symbol.name
+ symbol.type_pkg = symbol.pkg
symbol.name = name
symbol.pkg = selector.name
- symbol.signature = get_signature(&ast_context, v.types[i].derived, symbol)
+ symbol.signature = get_signature(&ast_context, symbol)
hover.contents = write_hover_content(&ast_context, symbol)
return hover, true, true
}
@@ -269,7 +273,7 @@ get_hover_information :: proc(document: ^Document, position: common.Position) ->
}
}
if resolved, ok := resolve_type_identifier(&ast_context, ident^); ok {
- resolved.signature = get_signature(&ast_context, ident, resolved)
+ resolved.signature = get_signature(&ast_context, resolved)
resolved.name = ident.name
if resolved.type == .Variable {
@@ -331,7 +335,7 @@ get_hover_information :: proc(document: ^Document, position: common.Position) ->
}
if resolved, ok := resolve_type_identifier(&ast_context, ident); ok {
- resolved.signature = get_signature(&ast_context, &ident, resolved)
+ resolved.signature = get_signature(&ast_context, resolved)
resolved.name = ident.name
if resolved.type == .Variable {
diff --git a/src/server/symbol.odin b/src/server/symbol.odin
index 8a3f4ab..7286028 100644
--- a/src/server/symbol.odin
+++ b/src/server/symbol.odin
@@ -162,6 +162,8 @@ Symbol :: struct {
doc: string,
signature: string, //type signature
type: SymbolType,
+ type_pkg: string,
+ type_name: string,
value: SymbolValue,
pointers: int, //how many `^` are applied to the symbol
flags: SymbolFlags,