Frontend Visual Theme Spec and Retirement of Host-Consumed Semantic CSS

This commit is contained in:
2026-05-06 15:50:35 +01:00
parent 10fd7f6111
commit e23367b022
8 changed files with 247 additions and 147 deletions
@@ -0,0 +1,29 @@
package p.studio.compiler.models;
import java.util.Objects;
public record FrontendSemanticToken(
int startOffset,
int endOffset,
String semanticKey) {
public FrontendSemanticToken {
if (startOffset < 0) {
throw new IllegalArgumentException("startOffset must be >= 0");
}
if (endOffset < startOffset) {
throw new IllegalArgumentException("endOffset must be >= startOffset");
}
semanticKey = requireText(semanticKey, "semanticKey");
}
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,14 @@
package p.studio.compiler.models;
import java.util.List;
@FunctionalInterface
public interface FrontendSemanticTokenProvider {
FrontendSemanticTokenProvider NOOP = documentText -> List.of();
List<FrontendSemanticToken> tokenize(String documentText);
static FrontendSemanticTokenProvider noop() {
return NOOP;
}
}
@@ -17,6 +17,8 @@ public class FrontendSpec {
private final List<Stdlib> stdlibVersions = List.of();
@Builder.Default
private final FrontendSemanticPresentationSpec semanticPresentation = FrontendSemanticPresentationSpec.empty();
@Builder.Default
private final FrontendSemanticTokenProvider semanticTokenProvider = FrontendSemanticTokenProvider.noop();
public String toString() {
return String.format("FrontendSpec(language=%s)", languageId);