feat(language-server): clear diagnostic for nested parallel blocks#2985
Conversation
Nested `parallel { parallel { ... } }` in dynamic views previously`produced a cryptic parser error because the grammar rejected the form`outright. The grammar now accepts `DynamicViewParallelSteps` as a step`inside another `DynamicViewParallelSteps`, and a new validator emits`a clear `Nested parallel blocks are not allowed` error on the inner`block.
`ViewsParser` filters nested ParallelSteps when building the c4 model`(the validator already errors on them) to keep the parser side narrow.
Resolves likec4#988
🦋 Changeset detectedLatest commit: e98fbe1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 22 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThis PR improves error reporting for nested ChangesNested Parallel Block Detection
🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add 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 |
davydkov
left a comment
There was a problem hiding this comment.
Great improvement, thank you!
Checklist
mainbefore creating this PR.pnpm typecheckandpnpm test.Summary
Resolves #988 (originally from @susliko in discussion #816).
Today
parallel { parallel { ... } }in a dynamic view produces a cryptic parser error likeExpecting token of type --> RightCurly <-- but found --> 'parallel' <--. The grammar simply forbids the nested form structurally, so users get the raw parser error.This PR:
DynamicViewParallelStepscan appear as a step inside anotherDynamicViewParallelSteps. The parser accepts the form now, instead of rejecting it.dynamicViewParallelStepsvalidator that walksstepsand emits a clear error —Nested parallel blocks are not allowed— on any nestedDynamicViewParallelSteps. The diagnostic is attached to the inner block so the squiggle lines up with the offendingparallel/parkeyword.Net behaviour: same outcome (the model is rejected), much better message.
Files
like-c4.langium:(steps+=(DynamicViewParallelSteps | DynamicViewStep))*.validation/dynamic-view.ts: newdynamicViewParallelStepscheck.validation/index.ts: wired under theDynamicViewParallelStepskey.model/parser/ViewsParser.ts:parseDynamicParallelStepsnow filters out nestedParallelStepsbefore callingparseDynamicStep(the validator has already errored on them; this keeps the c4-model side narrow and avoids a confusing internal type error).Test plan
New tests in
dynamic-view.spec.ts:parallel { parallel { ... } }— reportsNested parallel blocks are not allowed.par { par { ... } }(theparalias) — same diagnostic.Local:
pnpm test packages/language-server/src/validation/dynamic-view.spec.ts→ 12/12 passing,pnpm --filter @likec4/language-server typecheck→ clean,pnpm lint:errors-only→ 0 errors.Generated parser artifacts (
packages/language-server/src/generated/) are git-ignored, so CI'spnpm generatestep will produce the updated parser from the new grammar.