implements PLN-0071
This commit is contained in:
+2
@@ -6,6 +6,7 @@ import java.util.List;
|
||||
public record BaselineServerDescription(
|
||||
String name,
|
||||
String version,
|
||||
String frontendLanguageId,
|
||||
boolean hoverSupported,
|
||||
List<String> semanticTokenTypes,
|
||||
List<BaselineVisualTheme> visualThemes,
|
||||
@@ -14,6 +15,7 @@ public record BaselineServerDescription(
|
||||
public BaselineServerDescription {
|
||||
name = requireText(name, "name");
|
||||
version = requireText(version, "version");
|
||||
frontendLanguageId = requireText(frontendLanguageId, "frontendLanguageId");
|
||||
semanticTokenTypes = List.copyOf(Objects.requireNonNull(semanticTokenTypes, "semanticTokenTypes"));
|
||||
visualThemes = List.copyOf(Objects.requireNonNull(visualThemes, "visualThemes"));
|
||||
activeVisualThemeId = requireText(activeVisualThemeId, "activeVisualThemeId");
|
||||
|
||||
+1
@@ -36,6 +36,7 @@ public record CompilerLanguageServiceBridge() implements LanguageServiceBridge {
|
||||
return new BaselineServerDescription(
|
||||
"Prometeu Studio LSP",
|
||||
"0.1.0",
|
||||
context.languageId(),
|
||||
true,
|
||||
PBSDefinitions.PBS.getSemanticPresentation().semanticKeys(),
|
||||
PBSDefinitions.PBS.getSemanticPresentation().themes().stream().map(this::mapVisualTheme).toList(),
|
||||
|
||||
+29
@@ -5,7 +5,9 @@ import p.studio.lsp.messages.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public final class Lsp4jProtocolMessageMapper implements ProtocolMessageMapper {
|
||||
@Override
|
||||
@@ -26,6 +28,12 @@ public final class Lsp4jProtocolMessageMapper implements ProtocolMessageMapper {
|
||||
semanticTokens.setLegend(new SemanticTokensLegend(description.semanticTokenTypes(), List.of()));
|
||||
semanticTokens.setFull(true);
|
||||
capabilities.setSemanticTokensProvider(semanticTokens);
|
||||
capabilities.setExperimental(Map.of(
|
||||
"prometeuVisualThemes",
|
||||
Map.of(
|
||||
"frontendLanguageId", description.frontendLanguageId(),
|
||||
"activeVisualThemeId", description.activeVisualThemeId(),
|
||||
"visualThemes", description.visualThemes().stream().map(this::mapVisualThemePayload).toList())));
|
||||
|
||||
final InitializeResult result = new InitializeResult(capabilities);
|
||||
final ServerInfo serverInfo = new ServerInfo();
|
||||
@@ -122,4 +130,25 @@ public final class Lsp4jProtocolMessageMapper implements ProtocolMessageMapper {
|
||||
case ERROR -> DiagnosticSeverity.Error;
|
||||
};
|
||||
}
|
||||
|
||||
private Map<String, Object> mapVisualThemePayload(final BaselineVisualTheme theme) {
|
||||
final Map<String, Object> payload = new LinkedHashMap<>();
|
||||
payload.put("themeId", theme.themeId());
|
||||
payload.put("displayName", theme.displayName());
|
||||
payload.put("editorPalette", Map.of(
|
||||
"baseForeground", theme.editorPalette().baseForeground(),
|
||||
"selectionBackground", theme.editorPalette().selectionBackground(),
|
||||
"activeHighlightBackground", theme.editorPalette().activeHighlightBackground(),
|
||||
"lineNumberForeground", theme.editorPalette().lineNumberForeground(),
|
||||
"statusChipBackground", theme.editorPalette().statusChipBackground(),
|
||||
"statusChipBorder", theme.editorPalette().statusChipBorder(),
|
||||
"statusChipForeground", theme.editorPalette().statusChipForeground()));
|
||||
payload.put("tokenStyles", theme.tokenStyles().stream().map(tokenStyle -> Map.of(
|
||||
"semanticKey", tokenStyle.semanticKey(),
|
||||
"foreground", tokenStyle.foreground(),
|
||||
"italic", tokenStyle.italic(),
|
||||
"bold", tokenStyle.bold(),
|
||||
"underline", tokenStyle.underline())).toList());
|
||||
return payload;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user