simplify isLookaheadRelational method (#11922)
* refactor: move isLookaheadRelational to flow plugins * refactor: simplify isLookaheadRelational to isLookaheadToken_lt
This commit is contained in:
@@ -2873,7 +2873,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
noCalls: ?boolean,
|
||||
subscriptState: N.ParseSubscriptState,
|
||||
): N.Expression {
|
||||
if (this.match(tt.questionDot) && this.isLookaheadRelational("<")) {
|
||||
if (this.match(tt.questionDot) && this.isLookaheadToken_lt()) {
|
||||
subscriptState.optionalChainMember = true;
|
||||
if (noCalls) {
|
||||
subscriptState.stop = true;
|
||||
@@ -3475,4 +3475,16 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
super.updateContext(prevType);
|
||||
}
|
||||
}
|
||||
|
||||
// check if the next token is a tt.relation("<")
|
||||
isLookaheadToken_lt(): boolean {
|
||||
const next = this.nextTokenStart();
|
||||
if (this.input.charCodeAt(next) === charCodes.lessThan) {
|
||||
const afterNext = this.input.charCodeAt(next + 1);
|
||||
return (
|
||||
afterNext !== charCodes.lessThan && afterNext !== charCodes.equalsTo
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user