@@ -11,9 +11,14 @@ Required inputs:
1111- concrete class diagram
1212- mapping names, such as ` buildPat ` , ` observer ` , or ` ref `
1313- adapter/reference Java source directory
14- - concrete Java source directory
1514- output directory
1615
16+ The API accepts an optional concrete Java source directory. When it is omitted,
17+ does not exist, or contains no Java files, ` CodeAdapter ` generates the concrete
18+ Java baseline from the final concrete CD. A supplied directory that contains
19+ Java remains authoritative handwritten concrete code. The CLI still requires
20+ its existing concrete-code argument.
21+
1722The class diagrams define which reference classes, fields, and methods incarnate as concrete Java elements. Java code is parsed and transformed with MontiCore JavaDSL and Spoon.
1823
1924## Adaptation Flow
@@ -24,17 +29,22 @@ The class diagrams define which reference classes, fields, and methods incarnate
2429 a staging workspace or changing existing output.
25304 . Copy and filter reference adapter code for the active mapping.
26315 . Adapt types, fields, methods, parameters, constructor calls, and pattern-derived members.
27- 6 . Merge adapted code with existing concrete code.
28- 7 . Clean generated Java:
32+ 6 . Merge adapted code with existing concrete code, when present .
33+ 7 . Clean staged handwritten Java:
2934 - remove ` @Adapt ` annotations with Spoon
3035 - remove invalid generated imports through JavaDSL import declarations
3136 - preserve valid existing imports without inventing imports for unresolved
3237 simple names
3338 - keep Spoon as the only whole-file formatter; import cleanup edits only
3439 import declaration source ranges
35- 8 . Publish the completed staging directory transactionally, restoring the
40+ 8 . If no concrete Java was supplied, serialize the final concrete CD and run
41+ CD4Code with the staged adapted code as handwritten code. Merge generated
42+ ` *TOP.java ` companions and model-only declarations without overwriting the
43+ staged handwritten implementation.
44+ 9 . Clean the combined Java tree and publish the completed staging directory
45+ transactionally, restoring the
3646 previous output if publication fails.
37- 9 . Compile and structurally verify generated Java in tests.
47+ 10 . Compile and structurally verify generated Java in tests.
3848
3949The context-building step depends on the ` useConcretization ` argument of
4050` CodeAdapter.adapt(...) ` .
@@ -51,6 +61,11 @@ This mode delegates model repair to cdconcretization before code adaptation:
51613 . ` JavaTypeUpdateService ` projects Java-expressible elements that were added
5262 to the completed concrete CD, such as missing fields, methods, types, enum
5363 constants, inheritance, and interfaces.
64+ 4 . ` ReferenceCodeDependencySelector ` retains the transitive source-local
65+ helper closure of mapped reference types. Required Java-only helper members
66+ and helper classes do not need ignore annotations; unrelated source units
67+ are excluded. Reference-CD type uses inside retained helpers are adapted by
68+ the normal transformation passes.
5469
5570Use this mode when the concrete CD may need deterministic model-level repair
5671before Java adaptation.
@@ -60,16 +75,15 @@ before Java adaptation.
6075This mode does not mutate or complete the concrete CD. It builds a manual
6176incarnation context from:
6277
63- - explicit stereotypes for the active mapping name,
64- - deterministic name and adapted -name rules enabled by ` CDConfParameter ` ,
78+ - explicit stereotypes on concrete-CD elements for the active mapping name,
79+ - deterministic same -name rules enabled by ` CDConfParameter.NAME_MAPPING ` ,
6580- manual ` <<forEach="...">> ` mappings derived from already-known
6681 incarnations.
6782
6883The manual branch does not call ` ConcretizationCompleter ` or
6984` CDConformanceChecker ` , and it does not clone or create CD elements. Conflicts
70- are reported together as a ` CodeAdaptationException ` before
71- ` JavaLoader.removeDirectory(outputPath) ` is executed, so existing output is
72- preserved when adaptation cannot safely start.
85+ are reported together as a ` CodeAdaptationException ` before staging is created
86+ or existing output is touched.
7387
7488Supported manual ` forEach ` targets:
7589
@@ -83,6 +97,50 @@ example `getAttribute()` to `getFirstName()` and `getAge()`. The manual mode
8397does not invent cdconcretization suffix rules; concrete stereotypes or enabled
8498name rules must make the target deterministic.
8599
100+ #### Manual mappings without concrete Java (R-024)
101+
102+ The no-concrete-code API and manual mapping derivation are independent choices.
103+ This call combines them explicitly:
104+
105+ ``` java
106+ adapter. adaptWithoutConcreteCode(
107+ referenceCD,
108+ concreteCD,
109+ mappings,
110+ referenceCodePath,
111+ outputPath,
112+ false , // do not run cdconcretization
113+ true ); // allow exact common-parent grouping
114+ ```
115+
116+ The implementation then follows one transactional pipeline:
117+
118+ 1 . ` AdaptationWorkspace ` represents the concrete Java input as absent, while
119+ both CDs and the reference Java directory remain read-only inputs.
120+ 2 . Because ` useConcretization ` is false, the parsed concrete CD is neither
121+ cloned nor completed. ` AdaptationContextFactory ` delegates every mapping to
122+ ` ManualIncarnationContextBuilder ` .
123+ 3 . The builder scans concrete types first, then members within their mapped
124+ owners. An explicit ` <<mapping="ReferenceElement">> ` wins; enabled
125+ same-name/signature rules are the deterministic fallback. Reference-side
126+ ` forEach ` stereotypes copy or expand mappings already found in those passes.
127+ 4 . ` AdaptationConflictDetector ` and strict reference-Java validation run before
128+ staging. Manual mode does not enable R-026's unannotated-helper policy.
129+ 5 . Normal isolated mapping passes transform the reference Java. With no
130+ concrete Java base, this adapted result becomes the staged authoritative
131+ handwritten code.
132+ 6 . ` ConcreteCodeGenerationService ` serializes the unchanged concrete CD and
133+ runs CD4Code in a separate JVM, using the staged adapted Java as HWC.
134+ ` OutputCodeService ` keeps that HWC and adds generated ` *TOP.java ` companions,
135+ association fields, and model-only declarations.
136+ 7 . The combined sources are cleaned and published only after the entire run
137+ succeeds. Empty reference Java still reaches generation, so the concrete CD
138+ alone can produce a model baseline.
139+
140+ R-026 is intentionally a concretization-mode feature. Its transitive
141+ Java-helper selection is not used by the manual path above; unmatched manual
142+ helpers must still satisfy the normal manual validation policy.
143+
86144## Association Adaptation
87145
88146Associations affect Java through navigable role fields. For example,
@@ -117,6 +175,13 @@ assignments are rewritten only inside that owning Java type.
117175 immutable stable-key selection. An empty selection represents the ordinary case.
118176- ` MappingAdaptationRunner ` owns the isolated per-pass updater lifecycle, output filtering, merge,
119177 cleanup, and error wrapping.
178+ - ` ReferenceCodeDependencySelector ` builds a package-qualified dependency graph
179+ once from the reference source snapshot and selects mapping-specific helper
180+ closures in concretization mode. Ambiguous source-local type resolution is
181+ rejected deterministically.
182+ - ` ConcreteCodeGenerationService ` runs CD4Code in an isolated JVM and workspace when
183+ the API receives no concrete Java. ` OutputCodeService ` merges its result with
184+ staged handwritten code, which always has precedence.
120185- ` CDTypeRelations ` centralizes direct generated-AST access for interfaces,
121186 superclasses, modifiers, and type-reference printing. Runtime Java reflection
122187 is not used by the adapter.
0 commit comments