Skip to content

Commit ea96b4f

Browse files
authored
[Puml Parser] Optimize class ast and parser (#517)
2 parents 5021deb + decf534 commit ea96b4f

45 files changed

Lines changed: 1043 additions & 1142 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎plantuml/parser/puml_parser/src/class_diagram/BUILD‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ filegroup(
1717
srcs = [
1818
"src/class_ast.rs",
1919
"src/class_parser.rs",
20-
"src/class_traits.rs",
2120
"src/lib.rs",
2221
"src/source_map.rs",
2322
],

‎plantuml/parser/puml_parser/src/class_diagram/detail_design/class_ast.puml‎

Lines changed: 53 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -19,44 +19,44 @@ skinparam classAttributeIconSize 0
1919
' ========================
2020
' AST
2121
' ========================
22-
class ClassDef {
23-
name: Name
24-
namespace: String
25-
package: String
26-
attributes: Vec<Attribute>
27-
methods: Vec<Method>
28-
source_location: SourceLocation
22+
class ClassLikeDef {
23+
declaration: DeclarationCommon
24+
template_parameters: Option<Vec<String>>
25+
members: ClassLikeMembers
26+
kind: ClassLikeKind
2927
}
3028

31-
class StructDef {
32-
name: Name
33-
namespace: String
34-
package: String
35-
attributes: Vec<Attribute>
36-
methods: Vec<Method>
37-
source_location: SourceLocation
29+
enum ClassLikeKind {
30+
Class
31+
Struct
32+
Interface
3833
}
3934

40-
class InterfaceDef {
41-
name: Name
42-
namespace: String
43-
package: String
44-
attributes: Vec<Attribute>
35+
class EntityDef {
36+
declaration: DeclarationCommon
4537
methods: Vec<Method>
46-
source_location: SourceLocation
4738
}
4839

4940
class EnumDef {
41+
declaration: DeclarationCommon
42+
items: Vec<EnumItem>
43+
}
44+
45+
class DeclarationCommon {
5046
name: Name
5147
namespace: String
5248
package: String
5349
stereotypes: Vec<String>
54-
items: Vec<EnumItem>
5550
source_location: SourceLocation
5651
}
5752

53+
class ClassLikeMembers {
54+
attributes: Vec<Attribute>
55+
type_aliases: Vec<TypeAlias>
56+
methods: Vec<Method>
57+
}
58+
5859
class EnumItem {
59-
visibility: Option<Visibility>
6060
name: String
6161
value: Option<EnumValue>
6262
source_location: SourceLocation
@@ -80,13 +80,16 @@ class TypeAlias {
8080

8181
class Namespace {
8282
name: Name
83-
types: Vec<Element>
83+
source_location: SourceLocation
84+
types: Vec<TypeDefinition>
85+
relationships: Vec<Relationship>
8486
namespaces: Vec<Namespace>
8587
}
8688

8789
class Package {
8890
name: Name
89-
types: Vec<Element>
91+
source_location: SourceLocation
92+
types: Vec<TypeDefinition>
9093
packages: Vec<Package>
9194
relationships: Vec<Relationship>
9295
}
@@ -100,63 +103,69 @@ class ClassUmlFile {
100103
class Method {
101104
visibility: Visibility
102105
name: String
103-
generic_params: Vec<String>
106+
template_parameters: Option<Vec<String>>
104107
params: Vec<Param>
105108
type: Option<String>
109+
modifiers: Vec<String>
110+
is_friend: bool
106111
source_location: SourceLocation
107112
}
108113

109114
class Attribute {
110115
visibility: Visibility
111116
name: String
112117
type: Option<String>
118+
modifiers: Vec<String>
113119
source_location: SourceLocation
114120
}
115121

116122
' ========================
117123
' enum
118124
' ========================
119-
enum Element {
120-
ClassDef
121-
StructDef
125+
enum TypeDefinition {
126+
ClassLikeDef
127+
EntityDef
122128
EnumDef
123-
InterfaceDef
124129
}
125130

126131
enum ClassUmlTopLevel {
127-
Types
128-
Enum
132+
TypeDefinition
129133
Namespace
130134
Package
131135
}
132136

133137
' ========================
134138
' relationship
135139
' ========================
136-
ClassDef "1" o-- "*" Attribute
137-
ClassDef "1" o-- "*" Method
138-
139-
StructDef "1" o-- "*" Attribute
140-
StructDef "1" o-- "*" Method
140+
ClassLikeDef "1" *-- "1" DeclarationCommon
141+
ClassLikeDef "1" *-- "1" ClassLikeMembers
142+
ClassLikeDef "1" *-- "1" ClassLikeKind
143+
EntityDef "1" *-- "1" DeclarationCommon
144+
EntityDef "1" o-- "*" Method
145+
EnumDef "1" *-- "1" DeclarationCommon
141146

142-
InterfaceDef "1" o-- "*" Attribute
143-
InterfaceDef "1" o-- "*" Method
147+
ClassLikeMembers "1" o-- "*" Attribute
148+
ClassLikeMembers "1" o-- "*" TypeAlias
149+
ClassLikeMembers "1" o-- "*" Method
144150

145151
EnumDef "1" o-- "*" EnumItem
146152

147-
Element <|-- ClassDef
148-
Element <|-- StructDef
149-
Element <|-- EnumDef
150-
Element <|-- InterfaceDef
153+
TypeDefinition "1" *-- "1" ClassLikeDef
154+
TypeDefinition "1" *-- "1" EntityDef
155+
TypeDefinition "1" *-- "1" EnumDef
151156

152-
Namespace "1" o-- "*" Element
157+
Namespace "1" o-- "*" TypeDefinition
158+
Namespace "1" o-- "*" Relationship
153159
Namespace "1" o-- "*" Namespace
154160

155-
Package "1" o-- "*" Element
161+
Package "1" o-- "*" TypeDefinition
156162
Package "1" o-- "*" Package
157163
Package "1" o-- "*" Relationship
158164

159165
ClassUmlFile "1" o-- "*" ClassUmlTopLevel
160166
ClassUmlFile "1" o-- "*" Relationship
167+
ClassUmlTopLevel "1" *-- "1" TypeDefinition
168+
ClassUmlTopLevel "1" *-- "1" Namespace
169+
ClassUmlTopLevel "1" *-- "1" Package
161170

162171
@enduml

‎plantuml/parser/puml_parser/src/class_diagram/detail_design/test.puml‎

Lines changed: 0 additions & 83 deletions
This file was deleted.

0 commit comments

Comments
 (0)