-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add quick search to hexdocs.pm (#574)
* add quick search to hexdocs.pm Change-Id: Ifd888136b0c7cd9936bf02612bd87fdcce639ba7 * add hexdoc link for elixir std modlue and func Change-Id: I2f858ccab0a13fac426666263d59f4cf215db8a4 * parse deps at compile to gen hexdocs link Change-Id: Ief6e0fd0c13b2e42ddaf1817dfbf20b600971011 * fix ci Change-Id: I25228974078c7f09c6afc748c22144556b5cdc63 * fix ci Change-Id: I7e6debee937d2e4de5a3b990e4086b59e78a3aba * pass project_dir from server Change-Id: Iff48c16cf6a5d518004f7f211235e0be085985f2 * add some test for hover Change-Id: Id40baed74aeecf62f086f158185ed03345ef5ee0 * filter erlang module Change-Id: I77d984c72513b75d84958bdc63db093b7028142f Co-authored-by: zhuzhenfeng.code <[email protected]>
- Loading branch information
Showing
3 changed files
with
246 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
defmodule ElixirLS.LanguageServer.Providers.HoverTest do | ||
use ElixirLS.Utils.MixTest.Case, async: false | ||
import ElixirLS.LanguageServer.Test.PlatformTestHelpers | ||
|
||
alias ElixirLS.LanguageServer.Providers.Hover | ||
# mix cmd --app language_server mix test test/providers/hover_test.exs | ||
|
||
def fake_dir() do | ||
Path.join(__DIR__, "../../../..") |> Path.expand() |> maybe_convert_path_separators() | ||
end | ||
|
||
test "blank hover" do | ||
text = """ | ||
defmodule MyModule do | ||
def hello() do | ||
IO.inspect("hello world") | ||
end | ||
end | ||
""" | ||
|
||
{line, char} = {2, 1} | ||
|
||
assert {:ok, resp} = Hover.hover(text, line, char, fake_dir()) | ||
assert nil == resp | ||
end | ||
|
||
test "Elixir builtin module hover" do | ||
text = """ | ||
defmodule MyModule do | ||
def hello() do | ||
IO.inspect("hello world") | ||
end | ||
end | ||
""" | ||
|
||
{line, char} = {2, 5} | ||
|
||
assert {:ok, %{"contents" => %{kind: "markdown", value: v}}} = | ||
Hover.hover(text, line, char, fake_dir()) | ||
|
||
assert String.starts_with?(v, "> IO [view on hexdocs](https://hexdocs.pm/elixir/IO.html)") | ||
end | ||
|
||
test "Elixir builtin function hover" do | ||
text = """ | ||
defmodule MyModule do | ||
def hello() do | ||
IO.inspect("hello world") | ||
end | ||
end | ||
""" | ||
|
||
{line, char} = {2, 10} | ||
|
||
assert {:ok, %{"contents" => %{kind: "markdown", value: v}}} = | ||
Hover.hover(text, line, char, fake_dir()) | ||
|
||
assert String.starts_with?( | ||
v, | ||
"> IO.inspect(item, opts \\\\\\\\ []) [view on hexdocs](https://hexdocs.pm/elixir/IO.html#inspect/2)" | ||
) | ||
end | ||
|
||
test "Umbrella projects: Third deps module hover" do | ||
text = """ | ||
defmodule MyModule do | ||
def hello() do | ||
StreamData.integer() |> Stream.map(&abs/1) |> Enum.take(3) |> IO.inspect() | ||
end | ||
end | ||
""" | ||
|
||
{line, char} = {2, 10} | ||
|
||
assert {:ok, %{"contents" => %{kind: "markdown", value: v}}} = | ||
Hover.hover(text, line, char, fake_dir()) | ||
|
||
assert String.starts_with?( | ||
v, | ||
"> StreamData [view on hexdocs](https://hexdocs.pm/stream_data/StreamData.html)" | ||
) | ||
end | ||
|
||
test "Umbrella projects: Third deps function hover" do | ||
text = """ | ||
defmodule MyModule do | ||
def hello() do | ||
StreamData.integer() |> Stream.map(&abs/1) |> Enum.take(3) |> IO.inspect() | ||
end | ||
end | ||
""" | ||
|
||
{line, char} = {2, 18} | ||
|
||
assert {:ok, %{"contents" => %{kind: "markdown", value: v}}} = | ||
Hover.hover(text, line, char, fake_dir()) | ||
|
||
assert String.starts_with?( | ||
v, | ||
"> StreamData.integer() [view on hexdocs](https://hexdocs.pm/stream_data/StreamData.html#integer/0)" | ||
) | ||
end | ||
|
||
test "Erlang module hover is not support now" do | ||
text = """ | ||
defmodule MyModule do | ||
def hello() do | ||
:timer.sleep(1000) | ||
end | ||
end | ||
""" | ||
|
||
{line, char} = {2, 10} | ||
|
||
assert {:ok, %{"contents" => %{kind: "markdown", value: v}}} = | ||
Hover.hover(text, line, char, fake_dir()) | ||
|
||
assert not String.contains?( | ||
v, | ||
"[view on hexdocs]" | ||
) | ||
end | ||
end |