Skip to content

Commit a2bb2e2

Browse files
committed
silence warnings
1 parent 7234e39 commit a2bb2e2

File tree

11 files changed

+35
-23
lines changed

11 files changed

+35
-23
lines changed

lib/elixir_sense/core/binding.ex

+2-2
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,7 @@ defmodule ElixirSense.Core.Binding do
14561456
include_private,
14571457
stack
14581458
) do
1459-
case Code.string_to_quoted(func_spec) do
1459+
case Code.string_to_quoted(func_spec, emit_warnings: false) do
14601460
{:ok, {:@, _, [{_kind, _, [ast]}]}} ->
14611461
case extract_type(ast) do
14621462
{:ok, type} ->
@@ -1681,7 +1681,7 @@ defmodule ElixirSense.Core.Binding do
16811681
case types[{mod, type_name, arity}] do
16821682
%State.TypeInfo{specs: [type_spec], kind: kind}
16831683
when type_is_public(kind, include_private) ->
1684-
case Code.string_to_quoted(type_spec) do
1684+
case Code.string_to_quoted(type_spec, emit_warnings: false) do
16851685
{:ok, {:@, _, [{_kind, _, [ast]}]}} ->
16861686
case extract_type(ast) do
16871687
{:ok, type} ->

lib/elixir_sense/core/metadata.ex

+5-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,11 @@ defmodule ElixirSense.Core.Metadata do
124124
end
125125

126126
{meta, cursor_env} =
127-
case Code.string_to_quoted(source_with_cursor, columns: true, token_metadata: true) do
127+
case Code.string_to_quoted(source_with_cursor,
128+
columns: true,
129+
token_metadata: true,
130+
emit_warnings: false
131+
) do
128132
{:ok, ast} ->
129133
MetadataBuilder.build(ast).cursor_env || {[], nil}
130134

lib/elixir_sense/core/normalized/code.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ defmodule ElixirSense.Core.Normalized.Code do
7878
args_quoted =
7979
signatures
8080
|> Enum.join(" ")
81-
|> Code.string_to_quoted()
81+
|> Code.string_to_quoted(emit_warnings: false)
8282
|> case do
8383
{:ok, {^name, _, args}} -> args
8484
_ -> []

lib/elixir_sense/core/normalized/tokenizer.ex

