New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update: Add includeComments to getTokenByRangeStart (fixes #8068) #8069
Conversation
@kaicataldo, thanks for your PR! By analyzing the history of the files in this pull request, we identified @nzakas, @btmills and @not-an-aardvark to be potential reviewers. |
LGTM |
lib/token-store/index.js
Outdated
offset, | ||
-1, | ||
{ includeComments } | ||
).getOneToken(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createCursorWithSkip
is the function to normalize options for overload of number
(skip), function
(filter), or object
. I think we can use cursors.forward.createCursor
directly since this does not use skip
.
const token = cursors.forward.createCursor(
this.tokens,
this.comments,
this.indexMap,
offset, // startLoc
-1, // endLoc
includeComments,
null, // filter
0, // skip
-1 // count
).getOneToken()
Or, it's nice if we define cursors.forward.createBaseCursor
function with this part.
const token = cursors.forward.createBaseCursor(
this.tokens,
this.comments,
this.indexMap,
offset, // startLoc
-1, // endLoc
includeComments
).getOneToken()
e85ae18
to
dd123c8
Compare
LGTM |
dd123c8
to
b602123
Compare
LGTM |
lib/token-store/cursors.js
Outdated
* @param {number} endLoc - The end location of the iteration range. | ||
* @param {boolean} includeComments - The flag to iterate comments as well. | ||
* @returns {Cursor} The created base cursor. | ||
* @private |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was curious if this is actually private since we call these methods in token-store/index
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, it's my mistake of copy/paste!
lib/token-store/cursors.js
Outdated
@@ -52,8 +70,7 @@ class CursorFactory { | |||
* @private |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above.
LGTM |
@mysticatea I removed some other |
Thank you very much, yes. |
… (eslint#8069) * Update: Add includeComments to getTokenByRangeStart (fixes eslint#8068) * Remove @Private from public methods
What is the purpose of this pull request? (put an "X" next to item)
[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[x] Add something to the core
[ ] Other, please explain:
What changes did you make? (Give an overview)
Added an options object to
sourceCode.getTokenByRangeStart()
with anincludeComments
property.Is there anything you'd like reviewers to focus on?
Does this implementation seem correct? The other options didn't make sense in this context.