summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Fraser <george@fivetran.com>2019-01-02 20:03:30 -0800
committerGeorge Fraser <george@fivetran.com>2019-01-02 20:03:30 -0800
commitd668819fb00d45562d46a4fbf147a4a20c474272 (patch)
treed66a334bb0130e23a8f8c73b50b27c5cb2ca574c
parentf8d4692107f064814e8fe9c9bbb937365bf9e11a (diff)
downloadjava-language-server-d668819fb00d45562d46a4fbf147a4a20c474272.zip
Revert formatting changes
-rw-r--r--src/main/java/org/javacs/lsp/LSP.java30
1 files changed, 7 insertions, 23 deletions
diff --git a/src/main/java/org/javacs/lsp/LSP.java b/src/main/java/org/javacs/lsp/LSP.java
index e37fe2a..f8be413 100644
--- a/src/main/java/org/javacs/lsp/LSP.java
+++ b/src/main/java/org/javacs/lsp/LSP.java
@@ -13,7 +13,6 @@ import java.util.logging.Level;
import java.util.logging.Logger;
public class LSP {
-
private static final Gson gson = new Gson();
private static String readHeader(InputStream client) {
@@ -67,9 +66,7 @@ public class LSP {
while (true) {
result.append(next);
i++;
- if (i == byteLength) {
- break;
- }
+ if (i == byteLength) break;
next = read(client);
}
return result.toString();
@@ -80,14 +77,10 @@ public class LSP {
while (true) {
var line = readHeader(client);
// If header is empty, next line is the start of the message
- if (line.isEmpty()) {
- return readLength(client, contentLength);
- }
+ if (line.isEmpty()) return readLength(client, contentLength);
// If header contains length, save it
var maybeLength = parseHeader(line);
- if (maybeLength != -1) {
- contentLength = maybeLength;
- }
+ if (maybeLength != -1) contentLength = maybeLength;
}
}
@@ -130,7 +123,6 @@ public class LSP {
}
private static class RealClient implements LanguageClient {
-
final OutputStream send;
RealClient(OutputStream send) {
@@ -171,16 +163,12 @@ public class LSP {
// Read messages and process cancellations on a separate thread
class MessageReader implements Runnable {
-
void peek(Message message) {
if (message.method.equals("$/cancelRequest")) {
var params = gson.fromJson(message.params, CancelParams.class);
var removed = pending.removeIf(r -> r.id != null && r.id.equals(params.id));
- if (removed) {
- LOG.info(String.format("Cancelled request %d, which had not yet started", params.id));
- } else {
- LOG.info(String.format("Cannot cancel request %d because it has already started", params.id));
- }
+ if (removed) LOG.info(String.format("Cancelled request %d, which had not yet started", params.id));
+ else LOG.info(String.format("Cannot cancel request %d because it has already started", params.id));
}
}
@@ -206,9 +194,7 @@ public class LSP {
peek(message);
pending.put(message);
} catch (EndOfStream __) {
- if (kill()) {
- return;
- }
+ if (kill()) return;
} catch (Exception e) {
LOG.log(Level.SEVERE, e.getMessage(), e);
}
@@ -232,9 +218,7 @@ public class LSP {
break processMessages;
}
// If poll(_) failed, loop again
- if (r == null) {
- continue;
- }
+ if (r == null) continue;
// Otherwise, process the new message
switch (r.method) {
case "initialize":