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

support optional chaining operator #533

Merged
merged 1 commit into from
Aug 15, 2019
Merged

support optional chaining operator #533

merged 1 commit into from
Aug 15, 2019

Conversation

redguardtoo
Copy link
Contributor

(js2-highlight-function-call (js2-current-token))
(js2-get-token)
(let (args
(pos (js2-node-pos pn)))
(when use-optional-chaining-p
Copy link
Collaborator

Choose a reason for hiding this comment

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

How come this is needed for optional chaining, but not for normal chaining?

Copy link
Contributor Author

@redguardtoo redguardtoo Aug 10, 2019

Choose a reason for hiding this comment

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

See https://babeljs.io/docs/en/babel-plugin-proposal-optional-chaining

So now there two types of function call node, one is Test?.(); , the other is Test()

AST is like

                        function call token as parent token
 
function name token   parameters token

optional chaining token could be converted to a boolean flag in funcall call node. This flag is used when executing AST. Since js2-mode is just a parser to build the AST tree, optional chaining toke could be ignored in js2-parse-function-call

js2-mode.el Show resolved Hide resolved
@dgutov
Copy link
Collaborator

dgutov commented Aug 13, 2019

Could you add a NEWS entry? In NEWS.md, at the top.

@redguardtoo
Copy link
Contributor Author

@dgutov , I updated pull request.

@redguardtoo
Copy link
Contributor Author

updated

@@ -8,6 +8,10 @@
`js2-jsx-mode`.
* Using `js2-jsx-mode` will now trigger a warning in Emacs 27.

## 2019-08-14

* Support for optional-chaining operator `?.`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please put this under Next.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@dgutov
Copy link
Collaborator

dgutov commented Aug 15, 2019

Thank you

@dgutov dgutov merged commit b3841a7 into mooz:master Aug 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants