Repository navigation
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. ℹ️ Recent review info
Walkthrough
Priority: 🚥 Pre-merge checks | ✅ 4 | ❌ 1
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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/lib/monaco-languages/register-jsp.ts (1)
81-97: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd bracket/delimiter tokenization for Java scriptlet and EL punctuation.
jspScriptletOpenhas no rule for{}()[]or;/,, andelExpressionhas no rule for()[],,,?,:— common in scriptlet Java code and EL function calls/array access/ternaries (e.g.${fn:length(list)},${list[0]},<% if (x) { ... } %>). These characters currently fall through todefaultTokenone char at a time (no crash, but no bracket-matching or delimiter styling either).♻️ Proposed additions
jspScriptletOpen: [ [/%>/, 'keyword', '`@pop`'], [/\/\/.*/, 'comment'], [/\/\*/, 'comment', '`@javaComment`'], [/"([^"\\]|\\.)*"/, 'string'], [/'([^'\\]|\\.)*'/, 'string'], [/\b(true|false|null)\b/, 'constant.language'], [ /\b(if|else|for|while|do|switch|case|default|break|continue|return|try|catch|finally|throw|new|import|package)\b/, 'keyword' ], [/\b(int|long|short|byte|float|double|boolean|char|void|String|Object)\b/, 'type'], + [/[{}()[\]]/, '`@brackets`'], + [/[;,.]/, 'delimiter'], [/<=|>=|==|!=|&&|\|\||<<|>>|>>>|[-+*/%&|^<>=!]/, 'operator'], [/[a-zA-Z_][a-zA-Z0-9_]*/, 'identifier'], [/[0-9]+/, 'number'], [/\s+/, 'white'] ], ... elExpression: [ [/\}/, 'delimiter.curly', '`@pop`'], [/\b(and|or|not|eq|ne|gt|lt|ge|le|empty|instanceof)\b/, 'keyword.operator'], [/<=|>=|==|!=|&&|\|\||[-+*/%<>=!]/, 'keyword.operator'], [/\b(true|false|null)\b/, 'constant.language'], [/"([^"\\]|\\.)*"/, 'string'], [/'([^'\\]|\\.)*'/, 'string'], + [/[()[\]]/, '`@brackets`'], + [/[,?:]/, 'delimiter'], [/[a-zA-Z_][a-zA-Z0-9_.]*/, 'variable'], [/[0-9]+/, 'number'], [/\s+/, 'white'] ],
@bracketsresolves against the already-declaredbracketsarray (lines 9-13), so no further config changes are needed.Also applies to: 103-113
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e3f9e211-33f0-4f7f-bb2a-2ec4bd064a50
📥 Commits
Reviewing files that changed from the base of the PR and between 58ef46d and c9fc5fd637f8c0cd9f8507583e234e809399edef.
📒 Files selected for processing (6)
config/localization-coverage-allowlist.jsonsrc/renderer/src/lib/language-detect.test.tssrc/renderer/src/lib/language-detect.tssrc/renderer/src/lib/monaco-languages/register-jsp.test.tssrc/renderer/src/lib/monaco-languages/register-jsp.tssrc/renderer/src/lib/monaco-setup.ts
|
Hi @hwantage — I work in a large JSP codebase daily, so this PR was exactly the feature I needed and I read through it closely to see if I could use it right away. Three things came up while digging in, in case any are useful: 1. The HTML language service can be attached to a custom language id. 2. 3. I've opened #11309 with an implementation that wires the language service. Please feel free to lift any of it into this PR — if the maintainers prefer your shape I'll close mine. |
|
@taehwanis Thanks for the detailed review and code proposal! I've merged your HTML language service integration and tokenizer fixes into this PR (#10858) with Co-authored-by credit. |
Greptile SummaryThis PR adds full JSP (
Confidence Score: 5/5Safe to merge — the change is self-contained renderer-side tokenization with no side-effects on existing languages. The tokenizer is carefully designed: scriptlet terminator guards are in place for operators, line comments, block comments, and string literals; the HTML language service registration is idempotent; embedded JavaScript and CSS pops use both next and nextEmbedded as Monarch requires; and 17 test cases covering edge cases all pass. No existing language registrations are touched. Files Needing Attention: No files require special attention.
|
| Filename | Overview |
|---|---|
| src/renderer/src/lib/monaco-languages/register-jsp.ts | Core JSP tokenizer: introduces a Monarch language definition with 14 tokenizer states, careful (?!%>) lookahead guards, @popall for block-comment scriptlet terminator, case-sensitive Java keyword matching, and an HTML language service registration behind an idempotency guard. |
| src/renderer/src/lib/monaco-languages/register-jsp.test.ts | 350-line Vitest suite with 17 test cases covering state transitions, delimiter lengths, operator lookaheads, embedded-language pops, bracket exclusions, and tokenizer state-reference integrity. |
| src/renderer/src/lib/language-detect.ts | Adds .jsp and .jspf extension mappings to the EXT_TO_LANGUAGE lookup table, inserted in alphabetical order. |
| src/renderer/src/lib/language-detect.test.ts | Adds one test case confirming both .jsp and .jspf paths resolve to the jsp language id. |
| src/renderer/src/lib/monaco-setup.ts | Routes jsp to htmlWorker in the worker factory switch and calls registerJspLanguage(monaco) at boot, matching the pattern used by Svelte, Astro, Nim, and JSONL. |
Reviews (3): Last reviewed commit: "• fix(renderer): improve JSP scriptlet t..." | Re-trigger Greptile
|
@hwantage First, thanks for folding my suggestions into this PR and for the co-author credit — and your August 1 fixes look right to me. The scriptlet terminator inside block comments and string literals was the subtle one, and you got it. I wanted to tell you about something before doing it rather than after. While my #11294 and #11322 were going through, I noticed a pattern in how this repo merges outside contributions: small So I closed my #11309 — it duplicated yours anyway — and opened a two-line fallback instead: #12402 maps To be exact about what that does and does not do, I read the rendered token classes in a running build rather than reasoning from the diff:
Monaco's html tokenizer has no One thing I want to flag honestly: there is a chance a maintainer sees the fallback merge and treats #9795 as addressed, then closes this as superseded. A batch of PRs was closed that way on August 3. I would rather that not happen, which is why #12402 is written to point at this PR instead of competing with it. If you would rather I hold it until yours lands, say so and I will close it — no hard feelings at all. And if you would rather own that two-line change under your own name, I will close mine right away and you can open it. It is the easiest merge on the board and I am happy for it to be yours. |
|
Thank you so much for taking the time to share your thoughts and for keeping an eye on this! I’ve also been closely following the daily updates in Orca and saw your two recent PRs get merged. Since Orca Still, even if it takes some time, I really hope this PR doesn't get closed and eventually gets merged. As a developer who works with JSP and Java code on a daily basis, I’m looking forward to seeing full support land in a release as soon as possible. I completely welcome and support your fallback PR (#12402)—it will serve as a great interim workaround until this full grammar PR gets officially merged. |
…tablyai#10858) - Attach Monaco HTML language service to JSP files for hover, completion, and document symbols - Refine tokenization for scriptlets, comments, and EL expressions - Disable rename and formatting for JSP HTML service to prevent buffer corruption - Add comprehensive tests for JSP language registration and edge cases Co-authored-by: taehwanis <[email protected]>
- terminate scriptlets at %> inside comments and literals - recognize common Java collection and numeric types in JSP
- Remove superseded stopgap mapping of .jsp/.jspf to html now that dedicated jsp language is supported - Update language-detect test to assert .jsp/.jspf map to dedicated jsp language - Replace type assertions in register-jsp.test.ts with checked types and SAFETY rationale
7fb4f6c to
21ee0e3
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 Minor · Handle JSP delimiters before delegating to JavaScript or CSS. · register-jsp.ts:127-157
src/renderer/src/lib/monaco-languages/register-jsp.ts:127-157
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winHandle JSP delimiters before delegating to JavaScript or CSS. When
scriptOpenorstyleOpencloses, it switches to@scriptBodyor@styleBodyand activatesjavascriptorcss. Monarch keeps that embedded tokenizer active until anextEmbedded: '@pop'rule matches. Because these body states only match closing tags,${...},#{...}, and<%...%>can bypasselExpressionandjspScriptletand receive JavaScript/CSS scopes. Add JSP suspend-and-reenter transitions with regression tests, or document and test this limitation if JSP constructs are unsupported in script/style bodies. Repository embedded-language grammars already use this suspend-and-reenter pattern for template expressions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 51ac20cb-2ce3-4c71-9317-693cdd567b93
📥 Commits
Reviewing files that changed from the base of the PR and between 7fb4f6c7d38f9180158fe7f64e3e02d560825baa and 21ee0e3.
📒 Files selected for processing (4)
src/renderer/src/lib/language-detect.test.tssrc/renderer/src/lib/language-detect.tssrc/renderer/src/lib/monaco-languages/register-jsp.test.tssrc/renderer/src/lib/monaco-setup.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Monarch hands a <script> or <style> body to the JavaScript or CSS
tokenizer until the closing tag, so `${...}`, `#{...}` and `<% ... %>`
inside those blocks were coloured as JavaScript or CSS.
Add rules to scriptBody and styleBody that pop the embed on an EL or
scriptlet opener, tokenize the island with the existing elExpression and
jspScriptlet rules, and resume the embed on the closer. The two island
states are shared: the state name carries the body to return to and the
language to resume.
Known limits: the embedded tokenizer restarts on resume, so an island
inside a JavaScript string or comment leaves the rest of that literal
mis-coloured, and `<%-- --%>` inside a body is treated as a scriptlet.
|
@coderabbitai Regression tests run the real Known limits, left as-is: the embedded tokenizer restarts from its initial state on resume, so an island inside a JavaScript string or comment leaves the rest of that literal mis-coloured. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
ast-grep outline src/renderer/src/lib/monaco-languages/register-jsp.ts --items all
ast-grep outline src/renderer/src/lib/monaco-languages/register-jsp.test.ts --items all
printf '\n--- tokenizer transitions ---\n'
rg -n -A45 -B12 'scriptBody|styleBody|embedEl|embedScriptlet|nextEmbedded|jspScriptlet|elExpression' \
src/renderer/src/lib/monaco-languages/register-jsp.ts
printf '\n--- regression tests ---\n'
rg -n -A60 -B12 'MonarchTokenizer|script body|style body|per-token|embedded.*(JavaScript|CSS)|resum' \
src/renderer/src/lib/monaco-languages/register-jsp.test.tsLength of output: 12367
The regression tests use the real The known limitations are clear and acceptable for this change. An island inside an embedded string or comment cannot preserve the prior embedded tokenizer state. Treating ✏️ Learnings added
If you found this review helpful, would you consider giving us a shout-out on X? Thank you for using CodeRabbit! You are interacting with an AI system. |
|
Thank you @hwantage for this! We've shipped JSP as the official JSP Syntax plugin instead of building it into Orca, so it can be updated on its own. Your work is credited: you're a co-author of the plugin commit. To install: Settings → Plugins → turn on plugins → search for it and install. It needs Orca 1.4.246 or newer (older versions show "Needs Orca 1.4.246"), because that's the first release where an enabled plugin syntax takes precedence over Orca's own mapping for these files. Closing this PR as superseded. If it falls short for you, please reopen and tell us what is missing. |
Highlights .jsp, .jspf and .tag files with the vscode-jsp grammar (MIT) and bundles the HTML, Java, CSS and JavaScript grammars it embeds (VS Code, MIT; TextMate HTML bundle notice included). Orca reads no grammar injections, so JSP's injected rules are inlined. Needs Orca 1.4.246, the first release where an enabled plugin syntax beats Orca's HTML stopgap for .jsp/.jspf. Replaces stablyai/orca#10858 and stablyai/orca#11309 for stablyai/orca#9795. Co-authored-by: hwantage <[email protected]> Co-authored-by: taehwanis <[email protected]>
Summary
.jsp,.jspf) files in MonacoEditor (addresses #9795).
registerHTMLLanguageService) for JSP files to enable HTML tag completions, hovers, document symbols, and folding, while disabling buffer-modifying features (rename,formatting) to prevent scriptlet corruption.<and>inside scriptlets or EL expressions wereincorrectly paired as bracket match pairs.
ignoreCase: falseto avoid colouring variables as types inList list), adds(?!%>)lookahead guards to comments/operators to prevent swallowing the%>closing tag, andswitches operator tokens to
keyword.operatorfor proper theme compatibility.<c:if>,<c:forEach>, etc.) and supportsembedded
${...}and#{...}EL expressions within tag attributes.nextEmbedded: 'javascript'andnextEmbedded: 'css'stack handling for<script>and<style>blocks to ensure correct keyword colors (function,var, etc.) and bracket matching.refinements. (feat(editor): support syntax highlighting for JSP (.jsp) files (#9795) #10858)
Details & Verification
What Changed
.jspand.jspffile extensions to thejsplanguage ID inlanguage-detect.tsandmonaco-setup.ts(routing tohtmlWorker).registerHTMLLanguageService('jsp', undefined, jspHtmlModeConfiguration)to provide HTML hovers, completions, and folding while keeping buffer-editing features (rename,formatting) disabled.<and>frombrackets,autoClosingPairs, andsurroundingPairsinregister-jsp.tsto prevent false bracket pair highlighting on comparison operators.- Switched to case-sensitive matching for Java tokens to prevent
List listfrom colouringlistas a type.- Added
(?!%>)lookahead guards to line comments, block comments, and%operators so scriptlet closing tags (%>) are never swallowed.- Used
keyword.operatorfor theme-compatible operator highlighting.<c:*>and custom prefix tags with@tagRest/@tagCustomstate transitions, with support for embedded EL (${...},#{...}) and scriptlet expressions in attributes.@pophandling on closing tags.register-jsp.test.tschecking Monarch rule matches for operators, JSTL tags, EL expressions, comments, edge cases, and language service registration.Screenshots / Evidence
Testing
npx vitest run src/renderer/src/lib/monaco-languages/register-jsp.test.ts src/renderer/src/lib/language-detect.test.ts(Files 2 passed (2), Tests 19 passed (19))pnpm run tc:web(0 errors)npx oxlinton changed files (0 warnings, 0 errors)pnpm dev): Tested and verified syntax highlighting, JSTL tags, and bracket matching against real-world legacy JSP files.AI Review Report
Closes #9795