Remove input and length from state (#9646)
This commit is contained in:
@@ -1137,7 +1137,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
node.types = [];
|
||||
this.expect(tt.bracketL);
|
||||
// We allow trailing commas
|
||||
while (this.state.pos < this.state.length && !this.match(tt.bracketR)) {
|
||||
while (this.state.pos < this.length && !this.match(tt.bracketR)) {
|
||||
node.types.push(this.flowParseType());
|
||||
if (this.match(tt.bracketR)) break;
|
||||
this.expect(tt.comma);
|
||||
@@ -1938,7 +1938,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
|
||||
// ensure that inside flow types, we bypass the jsx parser plugin
|
||||
getTokenFromCode(code: number): void {
|
||||
const next = this.state.input.charCodeAt(this.state.pos + 1);
|
||||
const next = this.input.charCodeAt(this.state.pos + 1);
|
||||
if (code === charCodes.leftCurlyBrace && next === charCodes.verticalBar) {
|
||||
return this.finishOp(tt.braceBarL, 2);
|
||||
} else if (
|
||||
@@ -2710,7 +2710,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
|
||||
readToken_mult_modulo(code: number): void {
|
||||
const next = this.state.input.charCodeAt(this.state.pos + 1);
|
||||
const next = this.input.charCodeAt(this.state.pos + 1);
|
||||
if (
|
||||
code === charCodes.asterisk &&
|
||||
next === charCodes.slash &&
|
||||
@@ -2726,7 +2726,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
|
||||
readToken_pipe_amp(code: number): void {
|
||||
const next = this.state.input.charCodeAt(this.state.pos + 1);
|
||||
const next = this.input.charCodeAt(this.state.pos + 1);
|
||||
if (
|
||||
code === charCodes.verticalBar &&
|
||||
next === charCodes.rightCurlyBrace
|
||||
@@ -2762,7 +2762,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
|
||||
if (this.state.hasFlowComment) {
|
||||
const end = this.state.input.indexOf("*-/", (this.state.pos += 2));
|
||||
const end = this.input.indexOf("*-/", (this.state.pos += 2));
|
||||
if (end === -1) this.raise(this.state.pos - 2, "Unterminated comment");
|
||||
this.state.pos = end + 3;
|
||||
return;
|
||||
@@ -2776,22 +2776,20 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
let shiftToFirstNonWhiteSpace = 2;
|
||||
while (
|
||||
[charCodes.space, charCodes.tab].includes(
|
||||
this.state.input.charCodeAt(pos + shiftToFirstNonWhiteSpace),
|
||||
this.input.charCodeAt(pos + shiftToFirstNonWhiteSpace),
|
||||
)
|
||||
) {
|
||||
shiftToFirstNonWhiteSpace++;
|
||||
}
|
||||
|
||||
const ch2 = this.state.input.charCodeAt(shiftToFirstNonWhiteSpace + pos);
|
||||
const ch3 = this.state.input.charCodeAt(
|
||||
shiftToFirstNonWhiteSpace + pos + 1,
|
||||
);
|
||||
const ch2 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos);
|
||||
const ch3 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos + 1);
|
||||
|
||||
if (ch2 === charCodes.colon && ch3 === charCodes.colon) {
|
||||
return shiftToFirstNonWhiteSpace + 2; // check for /*::
|
||||
}
|
||||
if (
|
||||
this.state.input.slice(
|
||||
this.input.slice(
|
||||
shiftToFirstNonWhiteSpace + pos,
|
||||
shiftToFirstNonWhiteSpace + pos + 12,
|
||||
) === "flow-include"
|
||||
@@ -2805,7 +2803,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
|
||||
hasFlowCommentCompletion(): void {
|
||||
const end = this.state.input.indexOf("*/", this.state.pos);
|
||||
const end = this.input.indexOf("*/", this.state.pos);
|
||||
if (end === -1) {
|
||||
this.raise(this.state.pos, "Unterminated comment");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user