You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
fix(parser): improve member detection after colon in Mermaid#438
Enhance MermaidParser to check for member definitions following a colon, ensuring more accurate parsing of class diagram statements. Added related test coverage and parser method for class diagrams.
is cc.unitmesh.diagram.parser.mermaid.ParseResult.Error-> {
93
-
println("Parse failed with errors:")
94
-
result.errors.forEach { error->
95
-
println("${error.message}")
96
-
}
97
-
}
98
-
}
113
+
val successResult= resultas cc.unitmesh.diagram.parser.mermaid.ParseResult.Success
114
+
115
+
// Verify AST contains expected statements
116
+
assertEquals(2, successResult.ast.statements.size,"Should have 2 statements")
117
+
assertTrue(successResult.ast.statements[0]is cc.unitmesh.diagram.parser.mermaid.ClassStatementNode,"First statement should be ClassStatementNode")
118
+
assertTrue(successResult.ast.statements[1]is cc.unitmesh.diagram.parser.mermaid.ClassAnnotationStatementNode,"Second statement should be ClassAnnotationStatementNode")
119
+
120
+
// Verify class annotation statement details
121
+
val classAnnotationStatements= successResult.ast.statements.filterIsInstance<cc.unitmesh.diagram.parser.mermaid.ClassAnnotationStatementNode>()
122
+
assertEquals(1, classAnnotationStatements.size,"Should have exactly 1 class annotation statement")
123
+
124
+
val annotationStmt= classAnnotationStatements[0]
125
+
assertEquals("User", annotationStmt.className,"Class name should be 'User'")
126
+
assertEquals("Added", annotationStmt.annotation,"Annotation should be 'Added'")
127
+
128
+
// Test the class diagram parser
129
+
val classDiagramParser= cc.unitmesh.diagram.parser.MermaidClassDiagramParser()
130
+
val diagramResult= classDiagramParser.parse(successResult.ast)