Add parser support for placeholders (#9364)
This commit is contained in:
parent
c60c4dd375
commit
d832c0f434
@ -1048,19 +1048,8 @@ export default class ExpressionParser extends LValParser {
|
|||||||
if (isPrivate) {
|
if (isPrivate) {
|
||||||
this.expectOnePlugin(["classPrivateProperties", "classPrivateMethods"]);
|
this.expectOnePlugin(["classPrivateProperties", "classPrivateMethods"]);
|
||||||
const node = this.startNode();
|
const node = this.startNode();
|
||||||
const columnHashEnd = this.state.end;
|
|
||||||
this.next();
|
this.next();
|
||||||
const columnIdentifierStart = this.state.start;
|
this.assertNoSpace("Unexpected space between # and identifier");
|
||||||
|
|
||||||
const spacesBetweenHashAndIdentifier =
|
|
||||||
columnIdentifierStart - columnHashEnd;
|
|
||||||
if (spacesBetweenHashAndIdentifier != 0) {
|
|
||||||
this.raise(
|
|
||||||
columnIdentifierStart,
|
|
||||||
"Unexpected space between # and identifier",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
node.id = this.parseIdentifier(true);
|
node.id = this.parseIdentifier(true);
|
||||||
return this.finishNode(node, "PrivateName");
|
return this.finishNode(node, "PrivateName");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -416,15 +416,24 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
|
|
||||||
if (this.isLineTerminator()) {
|
if (this.isLineTerminator()) {
|
||||||
node.label = null;
|
node.label = null;
|
||||||
} else if (!this.match(tt.name)) {
|
|
||||||
this.unexpected();
|
|
||||||
} else {
|
} else {
|
||||||
node.label = this.parseIdentifier();
|
node.label = this.parseIdentifier();
|
||||||
this.semicolon();
|
this.semicolon();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify that there is an actual destination to break or
|
this.verifyBreakContinue(node, keyword);
|
||||||
// continue to.
|
|
||||||
|
return this.finishNode(
|
||||||
|
node,
|
||||||
|
isBreak ? "BreakStatement" : "ContinueStatement",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
verifyBreakContinue(
|
||||||
|
node: N.BreakStatement | N.ContinueStatement,
|
||||||
|
keyword: string,
|
||||||
|
) {
|
||||||
|
const isBreak = keyword === "break";
|
||||||
let i;
|
let i;
|
||||||
for (i = 0; i < this.state.labels.length; ++i) {
|
for (i = 0; i < this.state.labels.length; ++i) {
|
||||||
const lab = this.state.labels[i];
|
const lab = this.state.labels[i];
|
||||||
@ -436,10 +445,6 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
if (i === this.state.labels.length) {
|
if (i === this.state.labels.length) {
|
||||||
this.raise(node.start, "Unsyntactic " + keyword);
|
this.raise(node.start, "Unsyntactic " + keyword);
|
||||||
}
|
}
|
||||||
return this.finishNode(
|
|
||||||
node,
|
|
||||||
isBreak ? "BreakStatement" : "ContinueStatement",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
parseDebuggerStatement(node: N.DebuggerStatement): N.DebuggerStatement {
|
parseDebuggerStatement(node: N.DebuggerStatement): N.DebuggerStatement {
|
||||||
@ -800,7 +805,7 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
parseExpressionStatement(
|
parseExpressionStatement(
|
||||||
node: N.ExpressionStatement,
|
node: N.ExpressionStatement,
|
||||||
expr: N.Expression,
|
expr: N.Expression,
|
||||||
): N.ExpressionStatement {
|
): N.Statement {
|
||||||
node.expression = expr;
|
node.expression = expr;
|
||||||
this.semicolon();
|
this.semicolon();
|
||||||
return this.finishNode(node, "ExpressionStatement");
|
return this.finishNode(node, "ExpressionStatement");
|
||||||
@ -1024,6 +1029,7 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
): T {
|
): T {
|
||||||
const isStatement = statement & FUNC_STATEMENT;
|
const isStatement = statement & FUNC_STATEMENT;
|
||||||
const isHangingStatement = statement & FUNC_HANGING_STATEMENT;
|
const isHangingStatement = statement & FUNC_HANGING_STATEMENT;
|
||||||
|
const requireId = !!isStatement && !(statement & FUNC_NULLABLE_ID);
|
||||||
|
|
||||||
this.initFunction(node, isAsync);
|
this.initFunction(node, isAsync);
|
||||||
|
|
||||||
@ -1036,10 +1042,7 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
node.generator = this.eat(tt.star);
|
node.generator = this.eat(tt.star);
|
||||||
|
|
||||||
if (isStatement) {
|
if (isStatement) {
|
||||||
node.id =
|
node.id = this.parseFunctionId(requireId);
|
||||||
statement & FUNC_NULLABLE_ID && !this.match(tt.name)
|
|
||||||
? null
|
|
||||||
: this.parseIdentifier();
|
|
||||||
if (node.id && !isHangingStatement) {
|
if (node.id && !isHangingStatement) {
|
||||||
// If it is a regular function declaration in sloppy mode, then it is
|
// If it is a regular function declaration in sloppy mode, then it is
|
||||||
// subject to Annex B semantics (BIND_FUNCTION). Otherwise, the binding
|
// subject to Annex B semantics (BIND_FUNCTION). Otherwise, the binding
|
||||||
@ -1067,7 +1070,7 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
this.scope.enter(functionFlags(node.async, node.generator));
|
this.scope.enter(functionFlags(node.async, node.generator));
|
||||||
|
|
||||||
if (!isStatement) {
|
if (!isStatement) {
|
||||||
node.id = this.match(tt.name) ? this.parseIdentifier() : null;
|
node.id = this.parseFunctionId();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.parseFunctionParams(node);
|
this.parseFunctionParams(node);
|
||||||
@ -1090,6 +1093,10 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parseFunctionId(requireId?: boolean): ?N.Identifier {
|
||||||
|
return requireId || this.match(tt.name) ? this.parseIdentifier() : null;
|
||||||
|
}
|
||||||
|
|
||||||
parseFunctionParams(node: N.Function, allowModifiers?: boolean): void {
|
parseFunctionParams(node: N.Function, allowModifiers?: boolean): void {
|
||||||
const oldInParameters = this.state.inParameters;
|
const oldInParameters = this.state.inParameters;
|
||||||
this.state.inParameters = true;
|
this.state.inParameters = true;
|
||||||
@ -1122,7 +1129,7 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
|
|
||||||
this.parseClassId(node, isStatement, optionalId);
|
this.parseClassId(node, isStatement, optionalId);
|
||||||
this.parseClassSuper(node);
|
this.parseClassSuper(node);
|
||||||
this.parseClassBody(node);
|
node.body = this.parseClassBody(!!node.superClass);
|
||||||
|
|
||||||
this.state.strict = oldStrict;
|
this.state.strict = oldStrict;
|
||||||
|
|
||||||
@ -1149,7 +1156,7 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
parseClassBody(node: N.Class): void {
|
parseClassBody(constructorAllowsSuper: boolean): N.ClassBody {
|
||||||
this.state.classLevel++;
|
this.state.classLevel++;
|
||||||
|
|
||||||
const state = { hadConstructor: false };
|
const state = { hadConstructor: false };
|
||||||
@ -1159,8 +1166,6 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
|
|
||||||
this.expect(tt.braceL);
|
this.expect(tt.braceL);
|
||||||
|
|
||||||
const constructorAllowsSuper = node.superClass !== null;
|
|
||||||
|
|
||||||
// For the smartPipelines plugin: Disable topic references from outer
|
// For the smartPipelines plugin: Disable topic references from outer
|
||||||
// contexts within the class body. They are permitted in test expressions,
|
// contexts within the class body. They are permitted in test expressions,
|
||||||
// outside of the class body.
|
// outside of the class body.
|
||||||
@ -1212,9 +1217,9 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
node.body = this.finishNode(classBody, "ClassBody");
|
|
||||||
|
|
||||||
this.state.classLevel--;
|
this.state.classLevel--;
|
||||||
|
|
||||||
|
return this.finishNode(classBody, "ClassBody");
|
||||||
}
|
}
|
||||||
|
|
||||||
parseClassMember(
|
parseClassMember(
|
||||||
|
|||||||
@ -113,6 +113,13 @@ export default class UtilParser extends Tokenizer {
|
|||||||
this.eat(type) || this.unexpected(pos, type);
|
this.eat(type) || this.unexpected(pos, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Throws if the current token and the prev one are separated by a space.
|
||||||
|
assertNoSpace(message: string = "Unexpected space."): void {
|
||||||
|
if (this.state.start > this.state.lastTokEnd) {
|
||||||
|
this.raise(this.state.lastTokEnd, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Raise an unexpected token error. Can take the expected token type
|
// Raise an unexpected token error. Can take the expected token type
|
||||||
// instead of a message string.
|
// instead of a message string.
|
||||||
|
|
||||||
|
|||||||
@ -88,12 +88,17 @@ import estree from "./plugins/estree";
|
|||||||
import flow from "./plugins/flow";
|
import flow from "./plugins/flow";
|
||||||
import jsx from "./plugins/jsx";
|
import jsx from "./plugins/jsx";
|
||||||
import typescript from "./plugins/typescript";
|
import typescript from "./plugins/typescript";
|
||||||
|
import placeholders from "./plugins/placeholders";
|
||||||
|
|
||||||
// NOTE: estree must load first; flow and typescript must load last.
|
// NOTE: order is important. estree must come first; placeholders must come last.
|
||||||
export const mixinPluginNames = ["estree", "jsx", "flow", "typescript"];
|
|
||||||
export const mixinPlugins: { [name: string]: MixinPlugin } = {
|
export const mixinPlugins: { [name: string]: MixinPlugin } = {
|
||||||
estree,
|
estree,
|
||||||
jsx,
|
jsx,
|
||||||
flow,
|
flow,
|
||||||
typescript,
|
typescript,
|
||||||
|
placeholders,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const mixinPluginNames: $ReadOnlyArray<string> = Object.keys(
|
||||||
|
mixinPlugins,
|
||||||
|
);
|
||||||
|
|||||||
315
packages/babel-parser/src/plugins/placeholders.js
Normal file
315
packages/babel-parser/src/plugins/placeholders.js
Normal file
@ -0,0 +1,315 @@
|
|||||||
|
// @flow
|
||||||
|
|
||||||
|
import * as charCodes from "charcodes";
|
||||||
|
|
||||||
|
import { types as tt, TokenType } from "../tokenizer/types";
|
||||||
|
import type Parser from "../parser";
|
||||||
|
import * as N from "../types";
|
||||||
|
|
||||||
|
tt.placeholder = new TokenType("%%", { startsExpr: true });
|
||||||
|
|
||||||
|
export type PlaceholderTypes =
|
||||||
|
| "Identifier"
|
||||||
|
| "StringLiteral"
|
||||||
|
| "Expression"
|
||||||
|
| "Statement"
|
||||||
|
| "Declaration"
|
||||||
|
| "BlockStatement"
|
||||||
|
| "ClassBody"
|
||||||
|
| "Pattern";
|
||||||
|
|
||||||
|
// $PropertyType doesn't support enums. Use a fake "switch" (GetPlaceholderNode)
|
||||||
|
//type MaybePlaceholder<T: PlaceholderTypes> = $PropertyType<N, T> | N.Placeholder<T>;
|
||||||
|
|
||||||
|
type _Switch<Value, Cases, Index> = $Call<
|
||||||
|
(
|
||||||
|
$ElementType<$ElementType<Cases, Index>, 0>,
|
||||||
|
) => $ElementType<$ElementType<Cases, Index>, 1>,
|
||||||
|
Value,
|
||||||
|
>;
|
||||||
|
type $Switch<Value, Cases> = _Switch<Value, Cases, *>;
|
||||||
|
|
||||||
|
type NodeOf<T: PlaceholderTypes> = $Switch<
|
||||||
|
T,
|
||||||
|
[
|
||||||
|
["Identifier", N.Identifier],
|
||||||
|
["StringLiteral", N.StringLiteral],
|
||||||
|
["Expression", N.Expression],
|
||||||
|
["Statement", N.Statement],
|
||||||
|
["Declaration", N.Declaration],
|
||||||
|
["BlockStatement", N.BlockStatement],
|
||||||
|
["ClassBody", N.ClassBody],
|
||||||
|
["Pattern", N.Pattern],
|
||||||
|
],
|
||||||
|
>;
|
||||||
|
|
||||||
|
// Placeholder<T> breaks everything, because its type is incompatible with
|
||||||
|
// the substituted nodes.
|
||||||
|
type MaybePlaceholder<T: PlaceholderTypes> = NodeOf<T>; // | Placeholder<T>
|
||||||
|
|
||||||
|
export default (superClass: Class<Parser>): Class<Parser> =>
|
||||||
|
class extends superClass {
|
||||||
|
parsePlaceholder<T: PlaceholderTypes>(
|
||||||
|
expectedNode: T,
|
||||||
|
): /*?N.Placeholder<T>*/ ?MaybePlaceholder<T> {
|
||||||
|
if (this.match(tt.placeholder)) {
|
||||||
|
const node = this.startNode();
|
||||||
|
this.next();
|
||||||
|
this.assertNoSpace("Unexpected space in placeholder.");
|
||||||
|
|
||||||
|
// We can't use this.parseIdentifier because
|
||||||
|
// we don't want nested placeholders.
|
||||||
|
node.name = super.parseIdentifier(/* liberal */ true);
|
||||||
|
|
||||||
|
this.assertNoSpace("Unexpected space in placeholder.");
|
||||||
|
this.expect(tt.placeholder);
|
||||||
|
return this.finishPlaceholder(node, expectedNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
finishPlaceholder<T: PlaceholderTypes>(
|
||||||
|
node: N.Node,
|
||||||
|
expectedNode: T,
|
||||||
|
): /*N.Placeholder<T>*/ MaybePlaceholder<T> {
|
||||||
|
node.expectedNode = expectedNode;
|
||||||
|
return this.finishNode(node, "Placeholder");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================================ *
|
||||||
|
* tokenizer/index.js *
|
||||||
|
* ============================================================ */
|
||||||
|
|
||||||
|
getTokenFromCode(code: number) {
|
||||||
|
if (
|
||||||
|
code === charCodes.percentSign &&
|
||||||
|
this.state.input.charCodeAt(this.state.pos + 1) ===
|
||||||
|
charCodes.percentSign
|
||||||
|
) {
|
||||||
|
return this.finishOp(tt.placeholder, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.getTokenFromCode(...arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================================ *
|
||||||
|
* parser/expression.js *
|
||||||
|
* ============================================================ */
|
||||||
|
|
||||||
|
parseExprAtom(): MaybePlaceholder<"Expression"> {
|
||||||
|
return (
|
||||||
|
this.parsePlaceholder("Expression") || super.parseExprAtom(...arguments)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
parseIdentifier(): MaybePlaceholder<"Identifier"> {
|
||||||
|
// NOTE: This function only handles identifiers outside of
|
||||||
|
// expressions and binding patterns, since they are already
|
||||||
|
// handled by the parseExprAtom and parseBindingAtom functions.
|
||||||
|
// This is needed, for example, to parse "class %%NAME%% {}".
|
||||||
|
return (
|
||||||
|
this.parsePlaceholder("Identifier") ||
|
||||||
|
super.parseIdentifier(...arguments)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
checkReservedWord(word: string): void {
|
||||||
|
// Sometimes we call #checkReservedWord(node.name), expecting
|
||||||
|
// that node is an Identifier. If it is a Placeholder, name
|
||||||
|
// will be undefined.
|
||||||
|
if (word !== undefined) super.checkReservedWord(...arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================================ *
|
||||||
|
* parser/lval.js *
|
||||||
|
* ============================================================ */
|
||||||
|
|
||||||
|
parseBindingAtom(): MaybePlaceholder<"Pattern"> {
|
||||||
|
return (
|
||||||
|
this.parsePlaceholder("Pattern") || super.parseBindingAtom(...arguments)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
checkLVal(expr: N.Expression): void {
|
||||||
|
if (expr.type !== "Placeholder") super.checkLVal(...arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
toAssignable(node: N.Node): N.Node {
|
||||||
|
if (
|
||||||
|
node &&
|
||||||
|
node.type === "Placeholder" &&
|
||||||
|
node.expectedNode === "Expression"
|
||||||
|
) {
|
||||||
|
node.expectedNode = "Pattern";
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
return super.toAssignable(...arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================================================ *
|
||||||
|
* parser/statement.js *
|
||||||
|
* ============================================================ */
|
||||||
|
|
||||||
|
verifyBreakContinue(node: N.BreakStatement | N.ContinueStatement) {
|
||||||
|
if (node.label && node.label.type === "Placeholder") return;
|
||||||
|
super.verifyBreakContinue(...arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
parseExpressionStatement(
|
||||||
|
node: MaybePlaceholder<"Statement">,
|
||||||
|
expr: N.Expression,
|
||||||
|
): MaybePlaceholder<"Statement"> {
|
||||||
|
if (
|
||||||
|
expr.type !== "Placeholder" ||
|
||||||
|
(expr.extra && expr.extra.parenthesized)
|
||||||
|
) {
|
||||||
|
return super.parseExpressionStatement(...arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.match(tt.colon)) {
|
||||||
|
const stmt: N.LabeledStatement = node;
|
||||||
|
stmt.label = this.finishPlaceholder(expr, "Identifier");
|
||||||
|
this.next();
|
||||||
|
stmt.body = this.parseStatement("label");
|
||||||
|
return this.finishNode(stmt, "LabeledStatement");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.semicolon();
|
||||||
|
|
||||||
|
node.name = expr.name;
|
||||||
|
return this.finishPlaceholder(node, "Statement");
|
||||||
|
}
|
||||||
|
|
||||||
|
parseBlock(): MaybePlaceholder<"BlockStatement"> {
|
||||||
|
return (
|
||||||
|
this.parsePlaceholder("BlockStatement") ||
|
||||||
|
super.parseBlock(...arguments)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
parseFunctionId(): ?MaybePlaceholder<"Identifier"> {
|
||||||
|
return (
|
||||||
|
this.parsePlaceholder("Identifier") ||
|
||||||
|
super.parseFunctionId(...arguments)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
parseClass<T: N.Class>(
|
||||||
|
node: T,
|
||||||
|
isStatement: /* T === ClassDeclaration */ boolean,
|
||||||
|
optionalId?: boolean,
|
||||||
|
): T {
|
||||||
|
const type = isStatement ? "ClassDeclaration" : "ClassExpression";
|
||||||
|
|
||||||
|
this.next();
|
||||||
|
this.takeDecorators(node);
|
||||||
|
|
||||||
|
const placeholder = this.parsePlaceholder("Identifier");
|
||||||
|
if (placeholder) {
|
||||||
|
if (
|
||||||
|
this.match(tt._extends) ||
|
||||||
|
this.match(tt.placeholder) ||
|
||||||
|
this.match(tt.braceL)
|
||||||
|
) {
|
||||||
|
node.id = placeholder;
|
||||||
|
} else if (optionalId || !isStatement) {
|
||||||
|
node.id = null;
|
||||||
|
node.body = this.finishPlaceholder(placeholder, "ClassBody");
|
||||||
|
return this.finishNode(node, type);
|
||||||
|
} else {
|
||||||
|
this.unexpected(null, "A class name is required");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.parseClassId(node, isStatement, optionalId);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.parseClassSuper(node);
|
||||||
|
node.body =
|
||||||
|
this.parsePlaceholder("ClassBody") ||
|
||||||
|
this.parseClassBody(!!node.superClass);
|
||||||
|
return this.finishNode(node, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
parseExport(node: N.Node): N.Node {
|
||||||
|
const placeholder = this.parsePlaceholder("Identifier");
|
||||||
|
if (!placeholder) return super.parseExport(...arguments);
|
||||||
|
|
||||||
|
if (!this.isContextual("from") && !this.match(tt.comma)) {
|
||||||
|
// export %%DECL%%;
|
||||||
|
node.specifiers = [];
|
||||||
|
node.source = null;
|
||||||
|
node.declaration = this.finishPlaceholder(placeholder, "Declaration");
|
||||||
|
return this.finishNode(node, "ExportNamedDeclaration");
|
||||||
|
}
|
||||||
|
|
||||||
|
// export %%NAME%% from "foo";
|
||||||
|
this.expectPlugin("exportDefaultFrom");
|
||||||
|
const specifier = this.startNode();
|
||||||
|
specifier.exported = placeholder;
|
||||||
|
node.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")];
|
||||||
|
|
||||||
|
return super.parseExport(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
maybeParseExportDefaultSpecifier(node: N.Node): boolean {
|
||||||
|
if (node.specifiers && node.specifiers.length > 0) {
|
||||||
|
// "export %%NAME%%" has already been parsed by #parseExport.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.maybeParseExportDefaultSpecifier(...arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
checkExport(node: N.ExportNamedDeclaration): void {
|
||||||
|
const { specifiers } = node;
|
||||||
|
if (specifiers && specifiers.length) {
|
||||||
|
node.specifiers = specifiers.filter(
|
||||||
|
node => node.exported.type === "Placeholder",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
super.checkExport(node);
|
||||||
|
node.specifiers = specifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
parseImport(
|
||||||
|
node: N.Node,
|
||||||
|
): N.ImportDeclaration | N.TsImportEqualsDeclaration {
|
||||||
|
const placeholder = this.parsePlaceholder("Identifier");
|
||||||
|
if (!placeholder) return super.parseImport(...arguments);
|
||||||
|
|
||||||
|
node.specifiers = [];
|
||||||
|
|
||||||
|
if (!this.isContextual("from") && !this.match(tt.comma)) {
|
||||||
|
// import %%STRING%%;
|
||||||
|
node.source = this.finishPlaceholder(placeholder, "StringLiteral");
|
||||||
|
this.semicolon();
|
||||||
|
return this.finishNode(node, "ImportDeclaration");
|
||||||
|
}
|
||||||
|
|
||||||
|
// import %%DEFAULT%% ...
|
||||||
|
const specifier = this.startNodeAtNode(placeholder);
|
||||||
|
specifier.local = placeholder;
|
||||||
|
this.finishNode(specifier, "ImportDefaultSpecifier");
|
||||||
|
node.specifiers.push(specifier);
|
||||||
|
|
||||||
|
if (this.eat(tt.comma)) {
|
||||||
|
// import %%DEFAULT%%, * as ...
|
||||||
|
const hasStarImport = this.maybeParseStarImportSpecifier(node);
|
||||||
|
|
||||||
|
// import %%DEFAULT%%, { ...
|
||||||
|
if (!hasStarImport) this.parseNamedImportSpecifiers(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.expectContextual("from");
|
||||||
|
node.source = this.parseImportSource();
|
||||||
|
this.semicolon();
|
||||||
|
return this.finishNode(node, "ImportDeclaration");
|
||||||
|
}
|
||||||
|
|
||||||
|
parseImportSource(): MaybePlaceholder<"StringLiteral"> {
|
||||||
|
// import ... from %%STRING%%;
|
||||||
|
|
||||||
|
return (
|
||||||
|
this.parsePlaceholder("StringLiteral") ||
|
||||||
|
super.parseImportSource(...arguments)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -3,6 +3,7 @@
|
|||||||
import type { SourceType } from "./options";
|
import type { SourceType } from "./options";
|
||||||
import type { Token } from "./tokenizer";
|
import type { Token } from "./tokenizer";
|
||||||
import type { SourceLocation } from "./util/location";
|
import type { SourceLocation } from "./util/location";
|
||||||
|
import type { PlaceholderTypes } from "./plugins/placeholders";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If making any changes to the AST, update:
|
* If making any changes to the AST, update:
|
||||||
@ -45,6 +46,7 @@ export type Pattern =
|
|||||||
| ArrayPattern
|
| ArrayPattern
|
||||||
| RestElement
|
| RestElement
|
||||||
| AssignmentPattern;
|
| AssignmentPattern;
|
||||||
|
//| Placeholder<"Pattern">;
|
||||||
export type Declaration =
|
export type Declaration =
|
||||||
| VariableDeclaration
|
| VariableDeclaration
|
||||||
| ClassDeclaration
|
| ClassDeclaration
|
||||||
@ -53,6 +55,8 @@ export type Declaration =
|
|||||||
| TsTypeAliasDeclaration
|
| TsTypeAliasDeclaration
|
||||||
| TsEnumDeclaration
|
| TsEnumDeclaration
|
||||||
| TsModuleDeclaration;
|
| TsModuleDeclaration;
|
||||||
|
// | Placeholder<"Declaration">;
|
||||||
|
|
||||||
export type DeclarationBase = NodeBase & {
|
export type DeclarationBase = NodeBase & {
|
||||||
// TypeScript allows declarations to be prefixed by `declare`.
|
// TypeScript allows declarations to be prefixed by `declare`.
|
||||||
//TODO: a FunctionDeclaration is never "declare", because it's a TSDeclareFunction instead.
|
//TODO: a FunctionDeclaration is never "declare", because it's a TSDeclareFunction instead.
|
||||||
@ -78,6 +82,7 @@ export type Identifier = PatternBase & {
|
|||||||
// TypeScript only. Used in case of an optional parameter.
|
// TypeScript only. Used in case of an optional parameter.
|
||||||
optional?: ?true,
|
optional?: ?true,
|
||||||
};
|
};
|
||||||
|
// | Placeholder<"Identifier">;
|
||||||
|
|
||||||
export type PrivateName = NodeBase & {
|
export type PrivateName = NodeBase & {
|
||||||
type: "PrivateName",
|
type: "PrivateName",
|
||||||
@ -188,6 +193,7 @@ export type BlockStatement = NodeBase & {
|
|||||||
body: Array<Statement>, // TODO: $ReadOnlyArray
|
body: Array<Statement>, // TODO: $ReadOnlyArray
|
||||||
directives: $ReadOnlyArray<Directive>,
|
directives: $ReadOnlyArray<Directive>,
|
||||||
};
|
};
|
||||||
|
// | Placeholder<"BlockStatement">;
|
||||||
|
|
||||||
export type EmptyStatement = NodeBase & {
|
export type EmptyStatement = NodeBase & {
|
||||||
type: "EmptyStatement",
|
type: "EmptyStatement",
|
||||||
@ -682,6 +688,7 @@ export type ClassBody = NodeBase & {
|
|||||||
type: "ClassBody",
|
type: "ClassBody",
|
||||||
body: Array<ClassMember | TsIndexSignature>, // TODO: $ReadOnlyArray
|
body: Array<ClassMember | TsIndexSignature>, // TODO: $ReadOnlyArray
|
||||||
};
|
};
|
||||||
|
// | Placeholder<"ClassBody">;
|
||||||
|
|
||||||
export type ClassMemberBase = NodeBase &
|
export type ClassMemberBase = NodeBase &
|
||||||
HasDecorators & {
|
HasDecorators & {
|
||||||
@ -1421,6 +1428,16 @@ export type TsNonNullExpression = NodeBase & {
|
|||||||
expression: Expression,
|
expression: Expression,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ================
|
||||||
|
// Babel placeholders %%foo%%
|
||||||
|
// ================
|
||||||
|
|
||||||
|
export type Placeholder<N: PlaceholderTypes> = NodeBase & {
|
||||||
|
type: "Placeholder",
|
||||||
|
id: Identifier,
|
||||||
|
expectedNode: N,
|
||||||
|
};
|
||||||
|
|
||||||
// ================
|
// ================
|
||||||
// Other
|
// Other
|
||||||
// ================
|
// ================
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"throws": "Unexpected space between # and identifier (2:5)",
|
"throws": "Unexpected space between # and identifier (2:3)",
|
||||||
"plugins": ["classPrivateMethods"]
|
"plugins": ["classPrivateMethods"]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"throws": "Unexpected space between # and identifier (2:5)",
|
"throws": "Unexpected space between # and identifier (2:3)",
|
||||||
"plugins": ["classPrivateMethods"]
|
"plugins": ["classPrivateMethods"]
|
||||||
}
|
}
|
||||||
|
|||||||
1
packages/babel-parser/test/fixtures/placeholders/_errors/no-plugin/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/_errors/no-plugin/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
%%FOO%%
|
||||||
4
packages/babel-parser/test/fixtures/placeholders/_errors/no-plugin/options.json
vendored
Normal file
4
packages/babel-parser/test/fixtures/placeholders/_errors/no-plugin/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"plugins": [],
|
||||||
|
"throws": "Unexpected token (1:0)"
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/_errors/space-after/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/_errors/space-after/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
%%FOO %%
|
||||||
4
packages/babel-parser/test/fixtures/placeholders/_errors/space-after/options.json
vendored
Normal file
4
packages/babel-parser/test/fixtures/placeholders/_errors/space-after/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["placeholders"],
|
||||||
|
"throws": "Unexpected space in placeholder. (1:5)"
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/_errors/space-before/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/_errors/space-before/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
%% FOO%%
|
||||||
4
packages/babel-parser/test/fixtures/placeholders/_errors/space-before/options.json
vendored
Normal file
4
packages/babel-parser/test/fixtures/placeholders/_errors/space-before/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["placeholders"],
|
||||||
|
"throws": "Unexpected space in placeholder. (1:2)"
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/arrow/async-parenless/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/arrow/async-parenless/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
async %%PARAM%% => %%BODY%%;
|
||||||
4
packages/babel-parser/test/fixtures/placeholders/arrow/async-parenless/options.json
vendored
Normal file
4
packages/babel-parser/test/fixtures/placeholders/arrow/async-parenless/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["placeholders"],
|
||||||
|
"throws": "Unexpected token, expected \";\" (1:6)"
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/arrow/async/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/arrow/async/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
async (%%PARAM%%) => %%BODY%%;
|
||||||
136
packages/babel-parser/test/fixtures/placeholders/arrow/async/output.json
vendored
Normal file
136
packages/babel-parser/test/fixtures/placeholders/arrow/async/output.json
vendored
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 30,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 30
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 30,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 30
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start": 0,
|
||||||
|
"end": 30,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 30
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"expression": {
|
||||||
|
"type": "ArrowFunctionExpression",
|
||||||
|
"start": 0,
|
||||||
|
"end": 29,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 29
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": null,
|
||||||
|
"generator": false,
|
||||||
|
"async": true,
|
||||||
|
"params": [
|
||||||
|
{
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 7,
|
||||||
|
"end": 16,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 7
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 16
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 9,
|
||||||
|
"end": 14,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 14
|
||||||
|
},
|
||||||
|
"identifierName": "PARAM"
|
||||||
|
},
|
||||||
|
"name": "PARAM"
|
||||||
|
},
|
||||||
|
"expectedNode": "Pattern"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"body": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 21,
|
||||||
|
"end": 29,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 21
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 29
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 23,
|
||||||
|
"end": 27,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 23
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 27
|
||||||
|
},
|
||||||
|
"identifierName": "BODY"
|
||||||
|
},
|
||||||
|
"name": "BODY"
|
||||||
|
},
|
||||||
|
"expectedNode": "Expression"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/arrow/sync-parenless/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/arrow/sync-parenless/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
%%PARAM%% => %%BODY%%;
|
||||||
4
packages/babel-parser/test/fixtures/placeholders/arrow/sync-parenless/options.json
vendored
Normal file
4
packages/babel-parser/test/fixtures/placeholders/arrow/sync-parenless/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["placeholders"],
|
||||||
|
"throws": "Unexpected token, expected \";\" (1:10)"
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/arrow/sync/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/arrow/sync/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
(%%PARAM%%) => %%BODY%%;
|
||||||
136
packages/babel-parser/test/fixtures/placeholders/arrow/sync/output.json
vendored
Normal file
136
packages/babel-parser/test/fixtures/placeholders/arrow/sync/output.json
vendored
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 24,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 24
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 24,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 24
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start": 0,
|
||||||
|
"end": 24,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 24
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"expression": {
|
||||||
|
"type": "ArrowFunctionExpression",
|
||||||
|
"start": 0,
|
||||||
|
"end": 23,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 23
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": null,
|
||||||
|
"generator": false,
|
||||||
|
"async": false,
|
||||||
|
"params": [
|
||||||
|
{
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 1,
|
||||||
|
"end": 10,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 1
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 10
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 3,
|
||||||
|
"end": 8,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 3
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 8
|
||||||
|
},
|
||||||
|
"identifierName": "PARAM"
|
||||||
|
},
|
||||||
|
"name": "PARAM"
|
||||||
|
},
|
||||||
|
"expectedNode": "Pattern"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"body": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 15,
|
||||||
|
"end": 23,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 23
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 17,
|
||||||
|
"end": 21,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 17
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 21
|
||||||
|
},
|
||||||
|
"identifierName": "BODY"
|
||||||
|
},
|
||||||
|
"name": "BODY"
|
||||||
|
},
|
||||||
|
"expectedNode": "Expression"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/class/body_expression/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/class/body_expression/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
void class %%BODY%%
|
||||||
116
packages/babel-parser/test/fixtures/placeholders/class/body_expression/output.json
vendored
Normal file
116
packages/babel-parser/test/fixtures/placeholders/class/body_expression/output.json
vendored
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 19,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 19
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 19,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 19
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start": 0,
|
||||||
|
"end": 19,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 19
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"expression": {
|
||||||
|
"type": "UnaryExpression",
|
||||||
|
"start": 0,
|
||||||
|
"end": 19,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 19
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"operator": "void",
|
||||||
|
"prefix": true,
|
||||||
|
"argument": {
|
||||||
|
"type": "ClassExpression",
|
||||||
|
"start": 5,
|
||||||
|
"end": 19,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 5
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 19
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": null,
|
||||||
|
"body": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 11,
|
||||||
|
"end": 19,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 11
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 19
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 13,
|
||||||
|
"end": 17,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 13
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 17
|
||||||
|
},
|
||||||
|
"identifierName": "BODY"
|
||||||
|
},
|
||||||
|
"name": "BODY"
|
||||||
|
},
|
||||||
|
"expectedNode": "ClassBody"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/class/body_statement/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/class/body_statement/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
class Cl %%BODY%%
|
||||||
101
packages/babel-parser/test/fixtures/placeholders/class/body_statement/output.json
vendored
Normal file
101
packages/babel-parser/test/fixtures/placeholders/class/body_statement/output.json
vendored
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 17,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 17
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 17,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 17
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ClassDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 17,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 17
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 6,
|
||||||
|
"end": 8,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 6
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 8
|
||||||
|
},
|
||||||
|
"identifierName": "Cl"
|
||||||
|
},
|
||||||
|
"name": "Cl"
|
||||||
|
},
|
||||||
|
"superClass": null,
|
||||||
|
"body": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 9,
|
||||||
|
"end": 17,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 17
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 11,
|
||||||
|
"end": 15,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 11
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
},
|
||||||
|
"identifierName": "BODY"
|
||||||
|
},
|
||||||
|
"name": "BODY"
|
||||||
|
},
|
||||||
|
"expectedNode": "ClassBody"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
2
packages/babel-parser/test/fixtures/placeholders/class/decorators/input.js
vendored
Normal file
2
packages/babel-parser/test/fixtures/placeholders/class/decorators/input.js
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
@(%%FOO%%)
|
||||||
|
class A {}
|
||||||
6
packages/babel-parser/test/fixtures/placeholders/class/decorators/options.json
vendored
Normal file
6
packages/babel-parser/test/fixtures/placeholders/class/decorators/options.json
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"plugins": [
|
||||||
|
"placeholders",
|
||||||
|
["decorators", { "decoratorsBeforeExport": true }]
|
||||||
|
]
|
||||||
|
}
|
||||||
134
packages/babel-parser/test/fixtures/placeholders/class/decorators/output.json
vendored
Normal file
134
packages/babel-parser/test/fixtures/placeholders/class/decorators/output.json
vendored
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 21,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 10
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 21,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 10
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ClassDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 21,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 10
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"decorators": [
|
||||||
|
{
|
||||||
|
"type": "Decorator",
|
||||||
|
"start": 0,
|
||||||
|
"end": 10,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 10
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"expression": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 2,
|
||||||
|
"end": 9,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 2
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 4,
|
||||||
|
"end": 7,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 4
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 7
|
||||||
|
},
|
||||||
|
"identifierName": "FOO"
|
||||||
|
},
|
||||||
|
"name": "FOO"
|
||||||
|
},
|
||||||
|
"expectedNode": "Expression"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 17,
|
||||||
|
"end": 18,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 6
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 7
|
||||||
|
},
|
||||||
|
"identifierName": "A"
|
||||||
|
},
|
||||||
|
"name": "A"
|
||||||
|
},
|
||||||
|
"superClass": null,
|
||||||
|
"body": {
|
||||||
|
"type": "ClassBody",
|
||||||
|
"start": 19,
|
||||||
|
"end": 21,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 8
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 10
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"body": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/class/id-body/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/class/id-body/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
class %%ID%% %%BODY%%
|
||||||
117
packages/babel-parser/test/fixtures/placeholders/class/id-body/output.json
vendored
Normal file
117
packages/babel-parser/test/fixtures/placeholders/class/id-body/output.json
vendored
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 21,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 21
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 21,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 21
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ClassDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 21,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 21
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 6,
|
||||||
|
"end": 12,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 6
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 12
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 8,
|
||||||
|
"end": 10,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 8
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 10
|
||||||
|
},
|
||||||
|
"identifierName": "ID"
|
||||||
|
},
|
||||||
|
"name": "ID"
|
||||||
|
},
|
||||||
|
"expectedNode": "Identifier"
|
||||||
|
},
|
||||||
|
"superClass": null,
|
||||||
|
"body": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 13,
|
||||||
|
"end": 21,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 13
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 21
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 15,
|
||||||
|
"end": 19,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 19
|
||||||
|
},
|
||||||
|
"identifierName": "BODY"
|
||||||
|
},
|
||||||
|
"name": "BODY"
|
||||||
|
},
|
||||||
|
"expectedNode": "ClassBody"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/class/id-super-body/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/class/id-super-body/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
class %%ID%% extends %%SUPER%% %%BODY%%
|
||||||
149
packages/babel-parser/test/fixtures/placeholders/class/id-super-body/output.json
vendored
Normal file
149
packages/babel-parser/test/fixtures/placeholders/class/id-super-body/output.json
vendored
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 39,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 39
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 39,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 39
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ClassDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 39,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 39
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 6,
|
||||||
|
"end": 12,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 6
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 12
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 8,
|
||||||
|
"end": 10,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 8
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 10
|
||||||
|
},
|
||||||
|
"identifierName": "ID"
|
||||||
|
},
|
||||||
|
"name": "ID"
|
||||||
|
},
|
||||||
|
"expectedNode": "Identifier"
|
||||||
|
},
|
||||||
|
"superClass": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 21,
|
||||||
|
"end": 30,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 21
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 30
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 23,
|
||||||
|
"end": 28,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 23
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 28
|
||||||
|
},
|
||||||
|
"identifierName": "SUPER"
|
||||||
|
},
|
||||||
|
"name": "SUPER"
|
||||||
|
},
|
||||||
|
"expectedNode": "Expression"
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 31,
|
||||||
|
"end": 39,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 31
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 39
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 33,
|
||||||
|
"end": 37,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 33
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 37
|
||||||
|
},
|
||||||
|
"identifierName": "BODY"
|
||||||
|
},
|
||||||
|
"name": "BODY"
|
||||||
|
},
|
||||||
|
"expectedNode": "ClassBody"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/class/id-super/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/class/id-super/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
class %%ID%% extends %%SUPER%% {}
|
||||||
132
packages/babel-parser/test/fixtures/placeholders/class/id-super/output.json
vendored
Normal file
132
packages/babel-parser/test/fixtures/placeholders/class/id-super/output.json
vendored
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 33,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 33
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 33,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 33
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ClassDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 33,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 33
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 6,
|
||||||
|
"end": 12,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 6
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 12
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 8,
|
||||||
|
"end": 10,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 8
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 10
|
||||||
|
},
|
||||||
|
"identifierName": "ID"
|
||||||
|
},
|
||||||
|
"name": "ID"
|
||||||
|
},
|
||||||
|
"expectedNode": "Identifier"
|
||||||
|
},
|
||||||
|
"superClass": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 21,
|
||||||
|
"end": 30,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 21
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 30
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 23,
|
||||||
|
"end": 28,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 23
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 28
|
||||||
|
},
|
||||||
|
"identifierName": "SUPER"
|
||||||
|
},
|
||||||
|
"name": "SUPER"
|
||||||
|
},
|
||||||
|
"expectedNode": "Expression"
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "ClassBody",
|
||||||
|
"start": 31,
|
||||||
|
"end": 33,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 31
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 33
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"body": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/class/id_expression/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/class/id_expression/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
void class %%ID%% {}
|
||||||
132
packages/babel-parser/test/fixtures/placeholders/class/id_expression/output.json
vendored
Normal file
132
packages/babel-parser/test/fixtures/placeholders/class/id_expression/output.json
vendored
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 20,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 20
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 20,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 20
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start": 0,
|
||||||
|
"end": 20,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 20
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"expression": {
|
||||||
|
"type": "UnaryExpression",
|
||||||
|
"start": 0,
|
||||||
|
"end": 20,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 20
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"operator": "void",
|
||||||
|
"prefix": true,
|
||||||
|
"argument": {
|
||||||
|
"type": "ClassExpression",
|
||||||
|
"start": 5,
|
||||||
|
"end": 20,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 5
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 20
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 11,
|
||||||
|
"end": 17,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 11
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 17
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 13,
|
||||||
|
"end": 15,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 13
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
},
|
||||||
|
"identifierName": "ID"
|
||||||
|
},
|
||||||
|
"name": "ID"
|
||||||
|
},
|
||||||
|
"expectedNode": "Identifier"
|
||||||
|
},
|
||||||
|
"superClass": null,
|
||||||
|
"body": {
|
||||||
|
"type": "ClassBody",
|
||||||
|
"start": 18,
|
||||||
|
"end": 20,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 18
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 20
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"body": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/class/id_statement/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/class/id_statement/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
class %%ID%% {}
|
||||||
100
packages/babel-parser/test/fixtures/placeholders/class/id_statement/output.json
vendored
Normal file
100
packages/babel-parser/test/fixtures/placeholders/class/id_statement/output.json
vendored
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 15,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 15,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ClassDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 15,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 6,
|
||||||
|
"end": 12,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 6
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 12
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 8,
|
||||||
|
"end": 10,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 8
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 10
|
||||||
|
},
|
||||||
|
"identifierName": "ID"
|
||||||
|
},
|
||||||
|
"name": "ID"
|
||||||
|
},
|
||||||
|
"expectedNode": "Identifier"
|
||||||
|
},
|
||||||
|
"superClass": null,
|
||||||
|
"body": {
|
||||||
|
"type": "ClassBody",
|
||||||
|
"start": 13,
|
||||||
|
"end": 15,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 13
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"body": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/class/super/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/class/super/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
class Cl extends %%SUPER%% {}
|
||||||
116
packages/babel-parser/test/fixtures/placeholders/class/super/output.json
vendored
Normal file
116
packages/babel-parser/test/fixtures/placeholders/class/super/output.json
vendored
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 29,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 29
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 29,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 29
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ClassDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 29,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 29
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 6,
|
||||||
|
"end": 8,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 6
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 8
|
||||||
|
},
|
||||||
|
"identifierName": "Cl"
|
||||||
|
},
|
||||||
|
"name": "Cl"
|
||||||
|
},
|
||||||
|
"superClass": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 17,
|
||||||
|
"end": 26,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 17
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 26
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 19,
|
||||||
|
"end": 24,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 19
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 24
|
||||||
|
},
|
||||||
|
"identifierName": "SUPER"
|
||||||
|
},
|
||||||
|
"name": "SUPER"
|
||||||
|
},
|
||||||
|
"expectedNode": "Expression"
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "ClassBody",
|
||||||
|
"start": 27,
|
||||||
|
"end": 29,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 27
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 29
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"body": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/export/declaration/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/export/declaration/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export %%DECL%%;
|
||||||
100
packages/babel-parser/test/fixtures/placeholders/export/declaration/output.json
vendored
Normal file
100
packages/babel-parser/test/fixtures/placeholders/export/declaration/output.json
vendored
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 16,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 16
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 16,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 16
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExportNamedDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 15,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"specifiers": [],
|
||||||
|
"source": null,
|
||||||
|
"declaration": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 7,
|
||||||
|
"end": 15,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 7
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 9,
|
||||||
|
"end": 13,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 13
|
||||||
|
},
|
||||||
|
"identifierName": "DECL"
|
||||||
|
},
|
||||||
|
"name": "DECL"
|
||||||
|
},
|
||||||
|
"expectedNode": "Declaration"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "EmptyStatement",
|
||||||
|
"start": 15,
|
||||||
|
"end": 16,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 16
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/export/default-default-from/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/export/default-default-from/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export default from %%FILE%%;
|
||||||
7
packages/babel-parser/test/fixtures/placeholders/export/default-default-from/options.json
vendored
Normal file
7
packages/babel-parser/test/fixtures/placeholders/export/default-default-from/options.json
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"plugins": [
|
||||||
|
"placeholders"
|
||||||
|
],
|
||||||
|
"sourceType": "module",
|
||||||
|
"throws": "This experimental syntax requires enabling the parser plugin: 'exportDefaultFrom' (1:7)"
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/export/default-named-from-2/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/export/default-named-from-2/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export %%NAME%% from "file";
|
||||||
7
packages/babel-parser/test/fixtures/placeholders/export/default-named-from-2/options.json
vendored
Normal file
7
packages/babel-parser/test/fixtures/placeholders/export/default-named-from-2/options.json
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"plugins": [
|
||||||
|
"placeholders"
|
||||||
|
],
|
||||||
|
"sourceType": "module",
|
||||||
|
"throws": "This experimental syntax requires enabling the parser plugin: 'exportDefaultFrom' (1:16)"
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/export/default-named-from-3/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/export/default-named-from-3/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export %%NAME%% from %%FILE%%;
|
||||||
7
packages/babel-parser/test/fixtures/placeholders/export/default-named-from-3/options.json
vendored
Normal file
7
packages/babel-parser/test/fixtures/placeholders/export/default-named-from-3/options.json
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"plugins": [
|
||||||
|
"placeholders"
|
||||||
|
],
|
||||||
|
"sourceType": "module",
|
||||||
|
"throws": "This experimental syntax requires enabling the parser plugin: 'exportDefaultFrom' (1:16)"
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/export/default-named-from/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/export/default-named-from/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export name from %%FILE%%;
|
||||||
7
packages/babel-parser/test/fixtures/placeholders/export/default-named-from/options.json
vendored
Normal file
7
packages/babel-parser/test/fixtures/placeholders/export/default-named-from/options.json
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"plugins": [
|
||||||
|
"placeholders"
|
||||||
|
],
|
||||||
|
"sourceType": "module",
|
||||||
|
"throws": "This experimental syntax requires enabling the parser plugin: 'exportDefaultFrom' (1:7)"
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/export/named-alias-2/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/export/named-alias-2/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { name as %%ALIAS%% };
|
||||||
119
packages/babel-parser/test/fixtures/placeholders/export/named-alias-2/output.json
vendored
Normal file
119
packages/babel-parser/test/fixtures/placeholders/export/named-alias-2/output.json
vendored
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 29,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 29
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 29,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 29
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExportNamedDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 29,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 29
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"specifiers": [
|
||||||
|
{
|
||||||
|
"type": "ExportSpecifier",
|
||||||
|
"start": 9,
|
||||||
|
"end": 26,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 26
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"local": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 9,
|
||||||
|
"end": 13,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 13
|
||||||
|
},
|
||||||
|
"identifierName": "name"
|
||||||
|
},
|
||||||
|
"name": "name"
|
||||||
|
},
|
||||||
|
"exported": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 17,
|
||||||
|
"end": 26,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 17
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 26
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 19,
|
||||||
|
"end": 24,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 19
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 24
|
||||||
|
},
|
||||||
|
"identifierName": "ALIAS"
|
||||||
|
},
|
||||||
|
"name": "ALIAS"
|
||||||
|
},
|
||||||
|
"expectedNode": "Identifier"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": null,
|
||||||
|
"declaration": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/export/named-alias-3/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/export/named-alias-3/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { %%NAME%% as %%ALIAS%% };
|
||||||
135
packages/babel-parser/test/fixtures/placeholders/export/named-alias-3/output.json
vendored
Normal file
135
packages/babel-parser/test/fixtures/placeholders/export/named-alias-3/output.json
vendored
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 33,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 33
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 33,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 33
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExportNamedDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 33,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 33
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"specifiers": [
|
||||||
|
{
|
||||||
|
"type": "ExportSpecifier",
|
||||||
|
"start": 9,
|
||||||
|
"end": 30,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 30
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"local": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 9,
|
||||||
|
"end": 17,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 17
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 11,
|
||||||
|
"end": 15,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 11
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
},
|
||||||
|
"identifierName": "NAME"
|
||||||
|
},
|
||||||
|
"name": "NAME"
|
||||||
|
},
|
||||||
|
"expectedNode": "Identifier"
|
||||||
|
},
|
||||||
|
"exported": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 21,
|
||||||
|
"end": 30,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 21
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 30
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 23,
|
||||||
|
"end": 28,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 23
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 28
|
||||||
|
},
|
||||||
|
"identifierName": "ALIAS"
|
||||||
|
},
|
||||||
|
"name": "ALIAS"
|
||||||
|
},
|
||||||
|
"expectedNode": "Identifier"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": null,
|
||||||
|
"declaration": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/export/named-alias/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/export/named-alias/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { %%NAME%% as alias };
|
||||||
119
packages/babel-parser/test/fixtures/placeholders/export/named-alias/output.json
vendored
Normal file
119
packages/babel-parser/test/fixtures/placeholders/export/named-alias/output.json
vendored
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 29,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 29
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 29,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 29
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExportNamedDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 29,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 29
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"specifiers": [
|
||||||
|
{
|
||||||
|
"type": "ExportSpecifier",
|
||||||
|
"start": 9,
|
||||||
|
"end": 26,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 26
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"local": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 9,
|
||||||
|
"end": 17,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 17
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 11,
|
||||||
|
"end": 15,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 11
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
},
|
||||||
|
"identifierName": "NAME"
|
||||||
|
},
|
||||||
|
"name": "NAME"
|
||||||
|
},
|
||||||
|
"expectedNode": "Identifier"
|
||||||
|
},
|
||||||
|
"exported": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 21,
|
||||||
|
"end": 26,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 21
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 26
|
||||||
|
},
|
||||||
|
"identifierName": "alias"
|
||||||
|
},
|
||||||
|
"name": "alias"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": null,
|
||||||
|
"declaration": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/export/named-from-2/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/export/named-from-2/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { name } from %%FILE%%;
|
||||||
135
packages/babel-parser/test/fixtures/placeholders/export/named-from-2/output.json
vendored
Normal file
135
packages/babel-parser/test/fixtures/placeholders/export/named-from-2/output.json
vendored
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 30,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 30
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 30,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 30
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExportNamedDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 30,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 30
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"specifiers": [
|
||||||
|
{
|
||||||
|
"type": "ExportSpecifier",
|
||||||
|
"start": 9,
|
||||||
|
"end": 13,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 13
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"local": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 9,
|
||||||
|
"end": 13,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 13
|
||||||
|
},
|
||||||
|
"identifierName": "name"
|
||||||
|
},
|
||||||
|
"name": "name"
|
||||||
|
},
|
||||||
|
"exported": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 9,
|
||||||
|
"end": 13,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 13
|
||||||
|
},
|
||||||
|
"identifierName": "name"
|
||||||
|
},
|
||||||
|
"name": "name"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 21,
|
||||||
|
"end": 29,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 21
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 29
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 23,
|
||||||
|
"end": 27,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 23
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 27
|
||||||
|
},
|
||||||
|
"identifierName": "FILE"
|
||||||
|
},
|
||||||
|
"name": "FILE"
|
||||||
|
},
|
||||||
|
"expectedNode": "StringLiteral"
|
||||||
|
},
|
||||||
|
"declaration": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/export/named-from-3/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/export/named-from-3/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { %%NAME%% } from %%FILE%%;
|
||||||
167
packages/babel-parser/test/fixtures/placeholders/export/named-from-3/output.json
vendored
Normal file
167
packages/babel-parser/test/fixtures/placeholders/export/named-from-3/output.json
vendored
Normal file
@ -0,0 +1,167 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 34,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 34
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 34,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 34
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExportNamedDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 34,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 34
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"specifiers": [
|
||||||
|
{
|
||||||
|
"type": "ExportSpecifier",
|
||||||
|
"start": 9,
|
||||||
|
"end": 17,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 17
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"local": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 9,
|
||||||
|
"end": 17,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 17
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 11,
|
||||||
|
"end": 15,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 11
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
},
|
||||||
|
"identifierName": "NAME"
|
||||||
|
},
|
||||||
|
"name": "NAME"
|
||||||
|
},
|
||||||
|
"expectedNode": "Identifier"
|
||||||
|
},
|
||||||
|
"exported": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 9,
|
||||||
|
"end": 17,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 17
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 11,
|
||||||
|
"end": 15,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 11
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
},
|
||||||
|
"identifierName": "NAME"
|
||||||
|
},
|
||||||
|
"name": "NAME"
|
||||||
|
},
|
||||||
|
"expectedNode": "Identifier"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 25,
|
||||||
|
"end": 33,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 25
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 33
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 27,
|
||||||
|
"end": 31,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 27
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 31
|
||||||
|
},
|
||||||
|
"identifierName": "FILE"
|
||||||
|
},
|
||||||
|
"name": "FILE"
|
||||||
|
},
|
||||||
|
"expectedNode": "StringLiteral"
|
||||||
|
},
|
||||||
|
"declaration": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/export/named-from-alias-2/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/export/named-from-alias-2/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { name as %%ALIAS%% } from "file";
|
||||||
138
packages/babel-parser/test/fixtures/placeholders/export/named-from-alias-2/output.json
vendored
Normal file
138
packages/babel-parser/test/fixtures/placeholders/export/named-from-alias-2/output.json
vendored
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 41,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 41
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 41,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 41
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExportNamedDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 41,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 41
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"specifiers": [
|
||||||
|
{
|
||||||
|
"type": "ExportSpecifier",
|
||||||
|
"start": 9,
|
||||||
|
"end": 26,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 26
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"local": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 9,
|
||||||
|
"end": 13,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 13
|
||||||
|
},
|
||||||
|
"identifierName": "name"
|
||||||
|
},
|
||||||
|
"name": "name"
|
||||||
|
},
|
||||||
|
"exported": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 17,
|
||||||
|
"end": 26,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 17
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 26
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 19,
|
||||||
|
"end": 24,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 19
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 24
|
||||||
|
},
|
||||||
|
"identifierName": "ALIAS"
|
||||||
|
},
|
||||||
|
"name": "ALIAS"
|
||||||
|
},
|
||||||
|
"expectedNode": "Identifier"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": {
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start": 34,
|
||||||
|
"end": 40,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 34
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 40
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "file",
|
||||||
|
"raw": "\"file\""
|
||||||
|
},
|
||||||
|
"value": "file"
|
||||||
|
},
|
||||||
|
"declaration": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/export/named-from-alias-3/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/export/named-from-alias-3/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { %%NAME%% as %%ALIAS%% } from "file";
|
||||||
154
packages/babel-parser/test/fixtures/placeholders/export/named-from-alias-3/output.json
vendored
Normal file
154
packages/babel-parser/test/fixtures/placeholders/export/named-from-alias-3/output.json
vendored
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 45,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 45
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 45,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 45
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExportNamedDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 45,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 45
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"specifiers": [
|
||||||
|
{
|
||||||
|
"type": "ExportSpecifier",
|
||||||
|
"start": 9,
|
||||||
|
"end": 30,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 30
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"local": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 9,
|
||||||
|
"end": 17,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 17
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 11,
|
||||||
|
"end": 15,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 11
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
},
|
||||||
|
"identifierName": "NAME"
|
||||||
|
},
|
||||||
|
"name": "NAME"
|
||||||
|
},
|
||||||
|
"expectedNode": "Identifier"
|
||||||
|
},
|
||||||
|
"exported": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 21,
|
||||||
|
"end": 30,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 21
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 30
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 23,
|
||||||
|
"end": 28,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 23
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 28
|
||||||
|
},
|
||||||
|
"identifierName": "ALIAS"
|
||||||
|
},
|
||||||
|
"name": "ALIAS"
|
||||||
|
},
|
||||||
|
"expectedNode": "Identifier"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": {
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start": 38,
|
||||||
|
"end": 44,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 38
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 44
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "file",
|
||||||
|
"raw": "\"file\""
|
||||||
|
},
|
||||||
|
"value": "file"
|
||||||
|
},
|
||||||
|
"declaration": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/export/named-from-alias/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/export/named-from-alias/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { %%NAME%% as alias } from "file";
|
||||||
138
packages/babel-parser/test/fixtures/placeholders/export/named-from-alias/output.json
vendored
Normal file
138
packages/babel-parser/test/fixtures/placeholders/export/named-from-alias/output.json
vendored
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 41,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 41
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 41,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 41
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExportNamedDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 41,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 41
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"specifiers": [
|
||||||
|
{
|
||||||
|
"type": "ExportSpecifier",
|
||||||
|
"start": 9,
|
||||||
|
"end": 26,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 26
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"local": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 9,
|
||||||
|
"end": 17,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 17
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 11,
|
||||||
|
"end": 15,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 11
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
},
|
||||||
|
"identifierName": "NAME"
|
||||||
|
},
|
||||||
|
"name": "NAME"
|
||||||
|
},
|
||||||
|
"expectedNode": "Identifier"
|
||||||
|
},
|
||||||
|
"exported": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 21,
|
||||||
|
"end": 26,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 21
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 26
|
||||||
|
},
|
||||||
|
"identifierName": "alias"
|
||||||
|
},
|
||||||
|
"name": "alias"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": {
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start": 34,
|
||||||
|
"end": 40,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 34
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 40
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "file",
|
||||||
|
"raw": "\"file\""
|
||||||
|
},
|
||||||
|
"value": "file"
|
||||||
|
},
|
||||||
|
"declaration": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/export/named-from/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/export/named-from/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { %%NAME%% } from "file";
|
||||||
154
packages/babel-parser/test/fixtures/placeholders/export/named-from/output.json
vendored
Normal file
154
packages/babel-parser/test/fixtures/placeholders/export/named-from/output.json
vendored
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 32,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 32
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 32,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 32
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExportNamedDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 32,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 32
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"specifiers": [
|
||||||
|
{
|
||||||
|
"type": "ExportSpecifier",
|
||||||
|
"start": 9,
|
||||||
|
"end": 17,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 17
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"local": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 9,
|
||||||
|
"end": 17,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 17
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 11,
|
||||||
|
"end": 15,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 11
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
},
|
||||||
|
"identifierName": "NAME"
|
||||||
|
},
|
||||||
|
"name": "NAME"
|
||||||
|
},
|
||||||
|
"expectedNode": "Identifier"
|
||||||
|
},
|
||||||
|
"exported": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 9,
|
||||||
|
"end": 17,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 17
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 11,
|
||||||
|
"end": 15,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 11
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
},
|
||||||
|
"identifierName": "NAME"
|
||||||
|
},
|
||||||
|
"name": "NAME"
|
||||||
|
},
|
||||||
|
"expectedNode": "Identifier"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": {
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start": 25,
|
||||||
|
"end": 31,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 25
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 31
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "file",
|
||||||
|
"raw": "\"file\""
|
||||||
|
},
|
||||||
|
"value": "file"
|
||||||
|
},
|
||||||
|
"declaration": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/export/named/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/export/named/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { %%NAME%% };
|
||||||
135
packages/babel-parser/test/fixtures/placeholders/export/named/output.json
vendored
Normal file
135
packages/babel-parser/test/fixtures/placeholders/export/named/output.json
vendored
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 20,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 20
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 20,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 20
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExportNamedDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 20,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 20
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"specifiers": [
|
||||||
|
{
|
||||||
|
"type": "ExportSpecifier",
|
||||||
|
"start": 9,
|
||||||
|
"end": 17,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 17
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"local": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 9,
|
||||||
|
"end": 17,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 17
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 11,
|
||||||
|
"end": 15,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 11
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
},
|
||||||
|
"identifierName": "NAME"
|
||||||
|
},
|
||||||
|
"name": "NAME"
|
||||||
|
},
|
||||||
|
"expectedNode": "Identifier"
|
||||||
|
},
|
||||||
|
"exported": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 9,
|
||||||
|
"end": 17,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 17
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 11,
|
||||||
|
"end": 15,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 11
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
},
|
||||||
|
"identifierName": "NAME"
|
||||||
|
},
|
||||||
|
"name": "NAME"
|
||||||
|
},
|
||||||
|
"expectedNode": "Identifier"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": null,
|
||||||
|
"declaration": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
4
packages/babel-parser/test/fixtures/placeholders/export/options.json
vendored
Normal file
4
packages/babel-parser/test/fixtures/placeholders/export/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["placeholders", "exportDefaultFrom", "exportNamespaceFrom"],
|
||||||
|
"sourceType": "module"
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/export/star-from-2/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/export/star-from-2/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * as %%STAR%% from "file";
|
||||||
7
packages/babel-parser/test/fixtures/placeholders/export/star-from-2/options.json
vendored
Normal file
7
packages/babel-parser/test/fixtures/placeholders/export/star-from-2/options.json
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"plugins": [
|
||||||
|
"placeholders"
|
||||||
|
],
|
||||||
|
"sourceType": "module",
|
||||||
|
"throws": "This experimental syntax requires enabling the parser plugin: 'exportNamespaceFrom' (1:9)"
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/export/star-from-3/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/export/star-from-3/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * as %%STAR%% from %%FILE%%;
|
||||||
7
packages/babel-parser/test/fixtures/placeholders/export/star-from-3/options.json
vendored
Normal file
7
packages/babel-parser/test/fixtures/placeholders/export/star-from-3/options.json
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"plugins": [
|
||||||
|
"placeholders"
|
||||||
|
],
|
||||||
|
"sourceType": "module",
|
||||||
|
"throws": "This experimental syntax requires enabling the parser plugin: 'exportNamespaceFrom' (1:9)"
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/export/star-from/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/export/star-from/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from %%FILE%%;
|
||||||
83
packages/babel-parser/test/fixtures/placeholders/export/star-from/output.json
vendored
Normal file
83
packages/babel-parser/test/fixtures/placeholders/export/star-from/output.json
vendored
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 23,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 23
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 23,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 23
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExportAllDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 23,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 23
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"source": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 14,
|
||||||
|
"end": 22,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 14
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 22
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 16,
|
||||||
|
"end": 20,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 16
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 20
|
||||||
|
},
|
||||||
|
"identifierName": "FILE"
|
||||||
|
},
|
||||||
|
"name": "FILE"
|
||||||
|
},
|
||||||
|
"expectedNode": "StringLiteral"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/expression/01/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/expression/01/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
%%FOO%% + %%BAR%%(%%BAZ%%);
|
||||||
182
packages/babel-parser/test/fixtures/placeholders/expression/01/output.json
vendored
Normal file
182
packages/babel-parser/test/fixtures/placeholders/expression/01/output.json
vendored
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 27,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 27
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 27,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 27
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start": 0,
|
||||||
|
"end": 27,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 27
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"expression": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"start": 0,
|
||||||
|
"end": 26,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 26
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"left": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 0,
|
||||||
|
"end": 7,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 7
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 2,
|
||||||
|
"end": 5,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 2
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 5
|
||||||
|
},
|
||||||
|
"identifierName": "FOO"
|
||||||
|
},
|
||||||
|
"name": "FOO"
|
||||||
|
},
|
||||||
|
"expectedNode": "Expression"
|
||||||
|
},
|
||||||
|
"operator": "+",
|
||||||
|
"right": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"start": 10,
|
||||||
|
"end": 26,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 10
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 26
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"callee": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 10,
|
||||||
|
"end": 17,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 10
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 17
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 12,
|
||||||
|
"end": 15,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 12
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
},
|
||||||
|
"identifierName": "BAR"
|
||||||
|
},
|
||||||
|
"name": "BAR"
|
||||||
|
},
|
||||||
|
"expectedNode": "Expression"
|
||||||
|
},
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 18,
|
||||||
|
"end": 25,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 18
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 25
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 20,
|
||||||
|
"end": 23,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 20
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 23
|
||||||
|
},
|
||||||
|
"identifierName": "BAZ"
|
||||||
|
},
|
||||||
|
"name": "BAZ"
|
||||||
|
},
|
||||||
|
"expectedNode": "Expression"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
3
packages/babel-parser/test/fixtures/placeholders/expression/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/placeholders/expression/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["placeholders"]
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/function/body/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/function/body/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
function f() %%BODY%%
|
||||||
103
packages/babel-parser/test/fixtures/placeholders/function/body/output.json
vendored
Normal file
103
packages/babel-parser/test/fixtures/placeholders/function/body/output.json
vendored
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 21,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 21
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 21,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 21
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "FunctionDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 21,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 21
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 9,
|
||||||
|
"end": 10,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 10
|
||||||
|
},
|
||||||
|
"identifierName": "f"
|
||||||
|
},
|
||||||
|
"name": "f"
|
||||||
|
},
|
||||||
|
"generator": false,
|
||||||
|
"async": false,
|
||||||
|
"params": [],
|
||||||
|
"body": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 13,
|
||||||
|
"end": 21,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 13
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 21
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 15,
|
||||||
|
"end": 19,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 19
|
||||||
|
},
|
||||||
|
"identifierName": "BODY"
|
||||||
|
},
|
||||||
|
"name": "BODY"
|
||||||
|
},
|
||||||
|
"expectedNode": "BlockStatement"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/function/id-params-body/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/function/id-params-body/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
function %%ID%%(%%PARAM%%, %%PARAM%%) %%BODY%%
|
||||||
186
packages/babel-parser/test/fixtures/placeholders/function/id-params-body/output.json
vendored
Normal file
186
packages/babel-parser/test/fixtures/placeholders/function/id-params-body/output.json
vendored
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 46,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 46
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 46,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 46
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "FunctionDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 46,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 46
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 9,
|
||||||
|
"end": 15,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 11,
|
||||||
|
"end": 13,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 11
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 13
|
||||||
|
},
|
||||||
|
"identifierName": "ID"
|
||||||
|
},
|
||||||
|
"name": "ID"
|
||||||
|
},
|
||||||
|
"expectedNode": "Identifier"
|
||||||
|
},
|
||||||
|
"generator": false,
|
||||||
|
"async": false,
|
||||||
|
"params": [
|
||||||
|
{
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 16,
|
||||||
|
"end": 25,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 16
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 25
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 18,
|
||||||
|
"end": 23,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 18
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 23
|
||||||
|
},
|
||||||
|
"identifierName": "PARAM"
|
||||||
|
},
|
||||||
|
"name": "PARAM"
|
||||||
|
},
|
||||||
|
"expectedNode": "Pattern"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 27,
|
||||||
|
"end": 36,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 27
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 36
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 29,
|
||||||
|
"end": 34,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 29
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 34
|
||||||
|
},
|
||||||
|
"identifierName": "PARAM"
|
||||||
|
},
|
||||||
|
"name": "PARAM"
|
||||||
|
},
|
||||||
|
"expectedNode": "Pattern"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"body": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 38,
|
||||||
|
"end": 46,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 38
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 46
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 40,
|
||||||
|
"end": 44,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 40
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 44
|
||||||
|
},
|
||||||
|
"identifierName": "BODY"
|
||||||
|
},
|
||||||
|
"name": "BODY"
|
||||||
|
},
|
||||||
|
"expectedNode": "BlockStatement"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/function/id_declaration/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/function/id_declaration/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
function %%ID%%() {}
|
||||||
103
packages/babel-parser/test/fixtures/placeholders/function/id_declaration/output.json
vendored
Normal file
103
packages/babel-parser/test/fixtures/placeholders/function/id_declaration/output.json
vendored
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 20,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 20
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 20,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 20
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "FunctionDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 20,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 20
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 9,
|
||||||
|
"end": 15,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 11,
|
||||||
|
"end": 13,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 11
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 13
|
||||||
|
},
|
||||||
|
"identifierName": "ID"
|
||||||
|
},
|
||||||
|
"name": "ID"
|
||||||
|
},
|
||||||
|
"expectedNode": "Identifier"
|
||||||
|
},
|
||||||
|
"generator": false,
|
||||||
|
"async": false,
|
||||||
|
"params": [],
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"start": 18,
|
||||||
|
"end": 20,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 18
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 20
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"body": [],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/function/id_expression/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/function/id_expression/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
void function %%ID%%() {};
|
||||||
135
packages/babel-parser/test/fixtures/placeholders/function/id_expression/output.json
vendored
Normal file
135
packages/babel-parser/test/fixtures/placeholders/function/id_expression/output.json
vendored
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 26,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 26
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 26,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 26
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start": 0,
|
||||||
|
"end": 26,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 26
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"expression": {
|
||||||
|
"type": "UnaryExpression",
|
||||||
|
"start": 0,
|
||||||
|
"end": 25,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 25
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"operator": "void",
|
||||||
|
"prefix": true,
|
||||||
|
"argument": {
|
||||||
|
"type": "FunctionExpression",
|
||||||
|
"start": 5,
|
||||||
|
"end": 25,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 5
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 25
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 14,
|
||||||
|
"end": 20,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 14
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 20
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 16,
|
||||||
|
"end": 18,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 16
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 18
|
||||||
|
},
|
||||||
|
"identifierName": "ID"
|
||||||
|
},
|
||||||
|
"name": "ID"
|
||||||
|
},
|
||||||
|
"expectedNode": "Identifier"
|
||||||
|
},
|
||||||
|
"generator": false,
|
||||||
|
"async": false,
|
||||||
|
"params": [],
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"start": 23,
|
||||||
|
"end": 25,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 23
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 25
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"body": [],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/function/param/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/function/param/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
function f(%%PARAM%%) {}
|
||||||
121
packages/babel-parser/test/fixtures/placeholders/function/param/output.json
vendored
Normal file
121
packages/babel-parser/test/fixtures/placeholders/function/param/output.json
vendored
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 24,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 24
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 24,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 24
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "FunctionDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 24,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 24
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 9,
|
||||||
|
"end": 10,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 10
|
||||||
|
},
|
||||||
|
"identifierName": "f"
|
||||||
|
},
|
||||||
|
"name": "f"
|
||||||
|
},
|
||||||
|
"generator": false,
|
||||||
|
"async": false,
|
||||||
|
"params": [
|
||||||
|
{
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 11,
|
||||||
|
"end": 20,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 11
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 20
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 13,
|
||||||
|
"end": 18,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 13
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 18
|
||||||
|
},
|
||||||
|
"identifierName": "PARAM"
|
||||||
|
},
|
||||||
|
"name": "PARAM"
|
||||||
|
},
|
||||||
|
"expectedNode": "Pattern"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"start": 22,
|
||||||
|
"end": 24,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 22
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 24
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"body": [],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/import/default-file/input.mjs
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/import/default-file/input.mjs
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
import %%DEFAULT%% from %%FILE%%;
|
||||||
133
packages/babel-parser/test/fixtures/placeholders/import/default-file/output.json
vendored
Normal file
133
packages/babel-parser/test/fixtures/placeholders/import/default-file/output.json
vendored
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 33,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 33
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 33,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 33
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ImportDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 33,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 33
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"specifiers": [
|
||||||
|
{
|
||||||
|
"type": "ImportDefaultSpecifier",
|
||||||
|
"start": 7,
|
||||||
|
"end": 18,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 7
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 18
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"local": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 7,
|
||||||
|
"end": 18,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 7
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 18
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 9,
|
||||||
|
"end": 16,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 16
|
||||||
|
},
|
||||||
|
"identifierName": "DEFAULT"
|
||||||
|
},
|
||||||
|
"name": "DEFAULT"
|
||||||
|
},
|
||||||
|
"expectedNode": "Identifier"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 24,
|
||||||
|
"end": 32,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 24
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 32
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 26,
|
||||||
|
"end": 30,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 26
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 30
|
||||||
|
},
|
||||||
|
"identifierName": "FILE"
|
||||||
|
},
|
||||||
|
"name": "FILE"
|
||||||
|
},
|
||||||
|
"expectedNode": "StringLiteral"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/import/default-named-2/input.mjs
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/import/default-named-2/input.mjs
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
import %%DEFAULT%%, { named } from "file";
|
||||||
169
packages/babel-parser/test/fixtures/placeholders/import/default-named-2/output.json
vendored
Normal file
169
packages/babel-parser/test/fixtures/placeholders/import/default-named-2/output.json
vendored
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 42,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 42
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 42,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 42
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ImportDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 42,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 42
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"specifiers": [
|
||||||
|
{
|
||||||
|
"type": "ImportDefaultSpecifier",
|
||||||
|
"start": 7,
|
||||||
|
"end": 18,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 7
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 18
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"local": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 7,
|
||||||
|
"end": 18,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 7
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 18
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 9,
|
||||||
|
"end": 16,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 16
|
||||||
|
},
|
||||||
|
"identifierName": "DEFAULT"
|
||||||
|
},
|
||||||
|
"name": "DEFAULT"
|
||||||
|
},
|
||||||
|
"expectedNode": "Identifier"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ImportSpecifier",
|
||||||
|
"start": 22,
|
||||||
|
"end": 27,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 22
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 27
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"imported": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 22,
|
||||||
|
"end": 27,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 22
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 27
|
||||||
|
},
|
||||||
|
"identifierName": "named"
|
||||||
|
},
|
||||||
|
"name": "named"
|
||||||
|
},
|
||||||
|
"local": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 22,
|
||||||
|
"end": 27,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 22
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 27
|
||||||
|
},
|
||||||
|
"identifierName": "named"
|
||||||
|
},
|
||||||
|
"name": "named"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": {
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start": 35,
|
||||||
|
"end": 41,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 35
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 41
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "file",
|
||||||
|
"raw": "\"file\""
|
||||||
|
},
|
||||||
|
"value": "file"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/import/default-named-3/input.mjs
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/import/default-named-3/input.mjs
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
import %%DEFAULT%%, { %%NAMED%% } from "file";
|
||||||
201
packages/babel-parser/test/fixtures/placeholders/import/default-named-3/output.json
vendored
Normal file
201
packages/babel-parser/test/fixtures/placeholders/import/default-named-3/output.json
vendored
Normal file
@ -0,0 +1,201 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 46,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 46
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 46,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 46
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ImportDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 46,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 46
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"specifiers": [
|
||||||
|
{
|
||||||
|
"type": "ImportDefaultSpecifier",
|
||||||
|
"start": 7,
|
||||||
|
"end": 18,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 7
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 18
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"local": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 7,
|
||||||
|
"end": 18,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 7
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 18
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 9,
|
||||||
|
"end": 16,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 16
|
||||||
|
},
|
||||||
|
"identifierName": "DEFAULT"
|
||||||
|
},
|
||||||
|
"name": "DEFAULT"
|
||||||
|
},
|
||||||
|
"expectedNode": "Identifier"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ImportSpecifier",
|
||||||
|
"start": 22,
|
||||||
|
"end": 31,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 22
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 31
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"imported": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 22,
|
||||||
|
"end": 31,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 22
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 31
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 24,
|
||||||
|
"end": 29,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 24
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 29
|
||||||
|
},
|
||||||
|
"identifierName": "NAMED"
|
||||||
|
},
|
||||||
|
"name": "NAMED"
|
||||||
|
},
|
||||||
|
"expectedNode": "Identifier"
|
||||||
|
},
|
||||||
|
"local": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 22,
|
||||||
|
"end": 31,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 22
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 31
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 24,
|
||||||
|
"end": 29,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 24
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 29
|
||||||
|
},
|
||||||
|
"identifierName": "NAMED"
|
||||||
|
},
|
||||||
|
"name": "NAMED"
|
||||||
|
},
|
||||||
|
"expectedNode": "Identifier"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": {
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start": 39,
|
||||||
|
"end": 45,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 39
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 45
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "file",
|
||||||
|
"raw": "\"file\""
|
||||||
|
},
|
||||||
|
"value": "file"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/import/default-named/input.mjs
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/import/default-named/input.mjs
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
import _default, { %%NAMED%% } from "file";
|
||||||
185
packages/babel-parser/test/fixtures/placeholders/import/default-named/output.json
vendored
Normal file
185
packages/babel-parser/test/fixtures/placeholders/import/default-named/output.json
vendored
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 43,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 43
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 43,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 43
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ImportDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 43,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 43
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"specifiers": [
|
||||||
|
{
|
||||||
|
"type": "ImportDefaultSpecifier",
|
||||||
|
"start": 7,
|
||||||
|
"end": 15,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 7
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"local": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 7,
|
||||||
|
"end": 15,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 7
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
},
|
||||||
|
"identifierName": "_default"
|
||||||
|
},
|
||||||
|
"name": "_default"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ImportSpecifier",
|
||||||
|
"start": 19,
|
||||||
|
"end": 28,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 19
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 28
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"imported": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 19,
|
||||||
|
"end": 28,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 19
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 28
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 21,
|
||||||
|
"end": 26,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 21
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 26
|
||||||
|
},
|
||||||
|
"identifierName": "NAMED"
|
||||||
|
},
|
||||||
|
"name": "NAMED"
|
||||||
|
},
|
||||||
|
"expectedNode": "Identifier"
|
||||||
|
},
|
||||||
|
"local": {
|
||||||
|
"type": "Placeholder",
|
||||||
|
"start": 19,
|
||||||
|
"end": 28,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 19
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 28
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 21,
|
||||||
|
"end": 26,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 21
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 26
|
||||||
|
},
|
||||||
|
"identifierName": "NAMED"
|
||||||
|
},
|
||||||
|
"name": "NAMED"
|
||||||
|
},
|
||||||
|
"expectedNode": "Identifier"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": {
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start": 36,
|
||||||
|
"end": 42,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 36
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 42
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "file",
|
||||||
|
"raw": "\"file\""
|
||||||
|
},
|
||||||
|
"value": "file"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/placeholders/import/default-star-2/input.mjs
vendored
Normal file
1
packages/babel-parser/test/fixtures/placeholders/import/default-star-2/input.mjs
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
import _default, * as %%STAR%% from "file";
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user