Skip to content

fix(language-server): allow element names with underscore+digit prefix#2845

Merged
davydkov merged 1 commit into
mainfrom
fix/underscore-digit-identifier
Apr 7, 2026
Merged

fix(language-server): allow element names with underscore+digit prefix#2845
davydkov merged 1 commit into
mainfrom
fix/underscore-digit-identifier

Conversation

@davydkov

@davydkov davydkov commented Apr 7, 2026

Copy link
Copy Markdown
Member

Summary

  • Fix IdTerminal regex to accept identifiers starting with underscore(s) followed by a digit (e.g. _1password, __1service, _123)
  • The previous regex /[_]*[a-zA-Z][-\w]*/ required a letter immediately after underscores, which was more restrictive than documented
  • New regex /([a-zA-Z]|_+[a-zA-Z0-9])[-\w]*/ correctly allows both _<letter> and _<digit> starts

Fixes #2836

Test plan

  • Added valid test case for _1password, __1service, _123 element names
  • Verified existing invalid cases still fail (names starting with digit, only underscores)
  • All 316 language-server unit tests pass

🤖 Generated with Claude Code

…llowed by digit

Update IdTerminal regex to accept identifiers like `_1password`, `__1service`,
`_123` which were incorrectly rejected despite matching the documented naming rules.

Fixes #2836

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Apr 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d4a51b1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 20 packages
Name Type
@likec4/language-server Patch
@likec4/playground Patch
@likec4/language-services Patch
likec4 Patch
@likec4/mcp Patch
@likec4/vite-plugin Patch
likec4-vscode Patch
@likec4/docs-astro Patch
@likec4/style-preset Patch
@likec4/styles Patch
@likec4/config Patch
@likec4/core Patch
@likec4/diagram Patch
@likec4/generators Patch
@likec4/layouts Patch
@likec4/leanix-bridge Patch
@likec4/log Patch
@likec4/react Patch
@likec4/tsconfig Patch
@likec4/vscode-preview Patch

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

@davydkov davydkov merged commit 06ca18f into main Apr 7, 2026
15 of 16 checks passed
@davydkov davydkov deleted the fix/underscore-digit-identifier branch April 7, 2026 10:12
@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Fixed a parser inconsistency where element identifiers starting with an underscore followed by a digit (e.g., _1password) were incorrectly rejected. Updated the IdTerminal grammar rule to accept this pattern while maintaining validation constraints, added test coverage, and documented the fix.

Changes

Cohort / File(s) Summary
Grammar Rule Update
packages/language-server/src/like-c4.langium
Modified IdTerminal token from /[_]*[a-zA-Z][-\w]*/ to `/([a-zA-Z]
Test Coverage
packages/language-server/src/__tests__/model.spec.ts
Added validation test case for underscore-digit identifiers, covering patterns like _1password, __1service, and _123.
Changelog Entry
.changeset/fix-underscore-digit-identifier.md
Added Changesets documentation for the parser fix at patch level for @likec4/language-server.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: fixing the language server to allow element names with underscore+digit prefixes, which is the core objective of this PR.
Description check ✅ Passed The description is comprehensive, explaining the bug fix with before/after regex patterns, including test coverage details and verification that all tests pass.
Linked Issues check ✅ Passed The PR successfully addresses issue #2836 by modifying the IdTerminal regex to accept identifiers starting with underscores followed by digits, fixing the documented inconsistency in naming rules.
Out of Scope Changes check ✅ Passed All changes are within scope: grammar fix, test case addition, and changeset entry directly address the stated objective of fixing the underscore-digit identifier parsing issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📋 Issue Planner

Built with CodeRabbit's Coding Plans for faster development and fewer bugs.

View plan used: #2836

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/underscore-digit-identifier

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistency in element naming rule for digits

1 participant