refactor: remove inClassProperty parser state (#10906)
This commit is contained in:
parent
c09664f35d
commit
a18166d2a9
@ -1389,7 +1389,7 @@ export default class ExpressionParser extends LValParser {
|
|||||||
if (this.eat(tt.dot)) {
|
if (this.eat(tt.dot)) {
|
||||||
const metaProp = this.parseMetaProperty(node, meta, "target");
|
const metaProp = this.parseMetaProperty(node, meta, "target");
|
||||||
|
|
||||||
if (!this.scope.inNonArrowFunction && !this.state.inClassProperty) {
|
if (!this.scope.inNonArrowFunction && !this.scope.inClass) {
|
||||||
let error = "new.target can only be used in functions";
|
let error = "new.target can only be used in functions";
|
||||||
|
|
||||||
if (this.hasPlugin("classProperties")) {
|
if (this.hasPlugin("classProperties")) {
|
||||||
|
|||||||
@ -1048,11 +1048,9 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
|
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
|
||||||
const oldInClassProperty = this.state.inClassProperty;
|
|
||||||
const oldYieldPos = this.state.yieldPos;
|
const oldYieldPos = this.state.yieldPos;
|
||||||
const oldAwaitPos = this.state.awaitPos;
|
const oldAwaitPos = this.state.awaitPos;
|
||||||
this.state.maybeInArrowParameters = false;
|
this.state.maybeInArrowParameters = false;
|
||||||
this.state.inClassProperty = false;
|
|
||||||
this.state.yieldPos = -1;
|
this.state.yieldPos = -1;
|
||||||
this.state.awaitPos = -1;
|
this.state.awaitPos = -1;
|
||||||
this.scope.enter(functionFlags(node.async, node.generator));
|
this.scope.enter(functionFlags(node.async, node.generator));
|
||||||
@ -1084,7 +1082,6 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
|
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
|
||||||
this.state.inClassProperty = oldInClassProperty;
|
|
||||||
this.state.yieldPos = oldYieldPos;
|
this.state.yieldPos = oldYieldPos;
|
||||||
this.state.awaitPos = oldAwaitPos;
|
this.state.awaitPos = oldAwaitPos;
|
||||||
|
|
||||||
@ -1575,13 +1572,10 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
parseClassPrivateProperty(
|
parseClassPrivateProperty(
|
||||||
node: N.ClassPrivateProperty,
|
node: N.ClassPrivateProperty,
|
||||||
): N.ClassPrivateProperty {
|
): N.ClassPrivateProperty {
|
||||||
this.state.inClassProperty = true;
|
|
||||||
|
|
||||||
this.scope.enter(SCOPE_CLASS | SCOPE_SUPER);
|
this.scope.enter(SCOPE_CLASS | SCOPE_SUPER);
|
||||||
|
|
||||||
node.value = this.eat(tt.eq) ? this.parseMaybeAssign() : null;
|
node.value = this.eat(tt.eq) ? this.parseMaybeAssign() : null;
|
||||||
this.semicolon();
|
this.semicolon();
|
||||||
this.state.inClassProperty = false;
|
|
||||||
|
|
||||||
this.scope.exit();
|
this.scope.exit();
|
||||||
|
|
||||||
@ -1593,8 +1587,6 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
this.expectPlugin("classProperties");
|
this.expectPlugin("classProperties");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.state.inClassProperty = true;
|
|
||||||
|
|
||||||
this.scope.enter(SCOPE_CLASS | SCOPE_SUPER);
|
this.scope.enter(SCOPE_CLASS | SCOPE_SUPER);
|
||||||
|
|
||||||
if (this.match(tt.eq)) {
|
if (this.match(tt.eq)) {
|
||||||
@ -1605,7 +1597,6 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
node.value = null;
|
node.value = null;
|
||||||
}
|
}
|
||||||
this.semicolon();
|
this.semicolon();
|
||||||
this.state.inClassProperty = false;
|
|
||||||
|
|
||||||
this.scope.exit();
|
this.scope.exit();
|
||||||
|
|
||||||
|
|||||||
@ -64,7 +64,6 @@ export default class State {
|
|||||||
inType: boolean = false;
|
inType: boolean = false;
|
||||||
noAnonFunctionType: boolean = false;
|
noAnonFunctionType: boolean = false;
|
||||||
inPropertyName: boolean = false;
|
inPropertyName: boolean = false;
|
||||||
inClassProperty: boolean = false;
|
|
||||||
hasFlowComment: boolean = false;
|
hasFlowComment: boolean = false;
|
||||||
isIterator: boolean = false;
|
isIterator: boolean = false;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user