Repository navigation
[Puml Parser] Support free functions in class diagram - #511
Conversation
| namespace algorithm { | ||
| entity Placeholder <<function>> { | ||
| + clamp(value, min, max) | ||
| + max<T> max(a, b) |
There was a problem hiding this comment.
max max(a, b)fails to parse (grammar isname(params): Ret, no leading return type). Use + max(a, b).
| This resolves to the free functions `amp.algorithm.clamp`. Visibility markers | ||
| such as `+` are accepted for plantUML compatibility and do not affect | ||
| free-function semantics. |
There was a problem hiding this comment.
"plantUML" → "PlantUML"; also lists only clamp, add max
| type_kind = { | ||
| "abstract" ~ "class" | ||
| | "class" | ||
| | "entity" |
There was a problem hiding this comment.
"entity"has no word boundary.entity1 --> Fooandentity_manager --> Foo now fail to parse (parsed fine on main, even afterclass entity_manager). Same flaw already exists for class/struct/interface, but this widens it. Add !(ASCII_ALPHANUMERIC | "_") after the keyword, ideally for all of type_kind.
There was a problem hiding this comment.
Good catch.
While checking the grammar, I also found the same declaration-without-body pattern for object and enum; I will apply the same boundary there to keep the top-level declaration rules consistent.
| "entity" => { | ||
| let def = self.parse_type_def_into::<ClassDef>(pair)?; | ||
| Ok(Element::EntityDef(EntityDef { | ||
| name: def.name, | ||
| namespace: def.namespace, | ||
| package: def.package, | ||
| stereotypes: def.stereotypes, | ||
| methods: def.methods, | ||
| source_location, | ||
| })) | ||
| } |
There was a problem hiding this comment.
template params, extends/implements, attributes and type aliases on an entity are dropped silently. entity E <>andentity E extends Base <> both parse with no diagnostic. Reject or document.
There was a problem hiding this comment.
I've documented this limitation in the class-diagram support guide. I’m keeping the current behavior unchanged rather than adding rejection logic in this change.
After the abstract of class/interface/struct/..., maybe rejecting these constructs can be handled as a follow-up.
| .any(|stereotype| stereotype.eq_ignore_ascii_case("function")) | ||
| } | ||
|
|
||
| fn process_free_function_entity( |
There was a problem hiding this comment.
only scope.id is used, so entity amp.algorithm.Fn <>at root givesenclosing_namespace_id: None. Classes use the qualified name for the namespace.
There was a problem hiding this comment.
supported and add the following integration test
entity amp.algorithm.Fn <<function>> {
+ run()
}
3570a78 to
49fa9c0
Compare
49fa9c0 to
498aa5d
Compare
Head branch was pushed to by a user without write access
498aa5d to
13825d8
Compare
No description provided.