Skip to content

Commit 079b5ee

Browse files
Jenner Torrenceclaude
andcommitted
Implement Phase 1 & 2 of main application fixes (24 errors reduced)
Phase 1 - Critical AST Node Property Fixes: - Add softwareSystemId getter to SystemContextViewNode - Add containerId getter to ContainerInstanceNode - Add autoLayout, animations, includes, excludes properties to view nodes: - SystemLandscapeViewNode - ContainerViewNode - ComponentViewNode Phase 2 - Type Safety and Model Enhancements: - Fix ContainerInstance constructor parameters (remove invalid instanceId) - Add null safety handling for Map<String, String> properties in workspace builder - Add missing hasElementStyle and hasRelationshipStyle methods to Styles class - Add Map type conversion helper for workspace configuration - Fix nullable properties throughout workspace builder implementation Reduced compilation errors from 570 to 546. Main remaining issues are in parser implementation details and style node property access. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 083f30a commit 079b5ee

File tree

9 files changed

+280
-25
lines changed

9 files changed

+280
-25
lines changed

lib/application/dsl/workspace_builder_impl.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class WorkspaceBuilderImpl implements WorkspaceBuilder {
144144
name: node.name,
145145
description: node.description,
146146
tags: node.tags,
147-
properties: node.properties,
147+
properties: node.properties ?? {},
148148
location: node.location ?? 'Internal',
149149
);
150150

@@ -177,7 +177,7 @@ class WorkspaceBuilderImpl implements WorkspaceBuilder {
177177
name: node.name,
178178
description: node.description,
179179
tags: node.tags,
180-
properties: node.properties,
180+
properties: node.properties ?? {},
181181
location: node.location ?? 'Internal',
182182
);
183183

