1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var Errors_1 = require("./Errors");
|
4 | var Argument = (function () {
|
5 | function Argument(group, parameterType) {
|
6 | this.group = group;
|
7 | this.parameterType = parameterType;
|
8 | this.group = group;
|
9 | this.parameterType = parameterType;
|
10 | }
|
11 | Argument.build = function (treeRegexp, text, parameterTypes) {
|
12 | var group = treeRegexp.match(text);
|
13 | if (!group) {
|
14 | return null;
|
15 | }
|
16 | var argGroups = group.children;
|
17 | if (argGroups.length !== parameterTypes.length) {
|
18 | throw new Errors_1.CucumberExpressionError("Expression " + treeRegexp.regexp + " has " + argGroups.length + " capture groups (" + argGroups.map(function (g) { return g.value; }) + "), but there were " + parameterTypes.length + " parameter types (" + parameterTypes.map(function (p) { return p.name; }) + ")");
|
19 | }
|
20 | return parameterTypes.map(function (parameterType, i) { return new Argument(argGroups[i], parameterType); });
|
21 | };
|
22 | |
23 |
|
24 |
|
25 |
|
26 |
|
27 | Argument.prototype.getValue = function (thisObj) {
|
28 | var groupValues = this.group ? this.group.values : null;
|
29 | return this.parameterType.transform(thisObj, groupValues);
|
30 | };
|
31 | return Argument;
|
32 | }());
|
33 | exports.default = Argument;
|
34 | module.exports = Argument;
|
35 |
|
\ | No newline at end of file |