fix(review): apply autofix feedback

- Use cause-neutral "worker-excluded" label in skip messages and tests now
  that worker error/exit paths share the same exclusion contract as
  singleton-timeout (correctness + maintainability reviewers).
- Add JSDoc to findSelfOrAncestorOfType{s} explaining the parent-walk
  short-circuit vs root-DFS fallback (maintainability reviewer).
This commit is contained in:
Gergo Magyar 2026-05-19 08:56:03 +01:00
parent 724bd2c415
commit 25af32c121
3 changed files with 11 additions and 6 deletions

View file

@ -124,6 +124,9 @@ function shouldEmitReadMember(memberNode: SyntaxNode): boolean {
}
}
/** Walks the parent chain from `node` (inclusive), returning the first node
* whose type matches, or null. Faster than `findNodeAtRange` when the caller
* already holds the anchor node — avoids re-scanning the tree from the root. */
function findSelfOrAncestorOfType(node: SyntaxNode | undefined, type: string): SyntaxNode | null {
if (node === undefined) return null;
let current: SyntaxNode | null = node;
@ -134,6 +137,8 @@ function findSelfOrAncestorOfType(node: SyntaxNode | undefined, type: string): S
return null;
}
/** Walks the parent chain from `node` (inclusive), returning the first node
* whose type is in the set, or null. Plural form of {@link findSelfOrAncestorOfType}. */
function findSelfOrAncestorOfTypes(
node: SyntaxNode | undefined,
types: readonly string[],

View file

@ -894,12 +894,12 @@ export const processParsing = async (
{
skippedPaths: err.fallbackExcludePaths,
},
'Skipping worker-timeout files in sequential fallback:',
'Skipping worker-excluded files in sequential fallback:',
);
reportProgress?.(
lastProgress,
files.length,
`Skipping ${files.length - fallbackFiles.length} worker-timeout file(s) in sequential fallback`,
`Skipping ${files.length - fallbackFiles.length} worker-excluded file(s) in sequential fallback`,
);
}
logger.warn({ message }, 'Worker pool parsing stopped; continuing with sequential parser:');

View file

@ -70,7 +70,7 @@ describe('processParsing worker fallback', () => {
);
expect(result).toBeNull();
expect(progressDetails).toContain('Skipping 1 worker-timeout file(s) in sequential fallback');
expect(progressDetails).toContain('Skipping 1 worker-excluded file(s) in sequential fallback');
expect(
graph.nodes.some((node) => node.label === 'Function' && node.properties.name === 'a'),
).toBe(true);
@ -106,7 +106,7 @@ describe('processParsing worker fallback', () => {
);
expect(result).toBeNull();
expect(progressDetails).toContain('Skipping 1 worker-timeout file(s) in sequential fallback');
expect(progressDetails).toContain('Skipping 1 worker-excluded file(s) in sequential fallback');
expect(
graph.nodes.some((node) => node.label === 'Function' && node.properties.name === 'a'),
).toBe(true);
@ -145,7 +145,7 @@ describe('processParsing worker fallback', () => {
);
expect(result).toBeNull();
expect(progressDetails).toContain('Skipping 1 worker-timeout file(s) in sequential fallback');
expect(progressDetails).toContain('Skipping 1 worker-excluded file(s) in sequential fallback');
expect(
graph.nodes.some((node) => node.label === 'Function' && node.properties.name === 'a'),
).toBe(true);
@ -185,7 +185,7 @@ describe('processParsing worker fallback', () => {
'Sequential fallback after worker issue: replacement worker failed',
);
expect(
progressDetails.some((d) => d.startsWith('Skipping ') && d.includes('worker-timeout file')),
progressDetails.some((d) => d.startsWith('Skipping ') && d.includes('worker-excluded file')),
).toBe(false);
expect(
graph.nodes.some((node) => node.label === 'Function' && node.properties.name === 'a'),