@zenuml/core 3.39.3 → 3.40.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,163 @@
1
+ # Implementation Plan: Named Parameters Support
2
+
3
+ ## Overview
4
+ Add support for named parameters in method calls, allowing syntax like `A.method(param=value)` alongside existing positional parameters.
5
+
6
+ ## Current State Analysis
7
+
8
+ ### Grammar Structure
9
+ - **Parser**: `src/g4/sequenceParser.g4` defines parameter rules at lines 220-230
10
+ - **Current parameter rule**: `parameter: declaration | expr`
11
+ - **Parameters rule**: `parameters: parameter (COMMA parameter)* COMMA?`
12
+ - **Invocation**: Method calls use `invocation: OPAR parameters? CPAR`
13
+
14
+ ### Parser Logic
15
+ - **SignatureText.ts**: Handles parameter display via `getFormattedText()`
16
+ - **Parser.types.ts**: Defines `Parameter` and `Parameters` interfaces
17
+ - **Current behavior**: Parameters are parsed as expressions or type declarations
18
+
19
+ ## Implementation Stages
20
+
21
+ ### Stage 1: Grammar Extension
22
+ **Goal**: Extend ANTLR grammar to support named parameter syntax
23
+ **Success Criteria**:
24
+ - Grammar accepts `param=value` syntax
25
+ - Backward compatibility with existing positional syntax
26
+ - Parser generates successfully
27
+
28
+ **Tasks**:
29
+ - [x] Add `namedParameter` rule: `ID ASSIGN expr`
30
+ - [x] Update `parameter` rule to include `namedParameter | declaration | expr`
31
+ - [x] Add tests for grammar parsing
32
+ - [x] Regenerate parser with `pnpm antlr`
33
+
34
+ **Tests**:
35
+ - [x] `A.method(x=1, y=2)` parses correctly
36
+ - [x] `A.method(1, name="test")` mixed parameters work
37
+ - [x] Existing `A.method(1, 2)` still works
38
+
39
+ **Status**: Complete
40
+
41
+ ### Stage 2: Parser Type Extensions
42
+ **Goal**: Extend parser types and interfaces to handle named parameters
43
+ **Success Criteria**:
44
+ - Named parameter data accessible in parser contexts
45
+ - Type definitions support both named and positional parameters
46
+
47
+ **Tasks**:
48
+ - [x] Extend `Parameter` interface to distinguish parameter types
49
+ - [x] Add `NamedParameter` interface with name and value properties
50
+ - [x] Update `SignatureText.ts` to handle named parameter formatting
51
+ - [x] Update type assertions and context handling
52
+
53
+ **Tests**:
54
+ - [x] Named parameters accessible via parser API
55
+ - [x] `getFormattedText()` displays named parameters correctly
56
+ - [x] Type safety maintained
57
+
58
+ **Status**: Complete
59
+
60
+ ### Stage 3: Rendering Support
61
+ **Goal**: Update React components to render named parameters appropriately
62
+ **Success Criteria**:
63
+ - Named parameters displayed in sequence diagrams
64
+ - Clear visual distinction between parameter types
65
+ - Consistent formatting with existing design
66
+
67
+ **Tasks**:
68
+ - [x] Update message rendering components (via SignatureText.ts)
69
+ - [x] Enhance parameter display logic (formatParameters helper)
70
+ - [x] Ensure consistent formatting with existing design
71
+ - [x] Test rendering in development environment
72
+
73
+ **Tests**:
74
+ - [x] Named parameters render correctly: `method(userId=123,name="John")`
75
+ - [x] Mixed parameters work: `method(123,name="John",active=true)`
76
+ - [x] Backward compatibility maintained: `oldMethod(1,2,3)`
77
+ - [x] Complex scenarios: `mixedCall("first",second=456,"third")`
78
+
79
+ **Status**: Complete
80
+
81
+ ### Stage 4: Test Coverage & Integration
82
+ **Goal**: Comprehensive testing and integration with existing features
83
+ **Success Criteria**:
84
+ - Full test coverage for named parameter scenarios
85
+ - E2E tests validate end-to-end functionality
86
+ - No regressions in existing functionality
87
+
88
+ **Tasks**:
89
+ - [ ] Unit tests for parser logic
90
+ - [ ] Component tests for rendering
91
+ - [ ] E2E tests with Playwright
92
+ - [ ] Performance regression testing
93
+ - [ ] Documentation updates
94
+
95
+ **Tests**:
96
+ - All test suites pass
97
+ - Performance benchmarks maintained
98
+ - Edge cases handled properly
99
+
100
+ **Status**: Not Started
101
+
102
+ ### Stage 5: Documentation & Examples
103
+ **Goal**: User-facing documentation and examples
104
+ **Success Criteria**:
105
+ - Clear documentation of named parameter syntax
106
+ - Working examples in demo site
107
+ - Migration guidance for users
108
+
109
+ **Tasks**:
110
+ - [ ] Update grammar documentation
111
+ - [ ] Add examples to demo site
112
+ - [ ] Update README with new syntax
113
+ - [ ] API documentation updates
114
+
115
+ **Tests**:
116
+ - Documentation examples work correctly
117
+ - Demo site renders named parameter examples
118
+ - No broken links or outdated information
119
+
120
+ **Status**: Not Started
121
+
122
+ ## Technical Considerations
123
+
124
+ ### Backward Compatibility
125
+ - Existing positional parameter syntax must continue working
126
+ - Mixed parameter styles (positional + named) should be supported
127
+ - No breaking changes to existing APIs
128
+
129
+ ### Performance Impact
130
+ - Minimal impact on parser performance
131
+ - Named parameter detection should be efficient
132
+ - Memory usage considerations for parameter storage
133
+
134
+ ### Edge Cases
135
+ - Parameter name validation and uniqueness
136
+ - Error handling for invalid syntax
137
+ - Interaction with existing features (fragments, loops, etc.)
138
+
139
+ ### Dependencies
140
+ - ANTLR4 parser regeneration
141
+ - No new external dependencies required
142
+ - Maintain compatibility with existing build system
143
+
144
+ ## Risk Assessment
145
+
146
+ **Low Risk**:
147
+ - Grammar extension is straightforward
148
+ - Existing infrastructure supports parameter handling
149
+
150
+ **Medium Risk**:
151
+ - Rendering changes may require careful CSS updates
152
+ - Type system changes need thorough testing
153
+
154
+ **High Risk**:
155
+ - Parser performance impact needs monitoring
156
+ - Complex interaction with expression parsing
157
+
158
+ ## Success Metrics
159
+ - [ ] All existing tests pass
160
+ - [ ] New functionality covered by tests
161
+ - [ ] No performance degradation
162
+ - [ ] Documentation complete
163
+ - [ ] Community feedback positive
@@ -0,0 +1,30 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6
+ <meta name="viewport" content="width=device-width,initial-scale=1.0" />
7
+ <title>Named Parameters Test</title>
8
+ <style>
9
+ body {
10
+ margin: 0; /* mostly for demo on mobile */
11
+ }
12
+ </style>
13
+ </head>
14
+ <body>
15
+ <div id="diagram" class="diagram">
16
+ <pre class="zenuml" style="margin: 0">
17
+ title Named Parameters Test
18
+ // Testing named parameter syntax (param=value)
19
+ A.method(userId=123, name="John")
20
+ B.create(type="User", active=true)
21
+ C.mixedCall(1, name="Mixed", enabled=false)
22
+ D.oldStyle(1, 2, 3)
23
+ E.complex(first="value1", second=42, third=true, fourth="final")
24
+ </pre
25
+ >
26
+ </div>
27
+ <!-- built files will be auto injected -->
28
+ <script type="module" src="/src/main-cy.ts"></script>
29
+ </body>
30
+ </html>