aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-10-29 23:55:53 -0400
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-10-29 23:57:48 -0400
commit2e0f171e43d44b61c60296bab45fb86846f671f0 (patch)
tree838d91c485947fd587d8d7894c41c88fb3fb51de /src
parent25dafecd9238317c1534012f183dc828417e3da9 (diff)
Provide the resolved symbol for the proc to propagate docs and comments
Diffstat (limited to 'src')
-rw-r--r--src/server/analysis.odin100
-rw-r--r--src/server/caches.odin2
-rw-r--r--src/server/generics.odin33
3 files changed, 46 insertions, 89 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index 4c21c81..fdc1956 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -1811,37 +1811,7 @@ resolve_local_identifier :: proc(ast_context: ^AstContext, node: ast.Ident, loca
return_symbol, ok = make_symbol_bit_field_from_ast(ast_context, v, node.name), true
return_symbol.name = node.name
case ^ast.Proc_Lit:
- if is_procedure_generic(v.type) {
- return_symbol, ok = resolve_generic_function(ast_context, v^)
-
- if !ok && !ast_context.overloading {
- return_symbol, ok =
- make_symbol_procedure_from_ast(
- ast_context,
- local.rhs,
- v.type^,
- node.name,
- {},
- false,
- v.inlining,
- v.where_clauses,
- ),
- true
- }
- } else {
- return_symbol, ok =
- make_symbol_procedure_from_ast(
- ast_context,
- local.rhs,
- v.type^,
- node.name,
- {},
- false,
- v.inlining,
- v.where_clauses,
- ),
- true
- }
+ return_symbol, ok = resolve_proc_lit(ast_context, local.rhs, v, node.name, {}, false)
case ^ast.Proc_Group:
return_symbol, ok = resolve_function_overload(ast_context, v^)
case ^ast.Array_Type:
@@ -1935,38 +1905,7 @@ resolve_global_identifier :: proc(ast_context: ^AstContext, node: ast.Ident, glo
return_symbol, ok = make_symbol_bit_field_from_ast(ast_context, v, node.name), true
return_symbol.name = node.name
case ^ast.Proc_Lit:
- if is_procedure_generic(v.type) {
- return_symbol, ok = resolve_generic_function(ast_context, v^)
-
- //If we are not overloading just show the unresolved generic function
- if !ok && !ast_context.overloading {
- return_symbol, ok =
- make_symbol_procedure_from_ast(
- ast_context,
- global.expr,
- v.type^,
- node.name,
- global.attributes,
- false,
- v.inlining,
- v.where_clauses,
- ),
- true
- }
- } else {
- return_symbol, ok =
- make_symbol_procedure_from_ast(
- ast_context,
- global.expr,
- v.type^,
- node.name,
- global.attributes,
- false,
- v.inlining,
- v.where_clauses,
- ),
- true
- }
+ return_symbol, ok = resolve_proc_lit(ast_context, global.expr, v, node.name, global.attributes, false)
case ^ast.Proc_Group:
return_symbol, ok = resolve_function_overload(ast_context, v^)
case ^ast.Array_Type:
@@ -2013,6 +1952,38 @@ resolve_global_identifier :: proc(ast_context: ^AstContext, node: ast.Ident, glo
return return_symbol, ok
}
+resolve_proc_lit :: proc(
+ ast_context: ^AstContext,
+ node: ^ast.Node,
+ proc_lit: ^ast.Proc_Lit,
+ name: string,
+ attributes: []^ast.Attribute,
+ type: bool,
+) -> (
+ Symbol,
+ bool,
+) {
+ symbol := make_symbol_procedure_from_ast(
+ ast_context,
+ node,
+ proc_lit.type^,
+ name,
+ attributes,
+ type,
+ proc_lit.inlining,
+ proc_lit.where_clauses,
+ )
+
+ if is_procedure_generic(proc_lit.type) {
+ if generic_symbol, ok := resolve_generic_function(ast_context, proc_lit^, symbol); ok {
+ return generic_symbol, ok
+ } else if ast_context.overloading {
+ return {}, false
+ }
+ }
+ return symbol, true
+}
+
struct_type_from_identifier :: proc(ast_context: ^AstContext, node: ast.Ident) -> (^ast.Struct_Type, bool) {
if check_node_recursion(ast_context, node.derived.(^ast.Ident)) {
return {}, false
@@ -2533,8 +2504,7 @@ resolve_symbol_return :: proc(ast_context: ^AstContext, symbol: Symbol, ok := tr
v.arg_types,
v.return_types,
v.inlining,
- symbol.range,
- symbol.uri,
+ symbol,
); ok {
return resolved_symbol, ok
} else {
diff --git a/src/server/caches.odin b/src/server/caches.odin
index 423e568..ff7a422 100644
--- a/src/server/caches.odin
+++ b/src/server/caches.odin
@@ -2,8 +2,6 @@ package server
import "src:common"
-import "core:fmt"
-import "core:log"
import "core:mem/virtual"
import "core:os"
import "core:path/filepath"
diff --git a/src/server/generics.odin b/src/server/generics.odin
index ed35c65..37546a2 100644
--- a/src/server/generics.odin
+++ b/src/server/generics.odin
@@ -1,19 +1,9 @@
package server
-import "core:fmt"
-import "core:log"
-import "core:mem"
import "core:odin/ast"
-import "core:odin/parser"
import "core:odin/tokenizer"
-import "core:path/filepath"
-import path "core:path/slashpath"
import "core:reflect"
-import "core:slice"
-import "core:sort"
-import "core:strconv"
import "core:strings"
-import "core:unicode/utf8"
import "src:common"
@@ -487,7 +477,14 @@ resolve_generic_function :: proc {
resolve_generic_function_symbol,
}
-resolve_generic_function_ast :: proc(ast_context: ^AstContext, proc_lit: ast.Proc_Lit) -> (Symbol, bool) {
+resolve_generic_function_ast :: proc(
+ ast_context: ^AstContext,
+ proc_lit: ast.Proc_Lit,
+ proc_symbol: Symbol,
+) -> (
+ Symbol,
+ bool,
+) {
if ast_context.call == nil {
return Symbol{}, false
}
@@ -504,7 +501,7 @@ resolve_generic_function_ast :: proc(ast_context: ^AstContext, proc_lit: ast.Pro
range := common.get_token_range(proc_lit, ast_context.file.src)
uri := common.create_uri(proc_lit.pos.file, ast_context.allocator).uri
- return resolve_generic_function_symbol(ast_context, params, results, proc_lit.inlining, range, uri)
+ return resolve_generic_function_symbol(ast_context, params, results, proc_lit.inlining, proc_symbol)
}
@@ -513,8 +510,7 @@ resolve_generic_function_symbol :: proc(
params: []^ast.Field,
results: []^ast.Field,
inlining: ast.Proc_Inlining,
- proc_range: common.Range,
- proc_uri: string,
+ proc_symbol: Symbol,
) -> (
Symbol,
bool,
@@ -619,14 +615,6 @@ resolve_generic_function_symbol :: proc(
return {}, false
}
- symbol := Symbol {
- range = proc_range,
- type = .Function,
- name = function_name,
- uri = proc_uri,
- pkg = get_package_from_filepath(proc_uri),
- }
-
return_types := make([dynamic]^ast.Field, ast_context.allocator)
argument_types := make([dynamic]^ast.Field, ast_context.allocator)
@@ -680,6 +668,7 @@ resolve_generic_function_symbol :: proc(
}
+ symbol := proc_symbol
symbol.value = SymbolProcedureValue {
return_types = return_types[:],
arg_types = argument_types[:],