Skip to content

Commit 7d583f5

Browse files
authored
Merge pull request #9 from AnetteTaivere/restructure
Restructure project: move classes into appropriate packages
2 parents 1cd6399 + a87c626 commit 7d583f5

9 files changed

+407
-391
lines changed

src/main/java/Main.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import abstractdebugging.AbstractDebuggingServerLauncher;
33
import abstractdebugging.ResultsService;
44
import analysis.GoblintAnalysis;
5-
import analysis.ShowCFGCommand;
5+
import magpiebridge.ShowCFGCommand;
66
import api.GoblintService;
77
import api.GoblintServiceLauncher;
88
import api.messages.params.Params;
@@ -13,6 +13,9 @@
1313
import gobpie.GobPieException;
1414
import magpiebridge.core.MagpieServer;
1515
import magpiebridge.core.ServerAnalysis;
16+
import magpiebridge.GoblintLanguageExtensionHandler;
17+
import magpiebridge.GoblintMagpieServer;
18+
import magpiebridge.GoblintServerConfiguration;
1619
import org.apache.logging.log4j.LogManager;
1720
import org.apache.logging.log4j.Logger;
1821
import org.eclipse.lsp4j.MessageParams;

src/main/java/api/GoblintServiceLauncher.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package api;
22

33
import api.json.GoblintMessageJsonHandler;
4-
import api.json.GoblintSocketMessageConsumer;
5-
import api.json.GoblintSocketMessageProducer;
4+
import api.jsonrpc.GoblintSocketMessageConsumer;
5+
import api.jsonrpc.GoblintSocketMessageProducer;
66
import api.jsonrpc.AutoClosingMessageProcessor;
77
import api.jsonrpc.CloseableEndpoint;
88
import gobpie.GobPieException;
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
1-
package api.json;
2-
3-
import org.apache.logging.log4j.LogManager;
4-
import org.apache.logging.log4j.Logger;
5-
import org.eclipse.lsp4j.jsonrpc.JsonRpcException;
6-
import org.eclipse.lsp4j.jsonrpc.MessageConsumer;
7-
import org.eclipse.lsp4j.jsonrpc.json.MessageConstants;
8-
import org.eclipse.lsp4j.jsonrpc.json.MessageJsonHandler;
9-
import org.eclipse.lsp4j.jsonrpc.messages.Message;
10-
11-
import java.io.IOException;
12-
import java.io.OutputStream;
13-
import java.nio.charset.StandardCharsets;
14-
15-
16-
/**
17-
* A message consumer that serializes messages to JSON and sends them to an output stream.
18-
*
19-
* @since 0.0.3
20-
*/
21-
22-
public class GoblintSocketMessageConsumer implements MessageConsumer, MessageConstants {
23-
24-
private final String encoding;
25-
private final MessageJsonHandler jsonHandler;
26-
private final Object outputLock = new Object();
27-
private final OutputStream output;
28-
29-
private final Logger log = LogManager.getLogger(GoblintSocketMessageConsumer.class);
30-
31-
public GoblintSocketMessageConsumer(OutputStream output, MessageJsonHandler jsonHandler) {
32-
this(output, StandardCharsets.UTF_8.name(), jsonHandler);
33-
}
34-
35-
public GoblintSocketMessageConsumer(OutputStream output, String encoding, MessageJsonHandler jsonHandler) {
36-
this.output = output;
37-
this.encoding = encoding;
38-
this.jsonHandler = jsonHandler;
39-
}
40-
41-
@Override
42-
public void consume(Message message) {
43-
try {
44-
String content = jsonHandler.serialize(message) + "\n";
45-
byte[] contentBytes = content.getBytes(encoding);
46-
synchronized (outputLock) {
47-
output.write(contentBytes);
48-
output.flush();
49-
}
50-
log.debug("WRITTEN: {}", content);
51-
} catch (IOException exception) {
52-
throw new JsonRpcException(exception);
53-
}
54-
}
55-
56-
}
1+
package api.jsonrpc;
2+
3+
import org.apache.logging.log4j.LogManager;
4+
import org.apache.logging.log4j.Logger;
5+
import org.eclipse.lsp4j.jsonrpc.JsonRpcException;
6+
import org.eclipse.lsp4j.jsonrpc.MessageConsumer;
7+
import org.eclipse.lsp4j.jsonrpc.json.MessageConstants;
8+
import org.eclipse.lsp4j.jsonrpc.json.MessageJsonHandler;
9+
import org.eclipse.lsp4j.jsonrpc.messages.Message;
10+
11+
import java.io.IOException;
12+
import java.io.OutputStream;
13+
import java.nio.charset.StandardCharsets;
14+
15+
16+
/**
17+
* A message consumer that serializes messages to JSON and sends them to an output stream.
18+
*
19+
* @since 0.0.3
20+
*/
21+
22+
public class GoblintSocketMessageConsumer implements MessageConsumer, MessageConstants {
23+
24+
private final String encoding;
25+
private final MessageJsonHandler jsonHandler;
26+
private final Object outputLock = new Object();
27+
private final OutputStream output;
28+
29+
private final Logger log = LogManager.getLogger(GoblintSocketMessageConsumer.class);
30+
31+
public GoblintSocketMessageConsumer(OutputStream output, MessageJsonHandler jsonHandler) {
32+
this(output, StandardCharsets.UTF_8.name(), jsonHandler);
33+
}
34+
35+
public GoblintSocketMessageConsumer(OutputStream output, String encoding, MessageJsonHandler jsonHandler) {
36+
this.output = output;
37+
this.encoding = encoding;
38+
this.jsonHandler = jsonHandler;
39+
}
40+
41+
@Override
42+
public void consume(Message message) {
43+
try {
44+
String content = jsonHandler.serialize(message) + "\n";
45+
byte[] contentBytes = content.getBytes(encoding);
46+
synchronized (outputLock) {
47+
output.write(contentBytes);
48+
output.flush();
49+
}
50+
log.debug("WRITTEN: {}", content);
51+
} catch (IOException exception) {
52+
throw new JsonRpcException(exception);
53+
}
54+
}
55+
56+
}

0 commit comments

Comments
 (0)