|
| 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