-
Notifications
You must be signed in to change notification settings - Fork 215
Change workspace symbols to only look at modules in the current application #261
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
Conversation
…cation This improves speed considerably since many more modules are not processed. If the old behavior is preferred by some users we could investigate making it configurable. However, I think that this behavior is in line with LSP expectation: > The workspace symbol request is sent from the client to the server to list project-wide symbols matching the query string. from: https://microsoft.github.io/language-server-protocol/specification#workspace_symbol
@@ -483,6 +455,20 @@ defmodule ElixirLS.LanguageServer.Providers.WorkspaceSymbols do | |||
end) | |||
end | |||
|
|||
defp module_paths do | |||
app = Keyword.fetch!(Mix.Project.config(), :app) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it umbrella friendly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately not, we will need to find an umbrella-friendly alternative
@axelson Go ahead, I don't have a strong opinion on this. To be honest It was easier to get all modules working by public erlang APIs than private Mix APIs. |
So there's definitely a race condition in this PR:
It appears that |
The problem with the tests is that
But since the test is about formatting (this example is from the server "incremental formatter" test), the error has previously gone un-noticed. I think in general we want to revamp how the fixtures work, the current setup is not maintainable and has other issues. |
Logically speaking, I would expect it list the symbols from the same set that "find definition" can reach. Which for languages like Elixir (or Ruby) probably includes libraries. But the problem of too many results is understandable. So I was curious how other language servers address this.
Speaking of filtering, would it help if "functions search" only matched function names, unless the query string includes a |
Thanks for looking at how other implementations handle this. Maybe this should only be merged once it can be configurable.
Can you give an example of when the functions search matches something that is not a function name? |
I search for (:kind 12 :location
(:range
(:end
(:character 0 :line 43)
:start
(:character 0 :line 42))
:uri "file:///home/dgutov/abs/xyz/deps/ecto/lib/ecto/query/builder/limit_offset.ex")
:name "f Ecto.Query.Builder.LimitOffset.apply/3")
(:kind 12 :location
(:range
(:end
(:character 0 :line 8)
:start
(:character 0 :line 7))
:uri "file:///home/dgutov/abc/xyz/deps/ecto/lib/ecto/query/builder/limit_offset.ex")
:name "f Ecto.Query.Builder.LimitOffset.build/5")
(:kind 12 :location
(:range
(:end
(:character 0 :line 1)
:start
(:character 0 :line 0))
:uri "file:///home/dgutov/abc/xyz/deps/ecto/lib/ecto/query/builder/limit_offset.ex")
:name "f Ecto.Query.Builder.LimitOffset.module_info/1") I guess it could be matching additional things (like docstring contents and parameter names -- good candidates for the ability to turn off, BTW!), but the |
And another observation. Backstory: the Emacs client I'm using doesn't show the value of the So, for example, for the query /home/dgutov/abc/xyz/deps/ecto/lib/ecto/query.ex
1: defmodule Ecto.SubQuery do
1595: @doc """ Which is a bit confusing. The presentation can be improved, but let's set that aside for now. Looking at the request-response log, the corresponding entries were: (:kind 12 :location
(:range
(:end
(:character 0 :line 1595)
:start
(:character 0 :line 1594))
:uri "file:///home/dgutov/abc/xyz/deps/ecto/lib/ecto/query.ex")
:name "f Ecto.Query.limit/3")
(:kind 12 :location
(:range
(:end
(:character 0 :line 1)
:start
(:character 0 :line 0))
:uri "file:///home/dgutov/abc/xyz/deps/ecto/lib/ecto/query.ex")
:name "f Ecto.Query.limit/2") The two problems I see here:
defmacro limit(query, binding \\ [], expr) do
Builder.LimitOffset.build(:limit, query, binding, expr, __CALLER__)
end As a bonus, it would be nice if the line number always pointed at the function definition (and not at the beginning of its docstring). But that's tangential. |
Personally in favor of it only searching the project. In addition to the noise, I think in VS Code the "m", "f", "t" etc. prefixes aren't going to work unless there's a way to turn off this behavior. If we can't, then that's another point in favor of taking actions that speed up search results. |
@mattbaker It did work at the time workspace symbols was introduced. Looks like it's a recent change and no ways to disable it. The prefixes were introduced to increase search results relevance and speed. There are lots of erlang modules and functions in OTP and sifting through them quickly is not straightforward. Of course it could be achieved with NIF and some custom data structures or some clever prebuilt indexes.
@dgutov No, it matches only modules and function names with a fuzzy algorithm. In your case |
Exactly. I don't think |
Oh I know! I remember giving it a try, it was cool :) |
This improves speed considerably since many more modules are not processed. If the old behavior is preferred by some users we could investigate making it configurable.
However, I think that this behavior is in line with LSP expectation:
from:
https://microsoft.github.io/language-server-protocol/specification#workspace_symbol
@lukaszsamson I'm curious if you have any strong feelings on this. Personally I haven't been using the workspace symbols request because I want to look only at symbols in my project and right now it is too noisy.