summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorGeorge Fraser <george@fivetran.com>2019-03-31 10:48:22 -0700
committerGeorge Fraser <george@fivetran.com>2019-03-31 10:48:22 -0700
commitf00234f1bc0949e21527c189ce7ceb33438ec932 (patch)
tree8fc1321a7ed4f63fb979f75f4eefbb74f0e3e531 /src/main
parent46e48e7dce071d5cf592f1a15e4a3122f93735b4 (diff)
downloadjava-language-server-f00234f1bc0949e21527c189ce7ceb33438ec932.zip
Leave out optional fields
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/javacs/lsp/CompletionItem.java4
-rw-r--r--src/main/java/org/javacs/lsp/LSP.java8
2 files changed, 8 insertions, 4 deletions
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<TextEdit> additionalTextEdits;
public List<Character> 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);
}