clean up and simplify
This commit is contained in:
+3
-4
@@ -1,11 +1,10 @@
|
||||
package p.studio.lsp.api;
|
||||
|
||||
import p.studio.lsp.messages.LspProjectContext;
|
||||
import p.studio.lsp.messages.LspServerBootRequest;
|
||||
import p.studio.lsp.messages.LspServerHandle;
|
||||
import p.studio.lsp.messages.LspServerConfiguration;
|
||||
|
||||
public interface LspServerLifecycle {
|
||||
LspServerHandle bootServer(LspServerBootRequest request);
|
||||
void bootServer(LspServerConfiguration serverConfiguration, LspProjectContext context);
|
||||
|
||||
void shutdownServer(LspProjectContext project);
|
||||
void shutdownServer(LspProjectContext context);
|
||||
}
|
||||
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
package p.studio.lsp.messages;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public record LspServerBootRequest(
|
||||
LspProjectContext project,
|
||||
LspServerConfiguration configuration) {
|
||||
|
||||
public LspServerBootRequest {
|
||||
project = Objects.requireNonNull(project, "project");
|
||||
configuration = Objects.requireNonNull(configuration, "configuration");
|
||||
}
|
||||
|
||||
public static LspServerBootRequest defaults(final LspProjectContext project) {
|
||||
return new LspServerBootRequest(project, LspServerConfiguration.defaults());
|
||||
}
|
||||
}
|
||||
+9
-19
@@ -1,29 +1,19 @@
|
||||
package p.studio.lsp.messages;
|
||||
|
||||
import java.util.Objects;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
public record LspServerConfiguration(
|
||||
String host,
|
||||
int port) {
|
||||
@Builder
|
||||
@Getter
|
||||
public class LspServerConfiguration {
|
||||
public static final String DEFAULT_HOST = "127.0.0.1";
|
||||
public static final int DEFAULT_PORT = 7777;
|
||||
|
||||
public LspServerConfiguration {
|
||||
host = requireHost(host);
|
||||
if (port < 0 || port > 65535) {
|
||||
throw new IllegalArgumentException("port must be between 0 and 65535");
|
||||
}
|
||||
}
|
||||
@Builder.Default
|
||||
private final LspServerEndpoint endpoint = new LspServerEndpoint(DEFAULT_HOST, DEFAULT_PORT);
|
||||
|
||||
|
||||
public static LspServerConfiguration defaults() {
|
||||
return new LspServerConfiguration(DEFAULT_HOST, DEFAULT_PORT);
|
||||
}
|
||||
|
||||
private static String requireHost(final String value) {
|
||||
final String candidate = Objects.requireNonNull(value, "host").trim();
|
||||
if (candidate.isEmpty()) {
|
||||
throw new IllegalArgumentException("host must not be blank");
|
||||
}
|
||||
return candidate;
|
||||
return LspServerConfiguration.builder().build();
|
||||
}
|
||||
}
|
||||
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
package p.studio.lsp.messages;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public record LspServerHandle(
|
||||
LspProjectContext project,
|
||||
LspServerEndpoint endpoint) {
|
||||
|
||||
public LspServerHandle {
|
||||
project = Objects.requireNonNull(project, "project");
|
||||
endpoint = Objects.requireNonNull(endpoint, "endpoint");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user