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
@@ -0,0 +1,16 @@
package p.studio.lsp.dtos;
import java.nio.file.Path;
import java.util.Objects;
public record LspDefinitionTargetDTO(
String name,
Path documentPath,
LspRangeDTO range) {
public LspDefinitionTargetDTO {
name = Objects.requireNonNull(name, "name");
documentPath = Objects.requireNonNull(documentPath, "documentPath").toAbsolutePath().normalize();
range = Objects.requireNonNull(range, "range");
}
}
@@ -0,0 +1,24 @@
package p.studio.lsp.dtos;
import p.studio.lsp.messages.LspDiagnosticSeverity;
import java.nio.file.Path;
import java.util.Objects;
public record LspDiagnosticDTO(
Path documentPath,
LspRangeDTO range,
LspDiagnosticSeverity severity,
String phase,
String code,
String message) {
public LspDiagnosticDTO {
documentPath = Objects.requireNonNull(documentPath, "documentPath").toAbsolutePath().normalize();
range = Objects.requireNonNull(range, "range");
severity = Objects.requireNonNull(severity, "severity");
phase = phase == null ? "" : phase;
code = code == null ? "" : code;
message = Objects.requireNonNull(message, "message");
}
}
@@ -0,0 +1,13 @@
package p.studio.lsp.dtos;
import java.util.Objects;
public record LspHighlightSpanDTO(
LspRangeDTO range,
String semanticKey) {
public LspHighlightSpanDTO {
range = Objects.requireNonNull(range, "range");
semanticKey = Objects.requireNonNull(semanticKey, "semanticKey");
}
}
@@ -0,0 +1,15 @@
package p.studio.lsp.dtos;
public record LspRangeDTO(
int startOffset,
int endOffset) {
public LspRangeDTO {
startOffset = Math.max(0, startOffset);
endOffset = Math.max(startOffset, endOffset);
}
public boolean contains(final int offset) {
return startOffset <= offset && offset < endOffset;
}
}
@@ -0,0 +1,13 @@
package p.studio.lsp.dtos;
import java.util.List;
import java.util.Objects;
public record LspSessionStateDTO(
boolean semanticReadReady,
List<String> declaredCapabilities) {
public LspSessionStateDTO {
declaredCapabilities = List.copyOf(Objects.requireNonNull(declaredCapabilities, "declaredCapabilities"));
}
}
@@ -0,0 +1,23 @@
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 LspSymbolDTO(
String name,
LspSymbolKind kind,
Path documentPath,
LspRangeDTO range,
List<LspSymbolDTO> children) {
public LspSymbolDTO {
name = Objects.requireNonNull(name, "name");
kind = Objects.requireNonNull(kind, "kind");
documentPath = Objects.requireNonNull(documentPath, "documentPath").toAbsolutePath().normalize();
range = Objects.requireNonNull(range, "range");
children = List.copyOf(Objects.requireNonNull(children, "children"));
}
}