Skip to content

CD Concretization: Implicit Name Adaptation#92

Draft
fxjordan wants to merge 14 commits intodevfrom
cdconc/implict-name-adaptation
Draft

CD Concretization: Implicit Name Adaptation#92
fxjordan wants to merge 14 commits intodevfrom
cdconc/implict-name-adaptation

Conversation

@fxjordan
Copy link
Copy Markdown
Collaborator

Summary

Implements implicit name adaptation for CD concretization/conformance: when a concrete type
name is derived from a reference type name (e.g. Attacker from Observer), element names
containing the reference type name are automatically rewritten to use the concrete type name
(observersattackers, register(Observer o)register(Attacker o)).


Added

  • ADAPTED_NAME_MAPPING CDConfParameter — opt-in flag enabling implicit name adaptation in
    conformance checking
  • AdaptedNameAttributeIncStrategy, AdaptedNameMethodIncStrategy,
    AdaptedRoleNameAssocIncStrategy — three new incarnation strategies that accept adapted
    names as valid incarnations of reference elements
  • NameUtil.adaptTemplatedName — utility that applies three substitution patterns (exact
    substring, uncapitalized prefix, capitalized infix) to derive an adapted name from a reference
    name and a type mapping
  • Documentation in cddiff/doc/cdconcretization/:
    • README.md — completion overview and configuration parameters reference
    • feature-implicit-name-adaptation.md — user-guide style handbook with CD examples

Changed

  • DefaultCDConformanceContext: registers AdaptedNameAttributeIncStrategy,
    AdaptedNameMethodIncStrategy, and AdaptedRoleNameAssocIncStrategy when ADAPTED_NAME_MAPPING
    is set; attribute and method strategies intentionally use compTypeIncStrategy (exact
    incarnation) rather than subtype matching to prevent supertypes from being accepted as adapted
    incarnations of reference parameter types
  • BaseAttributeInTypeCompleter, BaseMethodInTypeCompleter: apply implicit name
    adaptation when copying reference elements; add <<ref>> stereotype only when
    ADAPTED_NAME_MAPPING is not set (the strategy handles recognition instead)
  • MissingAssociationsCDCompleter:
    • Snapshots existing associations at the start of complete() via originalAssociations
      only snapshot associations may suppress adding a new incarnation via inheritance; associations
      added during the same pass cannot
    • Supertype expansion in the coverage check is now conditional on the INHERITANCE parameter
    • Skips the _TypeName suffix on role names when implicit adaptation already produced a unique
      name for the incarnation
  • MatchCDAssocsBySrcTypeAndTgtRole.checkReverse: fixed swapped argument order in checkRole
    calls — the src side is now always passed first, consistent with check() and all subclass
    overrides

Fixed

  • StereotypeUtil.addStereotype: prevented duplicate stereotypes being added during repeated
    completion passes
  • DefaultAssocSideCompleter: role names copied from a reference association now get a freshly
    built CDRole node instead of sharing the reference AST node, preventing one mapping pass from
    mutating the role seen by a subsequent pass
  • AdaptedRoleNameAssocIncStrategy (and ImplicitRoleNameAssocIncStrategy): both now
    correctly resolve concrete and reference types from the right CD in reverse-direction association
    matching, following the checkReverse base-class fix above

Tests

  • testAssocRoleImplicitNameAdaptation — role name adapted from reference type name
  • testAssocNameImplicitNameAdaptation — association name adapted from reference type name
  • testAssocBothSidesMI — multiple incarnations: suffix added only when adaptation did not
    already produce a unique name
  • testAssocSubtypeAndSupertypeTarget — both Container→Item and Container→SpecialItem
    incarnations are always added even when SpecialItem extends Item (regression test for the
    originalAssociations snapshot fix)
  • EvaluationConcretizationTest.Observer.mutualObservers — bidirectional two-mapping scenario:
    Attacker↔Defender receives role (attackers) from ref1 and (defenders) from ref2

@fxjordan fxjordan changed the title CDConcretization: Implicit name adaptation CD Concretization: Implicit Name Adaptation Mar 29, 2026
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.

1 participant