Skip to content

[plantuml] clean up uid normalization and namespace resolution - #496

Merged
castler merged 6 commits into
mainfrom
joho_harmonize_uid_derivation
Oct 5, 2026
Merged

castler merged 6 commits into
mainfrom
joho_harmonize_uid_derivation

Conversation

@hoe-jo

@hoe-jo hoe-jo commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@hoe-jo
hoe-jo force-pushed the joho_harmonize_uid_derivation branch from bd4e946 to 869df0f Compare October 1, 2026 14:02
hoe-jo added 6 commits October 1, 2026 16:44
- Id leaf of classes, enums, packages and namespaces is the alias,
  else the name.
- References use the shared lookup and see entities declared before
  them, plus the scope-local hit.
- Simple names match the last segment of qualified declarations.
- Package-nested relationships resolve after all entities are
  registered.
- New errors: DuplicateEntity (incl. re-declared classes, which
  PlantUML merges) and AmbiguousReference.

Goldens with aliased classes now use the alias as id.
…ndpoints

Relationship endpoints only accepted '.'-separated qualified names;
'::' silently truncated the reference to its first segment (e.g.
`A --> ns::B` resolved "ns"). The grammar now accepts '::' as an
alternative separator and an optional leading '.' for an explicit
root-anchored reference, matching declarations and extends/implements.

Adds parser coverage for ::-qualified endpoints (with and without
multiplicities), a ::-qualified relationship label (must not be
mistaken for an endpoint), and a leading-'.' root-marker endpoint.
Also adds a resolver fixture for an unresolved qualified extends
target, now that it goes through the same lookup.

cross_diagram/qualified_reference moves from an error-case regression
baseline to a positive case now that the grammar resolves it.
Namespace blocks silently dropped relationship statements written inside
them (Package already supported this). Add a relationships field to the
Namespace AST node, parse it the same way as Package, and resolve it in
a second pass after all entities are registered, mirroring the package
path.
The component resolver tracked its nesting as a Vec<String> and joined
raw names, so `component "a::b"` and `component "a.b"` produced two
different ids and a quoted `"score::mw::log"` endpoint kept its '::'.

Scope, element ids, port ids and parent ids now go through
InternalScope and RootAnchor, as the class resolver already does, and
references are normalized before lookup. ComponentResolver gains
with_root_anchor(); new() keeps the empty anchor.

relation_quoted_name now yields `score.mw.log`. New fixture
invalid_duplicate_component_separator covers the duplicate across
separators.
The component resolver searched every descendant scope, fell back to a
global alias/label match and was ambiguous whenever a root element and
a nested one shared a leaf, even when `S.r` named the nearer one.

References now go through uid_normalization::resolve_reference, the
same lookup the class resolver uses: `S.r`, else the unique leaf;
qualified names are `S.r` or the root path. Intermediate scopes and
descendants are not searched and the label of an aliased element no
longer matches. When no element matches, ports are looked up the same
way and resolve to their owning component; the port role comes from the
port the reference named. Several matching ports are ambiguous and
reported by port id.

The leaf key used to index elements and ports moves to
uid_normalization::leaf_key and is shared with the class resolver.

New fixtures: relation_simple_name_prefers_direct_hit,
invalid_qualified_name_does_not_search_descendants,
invalid_ambiguous_nested_reference, invalid_unresolved_label_reference.
@hoe-jo
hoe-jo force-pushed the joho_harmonize_uid_derivation branch from 869df0f to f5b0178 Compare October 1, 2026 14:45
@castler
castler merged commit 058d7de into main Oct 5, 2026
15 checks passed
@castler
castler deleted the joho_harmonize_uid_derivation branch October 5, 2026 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants