Skip to content

feat: add dashed arrow variants to DSL#29

Open
swiftlysingh wants to merge 1 commit intomainfrom
feat/issue-19-dashed-arrows
Open

feat: add dashed arrow variants to DSL#29
swiftlysingh wants to merge 1 commit intomainfrom
feat/issue-19-dashed-arrows

Conversation

@swiftlysingh
Copy link
Copy Markdown
Owner

@swiftlysingh swiftlysingh commented Apr 10, 2026

Summary

  • add DSL parser support for <-- and <--> alongside solid <- and <->
  • preserve arrowhead semantics while applying dashed stroke style in generated Excalidraw output
  • add parser and generation tests plus README syntax examples

Testing

  • npm run build
  • npm run lint
  • npm run test:run
  • node dist/cli.js create tmp-dashed-arrows.dsl -o tmp-dashed-arrows.excalidraw

Summary by CodeRabbit

  • New Features

    • Extended DSL support for reverse arrows (<-, <--), bidirectional arrows (<->, <-->), and dashed variants to enable more directional connection options between nodes.
  • Documentation

    • Updated README with examples of new arrow notation syntaxes and their semantics.

Copilot AI review requested due to automatic review settings April 10, 2026 21:29
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 10, 2026

📝 Walkthrough

Walkthrough

The PR extends the DSL arrow syntax to support reverse (<-, <--), bidirectional (<->, <-->), and additional dashed arrow forms. The parser recognizes these new syntaxes, the type system tracks directionality via a reversed field, and arrowhead property handling improves to distinguish between missing and explicitly falsy values.

Changes

Cohort / File(s) Summary
Documentation
README.md
Extended DSL syntax documentation to clarify forward, reverse, bidirectional, and dashed arrow variants with their corresponding semantics and examples.
Type System
src/types/dsl.ts
Added optional reversed?: boolean property to GraphEdge interface to represent directionality inversion.
Parser & Lexer
src/parser/dsl-parser.ts
Extended tokenizer to recognize <-, <-->, <->, <-- arrow forms. Updated parser to track edge style and reversed state via pendingEdgeStyle and pendingReversed, applying arrowhead configuration based on arrow directionality.
Connection Factory
src/factory/connection-factory.ts
Improved arrowhead property handling using hasOwnProperty checks to distinguish between absent keys (defaulting to null or 'arrow') and explicitly set values in DSL style objects.
Test Coverage
tests/unit/parser/dsl-parser.test.ts
Added comprehensive test assertions for reverse and bidirectional arrow parsing, verifying correct reversed flag, arrowhead placement, and Excalidraw generation for all new arrow syntaxes.

Sequence Diagram

sequenceDiagram
    participant User as DSL Input
    participant Lexer
    participant Parser
    participant TypeSys as Type System
    participant Factory as Connection Factory
    participant Excal as Excalidraw Output
    
    User->>Lexer: [A] <-- [B]
    Lexer->>Lexer: Recognize `<--` token<br/>(dashed, reversed)
    Lexer->>Parser: Emit token with dashed=true
    Parser->>Parser: Set pendingReversed=true<br/>pendingEdgeStyle.startArrowhead='arrow'
    Parser->>TypeSys: Create GraphEdge<br/>(reversed=true)
    TypeSys->>Factory: Pass edge with reversed flag
    Factory->>Factory: Check endArrowhead key<br/>Set defaults via hasOwnProperty
    Factory->>Excal: Emit arrow element<br/>(startArrowhead, strokeStyle: dashed)
    Excal->>User: Render reverse dashed arrow
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 Arrows dance in all directions now,
Reverse and bidirectional—oh, how!
Dashed lines zigzag, reversed heads gleam,
The DSL flows like a flowing stream.
Connection magic, from left to right,
And back again—what a delightful sight!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add dashed arrow variants to DSL' directly and accurately describes the main change: extending the DSL parser to support new dashed arrow syntaxes (<--, <-->). It is concise, specific, and clearly conveys the primary modification across all changed files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ 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 feat/issue-19-dashed-arrows

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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the flowchart DSL to support dashed reverse (<--) and dashed bidirectional (<-->) connections (alongside new solid <- / <-> variants), ensuring the generated Excalidraw arrows preserve the intended arrowhead semantics while applying dashed stroke styling.

