chore(transpiler): prune dead code from Phase 2 cleanup - #851
Conversation
The Phase 2 transpiler consolidation left a few unreached surfaces that this commit removes: - Drop `@xmldom/xmldom` dependency. Was added for the DOM walker that Phase 2d retired; zero `src/` consumers remain. - Delete the CTN-globals plugin API (`CtnGlobalEntry`, `CtnGlobalVarTuple`, `ConfigurationExtraVariablesProvider`). No caller wires up a provider — the API was forward-looking only. `emit/configuration.ts` loses the `extraVarsProvider` option and the `collectConfigGlobals` / `tupleTypeToIr` helpers along with it; `transpileToSt`'s `options` parameter disappears as a consequence. Rename the surviving constant's home from `helpers/ctn-globals.ts` to `helpers/base-types.ts` (the file was named after the API surface that just went away). - Delete `isOfType` and `getSubTypes` from `helpers/type-hierarchy.ts`. Defined as a forward-looking overload-resolution helper, never called; `getSubTypes` was the only `isOfType` consumer. The `TypeHierarchy` constant itself stays — `emit/value.ts` reads it. - Delete `computePouTransitionName` and `computePouActionName` from `helpers/text-helpers.ts`. SFC-only naming helpers; SFC support was dropped in Phase 2d. `tsc --build`, `eslint`, and `prettier --check` clean. Editor and web `st-transpiler/` trees remain byte-identical for Shared Surface Sync.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (10)
💤 Files with no reviewable changes (3)
WalkthroughThis PR removes the CTN globals provider infrastructure from the ST transpiler, consolidates PLC base type definitions into a dedicated module, and simplifies the public transpiler APIs by eliminating optional configuration parameters that previously allowed external injection of extra variables at transpile time. ChangesCTN Globals Removal and API Simplification
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Follow-up to #843. The Phase 2 transpiler consolidation left a few unreached surfaces — this PR removes them and aligns naming.
Changes
Drop
@xmldom/xmldomdep. Added for the DOM walker Phase 2d retired. Zerosrc/consumers remain (verified with grep). Removed frompackage.json,package-lock.jsonregenerated. 8 transitive packages drop with it.Delete the CTN-globals plugin API. Removes:
helpers/ctn-globals.tstypesCtnGlobalEntry,CtnGlobalVarTuple,ConfigurationExtraVariablesProviderindex.tsemit/configuration.ts: theextraVarsProvideroption inGenerateConfigurationOptions, thecollectConfigGlobalshelper, thetupleTypeToIrhelpertranspileToSt'soptionsparameter (was only everextraVarsProvider)The API was forward-looking — no caller in either repo wires up a provider. The surviving constant
PLC_BASE_TYPES(used byemit/pou-graphical.tsandemit/pou-textual.ts) moves tohelpers/base-types.tssincectn-globalswas named after the API that just disappeared.Delete
isOfType+getSubTypesfromhelpers/type-hierarchy.ts.getSubTypeswas the onlyisOfTypeconsumer, andgetSubTypesitself has no callers. Both were placeholders for an overload-resolution path that never materialised.TypeHierarchyconstant stays —emit/value.tsstill uses it.Delete
computePouTransitionName+computePouActionNamefromhelpers/text-helpers.ts. SFC-only naming helpers; SFC support was dropped in Phase 2d (from-schema.tsthrows at projection time).Diff
-218 / +56lines on this side, matched on the web side.Verification
npx tsc --noEmitclean (modulo pre-existingstrucppmodule errors that exist ondevelopmenttoo).npx eslint src/backend/shared/transpilers/st-transpiler/— 0 errors.npx prettier --check src/backend/shared/transpilers/st-transpiler/clean.st-transpiler/byte-identical to web's. Paired with openplc-web equivalent:chore/transpiler-dead-code-cleanup.What this PR does NOT touch
compiler-adapter.ts'sladderToXml/fbdToXmlconsumers — those still feed the user-visible "Export Project to XML" feature.compilerFetchinweb-compiler-platform-port.ts— still used by/compile-arduino.pou-emission-order.ts's textual scanning — alive for ST/IL bodies.BlockIO/BlockInfos/BlockResolutionexports — they're return-type shapes forresolveBlockType, kept for API discoverability.__tests__/{pipeline,library-build-orchestrator}.test.tsthat referencetranspileXmlToSt(renamed totranspileToStin feat(compile): embed JSON→ST transpiler, retire xml2st binary #843). Those need a separate fix.🤖 Generated with Claude Code
Summary by CodeRabbit
Refactor
Chores