| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5e11fe7 commit 2643ab3
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -51,9 +51,6 @@ | |||
| 51 | 51 | public class ESNextParser extends JSXParser { | |
| 52 | 52 | public ESNextParser(Options options, String input, int startPos) { | |
| 53 | 53 | super(options.allowImportExportEverywhere(true), input, startPos); | |
| 54 | - | ||
| 55 | - // recognise `using` as a keyword. See https://github.com/tc39/proposal-explicit-resource-management | ||
| 56 | - this.keywords.add("using"); | ||
| 57 | 54 | } | |
| 58 | 55 | ||
| 59 | 56 | /* | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2699,6 +2699,19 @@ && inputSubstring(next, next + len).equals(keyword) | |||
| 2699 | 2699 | || !Identifiers.isIdentifierChar(this.input.codePointAt(next + len), false)); | |
| 2700 | 2700 | } | |
| 2701 | 2701 | ||
| 2702 | + // matches "using [identifier]" | ||
| 2703 | + boolean isUsingDecl() { | ||
| 2704 | + if (this.type != TokenType.name | ||
| 2705 | + || this.options.ecmaVersion() < 8 | ||
| 2706 | + || !this.value.equals("using")) return false; | ||
| 2707 | + | ||
| 2708 | + Matcher m = Whitespace.skipWhiteSpace.matcher(this.input); | ||
| 2709 | + m.find(this.pos); | ||
| 2710 | + int next = m.end(); | ||
| 2711 | + return !Whitespace.lineBreakG.matcher(inputSubstring(this.pos, next)).matches() | ||
| 2712 | + && Identifiers.isIdentifierChar(this.input.codePointAt(next + 1), false); | ||
| 2713 | + } | ||
| 2714 | + | ||
| 2702 | 2715 | /** | |
| 2703 | 2716 | * Parse a single statement. | |
| 2704 | 2717 | * | |
@@ -2749,7 +2762,7 @@ protected Statement parseStatement(boolean declaration, boolean topLevel, Set<St | |||
| 2749 | 2762 | return this.parseThrowStatement(startLoc); | |
| 2750 | 2763 | } else if (starttype == TokenType._try) { | |
| 2751 | 2764 | return this.parseTryStatement(startLoc); | |
| 2752 | - } else if (starttype == TokenType._const || starttype == TokenType._var || starttype == TokenType._using) { | ||
| 2765 | + } else if (starttype == TokenType._const || starttype == TokenType._var || this.isUsingDecl()) { | ||
| 2753 | 2766 | if (kind == null) kind = String.valueOf(this.value); | |
| 2754 | 2767 | if (!declaration && !kind.equals("var")) this.unexpected(); | |
| 2755 | 2768 | return this.parseVarStatement(startLoc, kind); | |
@@ -2859,7 +2872,7 @@ protected Statement parseForStatement(Position startLoc) { | |||
| 2859 | 2872 | if (this.isAwaitUsing() && this.inAsync) { | |
| 2860 | 2873 | this.next(); // just skip the await and treat it as a `using` statement | |
| 2861 | 2874 | } | |
| 2862 | - if (this.type == TokenType._var || this.type == TokenType._const || isLet || this.type == TokenType._using) { | ||
| 2875 | + if (this.type == TokenType._var || this.type == TokenType._const || isLet || (this.type == TokenType.name && this.value.equals("using"))) { | ||
| 2863 | 2876 | Position initStartLoc = this.startLoc; | |
| 2864 | 2877 | String kind = isLet ? "let" : String.valueOf(this.value); | |
| 2865 | 2878 | this.next(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -180,7 +180,6 @@ public void updateContext(Parser parser, TokenType prevType) { | |||
| 180 | 180 | _try = new TokenType(kw("try")), | |
| 181 | 181 | _var = new TokenType(kw("var")), | |
| 182 | 182 | _const = new TokenType(kw("const")), | |
| 183 | - _using = new TokenType(kw("using")), | ||
| 184 | 183 | _while = new TokenType(kw("while").isLoop()), | |
| 185 | 184 | _with = new TokenType(kw("with")), | |
| 186 | 185 | _new = new TokenType(kw("new").beforeExpr().startsExpr()), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,8 @@ | |||
| 1 | 1 | nodes | |
| 2 | 2 | | file://:0:0:0:0 | (Arguments) | semmle.label | (Arguments) | | |
| 3 | 3 | | file://:0:0:0:0 | (Arguments) | semmle.label | (Arguments) | | |
| 4 | + | file://:0:0:0:0 | (Arguments) | semmle.label | (Arguments) | | ||
| 5 | + | file://:0:0:0:0 | (Parameters) | semmle.label | (Parameters) | | ||
| 4 | 6 | | tst.js:1:1:10:1 | [FunctionDeclStmt] functio ... } } | semmle.label | [FunctionDeclStmt] functio ... } } | | |
| 5 | 7 | | tst.js:1:1:10:1 | [FunctionDeclStmt] functio ... } } | semmle.order | 1 | | |
| 6 | 8 | | tst.js:1:10:1:10 | [VarDecl] g | semmle.label | [VarDecl] g | | |
@@ -47,11 +49,27 @@ nodes | |||
| 47 | 49 | | tst.js:20:5:20:23 | [ExprStmt] console.log("end"); | semmle.label | [ExprStmt] console.log("end"); | | |
| 48 | 50 | | tst.js:20:13:20:15 | [Label] log | semmle.label | [Label] log | | |
| 49 | 51 | | tst.js:20:17:20:21 | [Literal] "end" | semmle.label | [Literal] "end" | | |
| 52 | + | tst.js:23:1:28:1 | [FunctionDeclStmt] functio ... } } | semmle.label | [FunctionDeclStmt] functio ... } } | | ||
| 53 | + | tst.js:23:1:28:1 | [FunctionDeclStmt] functio ... } } | semmle.order | 3 | | ||
| 54 | + | tst.js:23:10:23:18 | [VarDecl] usesUsing | semmle.label | [VarDecl] usesUsing | | ||
| 55 | + | tst.js:23:22:28:1 | [BlockStmt] { u ... } } | semmle.label | [BlockStmt] { u ... } } | | ||
| 56 | + | tst.js:24:5:24:9 | [VarRef] using | semmle.label | [VarRef] using | | ||
| 57 | + | tst.js:24:5:24:16 | [CallExpr] using("foo") | semmle.label | [CallExpr] using("foo") | | ||
| 58 | + | tst.js:24:5:24:17 | [ExprStmt] using("foo"); | semmle.label | [ExprStmt] using("foo"); | | ||
| 59 | + | tst.js:24:11:24:15 | [Literal] "foo" | semmle.label | [Literal] "foo" | | ||
| 60 | + | tst.js:25:5:27:5 | [FunctionDeclStmt] functio ... . } | semmle.label | [FunctionDeclStmt] functio ... . } | | ||
| 61 | + | tst.js:25:14:25:18 | [VarDecl] using | semmle.label | [VarDecl] using | | ||
| 62 | + | tst.js:25:20:25:22 | [SimpleParameter] foo | semmle.label | [SimpleParameter] foo | | ||
| 63 | + | tst.js:25:25:27:5 | [BlockStmt] { ... . } | semmle.label | [BlockStmt] { ... . } | | ||
| 50 | 64 | edges | |
| 51 | 65 | | file://:0:0:0:0 | (Arguments) | tst.js:4:10:4:18 | [AssignExpr] test = 20 | semmle.label | 0 | | |
| 52 | 66 | | file://:0:0:0:0 | (Arguments) | tst.js:4:10:4:18 | [AssignExpr] test = 20 | semmle.order | 0 | | |
| 53 | 67 | | file://:0:0:0:0 | (Arguments) | tst.js:20:17:20:21 | [Literal] "end" | semmle.label | 0 | | |
| 54 | 68 | | file://:0:0:0:0 | (Arguments) | tst.js:20:17:20:21 | [Literal] "end" | semmle.order | 0 | | |
| 69 | + | file://:0:0:0:0 | (Arguments) | tst.js:24:11:24:15 | [Literal] "foo" | semmle.label | 0 | | ||
| 70 | + | file://:0:0:0:0 | (Arguments) | tst.js:24:11:24:15 | [Literal] "foo" | semmle.order | 0 | | ||
| 71 | + | file://:0:0:0:0 | (Parameters) | tst.js:25:20:25:22 | [SimpleParameter] foo | semmle.label | 0 | | ||
| 72 | + | file://:0:0:0:0 | (Parameters) | tst.js:25:20:25:22 | [SimpleParameter] foo | semmle.order | 0 | | ||
| 55 | 73 | | tst.js:1:1:10:1 | [FunctionDeclStmt] functio ... } } | tst.js:1:10:1:10 | [VarDecl] g | semmle.label | 0 | | |
| 56 | 74 | | tst.js:1:1:10:1 | [FunctionDeclStmt] functio ... } } | tst.js:1:10:1:10 | [VarDecl] g | semmle.order | 0 | | |
| 57 | 75 | | tst.js:1:1:10:1 | [FunctionDeclStmt] functio ... } } | tst.js:1:14:10:1 | [BlockStmt] { u ... } } | semmle.label | 5 | | |
@@ -136,5 +154,25 @@ edges | |||
| 136 | 154 | | tst.js:20:5:20:22 | [MethodCallExpr] console.log("end") | tst.js:20:5:20:15 | [DotExpr] console.log | semmle.order | 0 | | |
| 137 | 155 | | tst.js:20:5:20:23 | [ExprStmt] console.log("end"); | tst.js:20:5:20:22 | [MethodCallExpr] console.log("end") | semmle.label | 1 | | |
| 138 | 156 | | tst.js:20:5:20:23 | [ExprStmt] console.log("end"); | tst.js:20:5:20:22 | [MethodCallExpr] console.log("end") | semmle.order | 1 | | |
| 157 | + | tst.js:23:1:28:1 | [FunctionDeclStmt] functio ... } } | tst.js:23:10:23:18 | [VarDecl] usesUsing | semmle.label | 0 | | ||
| 158 | + | tst.js:23:1:28:1 | [FunctionDeclStmt] functio ... } } | tst.js:23:10:23:18 | [VarDecl] usesUsing | semmle.order | 0 | | ||
| 159 | + | tst.js:23:1:28:1 | [FunctionDeclStmt] functio ... } } | tst.js:23:22:28:1 | [BlockStmt] { u ... } } | semmle.label | 5 | | ||
| 160 | + | tst.js:23:1:28:1 | [FunctionDeclStmt] functio ... } } | tst.js:23:22:28:1 | [BlockStmt] { u ... } } | semmle.order | 5 | | ||
| 161 | + | tst.js:23:22:28:1 | [BlockStmt] { u ... } } | tst.js:24:5:24:17 | [ExprStmt] using("foo"); | semmle.label | 1 | | ||
| 162 | + | tst.js:23:22:28:1 | [BlockStmt] { u ... } } | tst.js:24:5:24:17 | [ExprStmt] using("foo"); | semmle.order | 1 | | ||
| 163 | + | tst.js:23:22:28:1 | [BlockStmt] { u ... } } | tst.js:25:5:27:5 | [FunctionDeclStmt] functio ... . } | semmle.label | 2 | | ||
| 164 | + | tst.js:23:22:28:1 | [BlockStmt] { u ... } } | tst.js:25:5:27:5 | [FunctionDeclStmt] functio ... . } | semmle.order | 2 | | ||
| 165 | + | tst.js:24:5:24:16 | [CallExpr] using("foo") | file://:0:0:0:0 | (Arguments) | semmle.label | 1 | | ||
| 166 | + | tst.js:24:5:24:16 | [CallExpr] using("foo") | file://:0:0:0:0 | (Arguments) | semmle.order | 1 | | ||
| 167 | + | tst.js:24:5:24:16 | [CallExpr] using("foo") | tst.js:24:5:24:9 | [VarRef] using | semmle.label | 0 | | ||
| 168 | + | tst.js:24:5:24:16 | [CallExpr] using("foo") | tst.js:24:5:24:9 | [VarRef] using | semmle.order | 0 | | ||
| 169 | + | tst.js:24:5:24:17 | [ExprStmt] using("foo"); | tst.js:24:5:24:16 | [CallExpr] using("foo") | semmle.label | 1 | | ||
| 170 | + | tst.js:24:5:24:17 | [ExprStmt] using("foo"); | tst.js:24:5:24:16 | [CallExpr] using("foo") | semmle.order | 1 | | ||
| 171 | + | tst.js:25:5:27:5 | [FunctionDeclStmt] functio ... . } | file://:0:0:0:0 | (Parameters) | semmle.label | 1 | | ||
| 172 | + | tst.js:25:5:27:5 | [FunctionDeclStmt] functio ... . } | file://:0:0:0:0 | (Parameters) | semmle.order | 1 | | ||
| 173 | + | tst.js:25:5:27:5 | [FunctionDeclStmt] functio ... . } | tst.js:25:14:25:18 | [VarDecl] using | semmle.label | 0 | | ||
| 174 | + | tst.js:25:5:27:5 | [FunctionDeclStmt] functio ... . } | tst.js:25:14:25:18 | [VarDecl] using | semmle.order | 0 | | ||
| 175 | + | tst.js:25:5:27:5 | [FunctionDeclStmt] functio ... . } | tst.js:25:25:27:5 | [BlockStmt] { ... . } | semmle.label | 5 | | ||
| 176 | + | tst.js:25:5:27:5 | [FunctionDeclStmt] functio ... . } | tst.js:25:25:27:5 | [BlockStmt] { ... . } | semmle.order | 5 | | ||
| 139 | 177 | graphProperties | |
| 140 | 178 | | semmle.graphKind | tree | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,4 +18,11 @@ async function h() { | |||
| 18 | 18 | } | |
| 19 | 19 | ||
| 20 | 20 | console.log("end"); | |
| 21 | + } | ||
| 22 | + | ||
| 23 | + function usesUsing() { | ||
| 24 | + using("foo"); | ||
| 25 | + function using(foo) { | ||
| 26 | + // ... | ||
| 27 | + } | ||
| 21 | 28 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments