refactor, rename and reducing complexity

This commit is contained in:
2026-04-02 11:55:09 +01:00
parent b64be2a9a1
commit ba55b8e65f
120 changed files with 1134 additions and 1025 deletions
@@ -1,24 +0,0 @@
package p.lsp;
import p.lsp.dtos.PrometeuLspSessionStateDTO;
import p.lsp.messages.PrometeuLspAnalyzeDocumentRequest;
import p.lsp.messages.PrometeuLspAnalyzeDocumentResult;
import p.lsp.messages.PrometeuLspDefinitionRequest;
import p.lsp.messages.PrometeuLspDefinitionResult;
import p.studio.vfs.ProjectDocumentVfs;
public interface PrometeuLspService extends AutoCloseable {
PrometeuLspProjectContext projectContext();
ProjectDocumentVfs projectDocumentVfs();
PrometeuLspSessionStateDTO snapshot();
PrometeuLspAnalyzeDocumentResult analyzeDocument(PrometeuLspAnalyzeDocumentRequest request);
PrometeuLspDefinitionResult definition(PrometeuLspDefinitionRequest request);
@Override
default void close() {
}
}
@@ -1,7 +0,0 @@
package p.lsp;
import p.studio.vfs.ProjectDocumentVfs;
public interface PrometeuLspServiceFactory {
PrometeuLspService open(PrometeuLspProjectContext projectContext, ProjectDocumentVfs projectDocumentVfs);
}
@@ -1,6 +0,0 @@
package p.lsp.dtos;
public enum PrometeuLspDiagnosticSeverityDTO {
ERROR,
WARNING
}
@@ -1,5 +0,0 @@
package p.lsp.events;
public enum PrometeuLspEventKind {
SESSION_READY
}
@@ -1,5 +0,0 @@
package p.lsp.events;
public interface PrometeuLspEventSink {
void publish(PrometeuLspEvent event);
}
@@ -1,25 +0,0 @@
package p.lsp.messages;
import p.lsp.dtos.PrometeuLspDiagnosticDTO;
import p.lsp.dtos.PrometeuLspHighlightSpanDTO;
import p.lsp.dtos.PrometeuLspSessionStateDTO;
import p.lsp.dtos.PrometeuLspSymbolDTO;
import java.util.List;
import java.util.Objects;
public record PrometeuLspAnalyzeDocumentResult(
PrometeuLspSessionStateDTO sessionState,
List<PrometeuLspDiagnosticDTO> diagnostics,
List<PrometeuLspHighlightSpanDTO> semanticHighlights,
List<PrometeuLspSymbolDTO> documentSymbols,
List<PrometeuLspSymbolDTO> workspaceSymbols) {
public PrometeuLspAnalyzeDocumentResult {
Objects.requireNonNull(sessionState, "sessionState");
diagnostics = List.copyOf(Objects.requireNonNull(diagnostics, "diagnostics"));
semanticHighlights = List.copyOf(Objects.requireNonNull(semanticHighlights, "semanticHighlights"));
documentSymbols = List.copyOf(Objects.requireNonNull(documentSymbols, "documentSymbols"));
workspaceSymbols = List.copyOf(Objects.requireNonNull(workspaceSymbols, "workspaceSymbols"));
}
}
@@ -0,0 +1,21 @@
package p.studio.lsp;
import p.studio.lsp.dtos.LspSessionStateDTO;
import p.studio.lsp.messages.*;
import p.studio.vfs.VfsProjectDocument;
public interface LspService extends AutoCloseable {
LspProjectContext projectContext();
VfsProjectDocument projectDocumentVfs();
LspSessionStateDTO snapshot();
LspAnalyzeDocumentResult analyzeDocument(LspAnalyzeDocumentRequest request);
LspDefinitionResult definition(LspDefinitionRequest request);
@Override
default void close() {
}
}
@@ -0,0 +1,8 @@
package p.studio.lsp;
import p.studio.lsp.messages.LspProjectContext;
import p.studio.vfs.VfsProjectDocument;
public interface LspServiceFactory {
LspService open(LspProjectContext projectContext, VfsProjectDocument vfsProjectDocument);
}
@@ -1,14 +1,14 @@
package p.lsp.dtos;
package p.studio.lsp.dtos;
import java.nio.file.Path;
import java.util.Objects;
public record PrometeuLspDefinitionTargetDTO(
public record LspDefinitionTargetDTO(
String name,
Path documentPath,
PrometeuLspRangeDTO range) {
LspRangeDTO range) {
public PrometeuLspDefinitionTargetDTO {
public LspDefinitionTargetDTO {
name = Objects.requireNonNull(name, "name");
documentPath = Objects.requireNonNull(documentPath, "documentPath").toAbsolutePath().normalize();
range = Objects.requireNonNull(range, "range");
@@ -1,17 +1,19 @@
package p.lsp.dtos;
package p.studio.lsp.dtos;
import p.studio.lsp.messages.LspDiagnosticSeverity;
import java.nio.file.Path;
import java.util.Objects;
public record PrometeuLspDiagnosticDTO(
public record LspDiagnosticDTO(
Path documentPath,
PrometeuLspRangeDTO range,
PrometeuLspDiagnosticSeverityDTO severity,
LspRangeDTO range,
LspDiagnosticSeverity severity,
String phase,
String code,
String message) {
public PrometeuLspDiagnosticDTO {
public LspDiagnosticDTO {
documentPath = Objects.requireNonNull(documentPath, "documentPath").toAbsolutePath().normalize();
range = Objects.requireNonNull(range, "range");
severity = Objects.requireNonNull(severity, "severity");
@@ -1,12 +1,12 @@
package p.lsp.dtos;
package p.studio.lsp.dtos;
import java.util.Objects;
public record PrometeuLspHighlightSpanDTO(
PrometeuLspRangeDTO range,
public record LspHighlightSpanDTO(
LspRangeDTO range,
String semanticKey) {
public PrometeuLspHighlightSpanDTO {
public LspHighlightSpanDTO {
range = Objects.requireNonNull(range, "range");
semanticKey = Objects.requireNonNull(semanticKey, "semanticKey");
}
@@ -1,10 +1,10 @@
package p.lsp.dtos;
package p.studio.lsp.dtos;
public record PrometeuLspRangeDTO(
public record LspRangeDTO(
int startOffset,
int endOffset) {
public PrometeuLspRangeDTO {
public LspRangeDTO {
startOffset = Math.max(0, startOffset);
endOffset = Math.max(startOffset, endOffset);
}
@@ -1,13 +1,13 @@
package p.lsp.dtos;
package p.studio.lsp.dtos;
import java.util.List;
import java.util.Objects;
public record PrometeuLspSessionStateDTO(
public record LspSessionStateDTO(
boolean semanticReadReady,
List<String> declaredCapabilities) {
public PrometeuLspSessionStateDTO {
public LspSessionStateDTO {
declaredCapabilities = List.copyOf(Objects.requireNonNull(declaredCapabilities, "declaredCapabilities"));
}
}
@@ -1,17 +1,19 @@
package p.lsp.dtos;
package p.studio.lsp.dtos;
import p.studio.lsp.messages.LspSymbolKind;
import java.nio.file.Path;
import java.util.List;
import java.util.Objects;
public record PrometeuLspSymbolDTO(
public record LspSymbolDTO(
String name,
PrometeuLspSymbolKindDTO kind,
LspSymbolKind kind,
Path documentPath,
PrometeuLspRangeDTO range,
List<PrometeuLspSymbolDTO> children) {
LspRangeDTO range,
List<LspSymbolDTO> children) {
public PrometeuLspSymbolDTO {
public LspSymbolDTO {
name = Objects.requireNonNull(name, "name");
kind = Objects.requireNonNull(kind, "kind");
documentPath = Objects.requireNonNull(documentPath, "documentPath").toAbsolutePath().normalize();
@@ -1,12 +1,12 @@
package p.lsp.events;
package p.studio.lsp.events;
import java.util.Objects;
public record PrometeuLspEvent(
PrometeuLspEventKind kind,
public record LspEvent(
LspEventKind kind,
String message) {
public PrometeuLspEvent {
public LspEvent {
Objects.requireNonNull(kind, "kind");
Objects.requireNonNull(message, "message");
}
@@ -0,0 +1,5 @@
package p.studio.lsp.events;
public enum LspEventKind {
SESSION_READY
}
@@ -0,0 +1,5 @@
package p.studio.lsp.events;
public interface LspEventSink {
void publish(LspEvent event);
}
@@ -1,12 +1,12 @@
package p.lsp.messages;
package p.studio.lsp.messages;
import java.nio.file.Path;
import java.util.Objects;
public record PrometeuLspAnalyzeDocumentRequest(
public record LspAnalyzeDocumentRequest(
Path documentPath) {
public PrometeuLspAnalyzeDocumentRequest {
public LspAnalyzeDocumentRequest {
documentPath = Objects.requireNonNull(documentPath, "documentPath").toAbsolutePath().normalize();
}
}
@@ -0,0 +1,25 @@
package p.studio.lsp.messages;
import p.studio.lsp.dtos.LspDiagnosticDTO;
import p.studio.lsp.dtos.LspHighlightSpanDTO;
import p.studio.lsp.dtos.LspSessionStateDTO;
import p.studio.lsp.dtos.LspSymbolDTO;
import java.util.List;
import java.util.Objects;
public record LspAnalyzeDocumentResult(
LspSessionStateDTO sessionState,
List<LspDiagnosticDTO> diagnostics,
List<LspHighlightSpanDTO> semanticHighlights,
List<LspSymbolDTO> documentSymbols,
List<LspSymbolDTO> workspaceSymbols) {
public LspAnalyzeDocumentResult {
Objects.requireNonNull(sessionState, "sessionState");
diagnostics = List.copyOf(Objects.requireNonNull(diagnostics, "diagnostics"));
semanticHighlights = List.copyOf(Objects.requireNonNull(semanticHighlights, "semanticHighlights"));
documentSymbols = List.copyOf(Objects.requireNonNull(documentSymbols, "documentSymbols"));
workspaceSymbols = List.copyOf(Objects.requireNonNull(workspaceSymbols, "workspaceSymbols"));
}
}
@@ -1,13 +1,13 @@
package p.lsp.messages;
package p.studio.lsp.messages;
import java.nio.file.Path;
import java.util.Objects;
public record PrometeuLspDefinitionRequest(
public record LspDefinitionRequest(
Path documentPath,
int offset) {
public PrometeuLspDefinitionRequest {
public LspDefinitionRequest {
documentPath = Objects.requireNonNull(documentPath, "documentPath").toAbsolutePath().normalize();
offset = Math.max(0, offset);
}
@@ -1,17 +1,17 @@
package p.lsp.messages;
package p.studio.lsp.messages;
import p.lsp.dtos.PrometeuLspDefinitionTargetDTO;
import p.studio.lsp.dtos.LspDefinitionTargetDTO;
import java.nio.file.Path;
import java.util.List;
import java.util.Objects;
public record PrometeuLspDefinitionResult(
public record LspDefinitionResult(
Path documentPath,
int offset,
List<PrometeuLspDefinitionTargetDTO> targets) {
List<LspDefinitionTargetDTO> targets) {
public PrometeuLspDefinitionResult {
public LspDefinitionResult {
documentPath = Objects.requireNonNull(documentPath, "documentPath").toAbsolutePath().normalize();
offset = Math.max(0, offset);
targets = List.copyOf(Objects.requireNonNull(targets, "targets"));
@@ -0,0 +1,6 @@
package p.studio.lsp.messages;
public enum LspDiagnosticSeverity {
ERROR,
WARNING
}
@@ -1,14 +1,14 @@
package p.lsp;
package p.studio.lsp.messages;
import java.nio.file.Path;
import java.util.Objects;
public record PrometeuLspProjectContext(
public record LspProjectContext(
String projectName,
String languageId,
Path rootPath) {
public PrometeuLspProjectContext {
public LspProjectContext {
Objects.requireNonNull(projectName, "projectName");
Objects.requireNonNull(languageId, "languageId");
rootPath = Objects.requireNonNull(rootPath, "rootPath").toAbsolutePath().normalize();
@@ -1,6 +1,6 @@
package p.lsp.dtos;
package p.studio.lsp.messages;
public enum PrometeuLspSymbolKindDTO {
public enum LspSymbolKind {
FUNCTION,
METHOD,
CONSTRUCTOR,