Changes:

  • Add tokenization/parsing for <-, <->, <--, and <-->, including edge style arrowhead fields and a reversed flag.
  • Update arrow creation/mapping so endArrowhead: null is preserved (instead of being defaulted back to 'arrow').
  • Add unit tests + README syntax examples for the new arrow variants.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/unit/parser/dsl-parser.test.ts Adds parsing and generation assertions for dashed reverse/bidirectional arrows and solid semantics.
src/types/dsl.ts Extends GraphEdge with optional reversed metadata.
src/parser/dsl-parser.ts Tokenizes and parses new arrow operators, deriving arrowhead styles and dashed stroke styles.
src/factory/connection-factory.ts Adjusts arrowhead defaulting logic to allow explicit null arrowheads.
README.md Documents the new arrow syntaxes and adds examples.
package-lock.json Updates lockfile version metadata to 1.3.0.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 25 to 31
if (style.strokeStyle !== undefined) result.strokeStyle = style.strokeStyle;
if (style.roughness !== undefined) result.roughness = style.roughness;
result.startArrowhead = style.startArrowhead ?? null;
result.endArrowhead = style.endArrowhead ?? 'arrow';
result.endArrowhead = Object.prototype.hasOwnProperty.call(style, 'endArrowhead')
? style.endArrowhead
: 'arrow';
return result;
Comment on lines +80 to +85
startArrowhead: Object.prototype.hasOwnProperty.call(styleProps, 'startArrowhead')
? styleProps.startArrowhead!
: null,
endArrowhead: Object.prototype.hasOwnProperty.call(styleProps, 'endArrowhead')
? styleProps.endArrowhead!
: 'arrow',
Comment on lines +129 to +134
startArrowhead: Object.prototype.hasOwnProperty.call(styleProps, 'startArrowhead')
? styleProps.startArrowhead!
: null,
endArrowhead: Object.prototype.hasOwnProperty.call(styleProps, 'endArrowhead')
? styleProps.endArrowhead!
: 'arrow',
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/factory/connection-factory.ts (1)

27-31: Consider consistent property-presence checks for both arrowheads.

startArrowhead uses nullish coalescing (??) while endArrowhead uses hasOwnProperty. This asymmetry works correctly (since null is a valid ArrowheadType and ?? handles it properly), but using consistent patterns would improve readability.

♻️ Optional: Use consistent pattern
-  result.startArrowhead = style.startArrowhead ?? null;
-  result.endArrowhead = Object.prototype.hasOwnProperty.call(style, 'endArrowhead')
-    ? style.endArrowhead
-    : 'arrow';
+  result.startArrowhead = Object.prototype.hasOwnProperty.call(style, 'startArrowhead')
+    ? style.startArrowhead
+    : null;
+  result.endArrowhead = Object.prototype.hasOwnProperty.call(style, 'endArrowhead')
+    ? style.endArrowhead
+    : 'arrow';
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/factory/connection-factory.ts` around lines 27 - 31, Make the
property-presence checks consistent by changing the startArrowhead assignment to
use the same owns-property pattern as endArrowhead: replace the
nullish-coalescing assignment for result.startArrowhead with an
Object.prototype.hasOwnProperty.call(style, 'startArrowhead') conditional that
uses style.startArrowhead when present and falls back to null when absent,
keeping the existing endArrowhead logic unchanged; reference the variables
style, result, startArrowhead, and endArrowhead to locate and update the two
assignments.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/factory/connection-factory.ts`:
- Around line 27-31: Make the property-presence checks consistent by changing
the startArrowhead assignment to use the same owns-property pattern as
endArrowhead: replace the nullish-coalescing assignment for
result.startArrowhead with an Object.prototype.hasOwnProperty.call(style,
'startArrowhead') conditional that uses style.startArrowhead when present and
falls back to null when absent, keeping the existing endArrowhead logic
unchanged; reference the variables style, result, startArrowhead, and
endArrowhead to locate and update the two assignments.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0483028b-cd80-4702-8103-fba417d0a9b0

📥 Commits

Reviewing files that changed from the base of the PR and between a26f7dd and 590fcd5.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (5)
  • README.md
  • src/factory/connection-factory.ts
  • src/parser/dsl-parser.ts
  • src/types/dsl.ts
  • tests/unit/parser/dsl-parser.test.ts

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.

2 participants