diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index d361f4e..d02c0b7 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -158,6 +158,36 @@ jobs:
if-no-files-found: error
retention-days: 7
+ jsp-grammar-host:
+ # Runs on drafts too: it needs neither the Rust Core nor a package, only the
+ # host's pure-Go editor packages.
+ name: JSP grammar on the host tokenizer
+ runs-on: ubuntu-latest
+ timeout-minutes: 15
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ persist-credentials: false
+ - name: Read pinned host revision
+ id: host
+ run: echo "revision=$(node -p 'JSON.parse(require("fs").readFileSync("grammar-host.json")).revision')" >> "$GITHUB_OUTPUT"
+ - uses: actions/checkout@v4
+ with:
+ repository: 1lck/Lithe-IDEA
+ ref: ${{ steps.host.outputs.revision }}
+ path: .artifacts/grammar-host
+ sparse-checkout: desktop
+ persist-credentials: false
+ - uses: actions/setup-go@v5
+ with:
+ go-version-file: .artifacts/grammar-host/desktop/go.mod
+ cache: false
+ - uses: actions/setup-node@v4
+ with:
+ node-version: 22
+ - name: Tokenize JSP with the host's TextMate engine
+ run: node scripts/grammar/host-jsp.mjs .artifacts/grammar-host
+
native-settings-visual:
name: Native compiler settings screenshots
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
diff --git a/README.md b/README.md
index 331ec9f..81fcab0 100644
--- a/README.md
+++ b/README.md
@@ -343,3 +343,15 @@ node scripts/package/build-windows.mjs /path/to/lithe-java-backend.exe
## Linux ARM64 / x64
Linux 构建、资源归属与原生验证入口见 [Linux 构建与验证](docs/linux-packaging.md)。
+
+## JSP / EL 语法着色
+
+Java Support 把 `.jsp`、`.jspf`、`.tag`、`.tagf` 声明为 JSP 文档,并随插件包提供 TextMate 语法 `grammars/jsp.tmLanguage.json`。语法建立在宿主自带的 HTML 语法(`text.html.basic`)之上,HTML 以及其中 ``,
+ ``,
+ `<%-- ${hidden} <% ignored %> --%>`,
+ `
\${literal} #{bean.value}
`,
+ `<% if (ok) { %>`,
+ `yes`,
+ `<% } %>`,
+ `<% /* left open %>`,
+ `after`,
+ ``,
+ }
+ cases := []scopeCase{
+ {line: source[0], text: "page", want: []string{"meta.directive.jsp", "keyword.control.directive.jsp"}},
+ {line: source[0], text: "contentType", want: []string{"entity.other.attribute-name.jsp"}},
+ {line: source[1], text: "int", want: []string{"source.java.embedded.jsp", "storage.type.primitive.java"}},
+ {line: source[1], text: "// counted", want: []string{"comment.line.double-slash.java"}},
+ {line: source[1], text: "%>", want: []string{"punctuation.section.embedded.end.jsp"}, not: []string{"comment"}},
+ {line: source[1], text: "p>", want: []string{"entity.name.tag"}, not: []string{"source.java"}},
+ {line: source[1], text: "name", want: []string{"meta.expression.el.jsp", "variable.other.el.jsp"}},
+ {line: source[2], text: "url", want: []string{"string.quoted", "meta.embedded.block.jsp"}},
+ {line: source[2], text: "title}", want: []string{"string.quoted", "meta.expression.el.jsp"}},
+ {line: source[3], text: "c", want: []string{"entity.name.tag.namespace.jsp"}, not: []string{"invalid"}},
+ {line: source[3], text: "forEach", want: []string{"entity.name.tag.jsp"}, not: []string{"invalid"}},
+ {line: source[3], text: "items}", want: []string{"meta.expression.el.jsp"}},
+ {line: source[4], text: "var", want: []string{"source.js"}},
+ {line: source[4], text: "js}", want: []string{"source.js", "meta.expression.el.jsp"}},
+ {line: source[5], text: "color", want: []string{"source.css", "support.type.property-name"}},
+ {line: source[6], text: "hidden", want: []string{"comment.block.jsp"}, not: []string{"meta.expression.el.jsp"}},
+ {line: source[6], text: "ignored", want: []string{"comment.block.jsp"}, not: []string{"meta.embedded"}},
+ {line: source[7], text: "literal", not: []string{"meta.expression.el.jsp"}},
+ {line: source[7], text: "bean", want: []string{"meta.expression.el.jsp"}},
+ {line: source[9], text: "b>", want: []string{"entity.name.tag"}, not: []string{"source.java"}},
+ {line: source[10], text: "}", want: []string{"source.java.embedded.jsp"}},
+ {line: source[12], text: "i>", want: []string{"entity.name.tag"}, not: []string{"comment", "source.java"}},
+ {line: source[13], text: "jsp", want: []string{"entity.name.tag.namespace.jsp"}, not: []string{"invalid"}},
+ {line: source[13], text: "include", want: []string{"entity.name.tag.jsp"}},
+ }
+ tokens := tokenizeLines(t, s.grammar, source)
+ for _, c := range cases {
+ index := -1
+ for i, line := range source {
+ if line == c.line {
+ index = i
+ break
+ }
+ }
+ offset := strings.Index(c.line, c.text)
+ if index < 0 || offset < 0 {
+ t.Fatalf("case %q not found in %q", c.text, c.line)
+ }
+ scopes := scopesAt(tokens[index], offset)
+ for _, want := range c.want {
+ if !strings.Contains(scopes, want) {
+ t.Errorf("%q in %q: scopes %q lack %q", c.text, c.line, scopes, want)
+ }
+ }
+ for _, not := range c.not {
+ if strings.Contains(scopes, not) {
+ t.Errorf("%q in %q: scopes %q must not contain %q", c.text, c.line, scopes, not)
+ }
+ }
+ }
+ for i, line := range tokens {
+ for _, token := range line {
+ if scopes := token.Scopes.String(); strings.Contains(scopes, "invalid") {
+ t.Errorf("line %q: a token is marked invalid: %s", source[i], scopes)
+ }
+ }
+ }
+}
+
+func tokenizeLines(t *testing.T, grammar *textmate.Grammar, lines []string) [][]textmate.Token {
+ t.Helper()
+ tokenizer := grammar.NewTokenizer()
+ var state *textmate.StateStack
+ out := make([][]textmate.Token, len(lines))
+ for i, line := range lines {
+ var tokens []textmate.Token
+ var stopped bool
+ tokens, state, stopped = tokenizer.TokenizeLine(nil, []byte(line), state, 0)
+ if stopped {
+ t.Fatalf("tokenizing %q stopped", line)
+ }
+ out[i] = append([]textmate.Token(nil), tokens...)
+ }
+ return out
+}
+
+// scopesAt returns the scopes of the token that the ASCII offset starts in.
+func scopesAt(tokens []textmate.Token, offset int) string {
+ scopes := ""
+ for _, token := range tokens {
+ if token.Start > offset {
+ break
+ }
+ scopes = token.Scopes.String()
+ }
+ return scopes
+}
diff --git a/grammar-host.json b/grammar-host.json
new file mode 100644
index 0000000..35682be
--- /dev/null
+++ b/grammar-host.json
@@ -0,0 +1,5 @@
+{
+ "repository": "https://github.com/1lck/Lithe-IDEA",
+ "revision": "08ccf3ab6ae0f30b41200ec93c1d0aeefdcb7a5c",
+ "note": "Host whose TextMate tokenizer and bundled HTML, CSS, JavaScript and Java grammars check grammars/jsp.tmLanguage.json (scripts/grammar/host-jsp.mjs). Grammar injections need desktop 0.8.4 or later; on older hosts the root-level JSP rules still apply."
+}
diff --git a/io.github.lithe-idea.java-support/grammars/jsp.tmLanguage.json b/io.github.lithe-idea.java-support/grammars/jsp.tmLanguage.json
new file mode 100644
index 0000000..5057bec
--- /dev/null
+++ b/io.github.lithe-idea.java-support/grammars/jsp.tmLanguage.json
@@ -0,0 +1,367 @@
+{
+ "name": "JavaServer Pages",
+ "scopeName": "text.html.jsp",
+ "comment": "JSP on top of the host's HTML grammar. The JSP constructs are injected wherever HTML puts the text (element content, attribute values,