From f00234f1bc0949e21527c189ce7ceb33438ec932 Mon Sep 17 00:00:00 2001 From: George Fraser Date: Sun, 31 Mar 2019 10:48:22 -0700 Subject: Leave out optional fields --- src/main/java/org/javacs/lsp/CompletionItem.java | 4 ++-- src/main/java/org/javacs/lsp/LSP.java | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/javacs/lsp/CompletionItem.java b/src/main/java/org/javacs/lsp/CompletionItem.java index 678a535..2eab5da 100644 --- a/src/main/java/org/javacs/lsp/CompletionItem.java +++ b/src/main/java/org/javacs/lsp/CompletionItem.java @@ -8,9 +8,9 @@ public class CompletionItem { public int kind; public String detail; public MarkupContent documentation; - public boolean deprecated, preselect; + public Boolean deprecated, preselect; public String sortText, filterText, insertText; - public int insertTextFormat; + public Integer insertTextFormat; public TextEdit textEdit; public List additionalTextEdits; public List commitCharacters; diff --git a/src/main/java/org/javacs/lsp/LSP.java b/src/main/java/org/javacs/lsp/LSP.java index 8747bc1..4a46cf0 100644 --- a/src/main/java/org/javacs/lsp/LSP.java +++ b/src/main/java/org/javacs/lsp/LSP.java @@ -102,12 +102,16 @@ public class LSP { } } + static String toJson(Object message) { + return gson.toJson(message); + } + static void respond(OutputStream client, int requestId, Object params) { if (params instanceof Optional) { var option = (Optional) params; params = option.orElse(null); } - var jsonText = gson.toJson(params); + var jsonText = toJson(params); var messageText = String.format("{\"jsonrpc\":\"2.0\",\"id\":%d,\"result\":%s}", requestId, jsonText); writeClient(client, messageText); } @@ -117,7 +121,7 @@ public class LSP { var option = (Optional) params; params = option.orElse(null); } - var jsonText = gson.toJson(params); + var jsonText = toJson(params); var messageText = String.format("{\"jsonrpc\":\"2.0\",\"method\":\"%s\",\"params\":%s}", method, jsonText); writeClient(client, messageText); } -- cgit v1.2.3