-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved some generic AST functions into a common util file
- Loading branch information
Showing
5 changed files
with
60 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,3 +102,6 @@ dist | |
|
||
# TernJS port file | ||
.tern-port | ||
|
||
# IDE | ||
.vscode |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module.exports = { | ||
/** | ||
* Finds the first matching punctuator at document position greater than or equal to startPos. | ||
* | ||
* @param {Ast.Token[]} tokens array of program tokens | ||
* @param {number} startPos minimum document position | ||
* @param {string} punctuator a punctuator, such as "," | ||
* @returns found token or undefined if not found | ||
*/ | ||
findPunctuatorAfter(tokens, startPos, punctuator) { | ||
return tokens.find(token => | ||
token.type === "Punctuator" && | ||
token.value === punctuator && | ||
token.range[0] >= startPos | ||
); | ||
}, | ||
|
||
/** | ||
* Finds the first matching punctuator at document position greater than or equal to startPos and less than | ||
* endPos. | ||
* | ||
* @param {Ast.Token[]} tokens array of program tokens | ||
* @param {number} startPos minimum document position (inclusive) | ||
* @param {number} endPos maximum document position (exclusive) | ||
* @param {string} punctuator a punctuator, such as "," | ||
* @returns found token or undefined if not found | ||
*/ | ||
findPunctuatorBetween(tokens, startPos, endPos, punctuator) { | ||
return tokens.find(token => | ||
token.type === "Punctuator" && | ||
token.value === punctuator && | ||
token.range[0] >= startPos && | ||
token.range[1] < endPos | ||
); | ||
} | ||
}; |
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