Skip to content

Commit e3bddcb

Browse files
lukaszsamsonclaude
andcommitted
Address review: trailing-edge coverage for references/implementation/hover
Per review of #1270, the trailing-edge regression coverage previously only exercised the definition locator. Add equivalent "cursor at end of symbol / end of alias before `.`" cases for the References and Implementation locators and the Hover provider, which share the same SurroundContext.Toxic resolution, so those paths can't regress independently. Also bump elixir_sense to 9460c606 (review fixes: lazy classification, operator contexts preserved, qualified-alias override). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XRd15BX6wBpZ8ThaNSo232
1 parent b071697 commit e3bddcb

5 files changed

Lines changed: 65 additions & 2 deletions

File tree

apps/language_server/test/providers/hover_test.exs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,32 @@ defmodule ElixirLS.LanguageServer.Providers.HoverTest do
5656
)
5757
end
5858

59+
# elixir-lsp/elixir-ls#1027: at the end of the alias `IO` (on the `.` before `inspect`) the module
60+
# is hovered, not the remote function - the same trailing-edge resolution the definition locator uses.
61+
test "elixir module hover at the end of an alias before `.` (#1027)" do
62+
text = """
63+
defmodule MyModule do
64+
def hello() do
65+
IO.inspect("hello world")
66+
end
67+
end
68+
"""
69+
70+
# `IO` is on line 3, columns 5-6; the caret sits just past it, on the `.` (0-based char 6).
71+
{line, char} = {2, 6}
72+
parser_context = ParserContextBuilder.from_string(text)
73+
74+
{line, char} =
75+
SourceFile.lsp_position_to_elixir(parser_context.source_file.text, {line, char})
76+
77+
assert {:ok,
78+
%GenLSP.Structures.Hover{
79+
contents: %GenLSP.Structures.MarkupContent{kind: "markdown", value: v}
80+
}} = Hover.hover(parser_context, line, char)
81+
82+
assert String.starts_with?(v, "```elixir\nIO\n```\n\n*module*")
83+
end
84+
5985
test "function hover" do
6086
text = """
6187
defmodule MyModule do

apps/language_server/test/providers/implementation/locator_test.exs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,22 @@ defmodule ElixirLS.LanguageServer.Providers.Implementation.LocatorTest do
8080
"ElixirSenseExample.ExampleBehaviourWithDocCallbackNoImpl"
8181
end
8282

83+
# elixir-lsp/elixir-ls#1038: implementations resolve with the cursor at the end of the behaviour
84+
# alias (one column past its last character), not only when it is on a character of the name.
85+
test "find implementations of behaviour module with cursor at the end of the alias (#1038)" do
86+
buffer = """
87+
defmodule ElixirSenseExample.ExampleBehaviourWithDoc do
88+
end
89+
"""
90+
91+
# the alias starts at column 11 and is 42 characters long, so column 53 is its end (on the space).
92+
mid = Locator.implementations(buffer, 1, 32)
93+
at_end = Locator.implementations(buffer, 1, 53)
94+
95+
assert length(at_end) == 2
96+
assert at_end == mid
97+
end
98+
8399
test "find protocol implementations" do
84100
buffer = """
85101
defprotocol ElixirSenseExample.ExampleProtocol do

apps/language_server/test/providers/references/locator_test.exs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,27 @@ defmodule ElixirLS.LanguageServer.Providers.References.LocatorTest do
158158
%{start: %{line: 65, column: 79}, end: %{line: 65, column: 83}}
159159
end
160160

161+
# elixir-lsp/elixir-ls#1038: references resolve with the cursor at the end of the symbol
162+
# (one column past its last character), not only when it is on a character of the name.
163+
test "find references with cursor at the end of a function definition name (#1038)", %{
164+
trace: trace
165+
} do
166+
buffer = """
167+
defmodule ElixirSense.Providers.ReferencesTest.Modules.Callee1 do
168+
def func() do
169+
IO.puts ""
170+
end
171+
end
172+
"""
173+
174+
# `func` is on line 2 at columns 7-10; column 11 is the end of the symbol (on the `(`).
175+
mid = Locator.references(buffer, 2, 10, trace)
176+
at_end = Locator.references(buffer, 2, 11, trace)
177+
178+
assert at_end != []
179+
assert at_end == mid
180+
end
181+
161182
test "find references with cursor over a function definition with default arg", %{trace: trace} do
162183
buffer = """
163184
defmodule ElixirSenseExample.Subscription do

dep_versions.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[
2-
elixir_sense: "ee88a26f471cfc46a898d5a2c4c30bb7ad8beff4",
2+
elixir_sense: "9460c60651c2419d81fa447d70d3e1596e30dab0",
33
dialyxir_vendored: "accfec9393079abc4a82b7e79a4997f59f085b67",
44
jason_v: "f1c10fa9c445cb9f300266122ef18671054b2330",
55
erl2ex_vendored: "04f93e55f46d35d0aa3c149616f2c7a6a1ad9311",

mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"benchee": {:hex, :benchee, "1.1.0", "f3a43817209a92a1fade36ef36b86e1052627fd8934a8b937ac9ab3a76c43062", [:mix], [{:deep_merge, "~> 1.0", [hex: :deep_merge, repo: "hexpm", optional: false]}, {:statistex, "~> 1.0", [hex: :statistex, repo: "hexpm", optional: false]}], "hexpm", "7da57d545003165a012b587077f6ba90b89210fd88074ce3c60ce239eb5e6d93"},
33
"deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm", "ce708e5f094b9cd4e8f2be4f00d2f4250c4095be93f8cd6d018c753894885430"},
44
"dialyxir_vendored": {:git, "https://github.com/elixir-lsp/dialyxir.git", "accfec9393079abc4a82b7e79a4997f59f085b67", [ref: "accfec9393079abc4a82b7e79a4997f59f085b67"]},
5-
"elixir_sense": {:git, "https://github.com/elixir-lsp/elixir_sense.git", "ee88a26f471cfc46a898d5a2c4c30bb7ad8beff4", [ref: "ee88a26f471cfc46a898d5a2c4c30bb7ad8beff4"]},
5+
"elixir_sense": {:git, "https://github.com/elixir-lsp/elixir_sense.git", "9460c60651c2419d81fa447d70d3e1596e30dab0", [ref: "9460c60651c2419d81fa447d70d3e1596e30dab0"]},
66
"erl2ex_vendored": {:git, "https://github.com/elixir-lsp/erl2ex.git", "04f93e55f46d35d0aa3c149616f2c7a6a1ad9311", [ref: "04f93e55f46d35d0aa3c149616f2c7a6a1ad9311"]},
77
"erlex_vendored": {:git, "https://github.com/elixir-lsp/erlex.git", "50b8307f90451a5d0288fb239fb6405b5ca1f1a4", [ref: "50b8307f90451a5d0288fb239fb6405b5ca1f1a4"]},
88
"jason_v": {:git, "https://github.com/elixir-lsp/jason.git", "f1c10fa9c445cb9f300266122ef18671054b2330", [ref: "f1c10fa9c445cb9f300266122ef18671054b2330"]},

0 commit comments

Comments
 (0)