Repository navigation
fix(editor): map .jsp/.jspf to the html language id - #12402
Conversation
|
Warning Review limit reached
Next review available in: 2 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe language detector maps 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thanks for this — and for reading the rendered token classes instead of reasoning from the diff. Scoping a stopgap by where the boundary actually falls is the right way to do it. I pushed one small commit to your branch:
Two things worth folding into the description, both verified in a running build rather than reasoned about:
I looked at whether a different existing id would dodge those and concluded no: The preview button is the one I'd track separately — the gate keys off the language id alone, which is a pre-existing coupling in that subsystem rather than anything you introduced. |
* fix(editor): map .jsp/.jspf to the html language id * docs(editor): mark the jsp html mapping as a markup-only stopgap --------- Co-authored-by: Brennan Benson <[email protected]>
Summary
.jspand.jspffiles open as plaintext.EXT_TO_LANGUAGEinlanguage-detect.tshas no entry for either, sodetectLanguage()falls through to'plaintext'and the file renders with no color at all — including the plain HTML that makes up most of a typical JSP page.JSP is HTML markup with
<% %>scriptlets and${}expressions embedded in it, so Monaco's built-inhtmlid already colors the majority of such a file correctly. This is two lookup entries: no new language registration, no grammar, no worker routing.This is a stopgap, not the finished feature. #10858 by @hwantage adds a dedicated JSP grammar that tokenizes scriptlets and EL properly, which an
htmlmapping cannot do. I checked where the boundary actually falls by reading the rendered token classes in a running build rather than guessing:<c:forEach>/<c:if>mtk14for the tag, attribute values tokenized)<style>blockscolor:→mtk4, value →mtk5)<script>blocksconst→mtk6)<% %>mtk1span${...}ELmtk1; the braces only pick up bracket-pair colorization)That boundary is structural, not something to tune later: Monaco's html tokenizer has no
<%rule at all, so<becomes a delimiter and the remainder falls into the[^<]+text rule. When #10858 lands, these two entries should become'jsp'and this change disappears into it. I am opening this only because the full grammar has been open since July 27 and the no-color case is fixable in two lines today.Related: #9795 (feature request), #10858 (dedicated grammar), #11309 (my own grammar attempt, closed in favor of #10858).
Screenshots
Same
demo.jspin both images.Before —
.jspis not in the extension table, so the file falls back toplaintext(image reused from #11309, which showed the identical unmapped state):After — markup, embedded CSS and embedded JS are colored; scriptlet bodies and EL deliberately are not, per the table above:
Testing
pnpm lintpnpm typecheckpnpm testpnpm buildtypecheckpasses on all three projects (node, cli, web). The new test covers.jsp,.jspf, and an uppercase.JSPWindows path;vitest run src/renderer/src/lib/language-detect.test.tsis 14/14.oxlintis clean on both changed files. The unchecked boxes are explained under Notes.AI Review Report
Reviewed with an AI agent across three angles — correctness of the mapping, cross-platform behavior, and whether the change claims more than it delivers.
What it flagged and what changed as a result:
mtk1span, confirming Java and EL get no tokenization..html/.htmso the related entries stay adjacent, matching how.cts/.mtssit beside.ts.Cross-platform compatibility for macOS, Linux and Windows was explicitly checked. Nothing here branches on platform: the change is two lookup entries, and the existing
extname()helper already handles both/and\separators whiledetectLanguage()lowercases before lookup — the added test asserts an uppercase.JSPWindows path resolves correctly. No keyboard shortcuts, labels, shell behavior, path utilities, Electron platform differences, SSH/remote paths or git-provider behavior are touched.Security Audit
No meaningful risk surface. The change adds two string keys to a lookup table that maps a file extension to a Monaco language id. There is no input handling, command execution, path resolution beyond the existing extension parse, IPC, auth, secret material, or dependency change. The
htmllanguage and its worker are already bundled and routed for.html/.htm, so this introduces no new runtime capability — it only reuses one that already ships.Notes
pnpm lint:oxlintand the code-quality audits pass. The chain stops later atverify:skill-bundle-manifest, which reports stale generated artifacts underresources/skills/— a pre-existing state unrelated to this change, and those files are not in this diff.pnpm test: the full suite on a Windows machine fails a set of pre-existing tests that require a POSIX shell (spawn /bin/sh ENOENT); the count is unchanged by this PR. The test file touched here passes.pnpm buildis unchecked because verification here was done against a runningpnpm devbuild of this branch, which is what the screenshot and the token-class readings come from.mobile/src/session/mobile-file-language.tskeeps a separate extension table for the mobile surface and is intentionally not touched — it feeds a different highlighter, and feat(editor): add JSP syntax highlighting backed by the HTML language service #11309 left it alone for the same reason.