Skip to content
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

Merged
merged 2 commits into from Feb 18, 2017

Conversation

kaicataldo
Copy link
Member

@kaicataldo kaicataldo commented Feb 12, 2017

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 an includeComments 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.

@mention-bot
Copy link

@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.

@eslintbot
Copy link

LGTM

@kaicataldo kaicataldo added core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Feb 12, 2017
offset,
-1,
{ includeComments }
).getOneToken();
Copy link
Member

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()

@eslintbot
Copy link

LGTM

@eslintbot
Copy link

LGTM

* @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
Copy link
Member Author

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?

Copy link
Member

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!

@@ -52,8 +70,7 @@ class CursorFactory {
* @private
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.

@eslintbot
Copy link

LGTM

@kaicataldo
Copy link
Member Author

@mysticatea I removed some other @private comments because they're on exported methods/classes. Do you think that's right?

@mysticatea
Copy link
Member

Thank you very much, yes.
About almost @privates, I had forgotten removing when I split code to multiple files.

@kaicataldo kaicataldo self-assigned this Feb 14, 2017
@platinumazure platinumazure added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Feb 16, 2017
@alberto alberto merged commit 290fb1f into master Feb 18, 2017
@ilyavolodin ilyavolodin deleted the toke-store-comments branch February 18, 2017 14:48
pantosha pushed a commit to pantosha/eslint that referenced this pull request Feb 21, 2017
… (eslint#8069)

* Update: Add includeComments to getTokenByRangeStart (fixes eslint#8068)

* Remove @Private from public methods
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants