Lara-4 migration (WeaverGen2 + TS toolchain) - #51
Conversation
Replace the XML weaver specification (joinPointModel.xml, artifacts.xml,
actionModel.xml) with the Java DSL spec class KadabraSpec (new src-spec
source set), and generate the abstract joinpoint classes with WeaverGen2
instead of the old WeaverGenerator.
- KadabraSpec: weaver prefix 'J' (so the concrete joinpoint classes keep
their original J<X> names), root join point 'app', all join points of
the old XML model, keeping the public LARA API identical. The 'enum'
join point is dropped: it had no attributes, actions or concrete class.
- Enums LoopType, CommentType and RefType are now enumDefs, preserving
the original display values ('for', 'doWhile', 'readwrite', ...).
- Concrete joinpoints converted to the WeaverGen2 CRTP convention
(<J><X><Self extends J<X><Self>> extends A<X><Self>), with (node,
JWeaver) constructors and getNodeImpl() covariant overrides. Boxed
types only where the value can be undefined (line, isNumeric,
isSubtypeOf); all other attributes are primitives, matching the old
implementations.
- JGenericJoinPoint renamed to JJoinpoint: the editable base class
holding the implementation shared by all join points (it is also the
generic fallback join point). AJavaWeaverJoinPoint was merged into it.
toString/getToStringImpl keeps the old behavior (node.toString(), and
the 'node - <Spoon class>' suffix only for plain expression join
points), and the XML node join points pass their document to the
inherited node so navigation attributes keep working.
- Non-declared joinpoint subtypes (JFor, JWhile, JDoWhile, JForEach,
JExpressionStatement) moved to the new weaver.kadabra.subtypes
package, since WeaverGen2 requires every class in the joinpoints
package to be a declared join point. JOpAssignmentAux deleted
(replaced by JOpAssignment, which implements the same operator
semantics).
- The weaver class is renamed JavaWeaver -> JWeaver, the name derived
by WeaverGen2 from the prefix ('J' + 'Weaver').
- JWeaver: drop buildLanguageSpecification/buildLangSpecs, use setData
in begin() with the inherited dataStore, typed getRootJp().
- Gradle: LangSpec2/WeaverGen2 includeBuilds, generateWeaver JavaExec
running WeaverGen2Cli, spec source set, syncKadabraJsJavaBinaries task
finalizing installDist to refresh Kadabra-JS/java-binaries.
- Delete committed generated abstracts, old XML resources and the
JavaWeaverResource class; gitignore the new generated paths.
- Move sources src-api -> api and src-code -> code; drop the transpile step (build is now a single tsc noEmit typecheck over a root tsconfig with NodeNext, strict, verbatimModuleSyntax, erasableSyntaxOnly). - package.json: version 4.0.0, @specs-feup/lara ^4.0.0, package exports map, bin entry pointing at ./code/index.ts, oxlint/oxfmt/vitest scripts, prepack java-binaries validation and jest -> vitest tooling. - WeaverConfiguration: weaverFileName now points at the lara-4 @specs-feup/lara/code/Weaver.ts, the weaver class is the renamed weaver.kadabra.JWeaver, and the side effects import is the new @specs-feup/kadabra/api/Joinpoints.ts. - jest -> vitest: single vitest.config.ts using createWeaverVitestConfig with the weaver configuration; the KadabraWeaverTester helper now extends WeaverLegacyTester from @specs-feup/lara/vitest; eslint replaced by oxlint (oxlint.config.ts extending lara's config). - Regenerate api/Joinpoints.ts with lara-build-interfaces from the WeaverGen2-generated JWeaver.json, with three manual adjustments that the generator currently emits in non-compiling form: the 'self' and 'equals' members are no longer re-declared in Joinpoint (the polymorphic LaraJoinPoint declarations are kept), parameter defaults are not emitted in overload signatures, and the snippet 'setLine' overloads are made compatible with the global 'setLine' overloads. - Update the hand-written API code to the new typed enums (lowercase members, e.g. RefType.write), camelCase join point accessors, type-only imports and the non-erasable-syntax-free TS enum replacement in Types.ts; all lara imports now use .ts specifiers. - Update the node versions in the nightly workflow to match the lara-4 toolchain (25.x/24.x).
|
Note omen-alpha responding on behalf of @lm-sousa The two |
The lara-4 pull requests are stacked on multi-weaver; without this the PR pushes run no CI at all.
|




Note
omen-alpha responding on behalf of @lm-sousa
Problem
The repo's
multi-weaverbranch (weaver-instance refactor: removal ofTHREAD_LOCAL_WEAVER, Weaver engine threading through the joinpoints and node creation methods, CI fixes) had fallen behindmaster, and the whole weaver stack needs to move to lara-4 (@specs-feup/lara4.0.0) to stay in lockstep with clava and lara-framework.Solution
Rebased
multi-weaverontomaster(#52) and migrated both halves to the lara-4 stack, mirroring what was done in clava:Java (
JavaWeaver): the three XML specs (joinPointModel.xml,artifacts.xml,actionModel.xml) are replaced by the Java DSL spec classKadabraSpec(newsrc-specsource set); the build now usesLangSpec2/WeaverGen2(LanguageSpecification/WeaverGeneratorno longer exist in lara-framework). Abstract joinpoints are generated by WeaverGen2 (CRTP zig-zag hierarchy) instead of being committed; all 54 concrete joinpoints were converted to the new API (getNodeImpl(),*Implmethods, typedInsertPosition). A GradleSynctask now refreshesKadabra-JS/java-binariesoninstallDist.JS (
Kadabra-JS): sources movedsrc-api→api,src-code→code(no transpilation step anymore — the package ships raw.ts); version 4.0.0 with@specs-feup/lara ^4.0.0; single noEmittsconfig(TS7,erasableSyntaxOnly,verbatimModuleSyntax); jest→vitest viacreateWeaverVitestConfigfrom lara-4; eslint→oxlint/oxfmt;api/Joinpoints.tsregenerated withlara-build-interfaces; nightly CI bumped to Node 24/25.Depends on the
lara-4branches ofspecs-feup/lara-frameworkandspecs-feup/specs-java-libs(CI's branch-resolver resolves them by branch name).Stack
master←multi-weaver(#52) ← this PR (lara-4).Migration notes / judgment calls
JavaWeaver→JWeaver. The prefix is"J"(concrete classes areJ<X>), and WeaverGen2 derives the weaver class/JSON name fromprefix + "Weaver".enumjoinpoint dropped — it had no attributes, actions, or concrete class.JFor,JWhile,JDoWhile,JForEach,JExpressionStatementmoved toweaver.kadabra.subtypes(WeaverGen2 hard-errors on undeclared classes living injoinpoints/).JGenericJoinPoint→JJoinpoint(now the editable base + generic fallback, absorbing the oldAJavaWeaverJoinPoint);JOpAssignmentAuxdeleted in favor ofJOpAssignment.line(INTEGER_BOXED),isNumericandisSubtypeOf(BOOLEAN_BOXED) — everything else primitive, following clava's conventions.api/Joinpoints.tsneeds 3 hand-patches after every regeneration (builder dedup failure ofself/equalsfor the joinpoint namedthis; overload parameter defaults;snippetsetLineoverloads) — documented in the migration commit message.KadabraJavaTypes.ts/nightly referenceweaver.gui.KadabraLauncher, which does not exist anywhere.Verification
gradle clean installDist(includesgenerateWeaver) andcompileTestJava: BUILD SUCCESSFUL.tscclean,oxlintclean, vitest: 33/33 passed (same as the master baseline).