Skip to content

Update ElixirSense #80

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

Closed
wants to merge 1 commit into from
Closed

Update ElixirSense #80

wants to merge 1 commit into from

Conversation

axelson
Copy link
Member

@axelson axelson commented Nov 27, 2019

Here are some of the key PR's that this brings in:

* elixir-lsp/elixir_sense#56
* elixir-lsp/elixir_sense#57
* elixir-lsp/elixir_sense#58

Fixes #68
@victorolinasc
Copy link
Contributor

I've had to do the patch below in order to get newer versions passing. Hope it helps :)

   defp xref_at_cursor(text, line, character) do
-    env_at_cursor = line_environment(text, line)
+    {metadata, env_at_cursor} = line_environment(text, line)
     %{aliases: aliases} = env_at_cursor
 
     subject_at_cursor(text, line, character)
     # TODO: Don't call into here directly
     |> ElixirSense.Core.Source.split_module_and_func(aliases)
-    |> expand_mod_fun(env_at_cursor)
+    |> expand_mod_fun(metadata, env_at_cursor)
     |> add_arity(env_at_cursor)
     |> callers()
   end
 
   defp line_environment(text, line) do
     # TODO: Don't call into here directly
-    ElixirSense.Core.Parser.parse_string(text, true, true, line + 1)
-    |> ElixirSense.Core.Metadata.get_env(line + 1)
+    metadata = ElixirSense.Core.Parser.parse_string(text, true, true, line + 1)
+
+    {metadata, ElixirSense.Core.Metadata.get_env(metadata, line + 1)}
   end
 
   defp subject_at_cursor(text, line, character) do
@@ -43,11 +44,23 @@ defmodule ElixirLS.LanguageServer.Providers.References do
     ElixirSense.Core.Source.subject(text, line + 1, character + 1)
   end
 
-  defp expand_mod_fun({nil, nil}, _environment), do: nil
+  defp expand_mod_fun({nil, nil}, _metadata, _environment), do: nil
 
-  defp expand_mod_fun(mod_fun, %{imports: imports, aliases: aliases, module: module}) do
+  defp expand_mod_fun(mod_fun, metadata, %{
+         imports: imports,
+         aliases: aliases,
+         module: module
+       }) do
     # TODO: Don't call into here directly
-    mod_fun = ElixirSense.Core.Introspection.actual_mod_fun(mod_fun, imports, aliases, module)
+
+    mod_fun =
+      ElixirSense.Core.Introspection.actual_mod_fun(
+        mod_fun,
+        imports,
+        aliases,
+        module,
+        metadata.mods_funs
+      )
 

@axelson
Copy link
Member Author

axelson commented Nov 28, 2019

@victorolinasc thanks for the hint! Although this will probably be superseded by #82

@victorolinasc
Copy link
Contributor

Nice :) This was a dirty hack to make it work locally.

@victorolinasc
Copy link
Contributor

@axelson this can be closed now that #82 got merged, right?

@axelson
Copy link
Member Author

axelson commented Dec 30, 2019

Yes it can, thanks!

@axelson axelson closed this Dec 30, 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.

Pull in latest ElixirSense changes
2 participants