diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2021-12-02 18:20:37 +0100 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2021-12-02 18:20:37 +0100 |
| commit | 2f2ea17723be24d96e9f2f3043d668561f406b7b (patch) | |
| tree | 62689879b8abfd6910a27b50ee0b095ebd3f90c6 /src/server | |
| parent | 3e9f57f727123c2b2a6479493a2443aca77c3001 (diff) | |
Start working on goto with multiple locations(packages), and fix some odinfmt bugs.
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/definition.odin | 26 | ||||
| -rw-r--r-- | src/server/requests.odin | 16 | ||||
| -rw-r--r-- | src/server/types.odin | 1 |
3 files changed, 27 insertions, 16 deletions
diff --git a/src/server/definition.odin b/src/server/definition.odin index 6afd44e..6d44227 100644 --- a/src/server/definition.odin +++ b/src/server/definition.odin @@ -19,10 +19,12 @@ import "shared:common" import "shared:index" import "shared:analysis" -get_definition_location :: proc(document: ^common.Document, position: common.Position) -> (common.Location, bool) { +get_definition_location :: proc(document: ^common.Document, position: common.Position) -> ([]common.Location, bool) { using analysis; + locations := make([dynamic]common.Location, context.temp_allocator); + location: common.Location; ast_context := make_ast_context(document.ast, document.imports, document.package_name, document.uri.uri); @@ -33,7 +35,7 @@ get_definition_location :: proc(document: ^common.Document, position: common.Pos if !ok { log.warn("Failed to get position context"); - return location, false; + return {}, false; } get_globals(document.ast, &ast_context); @@ -60,9 +62,11 @@ get_definition_location :: proc(document: ^common.Document, position: common.Pos location.uri = resolved.uri; } - return location, true; + append(&locations, location); + + return locations[:], true; } else { - return location, false; + return {}, false; } } } @@ -78,7 +82,7 @@ get_definition_location :: proc(document: ^common.Document, position: common.Pos selector, ok = resolve_type_expression(&ast_context, position_context.selector); if !ok { - return location, false; + return {}, false; } field: string; @@ -107,12 +111,12 @@ get_definition_location :: proc(document: ^common.Document, position: common.Pos location.range = symbol.range; uri = symbol.uri; } else { - return location, false; + return {}, false; } } if !ok { - return location, false; + return {}, false; } } else if position_context.identifier != nil { @@ -120,10 +124,10 @@ get_definition_location :: proc(document: ^common.Document, position: common.Pos location.range = resolved.range; uri = resolved.uri; } else { - return location, false; + return {}, false; } } else { - return location, false; + return {}, false; } //if the symbol is generated by the ast we don't set the uri. @@ -133,5 +137,7 @@ get_definition_location :: proc(document: ^common.Document, position: common.Pos location.uri = uri; } - return location, true; + append(&locations, location) + + return locations[:], true; }
\ No newline at end of file diff --git a/src/server/requests.odin b/src/server/requests.odin index f80d7ea..1c9ea13 100644 --- a/src/server/requests.odin +++ b/src/server/requests.odin @@ -455,6 +455,8 @@ request_initialize :: proc (task: ^common.Task) { config.enable_hover = true; config.enable_format = true; config.enable_document_symbols = true; + config.formatter.characters = 90; + config.formatter.tabs = true; if uri, ok := common.parse_uri(project_uri, context.temp_allocator); ok { ols_config_path := path.join(elems = {uri.path, "ols.json"}, allocator = context.temp_allocator); @@ -629,17 +631,19 @@ request_definition :: proc (task: ^common.Task) { return; } - location, ok2 := get_definition_location(document, definition_params.position); + locations, ok2 := get_definition_location(document, definition_params.position); if !ok2 { log.warn("Failed to get definition location"); } - response := make_response_message( - params = location, - id = id); - - send_response(response, writer); + if len(locations) == 1 { + response := make_response_message(params = locations[0], id = id); + send_response(response, writer); + } else { + response := make_response_message(params = locations, id = id); + send_response(response, writer); + } } request_completion :: proc (task: ^common.Task) { diff --git a/src/server/types.odin b/src/server/types.odin index fe5200f..8ef11b8 100644 --- a/src/server/types.odin +++ b/src/server/types.odin @@ -19,6 +19,7 @@ ResponseParams :: union { ResponseInitializeParams, rawptr, common.Location, + []common.Location, CompletionList, SignatureHelp, []DocumentSymbol, |