Skip to content

Commit 7d93aa3

Browse files
committed
[plantuml] fix direction in lollipop
1 parent a9a8fc6 commit 7d93aa3

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

plantuml/parser/puml_resolver/src/component_diagram/src/component_resolver.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,9 +471,14 @@ impl ComponentResolver {
471471
});
472472
}
473473

474-
let decor_role = if line == "-" && left == ")" && middle.is_empty() && right.is_empty() {
474+
// A lollipop line may carry a direction hint, which adds a second dash
475+
// segment: `)-u-` or `-u-(`. The line field then contains `"--"` instead
476+
// of `"-"`. Direction is visual-only and does not affect semantics.
477+
let is_lollipop_line = line.chars().all(|c| c == '-') && !line.is_empty();
478+
479+
let decor_role = if is_lollipop_line && left == ")" && middle.is_empty() && right.is_empty() {
475480
Some(EndpointRole::Provided)
476-
} else if line == "-"
481+
} else if is_lollipop_line
477482
&& left.is_empty()
478483
&& ((middle == "(" && right.is_empty()) || (middle.is_empty() && right == "("))
479484
{

validation/core/src/readers/component_diagram_reader.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,30 @@ pub struct ComponentDiagramReader;
2626
impl ComponentDiagramReader {
2727
/// Read all `Component` and `Package` entities from the given FlatBuffers
2828
/// binary files.
29+
///
30+
/// Files that carry a known non-component file identifier (e.g. `CLSD` for
31+
/// class diagrams or `SEQD` for sequence diagrams) are silently skipped so
32+
/// that callers can pass all architectural-design FlatBuffers without
33+
/// pre-filtering by diagram type.
2934
pub fn read(paths: &[String]) -> Result<ComponentDiagramInputs, String> {
3035
let mut out = Vec::new();
3136

3237
for path in paths {
3338
let data = fs::read(path).map_err(|e| format!("Failed to read {path}: {e}"))?;
3439

40+
// FlatBuffers stores the file identifier at bytes 4-7 when one is
41+
// present. Component diagrams are written without an identifier
42+
// (builder.finish(root, None)), so bytes 4-7 are regular data.
43+
// Class diagrams ("CLSD") and sequence diagrams ("SEQD") carry an
44+
// explicit identifier. Skip such files here; they are not
45+
// component diagrams and must not be parsed with the component schema.
46+
if data.len() >= 8 {
47+
let file_id = &data[4..8];
48+
if file_id == b"CLSD" || file_id == b"SEQD" {
49+
continue;
50+
}
51+
}
52+
3553
let graph = flatbuffers::root::<fb_component::ComponentGraph>(&data)
3654
.map_err(|e| format!("Failed to parse FlatBuffer {path}: {e}"))?;
3755

0 commit comments

Comments
 (0)