diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2022-03-04 12:17:00 +0100 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2022-03-04 12:17:00 +0100 |
| commit | 58287455d64ab16091522bf8a358b079ef05daad (patch) | |
| tree | 7b6655d6d34b5ad6d719523e4938b8002c43d8ab /src/server/inlay_hints.odin | |
| parent | 63d0bd412a8817445d6dc18e79d5d54c94caf401 (diff) | |
strip colons and update ast to use unions
Diffstat (limited to 'src/server/inlay_hints.odin')
| -rw-r--r-- | src/server/inlay_hints.odin | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/server/inlay_hints.odin b/src/server/inlay_hints.odin index 1e7d2c3..ae3d9a0 100644 --- a/src/server/inlay_hints.odin +++ b/src/server/inlay_hints.odin @@ -9,11 +9,11 @@ import "shared:index" //document get_inlay_hints :: proc(document: ^common.Document, symbols: map[uintptr]index.Symbol) -> ([]InlayHint, bool) { - using analysis; + using analysis - hints := make([dynamic]InlayHint, context.temp_allocator); + hints := make([dynamic]InlayHint, context.temp_allocator) - ast_context := make_ast_context(document.ast, document.imports, document.package_name, document.uri.uri); + ast_context := make_ast_context(document.ast, document.imports, document.package_name, document.uri.uri) Visit_Data :: struct { calls: [dynamic]^ast.Node, @@ -21,20 +21,20 @@ get_inlay_hints :: proc(document: ^common.Document, symbols: map[uintptr]index.S data := Visit_Data { calls = make([dynamic]^ast.Node, context.temp_allocator), - }; + } visit :: proc(visitor: ^ast.Visitor, node: ^ast.Node) -> ^ast.Visitor { if node == nil || visitor == nil { - return nil; + return nil } - data := cast(^Visit_Data)visitor.data; + data := cast(^Visit_Data)visitor.data - if call, ok := node.derived.(ast.Call_Expr); ok { - append(&data.calls, node); + if call, ok := node.derived.(^ast.Call_Expr); ok { + append(&data.calls, node) } - return visitor; + return visitor } visitor := ast.Visitor { @@ -43,17 +43,17 @@ get_inlay_hints :: proc(document: ^common.Document, symbols: map[uintptr]index.S } for decl in document.ast.decls { - ast.walk(&visitor, decl); + ast.walk(&visitor, decl) } loop: for node_call in &data.calls { symbol_arg_count := 0 - call := node_call.derived.(ast.Call_Expr); + call := node_call.derived.(^ast.Call_Expr) for arg in call.args { - if _, ok := arg.derived.(ast.Field); ok { - continue loop; + if _, ok := arg.derived.(^ast.Field); ok { + continue loop } } @@ -62,23 +62,23 @@ get_inlay_hints :: proc(document: ^common.Document, symbols: map[uintptr]index.S for arg in symbol_call.arg_types { for name in arg.names { if symbol_arg_count >= len(call.args) { - continue loop; + continue loop } - if ident, ok := name.derived.(ast.Ident); ok { + if ident, ok := name.derived.(^ast.Ident); ok { hint := InlayHint { kind = "parameter", label = fmt.tprintf("%v = ", ident.name), range = common.get_token_range(call.args[symbol_arg_count], string(document.text)), } - append(&hints, hint); + append(&hints, hint) } - symbol_arg_count += 1; + symbol_arg_count += 1 } } } } } - return hints[:], true; + return hints[:], true }
\ No newline at end of file |