forked from elixir-editors/emacs-elixir
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementations provider (elixir-editors#415)
* move to provider * no need to feature check as formatter and references are available since elixir 1.7 and we require 1.8 * elixir_sense suggestions for erlang modules now properly include : no need to patch * elixir_sense definitions now return nil when not found extract location related code to a new module * add implementations provider * update elixir_sense * do not format test/tmp fixtures * move fixtures to common dir * do not build filesystem URIs by string concat as it will break on Windows * add tests * fix invalid uris * Revert "do not format test/tmp fixtures" This reverts commit 5012101bc4ba31052d26fbb4e184a624a75a6c76. * Revert "fix invalid uris" This reverts commit 38eeb67c129384aa4343e5a546d7a7c0fe159779. * run formatter * increase timeout * bump elixir_sense * don't catch everyting * bump elixir_sense fix tests on elixir < 1.11
- Loading branch information
1 parent
99a6447
commit 434f6bc
Showing
21 changed files
with
229 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
apps/language_server/lib/language_server/providers/implementation.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
defmodule ElixirLS.LanguageServer.Providers.Implementation do | ||
@moduledoc """ | ||
Go-to-implementation provider utilizing Elixir Sense | ||
""" | ||
|
||
alias ElixirLS.LanguageServer.Protocol | ||
|
||
def implementation(uri, text, line, character) do | ||
locations = ElixirSense.implementations(text, line + 1, character + 1) | ||
results = for location <- locations, do: Protocol.Location.new(location, uri) | ||
|
||
{:ok, results} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
apps/language_server/lib/language_server/providers/signature_help.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
apps/language_server/test/providers/implementation_test.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
defmodule ElixirLS.LanguageServer.Providers.ImplementationTest do | ||
use ExUnit.Case, async: true | ||
|
||
alias ElixirLS.LanguageServer.Providers.Implementation | ||
alias ElixirLS.LanguageServer.Protocol.Location | ||
alias ElixirLS.LanguageServer.SourceFile | ||
alias ElixirLS.LanguageServer.Test.FixtureHelpers | ||
require ElixirLS.Test.TextLoc | ||
|
||
test "find implementations" do | ||
# force load as currently only loaded or loadable modules that are a part | ||
# of an application are found | ||
Code.ensure_loaded?(ElixirLS.LanguageServer.Fixtures.ExampleBehaviourImpl) | ||
|
||
file_path = FixtureHelpers.get_path("example_behaviour.ex") | ||
text = File.read!(file_path) | ||
uri = SourceFile.path_to_uri(file_path) | ||
|
||
{line, char} = {0, 43} | ||
|
||
ElixirLS.Test.TextLoc.annotate_assert(file_path, line, char, """ | ||
defmodule ElixirLS.LanguageServer.Fixtures.ExampleBehaviour do | ||
^ | ||
""") | ||
|
||
assert {:ok, [%Location{uri: ^uri, range: range}]} = | ||
Implementation.implementation(uri, text, line, char) | ||
|
||
assert range == | ||
%{ | ||
"start" => %{"line" => 5, "character" => 10}, | ||
"end" => %{"line" => 5, "character" => 10} | ||
} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.