Skip to content

Cross-file qualified references through a root Element short name fail to resolve (#778) - #786

Closed
tkanov wants to merge 1 commit into
Systems-Modeling:masterfrom
tkanov:fix/short-name-global-scope
Closed

Cross-file qualified references through a root Element short name fail to resolve (#778)#786
tkanov wants to merge 1 commit into
Systems-Modeling:masterfrom
tkanov:fix/short-name-global-scope

Conversation

@tkanov

@tkanov tkanov commented Aug 10, 2026

Copy link
Copy Markdown

Fixes #778. A qualified name whose first segment is the short name of a root Element does not resolve across resources: part x : P::Foo; fails where part x : Alpha::Foo; succeeds, and private import P::*; fails likewise, although short names resolve in every same-resource position.

Cause. KerMLQualifiedNameProvider exports declaredName-based names only, so a root Element is never indexed under its declaredShortName – and KerMLGlobalScope.getSingleElement resolves the first segment of a cross-resource qualified name through that index, before the short-name-aware KerMLScope is reached.

Changes

  1. KerMLResourceDescriptionStrategy exports root Elements under their escaped declaredShortName. Nested Elements are unaffected, since KerMLScope already handles those.
  2. Short names are exported under a separate qualifier (<short-name>) and consulted by KerMLGlobalScope.getRootElement only after a declaredName lookup misses, so a declared name takes precedence structurally rather than by index order. Without this, package <ScalarValues> MyPackage in one resource made ScalarValues::Real unresolvable in another.
  3. Bound via bindIDefaultResourceDescriptionStrategy in KerMLRuntimeModule, SysMLRuntimeModule, KerMLxRuntimeModule and SysMLxRuntimeModule. Also exported org.omg.kerml.xtext.resource.
  4. ShortNameScopeTest, 7 cases. The cross-resource short-name cases fail before change 1. The three collision cases fail before change 2.

org.omg.sysml.interactive.tests (215), org.omg.kerml.xpect.tests (963) and org.omg.sysml.xpect.tests (308) all pass.

Notes

This applies to every root Element with a short name, not only Packages – a root part def <F> Foo; now resolves as F – consistent with a Namespace giving its members both memberName and memberShortName.

Where a short name and a declared name collide, the declared name wins and the short name is unreachable as a first segment. That cannot break a reference that resolves today, but it is a semantics call, so I am happy to report the collision as an error instead. Related: the declaredName-only index looks deliberate (ST6RI-628), so a check against the original intent may be warranted.

Also included, unrelated and latent: KerMLScope.qualifiedNameConverter is @Injected but every KerMLScope is constructed with new, so it is always null and getElement(String) would fail. It now comes from the injected KerMLScopeProvider. Happy to split out.

@tkanov
tkanov marked this pull request as draft August 10, 2026 10:41
@tkanov
tkanov force-pushed the fix/short-name-global-scope branch from efb2b59 to f4801d2 Compare August 10, 2026 10:59
@tkanov tkanov changed the title Cross-file qualified references through a Package short name fail to resolve (#778) Cross-file qualified references through a root Element short name fail to resolve (#778) Aug 10, 2026
@tkanov
tkanov marked this pull request as ready for review August 10, 2026 11:01
@seidewitz

Copy link
Copy Markdown
Member

Sorry, we cannot accept pull requests from outside our development team. We will take your issue (#778) into consideration (this is actually a known problem).

If you would like to contribute the the Pilot Implementation, consider joining (or having your organization join) the OMG Systems Modeling Community. The Pilot Implementation is maintained by the Reference Implementation Working Group of the SMC.

@seidewitz seidewitz closed this Aug 10, 2026
@tkanov
tkanov deleted the fix/short-name-global-scope branch August 11, 2026 10:03
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.

Cross-file qualified references through a package's short name fail to resolve (global scope indexes declaredName only)

2 participants