diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2021-12-25 13:43:58 +0100 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2021-12-25 13:43:58 +0100 |
| commit | bb1379a911f43134b8dc5ed9ec2eebb889b800fb (patch) | |
| tree | 8eb5090124d0bb4c18d353e1daf1d09d50531f8d /src/server/requests.odin | |
| parent | 74d5978d86d8da1e2f74727965d7d3d3b16c71f1 (diff) | |
add temp work
Diffstat (limited to 'src/server/requests.odin')
| -rw-r--r-- | src/server/requests.odin | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/src/server/requests.odin b/src/server/requests.odin index f4dc267..8fc0fa1 100644 --- a/src/server/requests.odin +++ b/src/server/requests.odin @@ -43,6 +43,7 @@ RequestType :: enum { FormatDocument, Hover, CancelRequest, + InlayHint, } RequestInfo :: struct { @@ -186,6 +187,7 @@ request_map: map[string]RequestType = { "textDocument/hover" = .Hover, "$/cancelRequest" = .CancelRequest, "textDocument/formatting" = .FormatDocument, + "odin/inlayHints" = .InlayHint, }; handle_error :: proc (err: common.Error, id: RequestId, writer: ^Writer) { @@ -282,6 +284,8 @@ handle_request :: proc (request: json.Value, config: ^common.Config, writer: ^Wr case .CancelRequest: case .FormatDocument: task_proc = request_format_document; + case .InlayHint: + task_proc = request_inlay_hint; } task := common.Task { @@ -298,9 +302,9 @@ handle_request :: proc (request: json.Value, config: ^common.Config, writer: ^Wr break; } } - case .Initialize,.Initialized: + case .Initialize, .Initialized: task_proc(&task); - case .Completion,.Definition,.Hover,.FormatDocument: + case .Completion, .Definition, .Hover, .FormatDocument: uri := root["params"].(json.Object)["textDocument"].(json.Object)["uri"].(json.String); @@ -315,7 +319,7 @@ handle_request :: proc (request: json.Value, config: ^common.Config, writer: ^Wr task_proc(&task); - case .DidClose,.DidChange,.DidOpen,.DidSave: + case .DidClose, .DidChange, .DidOpen, .DidSave: uri := root["params"].(json.Object)["textDocument"].(json.Object)["uri"].(json.String); @@ -335,7 +339,7 @@ handle_request :: proc (request: json.Value, config: ^common.Config, writer: ^Wr document_release(document); case .Shutdown,.Exit: task_proc(&task); - case .SignatureHelp,.SemanticTokensFull,.SemanticTokensRange,.DocumentSymbol: + case .SignatureHelp, .SemanticTokensFull, .SemanticTokensRange, .DocumentSymbol, .InlayHint: uri := root["params"].(json.Object)["textDocument"].(json.Object)["uri"].(json.String); @@ -541,6 +545,7 @@ request_initialize :: proc (task: ^common.Task) { tokenModifiers = token_modifiers, }, }, + inlayHintsProvider = true, documentSymbolProvider = config.enable_document_symbols, hoverProvider = config.enable_hover, documentFormattingProvider = config.enable_format, @@ -1108,3 +1113,34 @@ request_hover :: proc (task: ^common.Task) { send_response(response, writer); } + +request_inlay_hint :: proc (task: ^common.Task) { + info := get_request_info(task); + + using info; + + defer { + document_release(document); + json.destroy_value(root); + free(info); + } + + params_object, ok := params.(json.Object); + + if !ok { + handle_error(.ParseError, id, writer); + return; + } + + hints: []InlayHint; + hints, ok = get_inlay_hints(document); + + if !ok { + handle_error(.InternalError, id, writer); + return; + } + + response := make_response_message(params = hints, id = id); + + send_response(response, writer); +}
\ No newline at end of file |