@@ -470,10 +470,10 @@ class WorkspaceBuilderImpl implements WorkspaceBuilder {
470470
final instance = ContainerInstance(
471471
id: node.id,
472472
containerId: container.id, // Use the resolved container ID
473+
name: node.identifier, // Use identifier as name
473474
parentId: _currentParentId!,
474-
instanceId: node.instanceCount,
475475
tags: node.tags,
476-
properties: node.properties,
476+
properties: node.properties ?? {},
477477
);
478478

479479
// Add the container instance to our element map

lib/application/dsl/workspace_mapper_with_builder.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class WorkspaceMapper implements AstVisitor {
118118
_builder.createWorkspace(
119119
name: node.name,
120120
description: node.description,
121-
configuration: node.configuration,
121+
configuration: _convertMapToStringMap(node.configuration),
122122
);
123123

124124
// Process the model section
@@ -428,4 +428,10 @@ class WorkspaceMapper implements AstVisitor {
428428

429429
@override
430430
void visitViewPropertyNode(dynamic node) {}
431+
432+
/// Helper method to convert Map<String, dynamic> to Map<String, String>
433+
Map<String, String>? _convertMapToStringMap(Map<String, dynamic>? input) {
434+
if (input == null) return null;
435+
return input.map((k, v) => MapEntry(k, v.toString()));
436+
}
431437
}

lib/domain/parser/ast/nodes/component_view_node.dart

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,22 @@ class ComponentViewNode extends AstNode {
66
final String containerId;
77
final String? title;
88
final String? description;
9-
ComponentViewNode(
10-
{required this.key,
11-
required this.containerId,
12-
this.title,
13-
this.description,
14-
SourcePosition? sourcePosition})
15-
: super(sourcePosition);
9+
final dynamic autoLayout;
10+
final List<dynamic> animations;
11+
final List<dynamic> includes;
12+
final List<dynamic> excludes;
13+
14+
ComponentViewNode({
15+
required this.key,
16+
required this.containerId,
17+
this.title,
18+
this.description,
19+
this.autoLayout,
20+
this.animations = const [],
21+
this.includes = const [],
22+
this.excludes = const [],
23+
SourcePosition? sourcePosition,
24+
}) : super(sourcePosition);
1625

1726
@override
1827
void accept(AstVisitor visitor) => visitor.visitComponentViewNode(this);

lib/domain/parser/ast/nodes/container_instance_node.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ class ContainerInstanceNode extends AstNode {
1010
List<AstNode> relationships;
1111
List<AstNode> healthChecks;
1212
List<AstNode> children;
13+
14+
// Alias for id to match workspace builder usage
15+
String get containerId => id;
1316

1417
ContainerInstanceNode({
1518
required this.id,

lib/domain/parser/ast/nodes/container_view_node.dart

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,22 @@ class ContainerViewNode extends AstNode {
66
final String systemId;
77
final String? title;
88
final String? description;
9-
ContainerViewNode(
10-
{required this.key,
11-
required this.systemId,
12-
this.title,
13-
this.description,
14-
SourcePosition? sourcePosition})
15-
: super(sourcePosition);
9+
final dynamic autoLayout;
10+
final List<dynamic> animations;
11+
final List<dynamic> includes;
12+
final List<dynamic> excludes;
13+
14+
ContainerViewNode({
15+
required this.key,
16+
required this.systemId,
17+
this.title,
18+
this.description,
19+
this.autoLayout,
20+
this.animations = const [],
21+
this.includes = const [],
22+
this.excludes = const [],
23+
SourcePosition? sourcePosition,
24+
}) : super(sourcePosition);
1625

1726
@override
1827
void accept(AstVisitor visitor) => visitor.visitContainerViewNode(this);

lib/domain/parser/ast/nodes/system_context_view_node.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ class SystemContextViewNode extends AstNode {
1010
final List<dynamic> animations;
1111
final List<dynamic> includes;
1212
final List<dynamic> excludes;
13+
14+
// Alias for systemId to match workspace builder usage
15+
String get softwareSystemId => systemId;
1316

1417
SystemContextViewNode({
1518
required this.key,

lib/domain/parser/ast/nodes/system_landscape_view_node.dart

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,21 @@ class SystemLandscapeViewNode extends AstNode {
55
final String key;
66
final String? title;
77
final String? description;
8-
SystemLandscapeViewNode(
9-
{required this.key,
10-
this.title,
11-
this.description,
12-
SourcePosition? sourcePosition})
13-
: super(sourcePosition);
8+
final dynamic autoLayout;
9+
final List<dynamic> animations;
10+
final List<dynamic> includes;
11+
final List<dynamic> excludes;
12+
13+
SystemLandscapeViewNode({
14+
required this.key,
15+
this.title,
16+
this.description,
17+
this.autoLayout,
18+
this.animations = const [],
19+
this.includes = const [],
20+
this.excludes = const [],
21+
SourcePosition? sourcePosition,
22+
}) : super(sourcePosition);
1423

1524
@override
1625
void accept(AstVisitor visitor) => visitor.visitSystemLandscapeViewNode(this);

lib/domain/style/styles.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,16 @@ class Styles with _$Styles {
128128
// Get the merged style for all tags
129129
return getRelationshipStyle(relationship.tags);
130130
}
131+
132+
/// Checks if there is an element style defined for the given tag.
133+
bool hasElementStyle(String tag) {
134+
return elements.any((style) => style.tag == tag);
135+
}
136+
137+
/// Checks if there is a relationship style defined for the given tag.
138+
bool hasRelationshipStyle(String tag) {
139+
return relationships.any((style) => style.tag == tag);
140+
}
131141
}
132142

133143
/// Styles for architecture elements.

specs/main_app_fix_plan.md

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
# Main Flutter Application Fix Plan
2+
3+
## Executive Summary
4+
5+
The main Flutter application has 200+ compilation errors preventing it from running. This plan categorizes these errors by type and provides a systematic approach to fix them in priority order.
6+
7+
## Error Categories Analysis
8+
9+
### 1. Missing AST Node Properties (HIGH PRIORITY)
10+
**Impact**: 50+ errors, blocks workspace building
11+
**Root Cause**: AST nodes missing properties that WorkspaceBuilder expects
12+
13+
**Affected Files**:
14+
- `SystemContextViewNode` - missing `softwareSystemId` property
15+
- `SystemLandscapeViewNode` - missing `autoLayout`, `animations`, `includes`, `excludes` properties
16+
- `ContainerViewNode` - missing `autoLayout` property
17+
- `ContainerInstanceNode` - missing `containerId` property
18+
- `ComponentViewNode` - missing `autoLayout` property
19+
20+
### 2. Type Casting and Null Safety Issues (HIGH PRIORITY)
21+
**Impact**: 40+ errors, prevents model creation
22+
**Root Cause**: Incorrect type assignments and null safety violations
23+
24+
**Examples**:
25+
- `Map<String, dynamic>?` cannot be assigned to `Map<String, String>?`
26+
- `Map<String, String>?` cannot be assigned to non-nullable `Map<String, String>`
27+
- `AstNode` cannot be cast to specific node types
28+
29+
### 3. Missing Model Class Properties (MEDIUM PRIORITY)
30+
**Impact**: 30+ errors in model classes
31+
**Root Cause**: Model classes missing expected properties
32+
33+
**Examples**:
34+
- `ContainerInstance` missing `instanceId` parameter
35+
- `Styles` class missing methods: `hasElementStyle`, `hasRelationshipStyle`
36+
37+
### 4. View Parser Issues (MEDIUM PRIORITY)
38+
**Impact**: 20+ errors in view parsers
39+
**Root Cause**: View parsers referencing non-existent or incorrect AST node structures
40+
41+
### 5. Export Error Recovery (LOW PRIORITY)
42+
**Impact**: 10+ errors in export files
43+
**Root Cause**: Type resolution issues in export classes (already partially fixed)
44+
45+
## Implementation Plan
46+
47+
### Phase 1: Core AST Node Fixes (1-2 days)
48+
**Priority**: CRITICAL - Blocks all DSL parsing
49+
50+
1. **Fix SystemContextViewNode**
51+
- Add missing `softwareSystemId` property
52+
- Ensure property types match workspace builder expectations
53+
54+
2. **Fix SystemLandscapeViewNode**
55+
- Add missing `autoLayout`, `animations`, `includes`, `excludes` properties
56+
- Implement proper types for these properties
57+
58+
3. **Fix ContainerViewNode and ComponentViewNode**
59+
- Add missing `autoLayout` property
60+
- Standardize autoLayout structure across view nodes
61+
62+
4. **Fix ContainerInstanceNode**
63+
- Add missing `containerId` property
64+
- Verify property name matches usage in workspace builder
65+
66+
### Phase 2: Type Safety and Null Safety Fixes (1-2 days)
67+
**Priority**: HIGH - Prevents model creation
68+
69+
1. **Fix Map Type Conversions**
70+
- Convert `Map<String, dynamic>` to `Map<String, String>` where needed
71+
- Add null safety handling for nullable maps
72+
73+
2. **Fix AstNode Type Casting**
74+
- Implement proper type checking before casting
75+
- Add runtime type verification
76+
77+
3. **Fix Parameter Mismatches**
78+
- Align constructor parameters with actual usage
79+
- Fix `instanceId` vs expected parameters in `ContainerInstance`
80+
81+
### Phase 3: Model Class Enhancements (1 day)
82+
**Priority**: MEDIUM - Extends functionality
83+
84+
1. **Enhance Styles Class**
85+
- Add missing `hasElementStyle` and `hasRelationshipStyle` methods
86+
- Implement proper style lookup functionality
87+
88+
2. **Fix Model Property Mismatches**
89+
- Ensure all model classes have properties that workspace builder expects
90+
- Add any missing factory methods or constructors
91+
92+
### Phase 4: View Parser Fixes (1 day)
93+
**Priority**: MEDIUM - Enables view creation
94+
95+
1. **Fix View Parser Type References**
96+
- Ensure all view parsers use correct AST node types
97+
- Fix method signatures to match AST node interfaces
98+
99+
2. **Implement Missing View Parser Methods**
100+
- Add any missing parser methods referenced by workspace builder
101+
102+
### Phase 5: Integration Testing and Cleanup (1 day)
103+
**Priority**: LOW - Polish and verification
104+
105+
1. **Final Export File Fixes**
106+
- Complete any remaining export error fixes
107+
- Test export functionality with real data
108+
109+
2. **Integration Testing**
110+
- Test full DSL parsing pipeline
111+
- Verify workspace creation with sample DSL files
112+
113+
3. **Error Handling Enhancement**
114+
- Add proper error reporting throughout parsing pipeline
115+
- Implement graceful error recovery
116+
117+
## Detailed Implementation Steps
118+
119+
### Step 1: Fix SystemContextViewNode
120+
```dart
121+
class SystemContextViewNode extends AstNode {
122+
final String key;
123+
final String systemId;
124+
final String softwareSystemId; // ADD THIS
125+
final String? title;
126+
final String? description;
127+
final AutoLayoutNode? autoLayout; // TYPE THIS PROPERLY
128+
final List<AnimationNode> animations; // TYPE THIS PROPERLY
129+
final List<String> includes; // TYPE THIS PROPERLY
130+
final List<String> excludes; // TYPE THIS PROPERLY
131+
132+
// ... rest of implementation
133+
}
134+
```
135+
136+
### Step 2: Fix Map Type Conversions
137+
```dart
138+
// In workspace_mapper_with_builder.dart
139+
configuration: _convertMapToStringMap(node.configuration),
140+
141+
// Helper method
142+
Map<String, String>? _convertMapToStringMap(Map<String, dynamic>? input) {
143+
if (input == null) return null;
144+
return input.map((k, v) => MapEntry(k, v.toString()));
145+
}
146+
```
147+
148+
### Step 3: Fix Styles Class
149+
```dart
150+
// In styles.dart
151+
class Styles {
152+
// ... existing code
153+
154+
bool hasElementStyle(String tag) {
155+
return elements.any((style) => style.tag == tag);
156+
}
157+
158+
bool hasRelationshipStyle(String tag) {
159+
return relationships.any((style) => style.tag == tag);
160+
}
161+
}
162+
```
163+
164+
## Risk Assessment
165+
166+
### High Risk Areas
167+
1. **AST Node Changes**: Risk of breaking existing parser logic
168+
- Mitigation: Incremental changes with testing
169+
- Validation: Run parser tests after each change
170+
171+
2. **Type Casting**: Risk of runtime errors
172+
- Mitigation: Add proper type checking
173+
- Validation: Test with various DSL inputs
174+
175+
### Medium Risk Areas
176+
1. **Model Class Changes**: Risk of breaking serialization
177+
- Mitigation: Maintain backward compatibility
178+
- Validation: Test JSON serialization/deserialization
179+
180+
## Success Criteria
181+
182+
1. **Build Success**: `flutter run lib/main.dart` compiles without errors
183+
2. **Basic Functionality**: Can load and display a simple DSL file
184+
3. **Parser Pipeline**: Full DSL parsing completes without crashes
185+
4. **View Creation**: Can create and display basic views (system context, landscape)
186+
5. **Export Functionality**: Basic export formats work correctly
187+
188+
## Timeline Estimate
189+
190+
- **Phase 1 (AST Fixes)**: 2 days
191+
- **Phase 2 (Type Safety)**: 2 days
192+
- **Phase 3 (Model Enhancements)**: 1 day
193+
- **Phase 4 (View Parsers)**: 1 day
194+
- **Phase 5 (Testing/Cleanup)**: 1 day
195+
196+
**Total Estimate**: 7 days (1.5 weeks)
197+
198+
## Implementation Priority
199+
200+
1. Start with SystemContextViewNode (most critical path)
201+
2. Fix type safety issues in workspace builder
202+
3. Complete remaining AST node fixes
203+
4. Add missing model methods
204+
5. Test and validate complete pipeline
205+
206+
This plan addresses all major compilation issues systematically while minimizing risk and ensuring the application becomes fully functional.

0 commit comments

Comments
 (0)