diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2021-04-29 23:48:07 +0200 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2021-04-29 23:48:07 +0200 |
| commit | 881de49df4dafb143b39afa5b5f012d98d8a7e7b (patch) | |
| tree | 85d39e6dd2a8838d4db647c35366ebe9a79cd9f7 /src | |
| parent | ef23ff512b31adf1e4a8519d1a2b9a713e1499dc (diff) | |
new test + fixed for range bug
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/analysis.odin | 42 | ||||
| -rw-r--r-- | src/server/completion.odin | 6 |
2 files changed, 25 insertions, 23 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 23a1404..28a8249 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -655,6 +655,9 @@ resolve_function_overload :: proc(ast_context: ^AstContext, group: ast.Proc_Grou if len(candidates) > 1 { return index.Symbol { + type = candidates[0].type, + name = candidates[0].name, + pkg = candidates[0].pkg, value = index.SymbolAggregateValue { symbols = candidates[:], }, @@ -696,6 +699,12 @@ resolve_type_expression :: proc(ast_context: ^AstContext, node: ^ast.Expr) -> (i using ast; switch v in node.derived { + case Array_Type: + return make_symbol_array_from_ast(ast_context, v), true; + case Dynamic_Array_Type: + return make_symbol_dynamic_array_from_ast(ast_context, v), true; + case Map_Type: + return make_symbol_map_from_ast(ast_context, v), true; case Proc_Type: return make_symbol_procedure_from_ast(ast_context, node, v, ast_context.field_name), true; case Ident: @@ -1024,11 +1033,11 @@ resolve_type_identifier :: proc(ast_context: ^AstContext, node: ast.Ident) -> (i }; case: symbol = index.Symbol { - type = .Keyword, - signature = node.name, - pkg = ast_context.current_package, - value = index.SymbolBasicValue { - ident = ident, + type = .Keyword, + signature = node.name, + pkg = ast_context.current_package, + value = index.SymbolBasicValue { + ident = ident, }, }; } @@ -1380,34 +1389,21 @@ make_symbol_procedure_from_ast :: proc(ast_context: ^AstContext, n: ^ast.Node, v return symbol; } -make_symbol_slice_from_ast :: proc(ast_context: ^AstContext, n: ^ast.Node, v: ast.Slice_Expr) -> index.Symbol { - - symbol := index.Symbol { - range = common.get_token_range(n^, ast_context.file.src), - pkg = get_package_from_node(n^), - }; - - symbol.value = index.SymbolSliceValue { - expr = v.expr, - }; - - return symbol; -} - make_symbol_array_from_ast :: proc(ast_context: ^AstContext, v: ast.Array_Type) -> index.Symbol { symbol := index.Symbol { range = common.get_token_range(v.node, ast_context.file.src), + type = .Variable, pkg = get_package_from_node(v.node), }; - if v.len == nil { + if v.len != nil { symbol.value = index.SymbolFixedArrayValue { expr = v.elem, len = v.len, }; } else { - symbol.value = index.SymbolDynamicArrayValue { + symbol.value = index.SymbolSliceValue { expr = v.elem, }; } @@ -1419,6 +1415,7 @@ make_symbol_dynamic_array_from_ast :: proc(ast_context: ^AstContext, v: ast.Dyna symbol := index.Symbol { range = common.get_token_range(v.node, ast_context.file.src), + type = .Variable, pkg = get_package_from_node(v.node), }; @@ -1433,6 +1430,7 @@ make_symbol_map_from_ast :: proc(ast_context: ^AstContext, v: ast.Map_Type) -> i symbol := index.Symbol { range = common.get_token_range(v.node, ast_context.file.src), + type = .Variable, pkg = get_package_from_node(v.node), }; @@ -1448,6 +1446,7 @@ make_symbol_basic_type_from_ast :: proc(ast_context: ^AstContext, n: ^ast.Node, symbol := index.Symbol { range = common.get_token_range(n^, ast_context.file.src), + type = .Variable, pkg = get_package_from_node(n^), }; @@ -2209,7 +2208,6 @@ get_signature :: proc(ast_context: ^AstContext, ident: ast.Ident, symbol: index. if is_variable, ok := ast_context.variables[ident.name]; ok && is_variable { if local := get_local(ast_context, ident.pos.offset, ident.name); local != nil { - if i, ok := local.derived.(ast.Ident); ok { return get_signature(ast_context, i, symbol, true); } else { diff --git a/src/server/completion.odin b/src/server/completion.odin index 79c8d15..b237a17 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -935,14 +935,16 @@ get_identifier_completion :: proc(ast_context: ^AstContext, position_context: ^D for result in top_results { + result := result; + item := CompletionItem { label = result.symbol.name, - detail = concatenate_symbols_information(ast_context, result.symbol, true), }; if result.variable != nil { if ok := resolve_ident_is_variable(ast_context, result.variable^); ok { item.kind = .Variable; + result.symbol.type = .Variable; } else { item.kind = cast(CompletionItemKind)result.symbol.type; } @@ -950,6 +952,8 @@ get_identifier_completion :: proc(ast_context: ^AstContext, position_context: ^D item.kind = cast(CompletionItemKind)result.symbol.type; } + item.detail = concatenate_symbols_information(ast_context, result.symbol, true); + append(&items, item); } |