mirror of
https://github.com/github/codeql.git
synced 2026-04-24 16:25:15 +02:00
using is not a keyword
This commit is contained in:
@@ -51,9 +51,6 @@ import java.util.Set;
|
||||
public class ESNextParser extends JSXParser {
|
||||
public ESNextParser(Options options, String input, int startPos) {
|
||||
super(options.allowImportExportEverywhere(true), input, startPos);
|
||||
|
||||
// recognise `using` as a keyword. See https://github.com/tc39/proposal-explicit-resource-management
|
||||
this.keywords.add("using");
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -2699,6 +2699,19 @@ public class Parser {
|
||||
|| !Identifiers.isIdentifierChar(this.input.codePointAt(next + len), false));
|
||||
}
|
||||
|
||||
// matches "using [identifier]"
|
||||
boolean isUsingDecl() {
|
||||
if (this.type != TokenType.name
|
||||
|| this.options.ecmaVersion() < 8
|
||||
|| !this.value.equals("using")) return false;
|
||||
|
||||
Matcher m = Whitespace.skipWhiteSpace.matcher(this.input);
|
||||
m.find(this.pos);
|
||||
int next = m.end();
|
||||
return !Whitespace.lineBreakG.matcher(inputSubstring(this.pos, next)).matches()
|
||||
&& Identifiers.isIdentifierChar(this.input.codePointAt(next + 1), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a single statement.
|
||||
*
|
||||
@@ -2749,7 +2762,7 @@ public class Parser {
|
||||
return this.parseThrowStatement(startLoc);
|
||||
} else if (starttype == TokenType._try) {
|
||||
return this.parseTryStatement(startLoc);
|
||||
} else if (starttype == TokenType._const || starttype == TokenType._var || starttype == TokenType._using) {
|
||||
} else if (starttype == TokenType._const || starttype == TokenType._var || this.isUsingDecl()) {
|
||||
if (kind == null) kind = String.valueOf(this.value);
|
||||
if (!declaration && !kind.equals("var")) this.unexpected();
|
||||
return this.parseVarStatement(startLoc, kind);
|
||||
@@ -2859,7 +2872,7 @@ public class Parser {
|
||||
if (this.isAwaitUsing() && this.inAsync) {
|
||||
this.next(); // just skip the await and treat it as a `using` statement
|
||||
}
|
||||
if (this.type == TokenType._var || this.type == TokenType._const || isLet || this.type == TokenType._using) {
|
||||
if (this.type == TokenType._var || this.type == TokenType._const || isLet || (this.type == TokenType.name && this.value.equals("using"))) {
|
||||
Position initStartLoc = this.startLoc;
|
||||
String kind = isLet ? "let" : String.valueOf(this.value);
|
||||
this.next();
|
||||
|
||||
@@ -180,7 +180,6 @@ public class TokenType {
|
||||
_try = new TokenType(kw("try")),
|
||||
_var = new TokenType(kw("var")),
|
||||
_const = new TokenType(kw("const")),
|
||||
_using = new TokenType(kw("using")),
|
||||
_while = new TokenType(kw("while").isLoop()),
|
||||
_with = new TokenType(kw("with")),
|
||||
_new = new TokenType(kw("new").beforeExpr().startsExpr()),
|
||||
|
||||
Reference in New Issue
Block a user