implements PLN-0023

This commit is contained in:
2026-03-31 16:57:31 +01:00
parent 53552ca012
commit 8dd3b58f39
24 changed files with 297 additions and 9 deletions
@@ -1,3 +1,7 @@
plugins {
id("gradle.java-library-conventions")
}
dependencies {
implementation(project(":prometeu-vfs:prometeu-vfs-api"))
}
@@ -0,0 +1,16 @@
package p.lsp;
import java.nio.file.Path;
import java.util.Objects;
public record PrometeuLspProjectContext(
String projectName,
String languageId,
Path rootPath) {
public PrometeuLspProjectContext {
Objects.requireNonNull(projectName, "projectName");
Objects.requireNonNull(languageId, "languageId");
rootPath = Objects.requireNonNull(rootPath, "rootPath").toAbsolutePath().normalize();
}
}
@@ -0,0 +1,16 @@
package p.lsp;
import p.lsp.dtos.PrometeuLspSessionStateDTO;
import p.studio.vfs.ProjectDocumentVfs;
public interface PrometeuLspService extends AutoCloseable {
PrometeuLspProjectContext projectContext();
ProjectDocumentVfs projectDocumentVfs();
PrometeuLspSessionStateDTO snapshot();
@Override
default void close() {
}
}
@@ -0,0 +1,7 @@
package p.lsp;
import p.studio.vfs.ProjectDocumentVfs;
public interface PrometeuLspServiceFactory {
PrometeuLspService open(PrometeuLspProjectContext projectContext, ProjectDocumentVfs projectDocumentVfs);
}
@@ -0,0 +1,13 @@
package p.lsp.dtos;
import java.util.List;
import java.util.Objects;
public record PrometeuLspSessionStateDTO(
boolean semanticReadReady,
List<String> declaredCapabilities) {
public PrometeuLspSessionStateDTO {
declaredCapabilities = List.copyOf(Objects.requireNonNull(declaredCapabilities, "declaredCapabilities"));
}
}
@@ -0,0 +1,13 @@
package p.lsp.events;
import java.util.Objects;
public record PrometeuLspEvent(
PrometeuLspEventKind kind,
String message) {
public PrometeuLspEvent {
Objects.requireNonNull(kind, "kind");
Objects.requireNonNull(message, "message");
}
}
@@ -0,0 +1,5 @@
package p.lsp.events;
public enum PrometeuLspEventKind {
SESSION_READY
}
@@ -0,0 +1,5 @@
package p.lsp.events;
public interface PrometeuLspEventSink {
void publish(PrometeuLspEvent event);
}
@@ -0,0 +1,12 @@
package p.lsp.messages;
import java.nio.file.Path;
import java.util.Objects;
public record PrometeuLspAnalyzeDocumentRequest(
Path documentPath) {
public PrometeuLspAnalyzeDocumentRequest {
documentPath = Objects.requireNonNull(documentPath, "documentPath").toAbsolutePath().normalize();
}
}
@@ -0,0 +1,13 @@
package p.lsp.messages;
import p.lsp.dtos.PrometeuLspSessionStateDTO;
import java.util.Objects;
public record PrometeuLspAnalyzeDocumentResult(
PrometeuLspSessionStateDTO sessionState) {
public PrometeuLspAnalyzeDocumentResult {
Objects.requireNonNull(sessionState, "sessionState");
}
}
@@ -1,3 +1,8 @@
plugins {
id("gradle.java-library-conventions")
}
dependencies {
implementation(project(":prometeu-lsp:prometeu-lsp-api"))
implementation(project(":prometeu-vfs:prometeu-vfs-api"))
}
@@ -0,0 +1,20 @@
package p.lsp.v1;
import p.lsp.PrometeuLspProjectContext;
import p.lsp.PrometeuLspService;
import p.lsp.PrometeuLspServiceFactory;
import p.lsp.v1.internal.PrometeuLspV1Service;
import p.studio.vfs.ProjectDocumentVfs;
import java.util.Objects;
public final class PrometeuLspV1ServiceFactory implements PrometeuLspServiceFactory {
@Override
public PrometeuLspService open(
final PrometeuLspProjectContext projectContext,
final ProjectDocumentVfs projectDocumentVfs) {
return new PrometeuLspV1Service(
Objects.requireNonNull(projectContext, "projectContext"),
Objects.requireNonNull(projectDocumentVfs, "projectDocumentVfs"));
}
}
@@ -0,0 +1,38 @@
package p.lsp.v1.internal;
import p.lsp.PrometeuLspProjectContext;
import p.lsp.PrometeuLspService;
import p.lsp.dtos.PrometeuLspSessionStateDTO;
import p.studio.vfs.ProjectDocumentVfs;
import java.util.List;
import java.util.Objects;
public final class PrometeuLspV1Service implements PrometeuLspService {
private final PrometeuLspProjectContext projectContext;
private final ProjectDocumentVfs projectDocumentVfs;
public PrometeuLspV1Service(
final PrometeuLspProjectContext projectContext,
final ProjectDocumentVfs projectDocumentVfs) {
this.projectContext = Objects.requireNonNull(projectContext, "projectContext");
this.projectDocumentVfs = Objects.requireNonNull(projectDocumentVfs, "projectDocumentVfs");
}
@Override
public PrometeuLspProjectContext projectContext() {
return projectContext;
}
@Override
public ProjectDocumentVfs projectDocumentVfs() {
return projectDocumentVfs;
}
@Override
public PrometeuLspSessionStateDTO snapshot() {
return new PrometeuLspSessionStateDTO(
true,
List.of("diagnostics", "symbols", "definition", "highlight"));
}
}