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

xref: return absolute paths when possible #796

Closed
vemv opened this issue Aug 4, 2023 · 0 comments · Fixed by #797
Closed

xref: return absolute paths when possible #796

vemv opened this issue Aug 4, 2023 · 0 comments · Fixed by #797

Comments

@vemv
Copy link
Member

vemv commented Aug 4, 2023

Although clojure-emacs/cider#3349 is a good idea (I'm building on top of it), its technique of translating relative, unprefixed paths like "orchard/cljs/meta.cljc" sadly is not workable, because it only sometimes works.

cider-find-file's docstring says:

Return a buffer visiting the file URL if it exists, or nil otherwise.
If URL has a scheme prefix, it must represent a fully-qualified file path
or an entry within a zip/jar archive. If AVFS (archive virtual file
system; see online docs) is mounted the archive entry is opened inside the
AVFS directory, otherwise the entry is archived into a temporary read-only
buffer. If URL doesn't contain a scheme prefix and is an absolute path, it
is treated as such. Finally, if URL is relative, it is expanded within each
of the open Clojure buffers till an existing file ending with URL has been
found
.

Because it only translates relative paths for open buffers, it will often return nil.

Therefore, whenever possible, xref middleware ops have to return file:<absolute-path>.

cider-find-file's translation still seems desirable for some cases, mainly TRAMP and Docker.

@vemv vemv closed this as completed in #797 Aug 9, 2023
vemv added a commit that referenced this issue Aug 9, 2023
vemv added a commit that referenced this issue Aug 9, 2023
### New features

* Make the `track-state` middleware invokeable directly, by requesting the new `"cider/get-state"` op.
  * This makes it possible to access `:changed-namespaces` info on demand, which can be necessary for:
    * non-Piggieback based clojurescript repls
    * re-computing the ns info responding to external (non-nREPL triggered) events.

### Changes

* [#796](#796): `fn-refs` and `fn-deps` middleware: add new `:file-url` field.
  * these are absolute and prefixed by `file:` or `file:jar:`, whenever possible.
* `fn-refs` and `fn-deps` middleware: sort the results by file, line and column.
* Bump `orchard` to [1.4.2](https://github.com/clojure-emacs/orchard/blob/v0.14.2/CHANGELOG.md#0142-2023-08-09).
@vemv vemv mentioned this issue Aug 9, 2023
vemv added a commit that referenced this issue Aug 9, 2023
### New features

* Make the `track-state` middleware invokeable directly, by requesting the new `"cider/get-state"` op.
  * This makes it possible to access `:changed-namespaces` info on demand, which can be necessary for:
    * non-Piggieback based clojurescript repls
    * re-computing the ns info responding to external (non-nREPL triggered) events.

### Changes

* [#796](#796): `fn-refs` and `fn-deps` middleware: add new `:file-url` field.
  * these are absolute and prefixed by `file:` or `file:jar:`, whenever possible.
* `fn-refs` and `fn-deps` middleware: sort the results by file, line and column.
* Bump `orchard` to [1.4.2](https://github.com/clojure-emacs/orchard/blob/v0.14.2/CHANGELOG.md#0142-2023-08-09).
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 a pull request may close this issue.

1 participant