Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: greedy regex in common langium #6407

Conversation

thomascizeron
Copy link
Contributor

@thomascizeron thomascizeron commented Mar 23, 2025

📑 Summary

Refactor common langium grammar by adding common terminals and separate greedy terminal in separate files to fix terminal order

Resolves #6162

📏 Design Decisions

  • Refactor Common grammar to add common terminal in the right order (lazy to greedy)
  • Adapt existing grammar accordingly
    • Remove copy pasting and use import
  • Add tests to ensure title keyword do not breaks Architecture Diagrams again
    • Also add some parser test cases of some diagrams that needed the same fix.

📋 Tasks

Make sure you

  • 📖 have read the contribution guidelines
  • 💻 have added necessary unit/e2e tests.
  • 📓 have added documentation. Make sure MERMAID_RELEASE_VERSION is used for all new features.
  • 🦋 If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Note

For me common terminal definition should be defined in common langium, it ensures maintainability and homogeneity across the different diagrams. Architecture node labels should use STRING terminal as the other grammars use it to allow for special characters in title and be persistent with other grammar. Would fix #5928 that way, can do it in a separate PR if it's okay.

Title is not currently supported by Architecture renderer. It's probably why it was not tested. Added a TODO in the renderer as I didn't understand node position precisely and could not make it work.

Copy link

changeset-bot bot commented Mar 23, 2025

🦋 Changeset detected

Latest commit: f55ff99

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

This PR includes changesets to release 2 packages
Name Type
mermaid Patch
@mermaid-js/parser 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

@github-actions github-actions bot added the Type: Bug / Error Something isn't working or is incorrect label Mar 23, 2025
Copy link

pkg-pr-new bot commented Mar 23, 2025

Open in StackBlitz

npm i https://pkg.pr.new/mermaid-js/mermaid@6407
npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/mermaid-zenuml@6407
npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/layout-elk@6407
npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/parser@6407

commit: f55ff99

Copy link

netlify bot commented Mar 23, 2025

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit f55ff99
🔍 Latest deploy log https://app.netlify.com/sites/mermaid-js/deploys/67f507a3f990b000082cf60c
😎 Deploy Preview https://deploy-preview-6407--mermaid-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Mar 23, 2025

Codecov Report

Attention: Patch coverage is 4.76190% with 20 lines in your changes missing coverage. Please review.

Project coverage is 3.86%. Comparing base (3073526) to head (f55ff99).
Report is 8 commits behind head on develop.

Files with missing lines Patch % Lines
...ermaid/src/diagrams/architecture/architectureDb.ts 0.00% 11 Missing ⚠️
packages/parser/tests/test-util.ts 0.00% 9 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           develop   #6407      +/-   ##
==========================================
- Coverage     3.86%   3.86%   -0.01%     
==========================================
  Files          412     411       -1     
  Lines        43189   43192       +3     
  Branches       664     664              
==========================================
  Hits          1670    1670              
- Misses       41519   41522       +3     
Flag Coverage Δ
unit 3.86% <4.76%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
.../src/diagrams/architecture/architectureRenderer.ts 0.00% <ø> (ø)
...aid/src/diagrams/architecture/architectureTypes.ts 0.84% <100.00%> (ø)
packages/parser/src/language/index.ts 0.00% <ø> (ø)
packages/parser/tests/test-util.ts 1.56% <0.00%> (-0.26%) ⬇️
...ermaid/src/diagrams/architecture/architectureDb.ts 0.38% <0.00%> (-0.01%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@thomascizeron thomascizeron force-pushed the fix/6162_greedyRegexInCommonLangium branch from 720da17 to cdbd3e5 Compare April 2, 2025 16:50
Copy link

argos-ci bot commented Apr 2, 2025

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Apr 8, 2025, 11:34 AM

Copy link
Member

@sidharthv96 sidharthv96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!
The langium grammar is more readable now ❤️

@sidharthv96 sidharthv96 enabled auto-merge April 8, 2025 11:29
@sidharthv96 sidharthv96 added this pull request to the merge queue Apr 8, 2025
Merged via the queue into mermaid-js:develop with commit 01e2af0 Apr 8, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
2 participants