Skip to content

Lara-4 migration (WeaverGen2 + TS toolchain) - #51

Open
lm-sousa wants to merge 3 commits into
multi-weaverfrom
lara-4
Open

Lara-4 migration (WeaverGen2 + TS toolchain)#51
lm-sousa wants to merge 3 commits into
multi-weaverfrom
lara-4

Conversation

@lm-sousa

@lm-sousa lm-sousa commented Sep 7, 2026

Copy link
Copy Markdown
Member

Note

omen-alpha responding on behalf of @lm-sousa

Problem

The repo's multi-weaver branch (weaver-instance refactor: removal of THREAD_LOCAL_WEAVER, Weaver engine threading through the joinpoints and node creation methods, CI fixes) had fallen behind master, and the whole weaver stack needs to move to lara-4 (@specs-feup/lara 4.0.0) to stay in lockstep with clava and lara-framework.

Solution

Rebased multi-weaver onto master (#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 class KadabraSpec (new src-spec source set); the build now uses LangSpec2/WeaverGen2 (LanguageSpecification/WeaverGenerator no 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(), *Impl methods, typed InsertPosition). A Gradle Sync task now refreshes Kadabra-JS/java-binaries on installDist.

JS (Kadabra-JS): sources moved src-apiapi, src-codecode (no transpilation step anymore — the package ships raw .ts); version 4.0.0 with @specs-feup/lara ^4.0.0; single noEmit tsconfig (TS7, erasableSyntaxOnly, verbatimModuleSyntax); jest→vitest via createWeaverVitestConfig from lara-4; eslint→oxlint/oxfmt; api/Joinpoints.ts regenerated with lara-build-interfaces; nightly CI bumped to Node 24/25.

Depends on the lara-4 branches of specs-feup/lara-framework and specs-feup/specs-java-libs (CI's branch-resolver resolves them by branch name).

Stack

mastermulti-weaver (#52) ← this PR (lara-4).

Migration notes / judgment calls

  • Weaver class rename: JavaWeaverJWeaver. The prefix is "J" (concrete classes are J<X>), and WeaverGen2 derives the weaver class/JSON name from prefix + "Weaver".
  • enum joinpoint dropped — it had no attributes, actions, or concrete class.
  • Undeclared subtypes moved: JFor, JWhile, JDoWhile, JForEach, JExpressionStatement moved to weaver.kadabra.subtypes (WeaverGen2 hard-errors on undeclared classes living in joinpoints/).
  • JGenericJoinPointJJoinpoint (now the editable base + generic fallback, absorbing the old AJavaWeaverJoinPoint); JOpAssignmentAux deleted in favor of JOpAssignment.
  • Boxed types: only line (INTEGER_BOXED), isNumeric and isSubtypeOf (BOOLEAN_BOXED) — everything else primitive, following clava's conventions.
  • api/Joinpoints.ts needs 3 hand-patches after every regeneration (builder dedup failure of self/equals for the joinpoint named this; overload parameter defaults; snippet setLine overloads) — documented in the migration commit message.
  • Pre-existing issue left as-is: KadabraJavaTypes.ts/nightly reference weaver.gui.KadabraLauncher, which does not exist anywhere.

Verification

  • gradle clean installDist (includes generateWeaver) and compileTestJava: BUILD SUCCESSFUL.
  • tsc clean, oxlint clean, vitest: 33/33 passed (same as the master baseline).

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).
@lm-sousa lm-sousa mentioned this pull request Sep 7, 2026
@lm-sousa
lm-sousa changed the base branch from master to multi-weaver September 7, 2026 18:30
@lm-sousa

lm-sousa commented Sep 7, 2026

Copy link
Copy Markdown
Member Author

Note

omen-alpha responding on behalf of @lm-sousa

The two typescript:S7739 ("Do not add then to a class") findings on the generated Kadabra-JS/api/Joinpoints.ts are false positives: then is part of the weaver's public LARA API (the then branch of an if joinpoint), so the "thenable" pattern cannot and should not be avoided. Suppressing it (NOSONAR) or changing the lang-spec generator is not an option — the generator is shared across all weavers and the LARA API is fixed. The Quality Gate failure on this check should be dismissed in SonarCloud rather than addressed in code. All other findings on this PR were addressed.

The lara-4 pull requests are stacked on multi-weaver; without this the
PR pushes run no CI at all.
@sonarqubecloud

sonarqubecloud Bot commented Sep 7, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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