Closed DamienCassou closed 2 years ago
Hi Damien,
That looks like a bug.
Does the following make things better?
diff --git a/js2-mode.el b/js2-mode.el
index 65241ad..458a8ec 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -10373,11 +10373,11 @@ Returns the list in reverse order. Consumes the right-paren token."
pn pos target args beg end init)
(if (/= tt js2-NEW)
(setq pn (js2-parse-primary-expr))
+ (setq pos (js2-current-token-beg)
+ beg pos)
;; parse a 'new' expression
(js2-get-token)
- (setq pos (js2-current-token-beg)
- beg pos
- target (js2-parse-member-expr)
+ (setq target (js2-parse-member-expr)
end (js2-node-end target)
pn (make-js2-new-node :pos pos
:target target
That fixes my problem, thank you very much!
Thanks for testing. ;-)
I'm trying to get the node defining a variable's value from a variable reference. For example, given this code:
and the point on the "foo" of the
return
statement, I would like to get the node "new Foo()".Here is the code (copied from js2r-inline-var of js2r-vars.el but without any code from this project):
At the end, point is on
Foo
instead of being onnew
.In practice, this means that
js2r-inline-var
doesn't move thenew
keyword when inlining resulting in broken code:Is there a problem with my code?