mirror of
https://github.com/colbymchenry/codegraph.git
synced 2026-10-25 12:00:02 +08:00
fix(cfml): a <cfquery> or <cfscript> block that fails to parse no longer flags the file (#2843)
Both delegates in cfml-extractor.ts read a block with its own grammar
through a fresh TreeSitterExtractor and copied its errors onto the file.
That extractor warns "parse produced no symbols (tree has errors) - the
file is indexed but contributes nothing to the graph" when its tree has
errors and it found no symbols: true of the block, not of the file, and a
`<cfquery>` body never declares a symbol. So `codegraph init` printed the
warning and `codegraph status` counted the file among those whose symbols
are missing, though its component, methods and calls were indexed.
extractTagExpressions already drops the warning for the same reason.
Fix: the delegates record that warning as one naming the block and its
line, with code partial_parse, so `codegraph files --json` shows which
block failed while init and status, which key on parse_error, no longer
report the file. Other errors pass through unchanged.
The issue's own example SQL parses cleanly with the bundled cfquery
grammar, so the reporter's trigger was not reproduced; any query body the
grammar can't read (here `EQV` in a <cfif> condition) and any
statement-only <cfscript> block with a syntax error showed the same
warning.
Validation:
- New cfml-embedded-parse-warning.test.ts: the repro DAO keeps its class,
both methods and the call inside the failing query, and records one
partial_parse warning naming <cfquery> at line 6; a failing <cfscript>
block likewise; getIndexHealth lists neither file. All 3 fail on main's
extractor and pass. status-index-health.test.ts passes.
- On the repro, main prints the whole-file warning during init and status
says 1 file could not be parsed so its symbols are missing; with the fix
neither does.
- A/B vs main f406fe00: FW/1, BlogCFC, ColdBox, ContentBox, Preside and
CFWheels unchanged; in Wheels' vendor/wheels core (indexed as its own
project) one file changed, tests/html.cfm, whose <cfscript> block at line
8 fails: its warning now names that block. Nodes, edges and references
are identical in every repo. express and flask controls byte-identical.
- Index time, median of 4 interleaved runs, CPU with workers, main vs
fix: Preside 57.1 / 54.5 s, Wheels core 33.2 / 32.8 s. Within noise.
Fixes #2654
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
ef05970bb4
commit
6500a3782b
@@ -699,8 +699,32 @@ export class CfmlExtractor {
|
||||
}
|
||||
this.unresolvedReferences.push(ref);
|
||||
}
|
||||
for (const error of result.errors) {
|
||||
if (error.line) error.line += startLine;
|
||||
this.addBlockErrors(result.errors, scriptTag, 'cfscript', startLine);
|
||||
}
|
||||
|
||||
/**
|
||||
* Record a delegated block's errors as the file's (#2654). The block's own
|
||||
* extraction warns "parse produced no symbols … contributes nothing to the
|
||||
* graph" when its code has a syntax error and declares nothing — which a
|
||||
* `<cfquery>` body never does, so any SQL its grammar can't read earned it.
|
||||
* That is about the block, not the file, whose symbols come from the tag
|
||||
* walk: it is recorded as a block of the file that failed to parse, by its
|
||||
* tag and line, under its own code, so `init` and `status` don't report the
|
||||
* file as one that contributes nothing. Other errors pass through.
|
||||
*/
|
||||
private addBlockErrors(errors: ExtractionError[], tag: SyntaxNode, tagName: 'cfscript' | 'cfquery', lineOffset: number): void {
|
||||
for (const error of errors) {
|
||||
if (error.severity === 'warning' && error.code === 'parse_error') {
|
||||
const line = tag.startPosition.row + 1;
|
||||
this.errors.push({
|
||||
message: `${this.filePath}: <${tagName}> at line ${line} has a syntax error — the rest of the file is indexed, but calls inside that block may be missing from the graph`,
|
||||
line,
|
||||
severity: 'warning',
|
||||
code: 'partial_parse',
|
||||
});
|
||||
continue;
|
||||
}
|
||||
if (error.line) error.line += lineOffset;
|
||||
this.errors.push(error);
|
||||
}
|
||||
}
|
||||
@@ -733,10 +757,7 @@ export class CfmlExtractor {
|
||||
if ((!ref.fromNodeId || ref.fromNodeId === innerFileNodeId) && parentId) ref.fromNodeId = parentId;
|
||||
this.unresolvedReferences.push(ref);
|
||||
}
|
||||
for (const error of result.errors) {
|
||||
if (error.line) error.line += startLine;
|
||||
this.errors.push(error);
|
||||
}
|
||||
this.addBlockErrors(result.errors, queryTag, 'cfquery', startLine);
|
||||
}
|
||||
|
||||
/** Read a `cf_attribute`'s value by name from a tag node's direct `cf_attribute`/`cf_tag_attributes` children. */
|
||||
|
||||
Reference in New Issue
Block a user