public static void main()

in src/main/java/software/amazon/smithy/lsp/Main.java [34:76]


  public static void main(String[] args) {

    Socket socket = null;
    InputStream in;
    OutputStream out;

    try {
      String port = args[0];
      // If port is set to "0", use System.in/System.out.
      if (port.equals("0")) {
        in = System.in;
        out = System.out;
      } else {
        socket = new Socket("localhost", Integer.parseInt(port));
        in = socket.getInputStream();
        out = socket.getOutputStream();
      }
      SmithyLanguageServer server = new SmithyLanguageServer();
      Launcher<LanguageClient> launcher = LSPLauncher.createServerLauncher(server, in, out);
      LanguageClient client = launcher.getRemoteProxy();

      server.connect(client);

      launcher.startListening().get();
    } catch (ArrayIndexOutOfBoundsException e) {
      System.out.println("Missing port argument");
    } catch (NumberFormatException e) {
      System.out.println("Port number must be a valid integer");
    } catch (Exception e) {
      System.out.println(e);

      e.printStackTrace();
    } finally {
      try {
        if (socket != null) {
          socket.close();
        }
      } catch (Exception e) {
        System.out.println("Failed to close the socket");
        System.out.println(e);
      }
    }
  }