Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions javascript/extractor/src/com/semmle/jcorn/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -2598,7 +2598,10 @@ boolean isAsyncFunction() {
}

boolean isAwaitUsing() {
return isAsyncKeyword("await", "using");
if (!isAsyncKeyword("await", "using")) return false;
Matcher m = Whitespace.skipWhiteSpace.matcher(this.input);
m.find(this.pos);
return isUsingDecl(m.end() + "using".length());
}

// check 'pre [no LineTerminator here] keyword'
Expand All @@ -2625,11 +2628,15 @@ boolean isUsingDecl() {
|| this.options.ecmaVersion() < 8
|| !this.value.equals("using")) return false;

return isUsingDecl(this.pos);
}

boolean isUsingDecl(int pos) {
Matcher m = Whitespace.skipWhiteSpace.matcher(this.input);
m.find(this.pos);
m.find(pos);
Comment on lines 2635 to +2636
int next = m.end();
return this.input.length() > next &&
!Whitespace.lineBreakG.matcher(inputSubstring(this.pos, next)).matches()
!Whitespace.lineBreakG.matcher(inputSubstring(pos, next)).matches()
&& Identifiers.isIdentifierChar(this.input.codePointAt(next), false);
}

Expand Down Expand Up @@ -2809,7 +2816,7 @@ protected Statement parseForStatement(Position startLoc) {
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.name && this.value.equals("using"))) {
if (this.type == TokenType._var || this.type == TokenType._const || isLet || this.isUsingDecl()) {
Position initStartLoc = this.startLoc;
String kind = isLet ? "let" : String.valueOf(this.value);
this.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ nodes
| file://:0:0:0:0 | (Arguments) | semmle.label | (Arguments) |
| file://:0:0:0:0 | (Arguments) | semmle.label | (Arguments) |
| file://:0:0:0:0 | (Arguments) | semmle.label | (Arguments) |
| file://:0:0:0:0 | (Arguments) | semmle.label | (Arguments) |
| file://:0:0:0:0 | (Parameters) | semmle.label | (Parameters) |
| tst.html:1:5:1:9 | [ExprStmt] using | semmle.label | [ExprStmt] using |
| tst.html:1:5:1:9 | [ExprStmt] using | semmle.order | 1 |
Expand Down Expand Up @@ -69,6 +70,15 @@ nodes
| tst.js:28:5:28:16 | [CallExpr] using(using) | semmle.label | [CallExpr] using(using) |
| tst.js:28:5:28:17 | [ExprStmt] using(using); | semmle.label | [ExprStmt] using(using); |
| tst.js:28:11:28:15 | [VarRef] using | semmle.label | [VarRef] using |
| tst.js:31:1:33:1 | [FunctionDeclStmt] async f ... oo"); } | semmle.label | [FunctionDeclStmt] async f ... oo"); } |
| tst.js:31:1:33:1 | [FunctionDeclStmt] async f ... oo"); } | semmle.order | 5 |
| tst.js:31:16:31:29 | [VarDecl] asyncUsesUsing | semmle.label | [VarDecl] asyncUsesUsing |
| tst.js:31:33:33:1 | [BlockStmt] { a ... oo"); } | semmle.label | [BlockStmt] { a ... oo"); } |
| tst.js:32:5:32:22 | [AwaitExpr] await using("foo") | semmle.label | [AwaitExpr] await using("foo") |
| tst.js:32:5:32:23 | [ExprStmt] await using("foo"); | semmle.label | [ExprStmt] await using("foo"); |
| tst.js:32:11:32:15 | [VarRef] using | semmle.label | [VarRef] using |
| tst.js:32:11:32:22 | [CallExpr] using("foo") | semmle.label | [CallExpr] using("foo") |
| tst.js:32:17:32:21 | [Literal] "foo" | semmle.label | [Literal] "foo" |
edges
| file://:0:0:0:0 | (Arguments) | tst.js:4:10:4:18 | [AssignExpr] test = 20 | semmle.label | 0 |
| file://:0:0:0:0 | (Arguments) | tst.js:4:10:4:18 | [AssignExpr] test = 20 | semmle.order | 0 |
Expand All @@ -78,6 +88,8 @@ edges
| file://:0:0:0:0 | (Arguments) | tst.js:24:11:24:15 | [Literal] "foo" | semmle.order | 0 |
| file://:0:0:0:0 | (Arguments) | tst.js:28:11:28:15 | [VarRef] using | semmle.label | 0 |
| file://:0:0:0:0 | (Arguments) | tst.js:28:11:28:15 | [VarRef] using | semmle.order | 0 |
| file://:0:0:0:0 | (Arguments) | tst.js:32:17:32:21 | [Literal] "foo" | semmle.label | 0 |
| file://:0:0:0:0 | (Arguments) | tst.js:32:17:32:21 | [Literal] "foo" | semmle.order | 0 |
| file://:0:0:0:0 | (Parameters) | tst.js:25:20:25:22 | [SimpleParameter] foo | semmle.label | 0 |
| file://:0:0:0:0 | (Parameters) | tst.js:25:20:25:22 | [SimpleParameter] foo | semmle.order | 0 |
| tst.html:1:5:1:9 | [ExprStmt] using | tst.html:1:5:1:9 | [VarRef] using | semmle.label | 1 |
Expand Down Expand Up @@ -194,5 +206,19 @@ edges
| tst.js:28:5:28:16 | [CallExpr] using(using) | tst.js:28:5:28:9 | [VarRef] using | semmle.order | 0 |
| tst.js:28:5:28:17 | [ExprStmt] using(using); | tst.js:28:5:28:16 | [CallExpr] using(using) | semmle.label | 1 |
| tst.js:28:5:28:17 | [ExprStmt] using(using); | tst.js:28:5:28:16 | [CallExpr] using(using) | semmle.order | 1 |
| tst.js:31:1:33:1 | [FunctionDeclStmt] async f ... oo"); } | tst.js:31:16:31:29 | [VarDecl] asyncUsesUsing | semmle.label | 0 |
| tst.js:31:1:33:1 | [FunctionDeclStmt] async f ... oo"); } | tst.js:31:16:31:29 | [VarDecl] asyncUsesUsing | semmle.order | 0 |
| tst.js:31:1:33:1 | [FunctionDeclStmt] async f ... oo"); } | tst.js:31:33:33:1 | [BlockStmt] { a ... oo"); } | semmle.label | 5 |
| tst.js:31:1:33:1 | [FunctionDeclStmt] async f ... oo"); } | tst.js:31:33:33:1 | [BlockStmt] { a ... oo"); } | semmle.order | 5 |
| tst.js:31:33:33:1 | [BlockStmt] { a ... oo"); } | tst.js:32:5:32:23 | [ExprStmt] await using("foo"); | semmle.label | 1 |
| tst.js:31:33:33:1 | [BlockStmt] { a ... oo"); } | tst.js:32:5:32:23 | [ExprStmt] await using("foo"); | semmle.order | 1 |
| tst.js:32:5:32:22 | [AwaitExpr] await using("foo") | tst.js:32:11:32:22 | [CallExpr] using("foo") | semmle.label | 1 |
| tst.js:32:5:32:22 | [AwaitExpr] await using("foo") | tst.js:32:11:32:22 | [CallExpr] using("foo") | semmle.order | 1 |
| tst.js:32:5:32:23 | [ExprStmt] await using("foo"); | tst.js:32:5:32:22 | [AwaitExpr] await using("foo") | semmle.label | 1 |
| tst.js:32:5:32:23 | [ExprStmt] await using("foo"); | tst.js:32:5:32:22 | [AwaitExpr] await using("foo") | semmle.order | 1 |
| tst.js:32:11:32:22 | [CallExpr] using("foo") | file://:0:0:0:0 | (Arguments) | semmle.label | 1 |
| tst.js:32:11:32:22 | [CallExpr] using("foo") | file://:0:0:0:0 | (Arguments) | semmle.order | 1 |
| tst.js:32:11:32:22 | [CallExpr] using("foo") | tst.js:32:11:32:15 | [VarRef] using | semmle.label | 0 |
| tst.js:32:11:32:22 | [CallExpr] using("foo") | tst.js:32:11:32:15 | [VarRef] using | semmle.order | 0 |
graphProperties
| semmle.graphKind | tree |
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ function usesUsing() {
// ...
}
using(using);
}

async function asyncUsesUsing() {
await using("foo");
}
Loading