implements PLN-0069

This commit is contained in:
2026-05-06 13:48:09 +01:00
parent 54f8c0d6d8
commit 41bcd8c52a
7 changed files with 162 additions and 3 deletions
@@ -0,0 +1,33 @@
package p.studio.lsp.messages;
import java.util.Objects;
public record BaselineEditorPalette(
String baseForeground,
String selectionBackground,
String activeHighlightBackground,
String lineNumberForeground,
String statusChipBackground,
String statusChipBorder,
String statusChipForeground) {
public BaselineEditorPalette {
baseForeground = requireText(baseForeground, "baseForeground");
selectionBackground = requireText(selectionBackground, "selectionBackground");
activeHighlightBackground = requireText(activeHighlightBackground, "activeHighlightBackground");
lineNumberForeground = requireText(lineNumberForeground, "lineNumberForeground");
statusChipBackground = requireText(statusChipBackground, "statusChipBackground");
statusChipBorder = requireText(statusChipBorder, "statusChipBorder");
statusChipForeground = requireText(statusChipForeground, "statusChipForeground");
}
private static String requireText(
final String value,
final String field) {
final String candidate = Objects.requireNonNull(value, field).trim();
if (candidate.isEmpty()) {
throw new IllegalArgumentException(field + " must not be blank");
}
return candidate;
}
}
@@ -7,12 +7,19 @@ public record BaselineServerDescription(
String name,
String version,
boolean hoverSupported,
List<String> semanticTokenTypes) {
List<String> semanticTokenTypes,
List<BaselineVisualTheme> visualThemes,
String activeVisualThemeId) {
public BaselineServerDescription {
name = requireText(name, "name");
version = requireText(version, "version");
semanticTokenTypes = List.copyOf(Objects.requireNonNull(semanticTokenTypes, "semanticTokenTypes"));
visualThemes = List.copyOf(Objects.requireNonNull(visualThemes, "visualThemes"));
activeVisualThemeId = requireText(activeVisualThemeId, "activeVisualThemeId");
if (visualThemes.stream().map(BaselineVisualTheme::themeId).noneMatch(activeVisualThemeId::equals)) {
throw new IllegalArgumentException("activeVisualThemeId must reference one of the declared visual themes");
}
}
private static String requireText(
@@ -0,0 +1,26 @@
package p.studio.lsp.messages;
import java.util.Objects;
public record BaselineTokenStyle(
String semanticKey,
String foreground,
boolean italic,
boolean bold,
boolean underline) {
public BaselineTokenStyle {
semanticKey = requireText(semanticKey, "semanticKey");
foreground = requireText(foreground, "foreground");
}
private static String requireText(
final String value,
final String field) {
final String candidate = Objects.requireNonNull(value, field).trim();
if (candidate.isEmpty()) {
throw new IllegalArgumentException(field + " must not be blank");
}
return candidate;
}
}
@@ -0,0 +1,31 @@
package p.studio.lsp.messages;
import java.util.List;
import java.util.Objects;
public record BaselineVisualTheme(
String themeId,
String displayName,
BaselineEditorPalette editorPalette,
List<BaselineTokenStyle> tokenStyles) {
public BaselineVisualTheme {
themeId = requireText(themeId, "themeId");
displayName = requireText(displayName, "displayName");
editorPalette = Objects.requireNonNull(editorPalette, "editorPalette");
tokenStyles = List.copyOf(Objects.requireNonNull(tokenStyles, "tokenStyles"));
if (tokenStyles.isEmpty()) {
throw new IllegalArgumentException("tokenStyles must not be empty");
}
}
private static String requireText(
final String value,
final String field) {
final String candidate = Objects.requireNonNull(value, field).trim();
if (candidate.isEmpty()) {
throw new IllegalArgumentException(field + " must not be blank");
}
return candidate;
}
}