Skip to content

Commit 271a8ff

Browse files
committed
remove no longer needed hacks
1 parent 691240e commit 271a8ff

File tree

1 file changed

+0
-64
lines changed
  • apps/language_server/lib/language_server/providers/completion

1 file changed

+0
-64
lines changed

apps/language_server/lib/language_server/providers/completion/suggestion.ex

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,6 @@ defmodule ElixirLS.LanguageServer.Providers.Completion.Suggestion do
118118

119119
{text_before, text_after} = Source.split_at(code, line, column)
120120

121-
metadata =
122-
maybe_fix_autocomple_on_cursor(
123-
metadata,
124-
text_before,
125-
text_after,
126-
{line, column}
127-
)
128-
129121
# This works better than Code.Fragment.surround_context
130122
surround =
131123
case {prefix, suffix} do
@@ -150,62 +142,6 @@ defmodule ElixirLS.LanguageServer.Providers.Completion.Suggestion do
150142
find(hint, env, metadata, cursor_context, module_store, options)
151143
end
152144

153-
# Provides a last attempt to fix a couple of parse errors that
154-
# commonly appear when working with autocomplete on functions
155-
# without parens.
156-
#
157-
# Note: This will be removed after refactoring the parser to
158-
# allow unparsable nodes in the AST.
159-
defp maybe_fix_autocomple_on_cursor(%Metadata{error: nil} = meta, _, _, _) do
160-
meta
161-
end
162-
163-
defp maybe_fix_autocomple_on_cursor(metadata, text_before, text_after, {line, column}) do
164-
# Fix incomplete call, e.g. cursor after `var.`
165-
fix_incomplete_call = fn text_before, text_after ->
166-
if String.ends_with?(text_before, ".") do
167-
text_before <> "__fake_call__" <> text_after
168-
end
169-
end
170-
171-
# Fix incomplete kw, e.g. cursor after `option1: 1,`
172-
fix_incomplete_kw = fn text_before, text_after ->
173-
if Regex.match?(~r/\,\s*$/u, text_before) do
174-
text_before <> "__fake_key__: :__fake_value__" <> text_after
175-
end
176-
end
177-
178-
# Fix incomplete kw key, e.g. cursor after `option1: 1, opt`
179-
fix_incomplete_kw_key = fn text_before, text_after ->
180-
if Regex.match?(~r/\,\s*([\p{L}_][\p{L}\p{N}_@]*[?!]?)?$/u, text_before) do
181-
text_before <> ": :__fake_value__" <> text_after
182-
end
183-
end
184-
185-
# TODO this may no longer be needed
186-
# only fix_incomplete_call has some tests depending on it
187-
# on 1.17 no tests depend on those hacks
188-
fixers = [
189-
# fix_incomplete_call,
190-
# fix_incomplete_kw,
191-
# fix_incomplete_kw_key
192-
]
193-
194-
Enum.reduce_while(fixers, metadata, fn fun, metadata ->
195-
new_buffer = fun.(text_before, text_after)
196-
197-
with true <- new_buffer != nil,
198-
meta <- Parser.parse_string(new_buffer, false, false, {line, column}),
199-
%Metadata{error: error} <- meta,
200-
true <- error == nil do
201-
{:halt, meta}
202-
else
203-
_ ->
204-
{:cont, metadata}
205-
end
206-
end)
207-
end
208-
209145
@doc """
210146
Finds all suggestions for a hint based on context information.
211147
"""

0 commit comments

Comments
 (0)