rename decoratorsStage2 -> decorators2
This commit is contained in:
parent
e1972baff5
commit
e5fdb3448d
@ -48,8 +48,8 @@ const parserClassCache: { [key: string]: Class<Parser> } = {};
|
|||||||
/** Get a Parser class with plugins applied. */
|
/** Get a Parser class with plugins applied. */
|
||||||
function getParserClass(pluginsFromOptions: $ReadOnlyArray<string>): Class<Parser> {
|
function getParserClass(pluginsFromOptions: $ReadOnlyArray<string>): Class<Parser> {
|
||||||
|
|
||||||
if (pluginsFromOptions.indexOf("decorators") >= 0 && pluginsFromOptions.indexOf("decoratorsStage2") >= 0) {
|
if (pluginsFromOptions.indexOf("decorators") >= 0 && pluginsFromOptions.indexOf("decorators2") >= 0) {
|
||||||
throw new Error("Cannot use decorators and decoratorsStage2 plugin together");
|
throw new Error("Cannot use decorators and decorators2 plugin together");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter out just the plugins that have an actual mixin associated with them.
|
// Filter out just the plugins that have an actual mixin associated with them.
|
||||||
|
|||||||
@ -858,7 +858,7 @@ export default class ExpressionParser extends LValParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.match(tt.at)) {
|
if (this.match(tt.at)) {
|
||||||
if (this.hasPlugin("decoratorsStage2")) {
|
if (this.hasPlugin("decorators2")) {
|
||||||
this.raise(this.state.start, "Stage 2 decorators disallow object literal property decorators");
|
this.raise(this.state.start, "Stage 2 decorators disallow object literal property decorators");
|
||||||
} else {
|
} else {
|
||||||
// we needn't check if decorators (stage 0) plugin is enabled since it's checked by
|
// we needn't check if decorators (stage 0) plugin is enabled since it's checked by
|
||||||
|
|||||||
@ -187,7 +187,7 @@ export default class LValParser extends NodeUtils {
|
|||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
const decorators = [];
|
const decorators = [];
|
||||||
if (this.match(tt.at) && this.hasPlugin("decoratorsStage2")) {
|
if (this.match(tt.at) && this.hasPlugin("decorators2")) {
|
||||||
this.raise(this.state.start, "Stage 2 decorators cannot be used to decorate parameters");
|
this.raise(this.state.start, "Stage 2 decorators cannot be used to decorate parameters");
|
||||||
}
|
}
|
||||||
while (this.match(tt.at)) {
|
while (this.match(tt.at)) {
|
||||||
|
|||||||
@ -152,7 +152,7 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
takeDecorators(node: N.HasDecorators): void {
|
takeDecorators(node: N.HasDecorators): void {
|
||||||
if (this.state.decorators.length) {
|
if (this.state.decorators.length) {
|
||||||
node.decorators = this.state.decorators;
|
node.decorators = this.state.decorators;
|
||||||
if (this.hasPlugin("decoratorsStage2")) {
|
if (this.hasPlugin("decorators2")) {
|
||||||
this.resetStartLocationFromNode(node, this.state.decorators[0]);
|
this.resetStartLocationFromNode(node, this.state.decorators[0]);
|
||||||
}
|
}
|
||||||
this.state.decorators = [];
|
this.state.decorators = [];
|
||||||
@ -160,7 +160,7 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parseDecorators(allowExport?: boolean): void {
|
parseDecorators(allowExport?: boolean): void {
|
||||||
if (this.hasPlugin("decoratorsStage2")) {
|
if (this.hasPlugin("decorators2")) {
|
||||||
allowExport = false;
|
allowExport = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,14 +179,14 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parseDecorator(): N.Decorator {
|
parseDecorator(): N.Decorator {
|
||||||
if (!(this.hasPlugin("decorators") || this.hasPlugin("decoratorsStage2"))) {
|
if (!(this.hasPlugin("decorators") || this.hasPlugin("decorators2"))) {
|
||||||
this.unexpected();
|
this.unexpected();
|
||||||
}
|
}
|
||||||
|
|
||||||
const node = this.startNode();
|
const node = this.startNode();
|
||||||
this.next();
|
this.next();
|
||||||
|
|
||||||
if (this.hasPlugin("decoratorsStage2")) {
|
if (this.hasPlugin("decorators2")) {
|
||||||
const startPos = this.state.start;
|
const startPos = this.state.start;
|
||||||
const startLoc = this.state.startLoc;
|
const startLoc = this.state.startLoc;
|
||||||
let expr = this.parseIdentifier(false);
|
let expr = this.parseIdentifier(false);
|
||||||
@ -712,7 +712,7 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
// steal the decorators if there are any
|
// steal the decorators if there are any
|
||||||
if (decorators.length) {
|
if (decorators.length) {
|
||||||
member.decorators = decorators;
|
member.decorators = decorators;
|
||||||
if (this.hasPlugin("decoratorsStage2")) {
|
if (this.hasPlugin("decorators2")) {
|
||||||
this.resetStartLocationFromNode(member, decorators[0]);
|
this.resetStartLocationFromNode(member, decorators[0]);
|
||||||
}
|
}
|
||||||
decorators = [];
|
decorators = [];
|
||||||
@ -720,7 +720,7 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
|
|
||||||
this.parseClassMember(classBody, member, state);
|
this.parseClassMember(classBody, member, state);
|
||||||
|
|
||||||
if (this.hasPlugin("decoratorsStage2") && member.kind != "method" && member.decorators && member.decorators.length > 0) {
|
if (this.hasPlugin("decorators2") && member.kind != "method" && member.decorators && member.decorators.length > 0) {
|
||||||
this.raise(member.start, "Stage 2 decorators may only be used with a class or a class method");
|
this.raise(member.start, "Stage 2 decorators may only be used with a class or a class method");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"plugins": ["classProperties", "decoratorsStage2"],
|
"plugins": ["classProperties", "decorators2"],
|
||||||
"throws": "Stage 2 decorators may only be used with a class or a class method (2:2)"
|
"throws": "Stage 2 decorators may only be used with a class or a class method (2:2)"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"plugins": ["decoratorsStage2", "classProperties"],
|
"plugins": ["decorators2", "classProperties"],
|
||||||
"throws": "Stage 2 decorators may only be used with a class or a class method (2:2)"
|
"throws": "Stage 2 decorators may only be used with a class or a class method (2:2)"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"plugins": ["classProperties", "classPrivateProperties", "decoratorsStage2"],
|
"plugins": ["classProperties", "classPrivateProperties", "decorators2"],
|
||||||
"throws": "Stage 2 decorators may only be used with a class or a class method (2:2)"
|
"throws": "Stage 2 decorators may only be used with a class or a class method (2:2)"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"plugins": ["classProperties", "decoratorsStage2"],
|
"plugins": ["classProperties", "decorators2"],
|
||||||
"throws": "Stage 2 decorators may only be used with a class or a class method (2:2)"
|
"throws": "Stage 2 decorators may only be used with a class or a class method (2:2)"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"plugins": ["decoratorsStage2"]
|
"plugins": ["decorators2"]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"plugins": ["decorators", "decoratorsStage2"],
|
"plugins": ["decorators", "decorators2"],
|
||||||
"throws": "Cannot use decorators and decoratorsStage2 plugin together"
|
"throws": "Cannot use decorators and decorators2 plugin together"
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user