-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Identify JavaScript function parameters (#1446)
Support parameters for these types of functions: ```javascript // es6 class method foo(x, y) {} // es6 arrow function (x, y) => x x => x // es5 function function foo(x, y) {} // es5 anonymous function function (x, y) {} ```
- Loading branch information
1 parent
0c8f650
commit 0cc8c56
Showing
12 changed files
with
245 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
class Test { | ||
foo( x, y = 0) {} | ||
async bar(x, y = 0 ) {} | ||
$ ( ) {} | ||
awaitFoo(){} | ||
} | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["keyword", "class"], | ||
["class-name", ["Test"]], | ||
["punctuation", "{"], | ||
|
||
["function", "foo"], | ||
["punctuation", "("], | ||
["parameter", [ | ||
"x", | ||
["punctuation", ","], | ||
" y ", | ||
["operator", "="], | ||
["number", "0"] | ||
]], | ||
["punctuation", ")"], | ||
["punctuation", "{"], | ||
["punctuation", "}"], | ||
|
||
["keyword", "async"], | ||
["function", "bar"], | ||
["punctuation", "("], | ||
["parameter", [ | ||
"x", | ||
["punctuation", ","], | ||
" y ", | ||
["operator", "="], | ||
["number", "0"] | ||
]], | ||
["punctuation", ")"], | ||
["punctuation", "{"], | ||
["punctuation", "}"], | ||
|
||
["function", "$"], | ||
["punctuation", "("], | ||
["punctuation", ")"], | ||
["punctuation", "{"], | ||
["punctuation", "}"], | ||
|
||
["function", "awaitFoo"], | ||
["punctuation", "("], | ||
["punctuation", ")"], | ||
["punctuation", "{"], | ||
["punctuation", "}"], | ||
|
||
["punctuation", "}"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for class methods. |
107 changes: 92 additions & 15 deletions
107
tests/languages/javascript/function-variable_feature.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
fetch('some-resource.json') | ||
.then(response => response.json()) | ||
.catch(console.error); | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["function", "fetch"], | ||
["punctuation", "("], | ||
["string", "'some-resource.json'"], | ||
["punctuation", ")"], | ||
["punctuation", "."], | ||
["function", "then"], | ||
["punctuation", "("], | ||
"response ", | ||
["operator", "=>"], | ||
" response", | ||
["punctuation", "."], | ||
["function", "json"], | ||
["punctuation", "("], | ||
["punctuation", ")"], | ||
["punctuation", ")"], | ||
["punctuation", "."], | ||
["function", "catch"], | ||
["punctuation", "("], | ||
"console", | ||
["punctuation", "."], | ||
"error", | ||
["punctuation", ")"], | ||
["punctuation", ";"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for catch function which is not a keyword. See #1526 | ||
fetch('some-resource.json') | ||
.then(response => response.json()) | ||
.catch(console.error); | ||
---------------------------------------------------- | ||
[ | ||
["function", "fetch"], | ||
["punctuation", "("], | ||
["string", "'some-resource.json'"], | ||
["punctuation", ")"], | ||
["punctuation", "."], | ||
["function", "then"], | ||
["punctuation", "("], | ||
["parameter", ["response"]], | ||
["operator", "=>"], | ||
" response", | ||
["punctuation", "."], | ||
["function", "json"], | ||
["punctuation", "("], | ||
["punctuation", ")"], | ||
["punctuation", ")"], | ||
["punctuation", "."], | ||
["function", "catch"], | ||
["punctuation", "("], | ||
"console", | ||
["punctuation", "."], | ||
"error", | ||
["punctuation", ")"], | ||
["punctuation", ";"] | ||
] | ||
---------------------------------------------------- | ||
Checks for catch function which is not a keyword. See #1526 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters