Skip to content

Try js2-jump-to-definition first #10

Open
@TatriX

Description

@TatriX

js2-mode has a js2-jump-to-definition functions which can jump to a local definition.
Currently I'm using a bit hacky approach:

(defun my-js-jump-to-definition ()
  "Jump to a definition."
  (interactive)
  (condition-case-unless-debug nil
      (js2-jump-to-definition)
    (error
     (xref-pop-marker-stack)
     (xref-find-definitions (xref-backend-identifier-at-point (xref-find-backend))))))

The logic is simple: try jump with js2-mode ast, if it fails for whatever reason fallback to xref.
It would be cool if xref-js2 could use something like this for local jumps, because current behavior isn't quite good in my opinion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions