diff --git a/src/main/java/Client/ConsoleClientLauncher.java b/src/main/java/Client/ConsoleClientLauncher.java index c027741..d17cef1 100644 --- a/src/main/java/Client/ConsoleClientLauncher.java +++ b/src/main/java/Client/ConsoleClientLauncher.java @@ -19,7 +19,6 @@ public class ConsoleClientLauncher { private static Socket socket; public static MopeLSPClient client; - private Launcher cLauncher; private static ExecutorService executor; private static String host; private static int port; @@ -36,9 +35,9 @@ public ConsoleClientLauncher(String host, int port) throws IOException { menu = new ConsoleMenu(client); } - public Future launchClient() throws IOException { + public static Future launchClient() throws IOException { executor = Executors.newFixedThreadPool(2); - cLauncher = new LSPLauncher.Builder() + Launcher cLauncher = new LSPLauncher.Builder() .setLocalService(client) .setRemoteInterface(ModelicaLanguageServer.class) .setInput(socket.getInputStream()) @@ -74,6 +73,12 @@ public static void stopClient() throws ExecutionException{ logger.info("Client Finished"); } + public static void connectToServer() { + System.out.println("Serverip: "); + host= sc.next(); + System.out.println("Serverport: "); + port = sc.nextInt(); + } public static void shutdownServer() throws ExecutionException { @@ -86,11 +91,7 @@ public static void shutdownServer() throws ExecutionException { } public static void main(String[] args) throws Exception { - System.out.println("Serverip:"); - host= sc.next(); - System.out.println("Serverport:"); - port = sc.nextInt(); - + connectToServer(); ConsoleClientLauncher launcher = new ConsoleClientLauncher(host, port); clientListening = launcher.launchClient(); diff --git a/src/main/java/Server/MopeDocumentService.java b/src/main/java/Server/MopeDocumentService.java index c18fded..644ad7c 100644 --- a/src/main/java/Server/MopeDocumentService.java +++ b/src/main/java/Server/MopeDocumentService.java @@ -16,6 +16,7 @@ public class MopeDocumentService implements TextDocumentService { private ICompilerAdapter compiler; private static final Logger logger = LoggerFactory.getLogger(MopeDocumentService.class); + private UnsupportedOperationException unsupOpEx = null; @Override public CompletableFuture, CompletionList>> completion(CompletionParams completionParams) { @@ -41,17 +42,20 @@ public void didOpen(DidOpenTextDocumentParams params) { @Override public void didChange(DidChangeTextDocumentParams params) { - + // not yet implemented + throw unsupOpEx; } @Override public void didClose(DidCloseTextDocumentParams params) { - + // not yet implemented + throw unsupOpEx; } @Override public void didSave(DidSaveTextDocumentParams params) { - + // not yet implemented + throw unsupOpEx; } @Override diff --git a/src/main/java/Server/MopeLSPServerLauncher.java b/src/main/java/Server/MopeLSPServerLauncher.java index ba1bc71..69aa06d 100644 --- a/src/main/java/Server/MopeLSPServerLauncher.java +++ b/src/main/java/Server/MopeLSPServerLauncher.java @@ -26,7 +26,7 @@ public class MopeLSPServerLauncher { private static MopeLSPServer server; private static ExecutorService executor; private static Socket socket; - private static Logger logger = LoggerFactory.getLogger(MopeLSPServerLauncher.class); + public static Logger logger = LoggerFactory.getLogger(MopeLSPServerLauncher.class); private static ConfigObject configObject; public MopeLSPServerLauncher() throws IOException { @@ -36,7 +36,7 @@ public MopeLSPServerLauncher() throws IOException { serverSocket = new ServerSocket(configObject.port); } - public void launchServer() { + public static void launchServer() { System.setProperty(Log4jLoggerAdapter.ROOT_LOGGER_NAME, "TRACE"); diff --git a/src/main/java/Server/MopeWorkspaceService.java b/src/main/java/Server/MopeWorkspaceService.java index 98f1c63..8af5c25 100644 --- a/src/main/java/Server/MopeWorkspaceService.java +++ b/src/main/java/Server/MopeWorkspaceService.java @@ -7,8 +7,14 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; +import static Server.MopeLSPServerLauncher.logger; + public class MopeWorkspaceService implements WorkspaceService { + + public String error = "invalid command"; private final ModelicaService modelicaService; + private UnsupportedOperationException unsupOpEx = null; + @Override public CompletableFuture> symbol(WorkspaceSymbolParams workspaceSymbolParams) { return null; @@ -16,12 +22,14 @@ public CompletableFuture> symbol(WorkspaceSymb @Override public void didChangeConfiguration(DidChangeConfigurationParams didChangeConfigurationParams) { - + // not yet implemented + throw unsupOpEx; } @Override public void didChangeWatchedFiles(DidChangeWatchedFilesParams didChangeWatchedFilesParams) { - + //not yet implemented + throw unsupOpEx; } @Override @@ -34,27 +42,31 @@ public CompletableFuture executeCommand(ExecuteCommandParams params){ String argument = ""; if(!args.isEmpty()) argument = args.get(0).toString().replaceAll("\"", ""); switch(command){ - case "ExecuteCommand": + case "executeCommand": result = modelicaService.sendExpression(argument); break; - case "LoadFile": + case "loadFile": result = modelicaService.loadFile(argument); break; - case "CheckModel": + case "checkModel": result = modelicaService.checkModel(argument); break; - case "AddPath": + case "addPath": result = modelicaService.addModelicaPath(argument); break; - case "GetPath": + case "getPath": result = modelicaService.getModelicaPath(); break; - case "LoadModel": + case "loadModel": result = modelicaService.loadModel(argument); break; - case "Version": + case "version": result = modelicaService.getCompilerVersion(); break; + default: + result = CompletableFuture.completedFuture(error); + logger.error("Command is invalid, output is: " + result); + break; } try {