@cucumber/gherkin
Advanced tools
Comparing version 23.0.1 to 24.0.0
{ | ||
"name": "@cucumber/gherkin", | ||
"version": "23.0.1", | ||
"version": "24.0.0", | ||
"description": "Gherkin parser", | ||
@@ -27,11 +27,11 @@ "main": "dist/src/index.js", | ||
"@cucumber/gherkin-streams": "^5.0.1", | ||
"@types/mocha": "9.1.0", | ||
"@types/node": "16.11.26", | ||
"core-js": "3.21.1", | ||
"mocha": "9.2.2", | ||
"ts-node": "10.7.0", | ||
"typescript": "4.6.3" | ||
"@types/mocha": "9.1.1", | ||
"@types/node": "16.11.36", | ||
"core-js": "3.22.7", | ||
"mocha": "10.0.0", | ||
"ts-node": "10.8.0", | ||
"typescript": "4.7.2" | ||
}, | ||
"dependencies": { | ||
"@cucumber/messages": "^18.0.0" | ||
"@cucumber/messages": "^19.0.0" | ||
}, | ||
@@ -38,0 +38,0 @@ "directories": { |
@@ -110,2 +110,3 @@ "use strict"; | ||
keyword: stepLine.matchedKeyword, | ||
keywordType: stepLine.matchedKeywordType, | ||
text: stepLine.matchedText, | ||
@@ -112,0 +113,0 @@ dataTable: dataTable, |
@@ -11,5 +11,7 @@ import IToken, { IGherkinLine, Item } from './IToken'; | ||
private indentToRemove; | ||
private keywordTypesMap; | ||
constructor(defaultDialectName?: string); | ||
changeDialect(newDialectName: string, location?: messages.Location): void; | ||
reset(): void; | ||
initializeKeywordTypes(): void; | ||
match_TagLine(token: IToken<TokenType>): boolean; | ||
@@ -16,0 +18,0 @@ match_FeatureLine(token: IToken<TokenType>): boolean; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -8,2 +31,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
const Errors_1 = require("./Errors"); | ||
const messages = __importStar(require("@cucumber/messages")); | ||
const Parser_1 = require("./Parser"); | ||
@@ -13,2 +37,10 @@ const countSymbols_1 = __importDefault(require("./countSymbols")); | ||
const LANGUAGE_PATTERN = /^\s*#\s*language\s*:\s*([a-zA-Z\-_]+)\s*$/; | ||
function addKeywordTypeMappings(h, keywords, keywordType) { | ||
for (const k of keywords) { | ||
if (!(k in h)) { | ||
h[k] = []; | ||
} | ||
h[k].push(keywordType); | ||
} | ||
} | ||
class GherkinClassicTokenMatcher { | ||
@@ -26,2 +58,3 @@ constructor(defaultDialectName = 'en') { | ||
this.dialect = newDialect; | ||
this.initializeKeywordTypes(); | ||
} | ||
@@ -35,5 +68,12 @@ reset() { | ||
} | ||
initializeKeywordTypes() { | ||
this.keywordTypesMap = {}; | ||
addKeywordTypeMappings(this.keywordTypesMap, this.dialect.given, messages.StepKeywordType.CONTEXT); | ||
addKeywordTypeMappings(this.keywordTypesMap, this.dialect.when, messages.StepKeywordType.ACTION); | ||
addKeywordTypeMappings(this.keywordTypesMap, this.dialect.then, messages.StepKeywordType.OUTCOME); | ||
addKeywordTypeMappings(this.keywordTypesMap, [].concat(this.dialect.and).concat(this.dialect.but), messages.StepKeywordType.CONJUNCTION); | ||
} | ||
match_TagLine(token) { | ||
if (token.line.startsWith('@')) { | ||
this.setTokenMatched(token, Parser_1.TokenType.TagLine, null, null, null, this.getTags(token.line)); | ||
this.setTokenMatched(token, Parser_1.TokenType.TagLine, null, null, null, null, this.getTags(token.line)); | ||
return true; | ||
@@ -62,3 +102,3 @@ } | ||
// TODO: indent | ||
this.setTokenMatched(token, Parser_1.TokenType.TableRow, null, null, null, token.line.getTableCells()); | ||
this.setTokenMatched(token, Parser_1.TokenType.TableRow, null, null, null, null, token.line.getTableCells()); | ||
return true; | ||
@@ -135,3 +175,8 @@ } | ||
const title = token.line.getRestTrimmed(keyword.length); | ||
this.setTokenMatched(token, Parser_1.TokenType.StepLine, title, keyword); | ||
const keywordTypes = this.keywordTypesMap[keyword]; | ||
let keywordType = keywordTypes[0]; | ||
if (keywordTypes.length > 1) { | ||
keywordType = messages.StepKeywordType.UNKNOWN; | ||
} | ||
this.setTokenMatched(token, Parser_1.TokenType.StepLine, title, keyword, null, keywordType); | ||
return true; | ||
@@ -176,6 +221,7 @@ } | ||
} | ||
setTokenMatched(token, matchedType, text, keyword, indent, items) { | ||
setTokenMatched(token, matchedType, text, keyword, indent, keywordType, items) { | ||
token.matchedType = matchedType; | ||
token.matchedText = text; | ||
token.matchedKeyword = keyword; | ||
token.matchedKeywordType = keywordType; | ||
token.matchedIndent = | ||
@@ -182,0 +228,0 @@ typeof indent === 'number' ? indent : token.line == null ? 0 : token.line.indent; |
@@ -14,4 +14,6 @@ import ITokenMatcher from './ITokenMatcher'; | ||
private matchedFeatureLine; | ||
private keywordTypesMap; | ||
constructor(defaultDialectName?: string); | ||
changeDialect(newDialectName: string, location?: messages.Location): void; | ||
initializeKeywordTypes(): void; | ||
match_Language(token: Token): boolean; | ||
@@ -18,0 +20,0 @@ match_Empty(token: Token): boolean; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -8,5 +31,14 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
const gherkin_languages_json_1 = __importDefault(require("./gherkin-languages.json")); | ||
const messages = __importStar(require("@cucumber/messages")); | ||
const Errors_1 = require("./Errors"); | ||
const DIALECT_DICT = gherkin_languages_json_1.default; | ||
const DEFAULT_DOC_STRING_SEPARATOR = /^(```[`]*)(.*)/; | ||
function addKeywordTypeMappings(h, keywords, keywordType) { | ||
for (const k of keywords) { | ||
if (!(k in h)) { | ||
h[k] = []; | ||
} | ||
h[k].push(keywordType); | ||
} | ||
} | ||
class GherkinInMarkdownTokenMatcher { | ||
@@ -23,2 +55,3 @@ constructor(defaultDialectName = 'en') { | ||
.filter((value, index, self) => value !== '* ' && self.indexOf(value) === index); | ||
this.initializeKeywordTypes(); | ||
this.stepRegexp = new RegExp(`${KeywordPrefix.BULLET}(${this.nonStarStepKeywords.map(escapeRegExp).join('|')})`); | ||
@@ -43,3 +76,11 @@ const headerKeywords = [] | ||
this.dialect = newDialect; | ||
this.initializeKeywordTypes(); | ||
} | ||
initializeKeywordTypes() { | ||
this.keywordTypesMap = {}; | ||
addKeywordTypeMappings(this.keywordTypesMap, this.dialect.given, messages.StepKeywordType.CONTEXT); | ||
addKeywordTypeMappings(this.keywordTypesMap, this.dialect.when, messages.StepKeywordType.ACTION); | ||
addKeywordTypeMappings(this.keywordTypesMap, this.dialect.then, messages.StepKeywordType.OUTCOME); | ||
addKeywordTypeMappings(this.keywordTypesMap, [].concat(this.dialect.and).concat(this.dialect.but), messages.StepKeywordType.CONJUNCTION); | ||
} | ||
// We've made a deliberate choice not to support `# language: [ISO 639-1]` headers or similar | ||
@@ -162,2 +203,11 @@ // in Markdown. Users should specify a language globally. This can be done in | ||
token.matchedKeyword = match[2]; | ||
if (match[2] in this.keywordTypesMap) { | ||
// only set the keyword type if this is a step keyword | ||
if (this.keywordTypesMap[match[2]].length > 1) { | ||
token.matchedKeywordType = messages.StepKeywordType.UNKNOWN; | ||
} | ||
else { | ||
token.matchedKeywordType = this.keywordTypesMap[match[2]][0]; | ||
} | ||
} | ||
token.matchedText = match[3].trim(); | ||
@@ -164,0 +214,0 @@ indent += match[1].length; |
@@ -25,2 +25,3 @@ import * as messages from '@cucumber/messages'; | ||
matchedKeyword: string; | ||
matchedKeywordType: messages.StepKeywordType; | ||
matchedIndent: number; | ||
@@ -27,0 +28,0 @@ matchedGherkinDialect: string; |
@@ -16,2 +16,3 @@ import * as messages from '@cucumber/messages'; | ||
matchedGherkinDialect: string; | ||
matchedKeywordType: messages.StepKeywordType; | ||
constructor(line: GherkinLine, location: messages.Location); | ||
@@ -18,0 +19,0 @@ getTokenValue(): string; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const messages = __importStar(require("@cucumber/messages")); | ||
const pickleStepTypeFromKeyword = { | ||
[messages.StepKeywordType.UNKNOWN]: messages.PickleStepType.UNKNOWN, | ||
[messages.StepKeywordType.CONTEXT]: messages.PickleStepType.CONTEXT, | ||
[messages.StepKeywordType.ACTION]: messages.PickleStepType.ACTION, | ||
[messages.StepKeywordType.OUTCOME]: messages.PickleStepType.OUTCOME, | ||
[messages.StepKeywordType.CONJUNCTION]: null | ||
}; | ||
function compile(gherkinDocument, uri, newId) { | ||
@@ -45,7 +76,17 @@ const pickles = []; | ||
function compileScenario(inheritedTags, backgroundSteps, scenario, language, pickles, uri, newId) { | ||
const steps = scenario.steps.length === 0 | ||
? [] | ||
: backgroundSteps.map((step) => pickleStep(step, [], null, newId)); | ||
let lastKeywordType = messages.StepKeywordType.UNKNOWN; | ||
const steps = []; | ||
if (scenario.steps.length !== 0) { | ||
backgroundSteps.forEach((step) => { | ||
lastKeywordType = (step.keywordType === messages.StepKeywordType.CONJUNCTION) ? | ||
lastKeywordType : step.keywordType; | ||
steps.push(pickleStep(step, [], null, newId, lastKeywordType)); | ||
}); | ||
} | ||
const tags = [].concat(inheritedTags).concat(scenario.tags); | ||
scenario.steps.forEach((step) => steps.push(pickleStep(step, [], null, newId))); | ||
scenario.steps.forEach((step) => { | ||
lastKeywordType = (step.keywordType === messages.StepKeywordType.CONJUNCTION) ? | ||
lastKeywordType : step.keywordType; | ||
steps.push(pickleStep(step, [], null, newId, lastKeywordType)); | ||
}); | ||
const pickle = { | ||
@@ -68,7 +109,15 @@ id: newId(), | ||
examples.tableBody.forEach((valuesRow) => { | ||
const steps = scenario.steps.length === 0 | ||
? [] | ||
: backgroundSteps.map((step) => pickleStep(step, [], null, newId)); | ||
let lastKeywordType = messages.StepKeywordType.UNKNOWN; | ||
const steps = []; | ||
if (scenario.steps.length !== 0) { | ||
backgroundSteps.forEach((step) => { | ||
lastKeywordType = (step.keywordType === messages.StepKeywordType.CONJUNCTION) ? | ||
lastKeywordType : step.keywordType; | ||
steps.push(pickleStep(step, [], null, newId, lastKeywordType)); | ||
}); | ||
} | ||
scenario.steps.forEach((scenarioOutlineStep) => { | ||
const step = pickleStep(scenarioOutlineStep, variableCells, valuesRow, newId); | ||
lastKeywordType = (scenarioOutlineStep.keywordType === messages.StepKeywordType.CONJUNCTION) ? | ||
lastKeywordType : scenarioOutlineStep.keywordType; | ||
const step = pickleStep(scenarioOutlineStep, variableCells, valuesRow, newId, lastKeywordType); | ||
steps.push(step); | ||
@@ -130,3 +179,3 @@ }); | ||
} | ||
function pickleStep(step, variableCells, valuesRow, newId) { | ||
function pickleStep(step, variableCells, valuesRow, newId, keywordType) { | ||
const astNodeIds = [step.id]; | ||
@@ -140,2 +189,3 @@ if (valuesRow) { | ||
text: interpolate(step.text, variableCells, valueCells), | ||
type: pickleStepTypeFromKeyword[keywordType], | ||
argument: createPickleArguments(step, variableCells, valueCells), | ||
@@ -142,0 +192,0 @@ astNodeIds: astNodeIds, |
{ | ||
"name": "@cucumber/gherkin", | ||
"version": "23.0.1", | ||
"version": "24.0.0", | ||
"description": "Gherkin parser", | ||
@@ -27,11 +27,11 @@ "main": "dist/src/index.js", | ||
"@cucumber/gherkin-streams": "^5.0.1", | ||
"@types/mocha": "9.1.0", | ||
"@types/node": "16.11.26", | ||
"core-js": "3.21.1", | ||
"mocha": "9.2.2", | ||
"ts-node": "10.7.0", | ||
"typescript": "4.6.3" | ||
"@types/mocha": "9.1.1", | ||
"@types/node": "16.11.36", | ||
"core-js": "3.22.7", | ||
"mocha": "10.0.0", | ||
"ts-node": "10.8.0", | ||
"typescript": "4.7.2" | ||
}, | ||
"dependencies": { | ||
"@cucumber/messages": "^18.0.0" | ||
"@cucumber/messages": "^19.0.0" | ||
}, | ||
@@ -38,0 +38,0 @@ "directories": { |
@@ -128,2 +128,3 @@ import AstNode from './AstNode' | ||
keyword: stepLine.matchedKeyword, | ||
keywordType: stepLine.matchedKeywordType, | ||
text: stepLine.matchedText, | ||
@@ -130,0 +131,0 @@ dataTable: dataTable, |
@@ -970,5 +970,8 @@ { | ||
"* ", | ||
"Tha ", | ||
"Þa ", | ||
"Ða " | ||
"Bæþsealf ", | ||
"Bæþsealfa ", | ||
"Bæþsealfe ", | ||
"Ciricæw ", | ||
"Ciricæwe ", | ||
"Ciricæwa " | ||
] | ||
@@ -2399,3 +2402,3 @@ }, | ||
"र ", | ||
"अनी " | ||
"अनि " | ||
], | ||
@@ -3464,3 +3467,3 @@ "background": [ | ||
"* ", | ||
"Агар " | ||
"Belgilangan " | ||
], | ||
@@ -3467,0 +3470,0 @@ "name": "Uzbek", |
@@ -13,2 +13,11 @@ import DIALECTS from './gherkin-languages.json' | ||
function addKeywordTypeMappings(h: { [key: string]: messages.StepKeywordType[] }, keywords: readonly string[], keywordType: messages.StepKeywordType) { | ||
for (const k of keywords) { | ||
if (!(k in h)) { | ||
h[k] = [] as messages.StepKeywordType[] | ||
} | ||
h[k].push(keywordType) | ||
} | ||
} | ||
export default class GherkinClassicTokenMatcher implements ITokenMatcher<TokenType> { | ||
@@ -19,2 +28,3 @@ private dialect: Dialect | ||
private indentToRemove: number | ||
private keywordTypesMap: { [key: string]: messages.StepKeywordType[] } | ||
@@ -33,2 +43,3 @@ constructor(private readonly defaultDialectName: string = 'en') { | ||
this.dialect = newDialect | ||
this.initializeKeywordTypes() | ||
} | ||
@@ -44,5 +55,15 @@ | ||
initializeKeywordTypes() { | ||
this.keywordTypesMap = {} | ||
addKeywordTypeMappings(this.keywordTypesMap, this.dialect.given, messages.StepKeywordType.CONTEXT) | ||
addKeywordTypeMappings(this.keywordTypesMap, this.dialect.when, messages.StepKeywordType.ACTION) | ||
addKeywordTypeMappings(this.keywordTypesMap, this.dialect.then, messages.StepKeywordType.OUTCOME) | ||
addKeywordTypeMappings(this.keywordTypesMap, | ||
[].concat(this.dialect.and).concat(this.dialect.but), | ||
messages.StepKeywordType.CONJUNCTION) | ||
} | ||
match_TagLine(token: IToken<TokenType>) { | ||
if (token.line.startsWith('@')) { | ||
this.setTokenMatched(token, TokenType.TagLine, null, null, null, this.getTags(token.line)) | ||
this.setTokenMatched(token, TokenType.TagLine, null, null, null, null, this.getTags(token.line)) | ||
return true | ||
@@ -79,3 +100,3 @@ } | ||
// TODO: indent | ||
this.setTokenMatched(token, TokenType.TableRow, null, null, null, token.line.getTableCells()) | ||
this.setTokenMatched(token, TokenType.TableRow, null, null, null, null, token.line.getTableCells()) | ||
return true | ||
@@ -160,6 +181,13 @@ } | ||
const title = token.line.getRestTrimmed(keyword.length) | ||
this.setTokenMatched(token, TokenType.StepLine, title, keyword) | ||
const keywordTypes = this.keywordTypesMap[keyword] | ||
let keywordType = keywordTypes[0] | ||
if (keywordTypes.length > 1) { | ||
keywordType = messages.StepKeywordType.UNKNOWN | ||
} | ||
this.setTokenMatched(token, TokenType.StepLine, title, keyword, null, keywordType) | ||
return true | ||
} | ||
} | ||
return false | ||
@@ -215,2 +243,3 @@ } | ||
indent?: number, | ||
keywordType?: messages.StepKeywordType, | ||
items?: readonly Item[] | ||
@@ -221,2 +250,3 @@ ) { | ||
token.matchedKeyword = keyword | ||
token.matchedKeywordType = keywordType | ||
token.matchedIndent = | ||
@@ -223,0 +253,0 @@ typeof indent === 'number' ? indent : token.line == null ? 0 : token.line.indent |
@@ -12,2 +12,11 @@ import ITokenMatcher from './ITokenMatcher' | ||
function addKeywordTypeMappings(h: { [key: string]: messages.StepKeywordType[] }, keywords: readonly string[], keywordType: messages.StepKeywordType) { | ||
for (const k of keywords) { | ||
if (!(k in h)) { | ||
h[k] = [] as messages.StepKeywordType[] | ||
} | ||
h[k].push(keywordType) | ||
} | ||
} | ||
export default class GherkinInMarkdownTokenMatcher implements ITokenMatcher<TokenType> { | ||
@@ -22,2 +31,3 @@ private dialect: Dialect | ||
private matchedFeatureLine: boolean | ||
private keywordTypesMap: { [key: string]: messages.StepKeywordType[] } | ||
@@ -33,2 +43,3 @@ constructor(private readonly defaultDialectName: string = 'en') { | ||
.filter((value, index, self) => value !== '* ' && self.indexOf(value) === index) | ||
this.initializeKeywordTypes() | ||
@@ -63,4 +74,15 @@ this.stepRegexp = new RegExp( | ||
this.dialect = newDialect | ||
this.initializeKeywordTypes() | ||
} | ||
initializeKeywordTypes() { | ||
this.keywordTypesMap = {} | ||
addKeywordTypeMappings(this.keywordTypesMap, this.dialect.given, messages.StepKeywordType.CONTEXT) | ||
addKeywordTypeMappings(this.keywordTypesMap, this.dialect.when, messages.StepKeywordType.ACTION) | ||
addKeywordTypeMappings(this.keywordTypesMap, this.dialect.then, messages.StepKeywordType.OUTCOME) | ||
addKeywordTypeMappings(this.keywordTypesMap, | ||
[].concat(this.dialect.and).concat(this.dialect.but), | ||
messages.StepKeywordType.CONJUNCTION) | ||
} | ||
// We've made a deliberate choice not to support `# language: [ISO 639-1]` headers or similar | ||
@@ -249,2 +271,12 @@ // in Markdown. Users should specify a language globally. This can be done in | ||
token.matchedKeyword = match[2] | ||
if (match[2] in this.keywordTypesMap) { | ||
// only set the keyword type if this is a step keyword | ||
if (this.keywordTypesMap[match[2]].length > 1) { | ||
token.matchedKeywordType = messages.StepKeywordType.UNKNOWN | ||
} | ||
else { | ||
token.matchedKeywordType = this.keywordTypesMap[match[2]][0] | ||
} | ||
} | ||
token.matchedText = match[3].trim() | ||
@@ -251,0 +283,0 @@ indent += match[1].length |
@@ -35,2 +35,3 @@ import * as messages from '@cucumber/messages' | ||
matchedKeyword: string | ||
matchedKeywordType: messages.StepKeywordType | ||
matchedIndent: number | ||
@@ -37,0 +38,0 @@ matchedGherkinDialect: string |
import * as messages from '@cucumber/messages' | ||
import IGherkinDocument = messages.GherkinDocument | ||
const pickleStepTypeFromKeyword: { [key in messages.StepKeywordType]: messages.PickleStepType } = { | ||
[messages.StepKeywordType.UNKNOWN]: messages.PickleStepType.UNKNOWN, | ||
[messages.StepKeywordType.CONTEXT]: messages.PickleStepType.CONTEXT, | ||
[messages.StepKeywordType.ACTION]: messages.PickleStepType.ACTION, | ||
[messages.StepKeywordType.OUTCOME]: messages.PickleStepType.OUTCOME, | ||
[messages.StepKeywordType.CONJUNCTION]: null | ||
} | ||
export default function compile( | ||
@@ -107,10 +115,20 @@ gherkinDocument: IGherkinDocument, | ||
) { | ||
const steps = | ||
scenario.steps.length === 0 | ||
? [] | ||
: backgroundSteps.map((step) => pickleStep(step, [], null, newId)) | ||
let lastKeywordType = messages.StepKeywordType.UNKNOWN | ||
const steps = [] as messages.PickleStep[] | ||
if (scenario.steps.length !== 0) { | ||
backgroundSteps.forEach((step) => { | ||
lastKeywordType = (step.keywordType === messages.StepKeywordType.CONJUNCTION) ? | ||
lastKeywordType : step.keywordType | ||
steps.push(pickleStep(step, [], null, newId, lastKeywordType)) | ||
}) | ||
} | ||
const tags = [].concat(inheritedTags).concat(scenario.tags) | ||
scenario.steps.forEach((step) => steps.push(pickleStep(step, [], null, newId))) | ||
scenario.steps.forEach((step) => { | ||
lastKeywordType = (step.keywordType === messages.StepKeywordType.CONJUNCTION) ? | ||
lastKeywordType : step.keywordType | ||
steps.push(pickleStep(step, [], null, newId, lastKeywordType)) | ||
}) | ||
@@ -143,9 +161,16 @@ const pickle: messages.Pickle = { | ||
examples.tableBody.forEach((valuesRow) => { | ||
const steps = | ||
scenario.steps.length === 0 | ||
? [] | ||
: backgroundSteps.map((step) => pickleStep(step, [], null, newId)) | ||
let lastKeywordType = messages.StepKeywordType.UNKNOWN | ||
const steps = [] as messages.PickleStep[] | ||
if (scenario.steps.length !== 0) { | ||
backgroundSteps.forEach((step) => { | ||
lastKeywordType = (step.keywordType === messages.StepKeywordType.CONJUNCTION) ? | ||
lastKeywordType : step.keywordType | ||
steps.push(pickleStep(step, [], null, newId, lastKeywordType)) | ||
}) | ||
} | ||
scenario.steps.forEach((scenarioOutlineStep) => { | ||
const step = pickleStep(scenarioOutlineStep, variableCells, valuesRow, newId) | ||
lastKeywordType = (scenarioOutlineStep.keywordType === messages.StepKeywordType.CONJUNCTION) ? | ||
lastKeywordType : scenarioOutlineStep.keywordType | ||
const step = pickleStep(scenarioOutlineStep, variableCells, valuesRow, newId, lastKeywordType) | ||
steps.push(step) | ||
@@ -225,3 +250,4 @@ }) | ||
valuesRow: messages.TableRow | null, | ||
newId: messages.IdGenerator.NewId | ||
newId: messages.IdGenerator.NewId, | ||
keywordType: messages.StepKeywordType | ||
): messages.PickleStep { | ||
@@ -237,2 +263,3 @@ const astNodeIds = [step.id] | ||
text: interpolate(step.text, variableCells, valueCells), | ||
type: pickleStepTypeFromKeyword[keywordType], | ||
argument: createPickleArguments(step, variableCells, valueCells), | ||
@@ -239,0 +266,0 @@ astNodeIds: astNodeIds, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
803216
18548
+ Added@cucumber/messages@19.1.4(transitive)
+ Addeduuid@9.0.0(transitive)
- Removed@cucumber/messages@18.0.0(transitive)
- Removeduuid@8.3.2(transitive)
Updated@cucumber/messages@^19.0.0