Frontend Visual Theme Spec and Retirement of Host-Consumed Semantic CSS
This commit is contained in:
+29
@@ -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;
|
||||
}
|
||||
}
|
||||
+14
@@ -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;
|
||||
}
|
||||
}
|
||||
+2
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user