@step-forge/step-forge 0.0.25-alpha.3 → 0.0.25-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{analyzer-gYyAKIpM.js → analyzer-5H699Eg4.js} +106 -16
- package/dist/analyzer-5H699Eg4.js.map +1 -0
- package/dist/{analyzer-DIZPMxzN.cjs → analyzer-DRudicCk.cjs} +106 -16
- package/dist/analyzer-DRudicCk.cjs.map +1 -0
- package/dist/{analyzer-DnfK54Dw.js → analyzer-NsNpSFox.js} +106 -16
- package/dist/analyzer-NsNpSFox.js.map +1 -0
- package/dist/analyzer-cli.js +1 -1
- package/dist/analyzer.js +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/step-forge.cjs +1 -1
- package/dist/step-forge.js +1 -1
- package/package.json +1 -1
- package/dist/analyzer-DIZPMxzN.cjs.map +0 -1
- package/dist/analyzer-DnfK54Dw.js.map +0 -1
- package/dist/analyzer-gYyAKIpM.js.map +0 -1
|
@@ -4,6 +4,7 @@ import ts from "typescript";
|
|
|
4
4
|
import * as fs from "node:fs";
|
|
5
5
|
import { AstBuilder, GherkinClassicTokenMatcher, Parser } from "@cucumber/gherkin";
|
|
6
6
|
import * as messages from "@cucumber/messages";
|
|
7
|
+
import { CucumberExpression, ParameterType, ParameterTypeRegistry } from "@cucumber/cucumber-expressions";
|
|
7
8
|
//#region src/globFiles.ts
|
|
8
9
|
/** Glob metacharacters. A pattern with none of these is a literal path. */
|
|
9
10
|
const MAGIC = /[*?[\]{}!()]/;
|
|
@@ -43,6 +44,21 @@ const BUILDER_NAMES = {
|
|
|
43
44
|
whenBuilder: "when",
|
|
44
45
|
thenBuilder: "then"
|
|
45
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* Built-in parsers exported by the library, mapped to the cucumber-expression
|
|
49
|
+
* placeholder they register. A step's `.parsers([...])` drives which `{name}`
|
|
50
|
+
* each variable becomes; without this the extractor defaulted every variable to
|
|
51
|
+
* `{string}`, so `the deposit amount is {int}` was recorded as `{string}` and a
|
|
52
|
+
* plain number like `100` looked unmatched. Custom parsers are resolved from
|
|
53
|
+
* their `name` property (see {@link resolveCustomParserName}); anything we can't
|
|
54
|
+
* resolve falls back to `string`.
|
|
55
|
+
*/
|
|
56
|
+
const BUILTIN_PARSER_PLACEHOLDERS = {
|
|
57
|
+
intParser: "int",
|
|
58
|
+
numberParser: "float",
|
|
59
|
+
stringParser: "string",
|
|
60
|
+
booleanParser: "boolean"
|
|
61
|
+
};
|
|
46
62
|
function extractStepDefinitions(filePaths, tsConfigPath) {
|
|
47
63
|
const fast = extractWithSources(filePaths.map(parseSourceFile).filter((s) => s !== null), null);
|
|
48
64
|
if (!fast.needsChecker) return fast.results;
|
|
@@ -101,6 +117,7 @@ function extractFromSourceFile(sourceFile, ctx) {
|
|
|
101
117
|
function extractFromRegisterCall(registerCall, sourceFile, ctx) {
|
|
102
118
|
const chain = collectCallChain(registerCall);
|
|
103
119
|
let stepType = null;
|
|
120
|
+
let statementCall = null;
|
|
104
121
|
let expression = null;
|
|
105
122
|
let dependencies = {
|
|
106
123
|
given: {},
|
|
@@ -108,6 +125,7 @@ function extractFromRegisterCall(registerCall, sourceFile, ctx) {
|
|
|
108
125
|
then: {}
|
|
109
126
|
};
|
|
110
127
|
let produces = [];
|
|
128
|
+
let placeholders = null;
|
|
111
129
|
for (const link of chain) {
|
|
112
130
|
const name = getCallName(link);
|
|
113
131
|
if (!name) continue;
|
|
@@ -120,8 +138,12 @@ function extractFromRegisterCall(registerCall, sourceFile, ctx) {
|
|
|
120
138
|
dependencies = extractDependencies(link);
|
|
121
139
|
continue;
|
|
122
140
|
}
|
|
141
|
+
if (name === "parsers") {
|
|
142
|
+
placeholders = resolveParserPlaceholders(link, sourceFile);
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
123
145
|
if (name === "statement") {
|
|
124
|
-
|
|
146
|
+
statementCall = link;
|
|
125
147
|
continue;
|
|
126
148
|
}
|
|
127
149
|
if (BUILDER_NAMES[name]) {
|
|
@@ -129,6 +151,7 @@ function extractFromRegisterCall(registerCall, sourceFile, ctx) {
|
|
|
129
151
|
continue;
|
|
130
152
|
}
|
|
131
153
|
}
|
|
154
|
+
if (statementCall) expression = extractExpression(statementCall, placeholders);
|
|
132
155
|
if (!stepType || !expression) {
|
|
133
156
|
const reExport = resolveReExportedCall(chain, ctx);
|
|
134
157
|
if (reExport) {
|
|
@@ -168,14 +191,14 @@ function getCallName(call) {
|
|
|
168
191
|
if (ts.isIdentifier(expr)) return expr.text;
|
|
169
192
|
return null;
|
|
170
193
|
}
|
|
171
|
-
function extractExpression(statementCall) {
|
|
194
|
+
function extractExpression(statementCall, placeholders) {
|
|
172
195
|
const arg = statementCall.arguments[0];
|
|
173
196
|
if (!arg) return null;
|
|
174
197
|
if (ts.isStringLiteral(arg)) return arg.text;
|
|
175
|
-
if (ts.isArrowFunction(arg)) return extractExpressionFromArrowFunction(arg);
|
|
198
|
+
if (ts.isArrowFunction(arg)) return extractExpressionFromArrowFunction(arg, placeholders);
|
|
176
199
|
return null;
|
|
177
200
|
}
|
|
178
|
-
function extractExpressionFromArrowFunction(fn) {
|
|
201
|
+
function extractExpressionFromArrowFunction(fn, placeholders) {
|
|
179
202
|
const params = fn.parameters.map((p) => p.name.getText());
|
|
180
203
|
let body = fn.body;
|
|
181
204
|
if (ts.isBlock(body)) {
|
|
@@ -183,19 +206,63 @@ function extractExpressionFromArrowFunction(fn) {
|
|
|
183
206
|
if (returnStmt?.expression) body = returnStmt.expression;
|
|
184
207
|
else return null;
|
|
185
208
|
}
|
|
186
|
-
if (ts.isTemplateExpression(body)) return reconstructExpressionFromTemplate(body, params);
|
|
209
|
+
if (ts.isTemplateExpression(body)) return reconstructExpressionFromTemplate(body, params, placeholders);
|
|
187
210
|
if (ts.isNoSubstitutionTemplateLiteral(body)) return body.text;
|
|
188
211
|
return null;
|
|
189
212
|
}
|
|
190
|
-
function reconstructExpressionFromTemplate(template, paramNames) {
|
|
213
|
+
function reconstructExpressionFromTemplate(template, paramNames, placeholders) {
|
|
191
214
|
let result = template.head.text;
|
|
192
215
|
for (const span of template.templateSpans) {
|
|
193
|
-
|
|
194
|
-
|
|
216
|
+
let placeholder = "string";
|
|
217
|
+
if (ts.isIdentifier(span.expression) && paramNames.includes(span.expression.text)) {
|
|
218
|
+
const index = paramNames.indexOf(span.expression.text);
|
|
219
|
+
placeholder = placeholders?.[index] ?? "string";
|
|
220
|
+
}
|
|
221
|
+
result += `{${placeholder}}`;
|
|
195
222
|
result += span.literal.text;
|
|
196
223
|
}
|
|
197
224
|
return result;
|
|
198
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* Resolve `.parsers([intParser, colorParser])` to the placeholder name for each
|
|
228
|
+
* variable, positionally. Built-ins map via {@link BUILTIN_PARSER_PLACEHOLDERS};
|
|
229
|
+
* a custom parser is resolved from its `name` property in the same source file;
|
|
230
|
+
* anything unresolved defaults to `string`, matching the runtime default parser.
|
|
231
|
+
*/
|
|
232
|
+
function resolveParserPlaceholders(parsersCall, sourceFile) {
|
|
233
|
+
const arg = parsersCall.arguments[0];
|
|
234
|
+
if (!arg || !ts.isArrayLiteralExpression(arg)) return null;
|
|
235
|
+
return arg.elements.map((element) => {
|
|
236
|
+
if (ts.isIdentifier(element)) {
|
|
237
|
+
const builtin = BUILTIN_PARSER_PLACEHOLDERS[element.text];
|
|
238
|
+
if (builtin) return builtin;
|
|
239
|
+
const custom = resolveCustomParserName(element.text, sourceFile);
|
|
240
|
+
if (custom) return custom;
|
|
241
|
+
}
|
|
242
|
+
return "string";
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Find `const <identifier> = { name: "...", ... }` in `sourceFile` and return
|
|
247
|
+
* its `name` — the cucumber placeholder a custom `Parser` registers. Scoped to
|
|
248
|
+
* the file, so a parser imported from elsewhere won't resolve (it falls back to
|
|
249
|
+
* `string`); the common in-file `const colorParser: Parser<Color> = {...}` does.
|
|
250
|
+
*/
|
|
251
|
+
function resolveCustomParserName(identifier, sourceFile) {
|
|
252
|
+
let found = null;
|
|
253
|
+
const visit = (node) => {
|
|
254
|
+
if (found) return;
|
|
255
|
+
if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && node.name.text === identifier && node.initializer && ts.isObjectLiteralExpression(node.initializer)) {
|
|
256
|
+
for (const prop of node.initializer.properties) if (ts.isPropertyAssignment(prop) && ts.isIdentifier(prop.name) && prop.name.text === "name" && ts.isStringLiteralLike(prop.initializer)) {
|
|
257
|
+
found = prop.initializer.text;
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
ts.forEachChild(node, visit);
|
|
262
|
+
};
|
|
263
|
+
visit(sourceFile);
|
|
264
|
+
return found;
|
|
265
|
+
}
|
|
199
266
|
function extractDependencies(depsCall) {
|
|
200
267
|
const deps = {
|
|
201
268
|
given: {},
|
|
@@ -269,7 +336,7 @@ function resolveReExportedCall(chain, ctx) {
|
|
|
269
336
|
if (ts.isCallExpression(callExpr)) {
|
|
270
337
|
const callee = callExpr.expression;
|
|
271
338
|
if (ts.isIdentifier(callee) && BUILDER_NAMES[callee.text]) {
|
|
272
|
-
const expression = extractExpression(lastCall);
|
|
339
|
+
const expression = extractExpression(lastCall, null);
|
|
273
340
|
return {
|
|
274
341
|
stepType: BUILDER_NAMES[callee.text],
|
|
275
342
|
expression
|
|
@@ -401,13 +468,36 @@ function substituteExampleValues(text, substitution) {
|
|
|
401
468
|
}
|
|
402
469
|
//#endregion
|
|
403
470
|
//#region src/analyzer/stepMatcher.ts
|
|
471
|
+
/** `{name}` tokens in a cucumber expression (empty name is the anonymous `{}`). */
|
|
472
|
+
const PARAM_TOKEN = /\{([^}]*)\}/g;
|
|
473
|
+
/**
|
|
474
|
+
* Compile each definition's cucumber expression with the **same** engine the
|
|
475
|
+
* runtime uses (`@cucumber/cucumber-expressions`), so the analyzer and the
|
|
476
|
+
* runtime agree on what a step matches.
|
|
477
|
+
*
|
|
478
|
+
* A hand-rolled `{param}` → `(.+)` regex used to stand in here, but it treated
|
|
479
|
+
* cucumber-expression alternative (`a/b`) and optional (`text(s)`) syntax as
|
|
480
|
+
* literal characters — so any step definition using them (e.g.
|
|
481
|
+
* `there should be {int} error/errors`) never matched, and every such step was
|
|
482
|
+
* wrongly reported as an undefined step regardless of the real state.
|
|
483
|
+
*
|
|
484
|
+
* Built-in placeholders (`{int}`, `{float}`, `{string}`, `{word}`) keep their
|
|
485
|
+
* real, strict regexes so the analyzer disambiguates the way the runtime does
|
|
486
|
+
* (e.g. `no` isn't an `{int}`). The analyzer has only the expression string, not
|
|
487
|
+
* a custom parser's regexp, so each custom `{name}` is registered as a permissive
|
|
488
|
+
* parameter type (any value) — lenient about the value's exact shape, but still
|
|
489
|
+
* anchored by the surrounding literal text.
|
|
490
|
+
*/
|
|
404
491
|
function compileDefinitions(definitions) {
|
|
405
492
|
const compiled = [];
|
|
406
493
|
for (const def of definitions) try {
|
|
407
|
-
const
|
|
408
|
-
const
|
|
494
|
+
const registry = new ParameterTypeRegistry();
|
|
495
|
+
for (const [, name] of def.expression.matchAll(PARAM_TOKEN)) {
|
|
496
|
+
if (!name || registry.lookupByTypeName(name)) continue;
|
|
497
|
+
registry.defineParameterType(new ParameterType(name, /.+/, null, (value) => value));
|
|
498
|
+
}
|
|
409
499
|
compiled.push({
|
|
410
|
-
|
|
500
|
+
expression: new CucumberExpression(def.expression, registry),
|
|
411
501
|
definition: def
|
|
412
502
|
});
|
|
413
503
|
} catch {}
|
|
@@ -433,13 +523,13 @@ function findMatches(text, effectiveKeyword, compiled) {
|
|
|
433
523
|
Then: "then"
|
|
434
524
|
}[effectiveKeyword];
|
|
435
525
|
const typedMatches = [];
|
|
436
|
-
for (const {
|
|
526
|
+
for (const { expression, definition } of compiled) {
|
|
437
527
|
if (definition.stepType !== expectedStepType) continue;
|
|
438
|
-
if (
|
|
528
|
+
if (expression.match(text) != null) typedMatches.push(definition);
|
|
439
529
|
}
|
|
440
530
|
if (typedMatches.length > 0) return typedMatches;
|
|
441
531
|
const fallbackMatches = [];
|
|
442
|
-
for (const {
|
|
532
|
+
for (const { expression, definition } of compiled) if (expression.match(text) != null) fallbackMatches.push(definition);
|
|
443
533
|
return fallbackMatches;
|
|
444
534
|
}
|
|
445
535
|
//#endregion
|
|
@@ -550,4 +640,4 @@ async function analyze(config, options) {
|
|
|
550
640
|
//#endregion
|
|
551
641
|
export { parseFeatureContent as a, matchScenarioSteps as i, defaultRules as n, parseFeatureFiles as o, findMatchingDefinitions as r, extractStepDefinitions as s, analyze as t };
|
|
552
642
|
|
|
553
|
-
//# sourceMappingURL=analyzer-
|
|
643
|
+
//# sourceMappingURL=analyzer-5H699Eg4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyzer-5H699Eg4.js","names":[],"sources":["../../src/globFiles.ts","../../src/analyzer/stepExtractor.ts","../../src/analyzer/gherkinParser.ts","../../src/analyzer/stepMatcher.ts","../../src/analyzer/rules/ambiguousStepRule.ts","../../src/analyzer/rules/dependencyRule.ts","../../src/analyzer/rules/undefinedStepRule.ts","../../src/analyzer/rules/index.ts","../../src/analyzer/index.ts"],"sourcesContent":["import { glob } from \"node:fs/promises\";\nimport { stat } from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\n/** Glob metacharacters. A pattern with none of these is a literal path. */\nconst MAGIC = /[*?[\\]{}!()]/;\n\nasync function isFile(p: string): Promise<boolean> {\n try {\n return (await stat(p)).isFile();\n } catch {\n return false;\n }\n}\n\n/**\n * Resolve glob patterns to a de-duplicated list of absolute file paths, with one\n * important portability guarantee: a **literal absolute path** (no glob magic)\n * is returned directly if it exists, without being handed to `glob()`.\n *\n * This exists because `node:fs`'s `glob` diverges between runtimes — Node\n * matches an absolute-path pattern, Bun returns nothing for one. Rather than\n * depend on that behaviour, we only ever glob relative patterns (against `cwd`)\n * and short-circuit concrete absolute paths ourselves, so callers get identical\n * results under Node and Bun.\n */\nexport async function globFiles(\n patterns: string[],\n cwd: string = process.cwd()\n): Promise<string[]> {\n const files = new Set<string>();\n for (const pattern of patterns) {\n if (path.isAbsolute(pattern) && !MAGIC.test(pattern)) {\n if (await isFile(pattern)) files.add(pattern);\n continue;\n }\n for await (const match of glob(pattern, { cwd })) {\n files.add(path.resolve(cwd, match));\n }\n }\n return [...files];\n}\n","import ts from \"typescript\";\nimport { StepDefinitionMeta } from \"./types.js\";\n\ntype StepType = \"given\" | \"when\" | \"then\";\n\nconst BUILDER_NAMES: Record<string, StepType> = {\n givenBuilder: \"given\",\n whenBuilder: \"when\",\n thenBuilder: \"then\",\n};\n\n/**\n * Built-in parsers exported by the library, mapped to the cucumber-expression\n * placeholder they register. A step's `.parsers([...])` drives which `{name}`\n * each variable becomes; without this the extractor defaulted every variable to\n * `{string}`, so `the deposit amount is {int}` was recorded as `{string}` and a\n * plain number like `100` looked unmatched. Custom parsers are resolved from\n * their `name` property (see {@link resolveCustomParserName}); anything we can't\n * resolve falls back to `string`.\n */\nconst BUILTIN_PARSER_PLACEHOLDERS: Record<string, string> = {\n intParser: \"int\",\n numberParser: \"float\",\n stringParser: \"string\",\n booleanParser: \"boolean\",\n};\n\n/**\n * Threaded through the AST walk. `checker` is `null` on the parse-only fast\n * path; a step that genuinely needs type information sets `needsChecker`, which\n * triggers a one-time retry with a real type-checked `Program`.\n */\ninterface ExtractCtx {\n checker: ts.TypeChecker | null;\n needsChecker: boolean;\n}\n\nexport function extractStepDefinitions(\n filePaths: string[],\n tsConfigPath?: string\n): StepDefinitionMeta[] {\n // Fast path: parse each file with `createSourceFile` (tokenize + parse only,\n // no type resolution — ~1ms/file) and walk the AST. Building a full\n // type-checked `Program` loads `lib.*.d.ts` and resolves every import (~150ms)\n // and is only needed for two uncommon shapes: a `.step()` whose return isn't a\n // plain object literal, or the re-exported-builder pattern. Those set\n // `needsChecker`, and we retry once with a real Program below.\n const sources = filePaths\n .map(parseSourceFile)\n .filter((s): s is ts.SourceFile => s !== null);\n const fast = extractWithSources(sources, null);\n if (!fast.needsChecker) return fast.results;\n\n // Slow path: some step needs type information. Build the program once and\n // re-extract from *its* source files — the checker only understands nodes it\n // bound itself, so the parse-only ASTs above can't be reused here.\n const program = ts.createProgram(\n filePaths,\n resolveCompilerOptions(tsConfigPath)\n );\n const checker = program.getTypeChecker();\n const checkedSources = filePaths\n .map(fp => program.getSourceFile(fp))\n .filter((s): s is ts.SourceFile => s !== undefined);\n return extractWithSources(checkedSources, checker).results;\n}\n\n/** Parse a single file into an AST with no type resolution. */\nfunction parseSourceFile(filePath: string): ts.SourceFile | null {\n const text = ts.sys.readFile(filePath);\n if (text === undefined) return null;\n const scriptKind = filePath.endsWith(\".tsx\")\n ? ts.ScriptKind.TSX\n : ts.ScriptKind.TS;\n // setParentNodes: true — the extractor relies on `.getText()`/`.getStart()`,\n // which walk parent pointers up to the SourceFile.\n return ts.createSourceFile(\n filePath,\n text,\n ts.ScriptTarget.ESNext,\n true,\n scriptKind\n );\n}\n\n/** Resolve compiler options from tsconfig (fallback to sane defaults). */\nfunction resolveCompilerOptions(tsConfigPath?: string): ts.CompilerOptions {\n const configPath =\n tsConfigPath ?? ts.findConfigFile(process.cwd(), ts.sys.fileExists);\n let compilerOptions: ts.CompilerOptions = {\n target: ts.ScriptTarget.ESNext,\n module: ts.ModuleKind.ESNext,\n moduleResolution: ts.ModuleResolutionKind.Node10,\n strict: true,\n esModuleInterop: true,\n };\n\n if (configPath) {\n const configFile = ts.readConfigFile(configPath, ts.sys.readFile);\n if (!configFile.error) {\n const parsed = ts.parseJsonConfigFileContent(\n configFile.config,\n ts.sys,\n configPath.replace(/[/\\\\][^/\\\\]+$/, \"\")\n );\n compilerOptions = parsed.options;\n }\n }\n\n // Ensure noEmit so we don't write files\n compilerOptions.noEmit = true;\n return compilerOptions;\n}\n\nfunction extractWithSources(\n sources: ts.SourceFile[],\n checker: ts.TypeChecker | null\n): { results: StepDefinitionMeta[]; needsChecker: boolean } {\n const ctx: ExtractCtx = { checker, needsChecker: false };\n const results: StepDefinitionMeta[] = [];\n for (const sourceFile of sources) {\n results.push(...extractFromSourceFile(sourceFile, ctx));\n }\n return { results, needsChecker: ctx.needsChecker };\n}\n\nfunction extractFromSourceFile(\n sourceFile: ts.SourceFile,\n ctx: ExtractCtx\n): StepDefinitionMeta[] {\n const results: StepDefinitionMeta[] = [];\n\n function visit(node: ts.Node) {\n // The chain now terminates at `.step(...)`, which is the registration\n // point (there is no `.register()` anymore).\n if (\n ts.isCallExpression(node) &&\n ts.isPropertyAccessExpression(node.expression) &&\n node.expression.name.text === \"step\"\n ) {\n const meta = extractFromRegisterCall(node, sourceFile, ctx);\n if (meta) {\n results.push(meta);\n }\n }\n ts.forEachChild(node, visit);\n }\n\n visit(sourceFile);\n return results;\n}\n\nfunction extractFromRegisterCall(\n registerCall: ts.CallExpression,\n sourceFile: ts.SourceFile,\n ctx: ExtractCtx\n): StepDefinitionMeta | null {\n // Walk backwards through the method chain to find all parts\n // Pattern: builder().statement(...).dependencies?(...).step(...).register()\n // Or: Variable(\"...\").dependencies?(...).step(...).register()\n\n const chain = collectCallChain(registerCall);\n\n let stepType: StepType | null = null;\n let statementCall: ts.CallExpression | null = null;\n let expression: string | null = null;\n let dependencies: StepDefinitionMeta[\"dependencies\"] = {\n given: {},\n when: {},\n then: {},\n };\n let produces: string[] = [];\n // Placeholder names per variable, from `.parsers([...])` (positional).\n let placeholders: string[] | null = null;\n\n for (const link of chain) {\n const name = getCallName(link);\n if (!name) continue;\n\n if (name === \"register\") {\n // Already at register, continue\n continue;\n }\n\n if (name === \"step\") {\n produces = extractProducedKeys(link, ctx);\n continue;\n }\n\n if (name === \"dependencies\") {\n dependencies = extractDependencies(link);\n continue;\n }\n\n if (name === \"parsers\") {\n placeholders = resolveParserPlaceholders(link, sourceFile);\n continue;\n }\n\n if (name === \"statement\") {\n statementCall = link;\n // Try to find the builder type by continuing up the chain\n continue;\n }\n\n // Check if this is a builder call like givenBuilder()\n if (BUILDER_NAMES[name]) {\n stepType = BUILDER_NAMES[name];\n continue;\n }\n }\n\n // Build the expression after the whole chain is seen, so `.parsers([...])` —\n // which the chain visits before `.statement(...)` here, but conceptually\n // annotates it — determines each variable's placeholder.\n if (statementCall)\n expression = extractExpression(statementCall, placeholders);\n\n // If we didn't find the builder or expression in the chain, try the \"re-exported\" pattern:\n // const Given = givenBuilder<T>().statement;\n // Given(\"foo\").step(...).register()\n if (!stepType || !expression) {\n const reExport = resolveReExportedCall(chain, ctx);\n if (reExport) {\n if (!stepType) stepType = reExport.stepType;\n if (!expression) expression = reExport.expression;\n }\n }\n\n if (!stepType || !expression) {\n return null;\n }\n\n const line =\n sourceFile.getLineAndCharacterOfPosition(registerCall.getStart()).line + 1;\n\n return {\n stepType,\n expression,\n dependencies,\n produces,\n sourceFile: sourceFile.fileName,\n line,\n };\n}\n\n/**\n * Collect all call expressions in the method chain, from register() back to the origin.\n */\nfunction collectCallChain(call: ts.CallExpression): ts.CallExpression[] {\n const chain: ts.CallExpression[] = [call];\n let current: ts.Expression = call.expression;\n\n while (true) {\n // Walk through PropertyAccessExpression to find the next call\n if (ts.isPropertyAccessExpression(current)) {\n current = current.expression;\n }\n\n if (ts.isCallExpression(current)) {\n chain.push(current);\n current = current.expression;\n } else {\n break;\n }\n }\n\n return chain;\n}\n\nfunction getCallName(call: ts.CallExpression): string | null {\n const expr = call.expression;\n\n // .method() pattern\n if (ts.isPropertyAccessExpression(expr)) {\n return expr.name.text;\n }\n\n // direct call: functionName()\n if (ts.isIdentifier(expr)) {\n return expr.text;\n }\n\n return null;\n}\n\nfunction extractExpression(\n statementCall: ts.CallExpression,\n placeholders: string[] | null\n): string | null {\n const arg = statementCall.arguments[0];\n if (!arg) return null;\n\n // String literal: .statement(\"a user\")\n if (ts.isStringLiteral(arg)) {\n return arg.text;\n }\n\n // Arrow function with template literal: .statement((name: string) => `a user named ${name}`)\n if (ts.isArrowFunction(arg)) {\n return extractExpressionFromArrowFunction(arg, placeholders);\n }\n\n return null;\n}\n\nfunction extractExpressionFromArrowFunction(\n fn: ts.ArrowFunction,\n placeholders: string[] | null\n): string | null {\n const params = fn.parameters.map(p => p.name.getText());\n\n // The body should be a template expression or string literal\n let body = fn.body;\n\n // If wrapped in a block with a return, unwrap\n if (ts.isBlock(body)) {\n const returnStmt = body.statements.find(ts.isReturnStatement);\n if (returnStmt?.expression) {\n body = returnStmt.expression;\n } else {\n return null;\n }\n }\n\n if (ts.isTemplateExpression(body)) {\n return reconstructExpressionFromTemplate(body, params, placeholders);\n }\n\n if (ts.isNoSubstitutionTemplateLiteral(body)) {\n return body.text;\n }\n\n return null;\n}\n\nfunction reconstructExpressionFromTemplate(\n template: ts.TemplateExpression,\n paramNames: string[],\n placeholders: string[] | null\n): string {\n let result = template.head.text;\n\n for (const span of template.templateSpans) {\n // A variable interpolation becomes its declared parser placeholder (default\n // `{string}`); a non-variable interpolation falls back to `{string}`.\n let placeholder = \"string\";\n if (\n ts.isIdentifier(span.expression) &&\n paramNames.includes(span.expression.text)\n ) {\n const index = paramNames.indexOf(span.expression.text);\n placeholder = placeholders?.[index] ?? \"string\";\n }\n result += `{${placeholder}}`;\n result += span.literal.text;\n }\n\n return result;\n}\n\n/**\n * Resolve `.parsers([intParser, colorParser])` to the placeholder name for each\n * variable, positionally. Built-ins map via {@link BUILTIN_PARSER_PLACEHOLDERS};\n * a custom parser is resolved from its `name` property in the same source file;\n * anything unresolved defaults to `string`, matching the runtime default parser.\n */\nfunction resolveParserPlaceholders(\n parsersCall: ts.CallExpression,\n sourceFile: ts.SourceFile\n): string[] | null {\n const arg = parsersCall.arguments[0];\n if (!arg || !ts.isArrayLiteralExpression(arg)) return null;\n return arg.elements.map(element => {\n if (ts.isIdentifier(element)) {\n const builtin = BUILTIN_PARSER_PLACEHOLDERS[element.text];\n if (builtin) return builtin;\n const custom = resolveCustomParserName(element.text, sourceFile);\n if (custom) return custom;\n }\n return \"string\";\n });\n}\n\n/**\n * Find `const <identifier> = { name: \"...\", ... }` in `sourceFile` and return\n * its `name` — the cucumber placeholder a custom `Parser` registers. Scoped to\n * the file, so a parser imported from elsewhere won't resolve (it falls back to\n * `string`); the common in-file `const colorParser: Parser<Color> = {...}` does.\n */\nfunction resolveCustomParserName(\n identifier: string,\n sourceFile: ts.SourceFile\n): string | null {\n let found: string | null = null;\n const visit = (node: ts.Node): void => {\n if (found) return;\n if (\n ts.isVariableDeclaration(node) &&\n ts.isIdentifier(node.name) &&\n node.name.text === identifier &&\n node.initializer &&\n ts.isObjectLiteralExpression(node.initializer)\n ) {\n for (const prop of node.initializer.properties) {\n if (\n ts.isPropertyAssignment(prop) &&\n ts.isIdentifier(prop.name) &&\n prop.name.text === \"name\" &&\n ts.isStringLiteralLike(prop.initializer)\n ) {\n found = prop.initializer.text;\n return;\n }\n }\n }\n ts.forEachChild(node, visit);\n };\n visit(sourceFile);\n return found;\n}\n\nfunction extractDependencies(\n depsCall: ts.CallExpression\n): StepDefinitionMeta[\"dependencies\"] {\n const deps: StepDefinitionMeta[\"dependencies\"] = {\n given: {},\n when: {},\n then: {},\n };\n\n const arg = depsCall.arguments[0];\n if (!arg || !ts.isObjectLiteralExpression(arg)) return deps;\n\n for (const prop of arg.properties) {\n if (!ts.isPropertyAssignment(prop) || !ts.isIdentifier(prop.name)) continue;\n\n const phase = prop.name.text as \"given\" | \"when\" | \"then\";\n if (!deps[phase]) continue;\n\n if (ts.isObjectLiteralExpression(prop.initializer)) {\n for (const innerProp of prop.initializer.properties) {\n if (\n ts.isPropertyAssignment(innerProp) &&\n ts.isIdentifier(innerProp.name) &&\n ts.isStringLiteral(innerProp.initializer)\n ) {\n const val = innerProp.initializer.text;\n if (val === \"required\" || val === \"optional\") {\n deps[phase][innerProp.name.text] = val;\n }\n }\n }\n }\n }\n\n return deps;\n}\n\nfunction extractProducedKeys(\n stepCall: ts.CallExpression,\n ctx: ExtractCtx\n): string[] {\n const callback = stepCall.arguments[0];\n if (!callback) return [];\n\n // Try to get the return type of the callback by analyzing its body\n if (ts.isArrowFunction(callback) || ts.isFunctionExpression(callback)) {\n return extractProducedKeysFromCallback(callback, ctx);\n }\n\n return [];\n}\n\nfunction extractProducedKeysFromCallback(\n callback: ts.ArrowFunction | ts.FunctionExpression,\n ctx: ExtractCtx\n): string[] {\n const body = callback.body;\n\n // Concise arrow: () => ({ key: value })\n if (!ts.isBlock(body)) {\n return extractKeysFromExpression(body, ctx);\n }\n\n // Block body: look at return statements\n const keys = new Set<string>();\n function visitReturn(node: ts.Node) {\n if (ts.isReturnStatement(node) && node.expression) {\n for (const key of extractKeysFromExpression(node.expression, ctx)) {\n keys.add(key);\n }\n }\n ts.forEachChild(node, visitReturn);\n }\n visitReturn(body);\n return [...keys];\n}\n\nfunction extractKeysFromExpression(\n expr: ts.Expression,\n ctx: ExtractCtx\n): string[] {\n // Unwrap parenthesized expressions\n while (ts.isParenthesizedExpression(expr)) {\n expr = expr.expression;\n }\n\n // Object literal: { user: ..., token: ... }\n if (ts.isObjectLiteralExpression(expr)) {\n return expr.properties\n .filter(\n (p): p is ts.PropertyAssignment | ts.ShorthandPropertyAssignment =>\n ts.isPropertyAssignment(p) || ts.isShorthandPropertyAssignment(p)\n )\n .map(p => p.name.getText())\n .filter(Boolean);\n }\n\n // Non-literal return (a variable, a spread-only object, a function call): the\n // keys can only come from the type checker. On the parse-only pass we have\n // none — flag it so the caller retries with a real Program.\n if (!ctx.checker) {\n ctx.needsChecker = true;\n return [];\n }\n try {\n const type = ctx.checker.getTypeAtLocation(expr);\n return type\n .getProperties()\n .map(p => p.name)\n .filter(n => n !== \"merge\");\n } catch {\n return [];\n }\n}\n\ninterface ReExportResult {\n stepType: StepType;\n expression: string | null;\n}\n\nfunction resolveReExportedCall(\n chain: ts.CallExpression[],\n ctx: ExtractCtx\n): ReExportResult | null {\n // Look for the pattern: Variable(\"...\")... where Variable was assigned from builderType().statement\n // The last call in the chain (furthest from register) should be the variable call\n\n const lastCall = chain[chain.length - 1];\n if (!lastCall) return null;\n\n const expr = lastCall.expression;\n\n // If it's an identifier (like \"Given\", \"When\", \"Then\"), trace its declaration\n let identifier: ts.Identifier | null = null;\n if (ts.isIdentifier(expr)) {\n identifier = expr;\n } else if (\n ts.isPropertyAccessExpression(expr) &&\n ts.isIdentifier(expr.expression)\n ) {\n identifier = expr.expression;\n }\n\n if (!identifier) return null;\n\n // Tracing the re-exported builder's declaration needs symbol resolution,\n // which only a real Program provides. Flag for the checked retry.\n if (!ctx.checker) {\n ctx.needsChecker = true;\n return null;\n }\n\n const symbol = ctx.checker.getSymbolAtLocation(identifier);\n if (!symbol) return null;\n\n const decl = symbol.valueDeclaration;\n if (!decl || !ts.isVariableDeclaration(decl) || !decl.initializer)\n return null;\n\n // Check if initializer is builderType<T>().statement\n const init = decl.initializer;\n\n // Pattern: givenBuilder<T>().statement (PropertyAccessExpression)\n if (ts.isPropertyAccessExpression(init) && init.name.text === \"statement\") {\n const callExpr = init.expression;\n if (ts.isCallExpression(callExpr)) {\n const callee = callExpr.expression;\n if (ts.isIdentifier(callee) && BUILDER_NAMES[callee.text]) {\n // The lastCall IS the statement call — extract expression from it.\n // The re-exported-builder pattern carries no `.parsers(...)`, so\n // variables fall back to the default `{string}` placeholder.\n const expression = extractExpression(lastCall, null);\n return {\n stepType: BUILDER_NAMES[callee.text],\n expression,\n };\n }\n }\n }\n\n return null;\n}\n","import * as fs from \"node:fs\";\nimport {\n GherkinClassicTokenMatcher,\n Parser,\n AstBuilder,\n} from \"@cucumber/gherkin\";\nimport * as messages from \"@cucumber/messages\";\nimport { ParsedScenario, ParsedStep } from \"./types.js\";\n\ntype GherkinKeyword = \"Given\" | \"When\" | \"Then\" | \"And\" | \"But\";\n\nexport function parseFeatureFiles(filePaths: string[]): ParsedScenario[] {\n const scenarios: ParsedScenario[] = [];\n\n for (const filePath of filePaths) {\n const content = fs.readFileSync(filePath, \"utf-8\");\n const parsed = parseFeatureContent(content, filePath);\n scenarios.push(...parsed);\n }\n\n return scenarios;\n}\n\n/**\n * One parsed feature file: its `Feature:` title (empty if unnamed) plus every\n * scenario (outline rows expanded). {@link parseFeatureContent} exposes just the\n * scenarios; {@link parseFeatureCatalog} keeps the title too, for UIs that label\n * scenarios by their feature.\n */\nexport interface ParsedFeature {\n file: string;\n name: string;\n scenarios: ParsedScenario[];\n}\n\n/** Build a fresh gherkin parser and parse `content` into a document. */\nfunction parseDocument(content: string): messages.GherkinDocument {\n const builder = new AstBuilder(messages.IdGenerator.uuid());\n const matcher = new GherkinClassicTokenMatcher();\n return new Parser(builder, matcher).parse(content);\n}\n\n/**\n * Parse feature files into a catalog of `{ file, name, scenarios }`, one entry\n * per file (one gherkin parse each). Used by interactive mode to offer\n * feature/scenario names as typeahead choices labelled by their `Feature:` title.\n */\nexport function parseFeatureCatalog(filePaths: string[]): ParsedFeature[] {\n return filePaths.map(file => {\n const document = parseDocument(fs.readFileSync(file, \"utf-8\"));\n return {\n file,\n name: document.feature?.name ?? \"\",\n scenarios: documentToScenarios(document, file),\n };\n });\n}\n\nexport function parseFeatureContent(\n content: string,\n filePath: string\n): ParsedScenario[] {\n return documentToScenarios(parseDocument(content), filePath);\n}\n\n/** Expand a parsed gherkin document into scenarios (outline rows included). */\nfunction documentToScenarios(\n gherkinDocument: messages.GherkinDocument,\n filePath: string\n): ParsedScenario[] {\n const feature = gherkinDocument.feature;\n if (!feature) return [];\n\n // Collect background steps at the feature level\n const featureBackground: messages.Step[] = [];\n const scenarios: ParsedScenario[] = [];\n const featureTags = tagNames(feature.tags);\n\n for (const child of feature.children) {\n if (child.background) {\n featureBackground.push(...child.background.steps);\n }\n\n if (child.scenario) {\n scenarios.push(\n ...expandScenario(\n child.scenario,\n featureBackground,\n filePath,\n featureTags\n )\n );\n }\n\n if (child.rule) {\n // Rules can have their own backgrounds and tags, both inherited by the\n // rule's scenarios.\n const ruleBackground: messages.Step[] = [...featureBackground];\n const ruleTags = [...featureTags, ...tagNames(child.rule.tags)];\n for (const ruleChild of child.rule.children) {\n if (ruleChild.background) {\n ruleBackground.push(...ruleChild.background.steps);\n }\n if (ruleChild.scenario) {\n scenarios.push(\n ...expandScenario(\n ruleChild.scenario,\n ruleBackground,\n filePath,\n ruleTags\n )\n );\n }\n }\n }\n }\n\n return scenarios;\n}\n\n/** Extract tag names (each keeping its leading `@`), deduped in order. */\nfunction tagNames(tags: readonly messages.Tag[] | undefined): string[] {\n return [...new Set((tags ?? []).map(t => t.name))];\n}\n\nfunction expandScenario(\n scenario: messages.Scenario,\n backgroundSteps: messages.Step[],\n filePath: string,\n inheritedTags: string[]\n): ParsedScenario[] {\n const scenarioTags = [...inheritedTags, ...tagNames(scenario.tags)];\n const hasExamples =\n scenario.examples.length > 0 &&\n scenario.examples.some(e => e.tableBody.length > 0);\n\n if (!hasExamples) {\n // Regular scenario\n const bgParsed = convertSteps(backgroundSteps);\n const scenarioParsed = convertSteps(scenario.steps);\n const allSteps = resolveEffectiveKeywords([...bgParsed, ...scenarioParsed]);\n\n return [\n {\n name: scenario.name,\n file: filePath,\n line: scenario.location.line,\n steps: allSteps,\n tags: scenarioTags,\n },\n ];\n }\n\n // Scenario Outline — expand with each example row. Rows carry the outline's\n // base name so the runner can group them, plus the Examples-block tags.\n const results: ParsedScenario[] = [];\n for (const example of scenario.examples) {\n if (!example.tableHeader || example.tableBody.length === 0) continue;\n const headers = example.tableHeader.cells.map(c => c.value);\n const exampleTags = [...scenarioTags, ...tagNames(example.tags)];\n\n for (const row of example.tableBody) {\n const values = row.cells.map(c => c.value);\n const substitution: Record<string, string> = {};\n headers.forEach((h, i) => {\n substitution[h] = values[i];\n });\n\n const bgParsed = convertSteps(backgroundSteps);\n const scenarioSteps = convertSteps(scenario.steps).map(step => ({\n ...step,\n text: substituteExampleValues(step.text, substitution),\n }));\n const allSteps = resolveEffectiveKeywords([\n ...bgParsed,\n ...scenarioSteps,\n ]);\n\n results.push({\n name: headers.map((h, i) => `${h}=${values[i]}`).join(\", \"),\n file: filePath,\n line: row.location.line,\n steps: allSteps,\n tags: exampleTags,\n outline: { name: scenario.name },\n });\n }\n }\n\n return results;\n}\n\nfunction convertSteps(\n steps: readonly messages.Step[]\n): Omit<ParsedStep, \"effectiveKeyword\">[] {\n return steps.map(step => ({\n keyword: normalizeKeyword(step.keyword),\n text: step.text,\n line: step.location.line,\n // step.location.column points to the keyword start; shift past the\n // keyword (which includes a trailing space) so column points to the\n // start of the step text. This makes `column + text.length` produce\n // the correct end position for diagnostic ranges.\n column: (step.location.column ?? 1) + step.keyword.length,\n }));\n}\n\nfunction normalizeKeyword(keyword: string): GherkinKeyword {\n const trimmed = keyword.trim();\n // Gherkin keywords may include trailing space, e.g. \"Given \"\n if (trimmed === \"Given\") return \"Given\";\n if (trimmed === \"When\") return \"When\";\n if (trimmed === \"Then\") return \"Then\";\n if (trimmed === \"And\") return \"And\";\n if (trimmed === \"But\") return \"But\";\n // Fallback: treat as Given (shouldn't happen with valid Gherkin)\n return \"Given\";\n}\n\nfunction resolveEffectiveKeywords(\n steps: Omit<ParsedStep, \"effectiveKeyword\">[]\n): ParsedStep[] {\n let lastEffective: \"Given\" | \"When\" | \"Then\" = \"Given\";\n\n return steps.map(step => {\n let effectiveKeyword: \"Given\" | \"When\" | \"Then\";\n if (step.keyword === \"And\" || step.keyword === \"But\") {\n effectiveKeyword = lastEffective;\n } else {\n effectiveKeyword = step.keyword as \"Given\" | \"When\" | \"Then\";\n }\n lastEffective = effectiveKeyword;\n\n return {\n ...step,\n effectiveKeyword,\n };\n });\n}\n\nfunction substituteExampleValues(\n text: string,\n substitution: Record<string, string>\n): string {\n let result = text;\n for (const [key, value] of Object.entries(substitution)) {\n result = result.replace(new RegExp(`<${key}>`, \"g\"), value);\n }\n return result;\n}\n","import {\n CucumberExpression,\n ParameterType,\n ParameterTypeRegistry,\n} from \"@cucumber/cucumber-expressions\";\nimport { MatchedStep, ParsedScenario, StepDefinitionMeta } from \"./types.js\";\n\ninterface CompiledPattern {\n expression: CucumberExpression;\n definition: StepDefinitionMeta;\n}\n\n/** `{name}` tokens in a cucumber expression (empty name is the anonymous `{}`). */\nconst PARAM_TOKEN = /\\{([^}]*)\\}/g;\n\n/**\n * Compile each definition's cucumber expression with the **same** engine the\n * runtime uses (`@cucumber/cucumber-expressions`), so the analyzer and the\n * runtime agree on what a step matches.\n *\n * A hand-rolled `{param}` → `(.+)` regex used to stand in here, but it treated\n * cucumber-expression alternative (`a/b`) and optional (`text(s)`) syntax as\n * literal characters — so any step definition using them (e.g.\n * `there should be {int} error/errors`) never matched, and every such step was\n * wrongly reported as an undefined step regardless of the real state.\n *\n * Built-in placeholders (`{int}`, `{float}`, `{string}`, `{word}`) keep their\n * real, strict regexes so the analyzer disambiguates the way the runtime does\n * (e.g. `no` isn't an `{int}`). The analyzer has only the expression string, not\n * a custom parser's regexp, so each custom `{name}` is registered as a permissive\n * parameter type (any value) — lenient about the value's exact shape, but still\n * anchored by the surrounding literal text.\n */\nfunction compileDefinitions(\n definitions: StepDefinitionMeta[]\n): CompiledPattern[] {\n const compiled: CompiledPattern[] = [];\n for (const def of definitions) {\n try {\n const registry = new ParameterTypeRegistry();\n for (const [, name] of def.expression.matchAll(PARAM_TOKEN)) {\n if (!name || registry.lookupByTypeName(name)) continue;\n registry.defineParameterType(\n new ParameterType(name, /.+/, null, (value: string) => value)\n );\n }\n compiled.push({\n expression: new CucumberExpression(def.expression, registry),\n definition: def,\n });\n } catch {\n // Skip definitions whose expression can't be compiled.\n }\n }\n return compiled;\n}\n\nexport function matchScenarioSteps(\n scenario: ParsedScenario,\n definitions: StepDefinitionMeta[]\n): MatchedStep[] {\n const compiled = compileDefinitions(definitions);\n\n return scenario.steps.map(step => {\n const matches = findMatches(step.text, step.effectiveKeyword, compiled);\n return {\n ...step,\n definitions: matches,\n };\n });\n}\n\nexport function findMatchingDefinitions(\n text: string,\n effectiveKeyword: \"Given\" | \"When\" | \"Then\",\n definitions: StepDefinitionMeta[]\n): StepDefinitionMeta[] {\n const compiled = compileDefinitions(definitions);\n return findMatches(text, effectiveKeyword, compiled);\n}\n\nfunction findMatches(\n text: string,\n effectiveKeyword: \"Given\" | \"When\" | \"Then\",\n compiled: CompiledPattern[]\n): StepDefinitionMeta[] {\n const keywordToStepType: Record<string, string> = {\n Given: \"given\",\n When: \"when\",\n Then: \"then\",\n };\n const expectedStepType = keywordToStepType[effectiveKeyword];\n\n // First try to match with the correct step type\n const typedMatches: StepDefinitionMeta[] = [];\n for (const { expression, definition } of compiled) {\n if (definition.stepType !== expectedStepType) continue;\n if (expression.match(text) != null) typedMatches.push(definition);\n }\n\n if (typedMatches.length > 0) return typedMatches;\n\n // Fallback: match any step type\n const fallbackMatches: StepDefinitionMeta[] = [];\n for (const { expression, definition } of compiled) {\n if (expression.match(text) != null) fallbackMatches.push(definition);\n }\n\n return fallbackMatches;\n}\n","import {\n AnalysisRule,\n Diagnostic,\n MatchedStep,\n ParsedScenario,\n} from \"../types.js\";\n\nexport const ambiguousStepRule: AnalysisRule = {\n name: \"ambiguous-step\",\n\n check(\n scenario: ParsedScenario,\n matchedSteps: MatchedStep[]\n ): Diagnostic[] {\n return matchedSteps\n .filter((step) => step.definitions.length > 1)\n .map((step) => {\n const locations = step.definitions\n .map((d) => `${d.sourceFile}:${d.line}`)\n .join(\", \");\n return {\n file: scenario.file,\n range: {\n startLine: step.line,\n startColumn: step.column,\n endLine: step.line,\n endColumn: step.column + step.text.length,\n },\n severity: \"error\" as const,\n message: `Step \"${step.text}\" matches multiple step definitions: ${locations}`,\n rule: \"ambiguous-step\",\n source: \"step-forge\" as const,\n };\n });\n },\n};\n","import {\n AnalysisRule,\n Diagnostic,\n MatchedStep,\n ParsedScenario,\n} from \"../types.js\";\n\nexport const dependencyRule: AnalysisRule = {\n name: \"dependency-check\",\n\n check(\n scenario: ParsedScenario,\n matchedSteps: MatchedStep[]\n ): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n const produced = {\n given: new Set<string>(),\n when: new Set<string>(),\n then: new Set<string>(),\n };\n\n for (const step of matchedSteps) {\n if (step.definitions.length !== 1) continue;\n\n const { dependencies, produces, stepType } = step.definitions[0];\n\n // Collect all missing required dependencies for this step\n const missing: Record<string, string[]> = {};\n for (const phase of [\"given\", \"when\", \"then\"] as const) {\n for (const [key, requirement] of Object.entries(dependencies[phase])) {\n if (requirement === \"required\" && !produced[phase].has(key)) {\n if (!missing[phase]) {\n missing[phase] = [];\n }\n missing[phase].push(key);\n }\n }\n }\n\n if (Object.keys(missing).length > 0) {\n const lines = Object.entries(missing).map(\n ([phase, keys]) =>\n `${phase.charAt(0).toUpperCase() + phase.slice(1)}: ${keys.map((k) => `${phase}.${k}`).join(\", \")}`\n );\n const message =\n \"Missing required dependencies:\\n\" + lines.join(\"\\n\");\n\n diagnostics.push({\n file: scenario.file,\n range: {\n startLine: step.line,\n startColumn: step.column,\n endLine: step.line,\n endColumn: step.column + step.text.length,\n },\n severity: \"error\",\n message,\n rule: \"dependency-check\",\n source: \"step-forge\",\n });\n }\n\n // Add produced keys for this step\n for (const key of produces) {\n produced[stepType].add(key);\n }\n }\n\n return diagnostics;\n },\n};\n","import {\n AnalysisRule,\n Diagnostic,\n MatchedStep,\n ParsedScenario,\n} from \"../types.js\";\n\nexport const undefinedStepRule: AnalysisRule = {\n name: \"undefined-step\",\n\n check(\n scenario: ParsedScenario,\n matchedSteps: MatchedStep[]\n ): Diagnostic[] {\n return matchedSteps\n .filter((step) => step.definitions.length === 0)\n .map((step) => ({\n file: scenario.file,\n range: {\n startLine: step.line,\n startColumn: step.column,\n endLine: step.line,\n endColumn: step.column + step.text.length,\n },\n severity: \"error\" as const,\n message: `Step \"${step.text}\" does not match any step definition`,\n rule: \"undefined-step\",\n source: \"step-forge\" as const,\n }));\n },\n};\n","import {\n AnalysisRule,\n Diagnostic,\n MatchedStep,\n ParsedScenario,\n} from \"../types.js\";\nimport { ambiguousStepRule } from \"./ambiguousStepRule.js\";\nimport { dependencyRule } from \"./dependencyRule.js\";\nimport { undefinedStepRule } from \"./undefinedStepRule.js\";\n\nexport const defaultRules: AnalysisRule[] = [\n undefinedStepRule,\n ambiguousStepRule,\n dependencyRule,\n];\n\nexport function runRules(\n rules: AnalysisRule[],\n scenario: ParsedScenario,\n matchedSteps: MatchedStep[]\n): Diagnostic[] {\n return rules.flatMap((rule) => rule.check(scenario, matchedSteps));\n}\n","import { globFiles } from \"../globFiles.js\";\nimport { extractStepDefinitions } from \"./stepExtractor.js\";\nimport { parseFeatureFiles, parseFeatureContent } from \"./gherkinParser.js\";\nimport { matchScenarioSteps, findMatchingDefinitions } from \"./stepMatcher.js\";\nimport { defaultRules, runRules } from \"./rules/index.js\";\nimport type {\n AnalyzerConfig,\n AnalysisRule,\n Diagnostic,\n StepDefinitionMeta,\n ParsedScenario,\n MatchedStep,\n ParsedStep,\n} from \"./types.js\";\n\nexport type {\n AnalyzerConfig,\n AnalysisRule,\n Diagnostic,\n StepDefinitionMeta,\n ParsedScenario,\n MatchedStep,\n ParsedStep,\n};\n\nexport {\n extractStepDefinitions,\n parseFeatureFiles,\n parseFeatureContent,\n matchScenarioSteps,\n findMatchingDefinitions,\n defaultRules,\n};\n\nexport interface AnalyzeOptions {\n rules?: AnalysisRule[];\n}\n\nexport async function analyze(\n config: AnalyzerConfig,\n options?: AnalyzeOptions\n): Promise<Diagnostic[]> {\n const rules = options?.rules ?? defaultRules;\n\n // 1. Resolve file globs to paths\n const stepFilePaths = await globFiles(config.stepFiles);\n const featureFilePaths = await globFiles(config.featureFiles);\n\n if (stepFilePaths.length === 0) {\n return [];\n }\n if (featureFilePaths.length === 0) {\n return [];\n }\n\n // 2. Extract step metadata from step files\n const stepDefinitions = extractStepDefinitions(\n stepFilePaths,\n config.tsConfigPath\n );\n\n // 3. Parse feature files\n const scenarios = parseFeatureFiles(featureFilePaths);\n\n // 4. For each scenario, match steps and run rules\n const diagnostics: Diagnostic[] = [];\n for (const scenario of scenarios) {\n const matchedSteps = matchScenarioSteps(scenario, stepDefinitions);\n const scenarioDiags = runRules(rules, scenario, matchedSteps);\n diagnostics.push(...scenarioDiags);\n }\n\n return diagnostics;\n}\n"],"mapp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AI,GAGzD,CAAC,CAAC,KAAK,IAAI;KAEtD,YAAY,KAAK;MACf,MAAM,SAAS;MACf,OAAO;OACL,WAAW,KAAK;OAChB,aAAa,KAAK;OAClB,SAAS,KAAK;OACd,WAAW,KAAK,SAAS,KAAK,KAAK;MACrC;MACA,UAAU;MACV;MACA,MAAM;MACN,QAAQ;KACV,CAAC;IACH;IAGA,KAAK,MAAM,OAAO,UAChB,SAAS,SAAS,CAAC,IAAI,GAAG;GAE9B;GAEA,OAAO;EACT;CExDA;AACF;AAEA,SAAgB,SACd,OACA,UACA,cACc;CACd,OAAO,MAAM,SAAS,SAAS,KAAK,MAAM,UAAU,YAAY,CAAC;AACnE;;;ACgBA,eAAsB,QACpB,QACA,SACuB;CACvB,MAAM,QAAQ,SAAS,SAAS;CAGhC,MAAM,gBAAgB,MAAM,UAAU,OAAO,SAAS;CACtD,MAAM,mBAAmB,MAAM,UAAU,OAAO,YAAY;CAE5D,IAAI,cAAc,WAAW,GAC3B,OAAO,CAAC;CAEV,IAAI,iBAAiB,WAAW,GAC9B,OAAO,CAAC;CAIV,MAAM,kBAAkB,uBACtB,eACA,OAAO,YACT;CAGA,MAAM,YAAY,kBAAkB,gBAAgB;CAGpD,MAAM,cAA4B,CAAC;CACnC,KAAK,MAAM,YAAY,WAAW;EAEhC,MAAM,gBAAgB,SAAS,OAAO,UADjB,mBAAmB,UAAU,eACS,CAAC;EAC5D,YAAY,KAAK,GAAG,aAAa;CACnC;CAEA,OAAO;AACT"}
|
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
const require_gherkinParser = require("./gherkinParser-_ZgvELdy.cjs");
|
|
2
2
|
let typescript = require("typescript");
|
|
3
3
|
typescript = require_gherkinParser.__toESM(typescript, 1);
|
|
4
|
+
let _cucumber_cucumber_expressions = require("@cucumber/cucumber-expressions");
|
|
4
5
|
//#region src/analyzer/stepExtractor.ts
|
|
5
6
|
const BUILDER_NAMES = {
|
|
6
7
|
givenBuilder: "given",
|
|
7
8
|
whenBuilder: "when",
|
|
8
9
|
thenBuilder: "then"
|
|
9
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Built-in parsers exported by the library, mapped to the cucumber-expression
|
|
13
|
+
* placeholder they register. A step's `.parsers([...])` drives which `{name}`
|
|
14
|
+
* each variable becomes; without this the extractor defaulted every variable to
|
|
15
|
+
* `{string}`, so `the deposit amount is {int}` was recorded as `{string}` and a
|
|
16
|
+
* plain number like `100` looked unmatched. Custom parsers are resolved from
|
|
17
|
+
* their `name` property (see {@link resolveCustomParserName}); anything we can't
|
|
18
|
+
* resolve falls back to `string`.
|
|
19
|
+
*/
|
|
20
|
+
const BUILTIN_PARSER_PLACEHOLDERS = {
|
|
21
|
+
intParser: "int",
|
|
22
|
+
numberParser: "float",
|
|
23
|
+
stringParser: "string",
|
|
24
|
+
booleanParser: "boolean"
|
|
25
|
+
};
|
|
10
26
|
function extractStepDefinitions(filePaths, tsConfigPath) {
|
|
11
27
|
const fast = extractWithSources(filePaths.map(parseSourceFile).filter((s) => s !== null), null);
|
|
12
28
|
if (!fast.needsChecker) return fast.results;
|
|
@@ -65,6 +81,7 @@ function extractFromSourceFile(sourceFile, ctx) {
|
|
|
65
81
|
function extractFromRegisterCall(registerCall, sourceFile, ctx) {
|
|
66
82
|
const chain = collectCallChain(registerCall);
|
|
67
83
|
let stepType = null;
|
|
84
|
+
let statementCall = null;
|
|
68
85
|
let expression = null;
|
|
69
86
|
let dependencies = {
|
|
70
87
|
given: {},
|
|
@@ -72,6 +89,7 @@ function extractFromRegisterCall(registerCall, sourceFile, ctx) {
|
|
|
72
89
|
then: {}
|
|
73
90
|
};
|
|
74
91
|
let produces = [];
|
|
92
|
+
let placeholders = null;
|
|
75
93
|
for (const link of chain) {
|
|
76
94
|
const name = getCallName(link);
|
|
77
95
|
if (!name) continue;
|
|
@@ -84,8 +102,12 @@ function extractFromRegisterCall(registerCall, sourceFile, ctx) {
|
|
|
84
102
|
dependencies = extractDependencies(link);
|
|
85
103
|
continue;
|
|
86
104
|
}
|
|
105
|
+
if (name === "parsers") {
|
|
106
|
+
placeholders = resolveParserPlaceholders(link, sourceFile);
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
87
109
|
if (name === "statement") {
|
|
88
|
-
|
|
110
|
+
statementCall = link;
|
|
89
111
|
continue;
|
|
90
112
|
}
|
|
91
113
|
if (BUILDER_NAMES[name]) {
|
|
@@ -93,6 +115,7 @@ function extractFromRegisterCall(registerCall, sourceFile, ctx) {
|
|
|
93
115
|
continue;
|
|
94
116
|
}
|
|
95
117
|
}
|
|
118
|
+
if (statementCall) expression = extractExpression(statementCall, placeholders);
|
|
96
119
|
if (!stepType || !expression) {
|
|
97
120
|
const reExport = resolveReExportedCall(chain, ctx);
|
|
98
121
|
if (reExport) {
|
|
@@ -132,14 +155,14 @@ function getCallName(call) {
|
|
|
132
155
|
if (typescript.default.isIdentifier(expr)) return expr.text;
|
|
133
156
|
return null;
|
|
134
157
|
}
|
|
135
|
-
function extractExpression(statementCall) {
|
|
158
|
+
function extractExpression(statementCall, placeholders) {
|
|
136
159
|
const arg = statementCall.arguments[0];
|
|
137
160
|
if (!arg) return null;
|
|
138
161
|
if (typescript.default.isStringLiteral(arg)) return arg.text;
|
|
139
|
-
if (typescript.default.isArrowFunction(arg)) return extractExpressionFromArrowFunction(arg);
|
|
162
|
+
if (typescript.default.isArrowFunction(arg)) return extractExpressionFromArrowFunction(arg, placeholders);
|
|
140
163
|
return null;
|
|
141
164
|
}
|
|
142
|
-
function extractExpressionFromArrowFunction(fn) {
|
|
165
|
+
function extractExpressionFromArrowFunction(fn, placeholders) {
|
|
143
166
|
const params = fn.parameters.map((p) => p.name.getText());
|
|
144
167
|
let body = fn.body;
|
|
145
168
|
if (typescript.default.isBlock(body)) {
|
|
@@ -147,19 +170,63 @@ function extractExpressionFromArrowFunction(fn) {
|
|
|
147
170
|
if (returnStmt?.expression) body = returnStmt.expression;
|
|
148
171
|
else return null;
|
|
149
172
|
}
|
|
150
|
-
if (typescript.default.isTemplateExpression(body)) return reconstructExpressionFromTemplate(body, params);
|
|
173
|
+
if (typescript.default.isTemplateExpression(body)) return reconstructExpressionFromTemplate(body, params, placeholders);
|
|
151
174
|
if (typescript.default.isNoSubstitutionTemplateLiteral(body)) return body.text;
|
|
152
175
|
return null;
|
|
153
176
|
}
|
|
154
|
-
function reconstructExpressionFromTemplate(template, paramNames) {
|
|
177
|
+
function reconstructExpressionFromTemplate(template, paramNames, placeholders) {
|
|
155
178
|
let result = template.head.text;
|
|
156
179
|
for (const span of template.templateSpans) {
|
|
157
|
-
|
|
158
|
-
|
|
180
|
+
let placeholder = "string";
|
|
181
|
+
if (typescript.default.isIdentifier(span.expression) && paramNames.includes(span.expression.text)) {
|
|
182
|
+
const index = paramNames.indexOf(span.expression.text);
|
|
183
|
+
placeholder = placeholders?.[index] ?? "string";
|
|
184
|
+
}
|
|
185
|
+
result += `{${placeholder}}`;
|
|
159
186
|
result += span.literal.text;
|
|
160
187
|
}
|
|
161
188
|
return result;
|
|
162
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* Resolve `.parsers([intParser, colorParser])` to the placeholder name for each
|
|
192
|
+
* variable, positionally. Built-ins map via {@link BUILTIN_PARSER_PLACEHOLDERS};
|
|
193
|
+
* a custom parser is resolved from its `name` property in the same source file;
|
|
194
|
+
* anything unresolved defaults to `string`, matching the runtime default parser.
|
|
195
|
+
*/
|
|
196
|
+
function resolveParserPlaceholders(parsersCall, sourceFile) {
|
|
197
|
+
const arg = parsersCall.arguments[0];
|
|
198
|
+
if (!arg || !typescript.default.isArrayLiteralExpression(arg)) return null;
|
|
199
|
+
return arg.elements.map((element) => {
|
|
200
|
+
if (typescript.default.isIdentifier(element)) {
|
|
201
|
+
const builtin = BUILTIN_PARSER_PLACEHOLDERS[element.text];
|
|
202
|
+
if (builtin) return builtin;
|
|
203
|
+
const custom = resolveCustomParserName(element.text, sourceFile);
|
|
204
|
+
if (custom) return custom;
|
|
205
|
+
}
|
|
206
|
+
return "string";
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Find `const <identifier> = { name: "...", ... }` in `sourceFile` and return
|
|
211
|
+
* its `name` — the cucumber placeholder a custom `Parser` registers. Scoped to
|
|
212
|
+
* the file, so a parser imported from elsewhere won't resolve (it falls back to
|
|
213
|
+
* `string`); the common in-file `const colorParser: Parser<Color> = {...}` does.
|
|
214
|
+
*/
|
|
215
|
+
function resolveCustomParserName(identifier, sourceFile) {
|
|
216
|
+
let found = null;
|
|
217
|
+
const visit = (node) => {
|
|
218
|
+
if (found) return;
|
|
219
|
+
if (typescript.default.isVariableDeclaration(node) && typescript.default.isIdentifier(node.name) && node.name.text === identifier && node.initializer && typescript.default.isObjectLiteralExpression(node.initializer)) {
|
|
220
|
+
for (const prop of node.initializer.properties) if (typescript.default.isPropertyAssignment(prop) && typescript.default.isIdentifier(prop.name) && prop.name.text === "name" && typescript.default.isStringLiteralLike(prop.initializer)) {
|
|
221
|
+
found = prop.initializer.text;
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
typescript.default.forEachChild(node, visit);
|
|
226
|
+
};
|
|
227
|
+
visit(sourceFile);
|
|
228
|
+
return found;
|
|
229
|
+
}
|
|
163
230
|
function extractDependencies(depsCall) {
|
|
164
231
|
const deps = {
|
|
165
232
|
given: {},
|
|
@@ -233,7 +300,7 @@ function resolveReExportedCall(chain, ctx) {
|
|
|
233
300
|
if (typescript.default.isCallExpression(callExpr)) {
|
|
234
301
|
const callee = callExpr.expression;
|
|
235
302
|
if (typescript.default.isIdentifier(callee) && BUILDER_NAMES[callee.text]) {
|
|
236
|
-
const expression = extractExpression(lastCall);
|
|
303
|
+
const expression = extractExpression(lastCall, null);
|
|
237
304
|
return {
|
|
238
305
|
stepType: BUILDER_NAMES[callee.text],
|
|
239
306
|
expression
|
|
@@ -245,13 +312,36 @@ function resolveReExportedCall(chain, ctx) {
|
|
|
245
312
|
}
|
|
246
313
|
//#endregion
|
|
247
314
|
//#region src/analyzer/stepMatcher.ts
|
|
315
|
+
/** `{name}` tokens in a cucumber expression (empty name is the anonymous `{}`). */
|
|
316
|
+
const PARAM_TOKEN = /\{([^}]*)\}/g;
|
|
317
|
+
/**
|
|
318
|
+
* Compile each definition's cucumber expression with the **same** engine the
|
|
319
|
+
* runtime uses (`@cucumber/cucumber-expressions`), so the analyzer and the
|
|
320
|
+
* runtime agree on what a step matches.
|
|
321
|
+
*
|
|
322
|
+
* A hand-rolled `{param}` → `(.+)` regex used to stand in here, but it treated
|
|
323
|
+
* cucumber-expression alternative (`a/b`) and optional (`text(s)`) syntax as
|
|
324
|
+
* literal characters — so any step definition using them (e.g.
|
|
325
|
+
* `there should be {int} error/errors`) never matched, and every such step was
|
|
326
|
+
* wrongly reported as an undefined step regardless of the real state.
|
|
327
|
+
*
|
|
328
|
+
* Built-in placeholders (`{int}`, `{float}`, `{string}`, `{word}`) keep their
|
|
329
|
+
* real, strict regexes so the analyzer disambiguates the way the runtime does
|
|
330
|
+
* (e.g. `no` isn't an `{int}`). The analyzer has only the expression string, not
|
|
331
|
+
* a custom parser's regexp, so each custom `{name}` is registered as a permissive
|
|
332
|
+
* parameter type (any value) — lenient about the value's exact shape, but still
|
|
333
|
+
* anchored by the surrounding literal text.
|
|
334
|
+
*/
|
|
248
335
|
function compileDefinitions(definitions) {
|
|
249
336
|
const compiled = [];
|
|
250
337
|
for (const def of definitions) try {
|
|
251
|
-
const
|
|
252
|
-
const
|
|
338
|
+
const registry = new _cucumber_cucumber_expressions.ParameterTypeRegistry();
|
|
339
|
+
for (const [, name] of def.expression.matchAll(PARAM_TOKEN)) {
|
|
340
|
+
if (!name || registry.lookupByTypeName(name)) continue;
|
|
341
|
+
registry.defineParameterType(new _cucumber_cucumber_expressions.ParameterType(name, /.+/, null, (value) => value));
|
|
342
|
+
}
|
|
253
343
|
compiled.push({
|
|
254
|
-
|
|
344
|
+
expression: new _cucumber_cucumber_expressions.CucumberExpression(def.expression, registry),
|
|
255
345
|
definition: def
|
|
256
346
|
});
|
|
257
347
|
} catch {}
|
|
@@ -277,13 +367,13 @@ function findMatches(text, effectiveKeyword, compiled) {
|
|
|
277
367
|
Then: "then"
|
|
278
368
|
}[effectiveKeyword];
|
|
279
369
|
const typedMatches = [];
|
|
280
|
-
for (const {
|
|
370
|
+
for (const { expression, definition } of compiled) {
|
|
281
371
|
if (definition.stepType !== expectedStepType) continue;
|
|
282
|
-
if (
|
|
372
|
+
if (expression.match(text) != null) typedMatches.push(definition);
|
|
283
373
|
}
|
|
284
374
|
if (typedMatches.length > 0) return typedMatches;
|
|
285
375
|
const fallbackMatches = [];
|
|
286
|
-
for (const {
|
|
376
|
+
for (const { expression, definition } of compiled) if (expression.match(text) != null) fallbackMatches.push(definition);
|
|
287
377
|
return fallbackMatches;
|
|
288
378
|
}
|
|
289
379
|
//#endregion
|
|
@@ -438,4 +528,4 @@ Object.defineProperty(exports, "matchScenarioSteps", {
|
|
|
438
528
|
}
|
|
439
529
|
});
|
|
440
530
|
|
|
441
|
-
//# sourceMappingURL=analyzer-
|
|
531
|
+
//# sourceMappingURL=analyzer-DRudicCk.cjs.map
|