+8-6
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,22 @@ defmodule ElixirSense.Core.Normalized.Tokenizer do
66
"""
77
require Logger
88

9-
@spec tokenize(String.t()) :: [tuple]
10-
def tokenize(prefix) do
9+
@spec tokenize(String.t(), Keyword.t()) :: [tuple]
10+
def tokenize(prefix, options \\ []) do
11+
options = options |> Keyword.put(:emit_warnings, false)
12+
1113
prefix
1214
|> String.to_charlist()
13-
|> do_tokenize()
15+
|> do_tokenize(options)
1416
end
1517

16-
defp do_tokenize(prefix_charlist) do
18+
defp do_tokenize(prefix_charlist, options) do
1719
result =
1820
if Version.match?(System.version(), ">= 1.14.0-dev") do
19-
:elixir_tokenizer.tokenize(prefix_charlist, 1, [])
21+
:elixir_tokenizer.tokenize(prefix_charlist, 1, options)
2022
else
2123
# on 1.13 use our version as it has all the fixes from last 1.13 release
22-
:elixir_sense_tokenizer.tokenize(prefix_charlist, 1, [])
24+
:elixir_sense_tokenizer.tokenize(prefix_charlist, 1, options)
2325
end
2426

2527
case result do

lib/elixir_sense/core/options.ex

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ defmodule ElixirSense.Core.Options do
55

66
defp get_spec_ast_from_info(spec_info) do
77
for spec <- spec_info.specs do
8-
case Code.string_to_quoted(spec) do
8+
case Code.string_to_quoted(spec, emit_warnings: false) do
99
{:ok, {:@, _, [{_kind, _, [ast]}]}} -> ast
1010
_ -> nil
1111
end
@@ -455,7 +455,7 @@ defmodule ElixirSense.Core.Options do
455455
type
456456
]}
457457
]}
458-
]}} <- Code.string_to_quoted(spec) do
458+
]}} <- Code.string_to_quoted(spec, emit_warnings: false) do
459459
arg_names = for {arg_name, _, context} when is_atom(context) <- arg_names, do: arg_name
460460
{:ok, type, Enum.zip(arg_names, args)}
461461
else

lib/elixir_sense/core/parser.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ defmodule ElixirSense.Core.Parser do
7171
end
7272
end
7373

74-
@default_parser_options [columns: true, token_metadata: true]
74+
@default_parser_options [columns: true, token_metadata: true, emit_warnings: false]
7575

7676
def string_to_ast(source, options \\ []) when is_binary(source) do
7777
errors_threshold = Keyword.get(options, :errors_threshold, 6)

lib/elixir_sense/core/source.ex

+3-3
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ defmodule ElixirSense.Core.Source do
8686
def split_module_and_func("", _current_module, _aliases), do: {nil, nil}
8787

8888
def split_module_and_func(call, current_module, aliases) do
89-
case Code.string_to_quoted(call) do
89+
case Code.string_to_quoted(call, emit_warnings: false) do
9090
{:error, _} ->
9191
{nil, nil}
9292

@@ -293,7 +293,7 @@ defmodule ElixirSense.Core.Source do
293293
result
294294
|> Enum.join()
295295
|> Kernel.<>("_: _}")
296-
|> Code.string_to_quoted() do
296+
|> Code.string_to_quoted(emit_warnings: false) do
297297
extract_struct_module(ast, current_module)
298298
else
299299
_ -> nil
@@ -307,7 +307,7 @@ defmodule ElixirSense.Core.Source do
307307
~r/(alias|require|import|use)\s+(?<module>[^\s^\{^\}]+?)\.\{[^\}]*?$/u,
308308
text_before
309309
),
310-
{:ok, ast} <- Code.string_to_quoted(module_str),
310+
{:ok, ast} <- Code.string_to_quoted(module_str, emit_warnings: false),
311311
{:ok, module, elixir_prefix} <- extract_module(ast, current_module) do
312312
if elixir_prefix and module != Elixir do
313313
"Elixir." <> inspect(module)

lib/elixir_sense/providers/completion/reducers/record.ex

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ defmodule ElixirSense.Providers.Completion.Reducers.Record do
142142
with %TypeInfo{specs: [spec | _]} <-
143143
types[{module, record, 0}] || types[{module, :"#{record}_t", 0}] ||
144144
types[{module, :t, 0}],
145-
{:ok, ast} <- Code.string_to_quoted(spec),
145+
{:ok, ast} <- Code.string_to_quoted(spec, emit_warnings: false),
146146
{:@, _,
147147
[
148148
{kind, _,
@@ -172,7 +172,7 @@ defmodule ElixirSense.Providers.Completion.Reducers.Record do
172172
end
173173

174174
with [info | _] <- candidates,
175-
{:ok, ast} <- Code.string_to_quoted(info.spec),
175+
{:ok, ast} <- Code.string_to_quoted(info.spec, emit_warnings: false),
176176
{:@, _,
177177
[
178178
{kind, _,

lib/elixir_sense/providers/completion/reducers/returns.ex

+9-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ defmodule ElixirSense.Providers.Completion.Reducers.Returns do
3232

3333
%State.SpecInfo{specs: info_specs} ->
3434
for spec <- info_specs,
35-
{:ok, {:@, _, [{_, _, [quoted]}]}} <- [Code.string_to_quoted(spec)],
35+
{:ok, {:@, _, [{_, _, [quoted]}]}} <- [
36+
Code.string_to_quoted(spec, emit_warnings: false)
37+
],
3638
return <- Introspection.get_returns_from_spec_ast(quoted) do
3739
format_return(return)
3840
end
@@ -49,7 +51,9 @@ defmodule ElixirSense.Providers.Completion.Reducers.Returns do
4951

5052
%State.SpecInfo{specs: info_specs} ->
5153
for spec <- info_specs,
52-
{:ok, {:@, _, [{_, _, [quoted]}]}} <- [Code.string_to_quoted(spec)],
54+
{:ok, {:@, _, [{_, _, [quoted]}]}} <- [
55+
Code.string_to_quoted(spec, emit_warnings: false)
56+
],
5357
return <- Introspection.get_returns_from_spec_ast(quoted) do
5458
format_return(return)
5559
end
@@ -68,7 +72,9 @@ defmodule ElixirSense.Providers.Completion.Reducers.Returns do
6872

6973
%State.SpecInfo{specs: info_specs} ->
7074
for spec <- info_specs,
71-
{:ok, {:@, _, [{:callback, _, [quoted]}]}} <- [Code.string_to_quoted(spec)],
75+
{:ok, {:@, _, [{:callback, _, [quoted]}]}} <- [
76+
Code.string_to_quoted(spec, emit_warnings: false)
77+
],
7278
return <- Introspection.get_returns_from_spec_ast(quoted) do
7379
format_return(return)
7480
end

lib/elixir_sense/providers/plugins/ecto/query.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ defmodule ElixirSense.Providers.Plugins.Ecto.Query do
253253
matches = from_matches ++ join_matches
254254

255255
Enum.reduce(matches, %{}, fn [_, _, var, expr], bindings ->
256-
case Code.string_to_quoted(expr) do
256+
case Code.string_to_quoted(expr, emit_warnings: false) do
257257
{:ok, expr_ast} ->
258258
type = infer_type(expr_ast, bindings, env, buffer_metadata, {line, col})
259259
Map.put(bindings, var, %{type: type})

lib/elixir_sense/providers/utils/field.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ defmodule ElixirSense.Providers.Utils.Field do
2121
case types[{mod, :t, 0}] do
2222
%State.TypeInfo{specs: [type_spec], kind: kind}
2323
when type_is_public(kind, include_private) ->
24-
case Code.string_to_quoted(type_spec) do
24+
case Code.string_to_quoted(type_spec, emit_warnings: false) do
2525
{:ok, {:@, _, [{_kind, _, [spec]}]}} ->
2626
spec
2727
|> get_fields_from_struct_spec()

0 commit comments

Comments
 (0)