/** * Returns with the client host. Defaults to {@code localhost} if not set. Has * absolutely no effect, if this is set but the {@code CLIENT_PORT} is not. */ public static String getClientHost() { return Environment.get(CLIENT_HOST); }
/** * Retrieves environment variable or system property value for given name. * Checks the environment value first. * * @return value or null */ public static String get(final String name, final String defaultValue){ String value = get(name); if(value == null) { value = defaultValue; } return value; }
/** * Returns with the client port if set. Otherwise, returns with {@code null}. * Throw an {@link IllegalStateException} if the port is set but it has an * invalid port number. * * When the client port environment variable is set to a valid port number, then * plain socket communication will be used between the language client and the * server instead of the standard IO stream one. */ public static Integer getClientPort() { final String port = Environment.get(CLIENT_PORT); if (port != null) { int clientPort = Integer.parseInt(port); Preconditions.checkState(clientPort >= 1 && clientPort <= 65535, "The port must be an integer between 1 and 65535. It was: '" + port + "'."); return clientPort; } return null; }
/** * Has no effect, and always returns with {@code false} if the JDT LS has been * started from the source either in debug or development mode. If the * {@code CLIENT_HOST} and {@code CLIENT_PORT} environment variables are set and * the {@link JDTEnvironmentUtils#SOCKET_STREAM_DEBUG socket.stream.debug} is * set to {@code true}, the the server will start with plain socket connection * and will wait until the client connects. */ public static boolean inSocketStreamDebugMode() { return Boolean.parseBoolean(Environment.get(SOCKET_STREAM_DEBUG, "false")) && (Platform.inDebugMode() || Platform.inDevelopmentMode()) && getClientHost() != null && getClientPort() != null; }