File tree Expand file tree Collapse file tree 2 files changed +46
-2
lines changed
lib/language_server/providers Expand file tree Collapse file tree 2 files changed +46
-2
lines changed Original file line number Diff line number Diff line change @@ -25,11 +25,11 @@ defmodule ElixirLS.LanguageServer.Providers.Hover do
25
25
% { subject: "" } ->
26
26
nil
27
27
28
- % { subject: subject , docs: docs } ->
28
+ % { subject: subject , docs: docs , actual_subject: actual_subject } ->
29
29
line_text = Enum . at ( SourceFile . lines ( text ) , line - 1 )
30
30
range = highlight_range ( line_text , line - 1 , character - 1 , subject )
31
31
32
- % { "contents" => contents ( docs , subject , project_dir ) , "range" => range }
32
+ % { "contents" => contents ( docs , actual_subject , project_dir ) , "range" => range }
33
33
end
34
34
35
35
{ :ok , response }
Original file line number Diff line number Diff line change @@ -101,6 +101,50 @@ defmodule ElixirLS.LanguageServer.Providers.HoverTest do
101
101
)
102
102
end
103
103
104
+ test "Import function hover" do
105
+ text = """
106
+ defmodule MyModule do
107
+ import Task.Supervisor
108
+
109
+ def hello() do
110
+ start_link()
111
+ end
112
+ end
113
+ """
114
+
115
+ { line , char } = { 4 , 5 }
116
+
117
+ assert { :ok , % { "contents" => % { kind: "markdown" , value: v } } } =
118
+ Hover . hover ( text , line , char , fake_dir ( ) )
119
+
120
+ assert String . starts_with? (
121
+ v ,
122
+ "> Task.Supervisor.start_link(options \\ \\ \\ \\ []) [view on hexdocs](https://hexdocs.pm/elixir/Task.Supervisor.html#start_link/1)"
123
+ )
124
+ end
125
+
126
+ test "Alias module function hover" do
127
+ text = """
128
+ defmodule MyModule do
129
+ alias Task.Supervisor
130
+
131
+ def hello() do
132
+ Supervisor.start_link()
133
+ end
134
+ end
135
+ """
136
+
137
+ { line , char } = { 4 , 15 }
138
+
139
+ assert { :ok , % { "contents" => % { kind: "markdown" , value: v } } } =
140
+ Hover . hover ( text , line , char , fake_dir ( ) )
141
+
142
+ assert String . starts_with? (
143
+ v ,
144
+ "> Task.Supervisor.start_link(options \\ \\ \\ \\ []) [view on hexdocs](https://hexdocs.pm/elixir/Task.Supervisor.html#start_link/1)"
145
+ )
146
+ end
147
+
104
148
test "Erlang module hover is not support now" do
105
149
text = """
106
150
defmodule MyModule do
You can’t perform that action at this time.
0 commit comments