feat(lang): CFML tag-dialect .cfc routing + embedded <cfscript> defs - #1412
feat(lang): CFML tag-dialect .cfc routing + embedded <cfscript> defs#1412allanoepping wants to merge 1 commit into
Conversation
|
Thanks for opening this — it has been seen, and it is queued. This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence. Current review status: working through a backlog. What that means for this PR, concretely:
Things that will genuinely speed it up whenever review does happen:
If this fixes a bug, a reproduction we can run is worth more than a description of the symptom. Thanks for contributing, and sorry in advance for the wait. |
Two extraction fixes for legacy tag-based CFML/ColdFusion, where the
vendored cfmleditor grammar (Lucee-tuned, script-first) leaves most
real-world components unextracted.
1. .cfc dialect disambiguation (cbm_disambiguate_cfc)
The extension table maps .cfc -> cfscript unconditionally, but legacy
codebases are predominantly tag-based (<cfcomponent>). Content-sniff the
file head, mirroring cbm_disambiguate_cls/inc: <cfcomponent>/<cffunction>
route to the cfml tag grammar; a leading <cfscript>-wrapped "component {}"
or a plain script component route to cfscript; leading <!--- ---> comments
are skipped.
2. Embedded <cfscript> definition extraction (cbm_extract_embedded_defs)
The HTML-derived cfml grammar keeps <cfscript> bodies as opaque
cf_script_content, so script functions inside tag components were never
extracted. Re-parse cf_script_tag -> cf_script_content slices with the
cfscript grammar (reusing the embedded-imports machinery) and walk them
for definitions via a new cbm_extract_definitions_body() that skips the
Module node. Block-relative line numbers are shifted by the block's start
row; CBMDefinition carries only line positions, so a constant offset is a
complete remap. Definitions only (calls/usages would need byte remapping),
so existing edges cannot be corrupted. As a bonus, functions are recovered
even when a <cfsetting> void-tag ERROR cascade damages the surrounding tree.
The opt-in is an extract_definitions flag on CBMEmbeddedLangSpec (carried by
CFML's embedded_imports entry), not a new CBMLangSpec field -- the latter
would trip -Wmissing-field-initializers across every language row under
clang -Werror.
Tests: extract_cfml_embedded_cfscript_defs (extraction + line remap) and
eight lang_cfc_* disambiguation cases. Verified on a ~700-file legacy CFML
codebase: parse timeouts 4->0, api.cfc 0->62 functions, +1,532 function
nodes overall, with exact line numbers.
Signed-off-by: Allan Oepping <allan@intellipay.com>
0ff692d to
aeac05c
Compare
|
The Windows red check ( Two Windows-runner environmental failures surface there:
Everything relevant is green, including the full suite under clang-TSAN on Linux + macOS (which exercises the new |
Summary
Two extraction fixes for legacy tag-based CFML / ColdFusion. The vendored
cfmleditor/tree-sitter-cfmlgrammar is Lucee-tuned and script-first, so onolder codebases (predominantly
<cfcomponent>tag components with<cfscript>bodies) most functions were never extracted. Both fixes mirror existing
conventions in the codebase.
1.
.cfcdialect disambiguation —cbm_disambiguate_cfc()The extension table maps
.cfc → cfscriptunconditionally, but a.cfcmay bescript-dialect (
component { … }) or tag-dialect (<cfcomponent> … </cfcomponent>).New content-sniff (same shape as
cbm_disambiguate_cls/inc):<cfcomponent>or a bare top-level<cffunction>→CBM_LANG_CFML(tag grammar)<cfscript>-wrappedcomponent {}, or a plain script component →CBM_LANG_CFSCRIPT<!--- --->comments are skipped before deciding2. Embedded
<cfscript>definitions —cbm_extract_embedded_defs()The HTML-derived
cfmlgrammar keeps<cfscript>bodies as an opaquecf_script_contenttoken, so script functions inside tag components produced nofunction_declarationnodes. This re-parses eachcf_script_tag → cf_script_contentslice with the
cfscriptgrammar (reusing theembedded_importsmachinery) andwalks it for definitions via a new
cbm_extract_definitions_body()that skips theModule node. Block-relative line numbers are shifted by the block's start row —
CBMDefinitioncarries only line positions, so a constant offset is a completeremap. Definitions only (calls/usages would need byte remapping), so existing
edges cannot be corrupted. Bonus: functions are recovered even when a
<cfsetting>void-tag ERROR cascade damages the surrounding tree.
Adds an
embedded_defsfield toCBMLangSpec, wired only toCBM_LANG_CFML.Tests
extract_cfml_embedded_cfscript_defs— script funcs inside<cfscript>in a tagcomponent extract with correct (remapped) line numbers, alongside a
<cffunction>.lang_cfc_*— tag / script /<cfscript>-wrapped / bare<cffunction>/leading-comment / read-fail routing.
scripts/test.sh --suites "language extraction grammar_regression"→ 497 passed, 0 failed.Real-world impact
Indexing a ~700-file legacy CFML app (156/176
.cfcare tag-based):api.cfc0 → 62 functions,api-a.cfc0 → 48Notes
Not addressed here:
<cfsetting>(and other void CF tags) still emit tree-sitterERROR nodes in the
cfmlgrammar — cosmetic now that functions are recovered, buta genuine grammar issue that belongs in
cfmleditor/tree-sitter-cfml(regeneratingparser.cfromgrammar.js).