Partial Application Syntax: Stage 1 (#9343)
* add partial application syntax and some tests * remove unnecessary error message and hasPartial function from parseNewArguments * add types for PartialExpression * Update the tests * rename PartialExpression to Partial * move Partial from expressions to types and rename to ArgumentPlaceholder * add tests for ArgumentPlaceholder in babel-generator * rename Partial to ArgumentPlaceholder * update the tests * remove alias from the type and undo changes in generated folder * adds a nice error message * better definition for the type * auto-generated files * update the conditional for allowPlaceholder message and tests * update CallExpression definition to accept ArgumentPlaceholder * change description * clean up * indent ArgumentPlaceholder entry and revert unwanted changes
This commit is contained in:
parent
37a427f692
commit
c60c4dd375
@ -7,6 +7,10 @@ export function Identifier(node: Object) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function ArgumentPlaceholder() {
|
||||||
|
this.token("?");
|
||||||
|
}
|
||||||
|
|
||||||
export function RestElement(node: Object) {
|
export function RestElement(node: Object) {
|
||||||
this.token("...");
|
this.token("...");
|
||||||
this.print(node.argument, node);
|
this.print(node.argument, node);
|
||||||
|
|||||||
12
packages/babel-generator/test/fixtures/types/ArgumentPlaceholder/input.js
vendored
Normal file
12
packages/babel-generator/test/fixtures/types/ArgumentPlaceholder/input.js
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
foo(?);
|
||||||
|
foo(?, x);
|
||||||
|
foo(x, ?);
|
||||||
|
foo(?, x, ?);
|
||||||
|
obj.foo(x, ?);
|
||||||
|
obj.foo(?, x);
|
||||||
|
obj.foo(?, x, ?);
|
||||||
|
class foo {
|
||||||
|
constructor() {
|
||||||
|
baz(this, () => super.bar(?));
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-generator/test/fixtures/types/ArgumentPlaceholder/options.json
vendored
Normal file
1
packages/babel-generator/test/fixtures/types/ArgumentPlaceholder/options.json
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{ "plugins": ["partialApplication"] }
|
||||||
14
packages/babel-generator/test/fixtures/types/ArgumentPlaceholder/output.js
vendored
Normal file
14
packages/babel-generator/test/fixtures/types/ArgumentPlaceholder/output.js
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
foo(?);
|
||||||
|
foo(?, x);
|
||||||
|
foo(x, ?);
|
||||||
|
foo(?, x, ?);
|
||||||
|
obj.foo(x, ?);
|
||||||
|
obj.foo(?, x);
|
||||||
|
obj.foo(?, x, ?);
|
||||||
|
|
||||||
|
class foo {
|
||||||
|
constructor() {
|
||||||
|
baz(this, () => super.bar(?));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -72,6 +72,7 @@ These are the core @babel/parser (babylon) AST node types.
|
|||||||
- [LogicalExpression](#logicalexpression)
|
- [LogicalExpression](#logicalexpression)
|
||||||
- [LogicalOperator](#logicaloperator)
|
- [LogicalOperator](#logicaloperator)
|
||||||
- [SpreadElement](#spreadelement)
|
- [SpreadElement](#spreadelement)
|
||||||
|
- [ArgumentPlaceholder](#argumentplaceholder)
|
||||||
- [MemberExpression](#memberexpression)
|
- [MemberExpression](#memberexpression)
|
||||||
- [BindExpression](#bindexpression)
|
- [BindExpression](#bindexpression)
|
||||||
- [ConditionalExpression](#conditionalexpression)
|
- [ConditionalExpression](#conditionalexpression)
|
||||||
@ -862,6 +863,14 @@ interface SpreadElement <: Node {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### ArgumentPlaceholder
|
||||||
|
|
||||||
|
```js
|
||||||
|
interface ArgumentPlaceholder <: Node {
|
||||||
|
type: "ArgumentPlaceholder";
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### MemberExpression
|
### MemberExpression
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|||||||
@ -323,7 +323,6 @@ export default class ExpressionParser extends LValParser {
|
|||||||
const operator = this.state.value;
|
const operator = this.state.value;
|
||||||
node.left = left;
|
node.left = left;
|
||||||
node.operator = operator;
|
node.operator = operator;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
operator === "**" &&
|
operator === "**" &&
|
||||||
left.type === "UnaryExpression" &&
|
left.type === "UnaryExpression" &&
|
||||||
@ -634,6 +633,7 @@ export default class ExpressionParser extends LValParser {
|
|||||||
tt.parenR,
|
tt.parenR,
|
||||||
possibleAsync,
|
possibleAsync,
|
||||||
base.type === "Import",
|
base.type === "Import",
|
||||||
|
base.type !== "Super",
|
||||||
);
|
);
|
||||||
if (!state.optionalChainMember) {
|
if (!state.optionalChainMember) {
|
||||||
this.finishCallExpression(node);
|
this.finishCallExpression(node);
|
||||||
@ -744,6 +744,7 @@ export default class ExpressionParser extends LValParser {
|
|||||||
close: TokenType,
|
close: TokenType,
|
||||||
possibleAsyncArrow: boolean,
|
possibleAsyncArrow: boolean,
|
||||||
dynamicImport?: boolean,
|
dynamicImport?: boolean,
|
||||||
|
allowPlaceholder?: boolean,
|
||||||
): $ReadOnlyArray<?N.Expression> {
|
): $ReadOnlyArray<?N.Expression> {
|
||||||
const elts = [];
|
const elts = [];
|
||||||
let innerParenStart;
|
let innerParenStart;
|
||||||
@ -776,6 +777,7 @@ export default class ExpressionParser extends LValParser {
|
|||||||
false,
|
false,
|
||||||
possibleAsyncArrow ? { start: 0 } : undefined,
|
possibleAsyncArrow ? { start: 0 } : undefined,
|
||||||
possibleAsyncArrow ? { start: 0 } : undefined,
|
possibleAsyncArrow ? { start: 0 } : undefined,
|
||||||
|
allowPlaceholder,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1945,6 +1947,7 @@ export default class ExpressionParser extends LValParser {
|
|||||||
allowEmpty: ?boolean,
|
allowEmpty: ?boolean,
|
||||||
refShorthandDefaultPos: ?Pos,
|
refShorthandDefaultPos: ?Pos,
|
||||||
refNeedsArrowPos: ?Pos,
|
refNeedsArrowPos: ?Pos,
|
||||||
|
allowPlaceholder: ?boolean,
|
||||||
): ?N.Expression {
|
): ?N.Expression {
|
||||||
let elt;
|
let elt;
|
||||||
if (allowEmpty && this.match(tt.comma)) {
|
if (allowEmpty && this.match(tt.comma)) {
|
||||||
@ -1957,6 +1960,14 @@ export default class ExpressionParser extends LValParser {
|
|||||||
spreadNodeStartPos,
|
spreadNodeStartPos,
|
||||||
spreadNodeStartLoc,
|
spreadNodeStartLoc,
|
||||||
);
|
);
|
||||||
|
} else if (this.match(tt.question)) {
|
||||||
|
this.expectPlugin("partialApplication");
|
||||||
|
if (!allowPlaceholder) {
|
||||||
|
this.raise(this.state.start, "Unexpected argument placeholder");
|
||||||
|
}
|
||||||
|
const node = this.startNode();
|
||||||
|
this.next();
|
||||||
|
elt = this.finishNode(node, "ArgumentPlaceholder");
|
||||||
} else {
|
} else {
|
||||||
elt = this.parseMaybeAssign(
|
elt = this.parseMaybeAssign(
|
||||||
false,
|
false,
|
||||||
|
|||||||
@ -340,6 +340,8 @@ export type VariableDeclarator = NodeBase & {
|
|||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
|
|
||||||
|
export type ArgumentPlaceholder = NodeBase & { type: "ArgumentPlaceholder" };
|
||||||
|
|
||||||
export type Decorator = NodeBase & {
|
export type Decorator = NodeBase & {
|
||||||
type: "Decorator",
|
type: "Decorator",
|
||||||
expression: Expression,
|
expression: Expression,
|
||||||
|
|||||||
1
packages/babel-parser/test/fixtures/experimental/partial-application/call-expr/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/experimental/partial-application/call-expr/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
foo(?)
|
||||||
3
packages/babel-parser/test/fixtures/experimental/partial-application/call-expr/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/experimental/partial-application/call-expr/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["partialApplication"]
|
||||||
|
}
|
||||||
99
packages/babel-parser/test/fixtures/experimental/partial-application/call-expr/output.json
vendored
Normal file
99
packages/babel-parser/test/fixtures/experimental/partial-application/call-expr/output.json
vendored
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 6,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 6
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 6,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 6
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start": 0,
|
||||||
|
"end": 6,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 6
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"start": 0,
|
||||||
|
"end": 6,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 6
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 0,
|
||||||
|
"end": 3,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 3
|
||||||
|
},
|
||||||
|
"identifierName": "foo"
|
||||||
|
},
|
||||||
|
"name": "foo"
|
||||||
|
},
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"type": "ArgumentPlaceholder",
|
||||||
|
"start": 4,
|
||||||
|
"end": 5,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 4
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
class foo {
|
||||||
|
constructor() {
|
||||||
|
baz(this, () => super.bar(?));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["partialApplication"]
|
||||||
|
}
|
||||||
@ -0,0 +1,305 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 78,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 5,
|
||||||
|
"column": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 78,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 5,
|
||||||
|
"column": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ClassDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 78,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 5,
|
||||||
|
"column": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 6,
|
||||||
|
"end": 9,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 6
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"identifierName": "foo"
|
||||||
|
},
|
||||||
|
"name": "foo"
|
||||||
|
},
|
||||||
|
"superClass": null,
|
||||||
|
"body": {
|
||||||
|
"type": "ClassBody",
|
||||||
|
"start": 10,
|
||||||
|
"end": 78,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 10
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 5,
|
||||||
|
"column": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ClassMethod",
|
||||||
|
"start": 16,
|
||||||
|
"end": 76,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 4
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 4,
|
||||||
|
"column": 5
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"static": false,
|
||||||
|
"key": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 16,
|
||||||
|
"end": 27,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 4
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 15
|
||||||
|
},
|
||||||
|
"identifierName": "constructor"
|
||||||
|
},
|
||||||
|
"name": "constructor"
|
||||||
|
},
|
||||||
|
"computed": false,
|
||||||
|
"kind": "constructor",
|
||||||
|
"id": null,
|
||||||
|
"generator": false,
|
||||||
|
"async": false,
|
||||||
|
"params": [],
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"start": 30,
|
||||||
|
"end": 76,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 18
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 4,
|
||||||
|
"column": 5
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start": 40,
|
||||||
|
"end": 70,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 8
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 38
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"start": 40,
|
||||||
|
"end": 69,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 8
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 37
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 40,
|
||||||
|
"end": 43,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 8
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 11
|
||||||
|
},
|
||||||
|
"identifierName": "baz"
|
||||||
|
},
|
||||||
|
"name": "baz"
|
||||||
|
},
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"type": "ThisExpression",
|
||||||
|
"start": 44,
|
||||||
|
"end": 48,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 12
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 16
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ArrowFunctionExpression",
|
||||||
|
"start": 50,
|
||||||
|
"end": 68,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 18
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 36
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": null,
|
||||||
|
"generator": false,
|
||||||
|
"async": false,
|
||||||
|
"params": [],
|
||||||
|
"body": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"start": 56,
|
||||||
|
"end": 68,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 24
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 36
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"callee": {
|
||||||
|
"type": "MemberExpression",
|
||||||
|
"start": 56,
|
||||||
|
"end": 65,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 24
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 33
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"object": {
|
||||||
|
"type": "Super",
|
||||||
|
"start": 56,
|
||||||
|
"end": 61,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 24
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 29
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"property": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 62,
|
||||||
|
"end": 65,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 30
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 33
|
||||||
|
},
|
||||||
|
"identifierName": "bar"
|
||||||
|
},
|
||||||
|
"name": "bar"
|
||||||
|
},
|
||||||
|
"computed": false
|
||||||
|
},
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"type": "ArgumentPlaceholder",
|
||||||
|
"start": 66,
|
||||||
|
"end": 67,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 34
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 35
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
3
packages/babel-parser/test/fixtures/experimental/partial-application/for-any-arg/input.js
vendored
Normal file
3
packages/babel-parser/test/fixtures/experimental/partial-application/for-any-arg/input.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
foo(?,x,?)
|
||||||
|
|
||||||
|
bar.foo(?, x, ?)
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["partialApplication"]
|
||||||
|
}
|
||||||
260
packages/babel-parser/test/fixtures/experimental/partial-application/for-any-arg/output.json
vendored
Normal file
260
packages/babel-parser/test/fixtures/experimental/partial-application/for-any-arg/output.json
vendored
Normal file
@ -0,0 +1,260 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 28,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 16
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 28,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 16
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start": 0,
|
||||||
|
"end": 10,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 10
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"start": 0,
|
||||||
|
"end": 10,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 10
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 0,
|
||||||
|
"end": 3,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 3
|
||||||
|
},
|
||||||
|
"identifierName": "foo"
|
||||||
|
},
|
||||||
|
"name": "foo"
|
||||||
|
},
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"type": "ArgumentPlaceholder",
|
||||||
|
"start": 4,
|
||||||
|
"end": 5,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 4
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 6,
|
||||||
|
"end": 7,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 6
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 7
|
||||||
|
},
|
||||||
|
"identifierName": "x"
|
||||||
|
},
|
||||||
|
"name": "x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ArgumentPlaceholder",
|
||||||
|
"start": 8,
|
||||||
|
"end": 9,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 8
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start": 12,
|
||||||
|
"end": 28,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 16
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"start": 12,
|
||||||
|
"end": 28,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 16
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"callee": {
|
||||||
|
"type": "MemberExpression",
|
||||||
|
"start": 12,
|
||||||
|
"end": 19,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 7
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"object": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 12,
|
||||||
|
"end": 15,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 3
|
||||||
|
},
|
||||||
|
"identifierName": "bar"
|
||||||
|
},
|
||||||
|
"name": "bar"
|
||||||
|
},
|
||||||
|
"property": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 16,
|
||||||
|
"end": 19,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 4
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 7
|
||||||
|
},
|
||||||
|
"identifierName": "foo"
|
||||||
|
},
|
||||||
|
"name": "foo"
|
||||||
|
},
|
||||||
|
"computed": false
|
||||||
|
},
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"type": "ArgumentPlaceholder",
|
||||||
|
"start": 20,
|
||||||
|
"end": 21,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 8
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 9
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 23,
|
||||||
|
"end": 24,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 11
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 12
|
||||||
|
},
|
||||||
|
"identifierName": "x"
|
||||||
|
},
|
||||||
|
"name": "x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ArgumentPlaceholder",
|
||||||
|
"start": 26,
|
||||||
|
"end": 27,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 14
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 15
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
3
packages/babel-parser/test/fixtures/experimental/partial-application/from-left/input.js
vendored
Normal file
3
packages/babel-parser/test/fixtures/experimental/partial-application/from-left/input.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
foo(x,?)
|
||||||
|
|
||||||
|
bar.foo(x,?)
|
||||||
3
packages/babel-parser/test/fixtures/experimental/partial-application/from-left/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/experimental/partial-application/from-left/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["partialApplication"]
|
||||||
|
}
|
||||||
230
packages/babel-parser/test/fixtures/experimental/partial-application/from-left/output.json
vendored
Normal file
230
packages/babel-parser/test/fixtures/experimental/partial-application/from-left/output.json
vendored
Normal file
@ -0,0 +1,230 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 22,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 12
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 22,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 12
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start": 0,
|
||||||
|
"end": 8,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 8
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"start": 0,
|
||||||
|
"end": 8,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 8
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 0,
|
||||||
|
"end": 3,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 3
|
||||||
|
},
|
||||||
|
"identifierName": "foo"
|
||||||
|
},
|
||||||
|
"name": "foo"
|
||||||
|
},
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 4,
|
||||||
|
"end": 5,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 4
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 5
|
||||||
|
},
|
||||||
|
"identifierName": "x"
|
||||||
|
},
|
||||||
|
"name": "x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ArgumentPlaceholder",
|
||||||
|
"start": 6,
|
||||||
|
"end": 7,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 6
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 7
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start": 10,
|
||||||
|
"end": 22,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 12
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"start": 10,
|
||||||
|
"end": 22,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 12
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"callee": {
|
||||||
|
"type": "MemberExpression",
|
||||||
|
"start": 10,
|
||||||
|
"end": 17,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 7
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"object": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 10,
|
||||||
|
"end": 13,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 3
|
||||||
|
},
|
||||||
|
"identifierName": "bar"
|
||||||
|
},
|
||||||
|
"name": "bar"
|
||||||
|
},
|
||||||
|
"property": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 14,
|
||||||
|
"end": 17,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 4
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 7
|
||||||
|
},
|
||||||
|
"identifierName": "foo"
|
||||||
|
},
|
||||||
|
"name": "foo"
|
||||||
|
},
|
||||||
|
"computed": false
|
||||||
|
},
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 18,
|
||||||
|
"end": 19,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 8
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"identifierName": "x"
|
||||||
|
},
|
||||||
|
"name": "x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ArgumentPlaceholder",
|
||||||
|
"start": 20,
|
||||||
|
"end": 21,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 10
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 11
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
3
packages/babel-parser/test/fixtures/experimental/partial-application/from-right/input.js
vendored
Normal file
3
packages/babel-parser/test/fixtures/experimental/partial-application/from-right/input.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
foo(?,x)
|
||||||
|
|
||||||
|
bar.foo(?,x)
|
||||||
3
packages/babel-parser/test/fixtures/experimental/partial-application/from-right/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/experimental/partial-application/from-right/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["partialApplication"]
|
||||||
|
}
|
||||||
230
packages/babel-parser/test/fixtures/experimental/partial-application/from-right/output.json
vendored
Normal file
230
packages/babel-parser/test/fixtures/experimental/partial-application/from-right/output.json
vendored
Normal file
@ -0,0 +1,230 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 22,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 12
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 22,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 12
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start": 0,
|
||||||
|
"end": 8,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 8
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"start": 0,
|
||||||
|
"end": 8,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 8
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 0,
|
||||||
|
"end": 3,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 3
|
||||||
|
},
|
||||||
|
"identifierName": "foo"
|
||||||
|
},
|
||||||
|
"name": "foo"
|
||||||
|
},
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"type": "ArgumentPlaceholder",
|
||||||
|
"start": 4,
|
||||||
|
"end": 5,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 4
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 6,
|
||||||
|
"end": 7,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 6
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 7
|
||||||
|
},
|
||||||
|
"identifierName": "x"
|
||||||
|
},
|
||||||
|
"name": "x"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start": 10,
|
||||||
|
"end": 22,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 12
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"start": 10,
|
||||||
|
"end": 22,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 12
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"callee": {
|
||||||
|
"type": "MemberExpression",
|
||||||
|
"start": 10,
|
||||||
|
"end": 17,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 7
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"object": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 10,
|
||||||
|
"end": 13,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 3
|
||||||
|
},
|
||||||
|
"identifierName": "bar"
|
||||||
|
},
|
||||||
|
"name": "bar"
|
||||||
|
},
|
||||||
|
"property": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 14,
|
||||||
|
"end": 17,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 4
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 7
|
||||||
|
},
|
||||||
|
"identifierName": "foo"
|
||||||
|
},
|
||||||
|
"name": "foo"
|
||||||
|
},
|
||||||
|
"computed": false
|
||||||
|
},
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"type": "ArgumentPlaceholder",
|
||||||
|
"start": 18,
|
||||||
|
"end": 19,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 8
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 9
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 20,
|
||||||
|
"end": 21,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 10
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 11
|
||||||
|
},
|
||||||
|
"identifierName": "x"
|
||||||
|
},
|
||||||
|
"name": "x"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
6
packages/babel-parser/test/fixtures/experimental/partial-application/in-SuperCall/input.js
vendored
Normal file
6
packages/babel-parser/test/fixtures/experimental/partial-application/in-SuperCall/input.js
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
class Foo extends Bar {
|
||||||
|
constructor(x){
|
||||||
|
super(x, 1, ?, ?);
|
||||||
|
this.x = x;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["partialApplication"],
|
||||||
|
"throws": "Unexpected argument placeholder (3:16)"
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/experimental/partial-application/in-new/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/experimental/partial-application/in-new/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
new bar(x, ?, 2, ?)
|
||||||
4
packages/babel-parser/test/fixtures/experimental/partial-application/in-new/options.json
vendored
Normal file
4
packages/babel-parser/test/fixtures/experimental/partial-application/in-new/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["partialApplication"],
|
||||||
|
"throws": "Unexpected argument placeholder (1:11)"
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
? + x
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["partialApplication"],
|
||||||
|
"throws": "Unexpected token (1:0)"
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
?.f()
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["partialApplication"],
|
||||||
|
"throws": "Unexpected token (1:0)"
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
src
|
||||||
|
test
|
||||||
|
*.log
|
||||||
19
packages/babel-plugin-syntax-partial-application/README.md
Normal file
19
packages/babel-plugin-syntax-partial-application/README.md
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# @babel/plugin-syntax-partial-application
|
||||||
|
|
||||||
|
> Allow parsing of optional properties
|
||||||
|
|
||||||
|
See our website [@babel/plugin-syntax-partial-application](https://babeljs.io/docs/en/next/babel-plugin-syntax-partial-application.html) for more information.
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
Using npm:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install --save-dev @babel/plugin-syntax-partial-application
|
||||||
|
```
|
||||||
|
|
||||||
|
or using yarn:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
yarn add @babel/plugin-syntax-partial-application --dev
|
||||||
|
```
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"name": "@babel/plugin-syntax-partial-application",
|
||||||
|
"version": "7.2.0",
|
||||||
|
"description": "Allow parsing of partial application syntax",
|
||||||
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-syntax-partial-application",
|
||||||
|
"license": "MIT",
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
},
|
||||||
|
"main": "lib/index.js",
|
||||||
|
"keywords": [
|
||||||
|
"babel-plugin"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/helper-plugin-utils": "^7.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@babel/core": "^7.0.0-0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@babel/core": "^7.2.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
import { declare } from "@babel/helper-plugin-utils";
|
||||||
|
|
||||||
|
export default declare(api => {
|
||||||
|
api.assertVersion(7);
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: "syntax-partial-application",
|
||||||
|
|
||||||
|
manipulateOptions(opts, parserOpts) {
|
||||||
|
parserOpts.plugins.push("partialApplication");
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
@ -660,6 +660,12 @@ export function assertParenthesizedExpression(
|
|||||||
): void {
|
): void {
|
||||||
assert("ParenthesizedExpression", node, opts);
|
assert("ParenthesizedExpression", node, opts);
|
||||||
}
|
}
|
||||||
|
export function assertArgumentPlaceholder(
|
||||||
|
node: Object,
|
||||||
|
opts?: Object = {},
|
||||||
|
): void {
|
||||||
|
assert("ArgumentPlaceholder", node, opts);
|
||||||
|
}
|
||||||
export function assertAwaitExpression(node: Object, opts?: Object = {}): void {
|
export function assertAwaitExpression(node: Object, opts?: Object = {}): void {
|
||||||
assert("AwaitExpression", node, opts);
|
assert("AwaitExpression", node, opts);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -596,6 +596,10 @@ export function ParenthesizedExpression(...args: Array<any>): Object {
|
|||||||
return builder("ParenthesizedExpression", ...args);
|
return builder("ParenthesizedExpression", ...args);
|
||||||
}
|
}
|
||||||
export { ParenthesizedExpression as parenthesizedExpression };
|
export { ParenthesizedExpression as parenthesizedExpression };
|
||||||
|
export function ArgumentPlaceholder(...args: Array<any>): Object {
|
||||||
|
return builder("ArgumentPlaceholder", ...args);
|
||||||
|
}
|
||||||
|
export { ArgumentPlaceholder as argumentPlaceholder };
|
||||||
export function AwaitExpression(...args: Array<any>): Object {
|
export function AwaitExpression(...args: Array<any>): Object {
|
||||||
return builder("AwaitExpression", ...args);
|
return builder("AwaitExpression", ...args);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -138,7 +138,12 @@ defineType("CallExpression", {
|
|||||||
validate: chain(
|
validate: chain(
|
||||||
assertValueType("array"),
|
assertValueType("array"),
|
||||||
assertEach(
|
assertEach(
|
||||||
assertNodeType("Expression", "SpreadElement", "JSXNamespacedName"),
|
assertNodeType(
|
||||||
|
"Expression",
|
||||||
|
"SpreadElement",
|
||||||
|
"JSXNamespacedName",
|
||||||
|
"ArgumentPlaceholder",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|||||||
@ -10,6 +10,8 @@ import {
|
|||||||
classMethodOrDeclareMethodCommon,
|
classMethodOrDeclareMethodCommon,
|
||||||
} from "./es2015";
|
} from "./es2015";
|
||||||
|
|
||||||
|
defineType("ArgumentPlaceholder", {});
|
||||||
|
|
||||||
defineType("AwaitExpression", {
|
defineType("AwaitExpression", {
|
||||||
builder: ["argument"],
|
builder: ["argument"],
|
||||||
visitor: ["argument"],
|
visitor: ["argument"],
|
||||||
|
|||||||
@ -2093,6 +2093,20 @@ export function isParenthesizedExpression(
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
export function isArgumentPlaceholder(node: ?Object, opts?: Object): boolean {
|
||||||
|
if (!node) return false;
|
||||||
|
|
||||||
|
const nodeType = node.type;
|
||||||
|
if (nodeType === "ArgumentPlaceholder") {
|
||||||
|
if (typeof opts === "undefined") {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return shallowEqual(node, opts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
export function isAwaitExpression(node: ?Object, opts?: Object): boolean {
|
export function isAwaitExpression(node: ?Object, opts?: Object): boolean {
|
||||||
if (!node) return false;
|
if (!node) return false;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user