Skip to content

Commit 7234e39

Browse files
committed
fix a couple of dialyzer errors
1 parent 28c163b commit 7234e39

File tree

12 files changed

+30
-39
lines changed

12 files changed

+30
-39
lines changed

lib/elixir_sense.ex

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ defmodule ElixirSense do
5757
boolean,
5858
keyword
5959
) ::
60-
{:ok, Macro.t()} | {:error, :parse_error}
60+
{:ok, Macro.t()} | {:error, any()}
6161
def string_to_quoted(
6262
source,
6363
cursor_position \\ nil,
@@ -74,7 +74,7 @@ defmodule ElixirSense do
7474

7575
case Parser.string_to_ast(source, string_to_ast_options) do
7676
{:ok, ast, _source, _error} -> {:ok, ast}
77-
other -> other
77+
other = {:error, _} -> other
7878
end
7979
end
8080

lib/elixir_sense/core/introspection.ex

+3-3
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ defmodule ElixirSense.Core.Introspection do
802802
@spec actual_module(
803803
nil | module,
804804
ElixirSense.Core.State.Env.t(),
805-
ElixirSense.Core.State.mods_funs_to_positions_t(),
805+
ElixirSense.Core.Compiler.State.mods_funs_to_positions_t(),
806806
boolean
807807
) :: {nil | module, boolean}
808808
def actual_module(module, env, mods_funs, expand_aliases?) do
@@ -891,8 +891,8 @@ defmodule ElixirSense.Core.Introspection do
891891
@spec actual_mod_fun(
892892
{nil | module, nil | atom},
893893
ElixirSense.Core.State.Env.t(),
894-
ElixirSense.Core.State.mods_funs_to_positions_t(),
895-
ElixirSense.Core.State.types_t(),
894+
ElixirSense.Core.Compiler.State.mods_funs_to_positions_t(),
895+
ElixirSense.Core.Compiler.State.types_t(),
896896
{pos_integer, pos_integer},
897897
boolean
898898
) :: {nil | module, nil | atom, boolean, nil | :mod_fun | :type}

lib/elixir_sense/core/metadata.ex

+8-8
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ defmodule ElixirSense.Core.Metadata do
1212

1313
@type t :: %ElixirSense.Core.Metadata{
1414
source: String.t(),
15-
mods_funs_to_positions: State.mods_funs_to_positions_t(),
15+
mods_funs_to_positions: ElixirSense.Core.Compiler.State.mods_funs_to_positions_t(),
1616
cursor_env: nil | {keyword(), ElixirSense.Core.State.Env.t()},
1717
closest_env:
1818
nil
1919
| {{pos_integer, pos_integer}, {non_neg_integer, non_neg_integer},
2020
ElixirSense.Core.State.Env.t()},
21-
lines_to_env: State.lines_to_env_t(),
22-
calls: State.calls_t(),
23-
vars_info_per_scope_id: State.vars_info_per_scope_id_t(),
24-
types: State.types_t(),
25-
specs: State.specs_t(),
26-
structs: State.structs_t(),
27-
records: State.records_t(),
21+
lines_to_env: ElixirSense.Core.Compiler.State.lines_to_env_t(),
22+
calls: ElixirSense.Core.Compiler.State.calls_t(),
23+
vars_info_per_scope_id: ElixirSense.Core.Compiler.State.vars_info_per_scope_id_t(),
24+
types: ElixirSense.Core.Compiler.State.types_t(),
25+
specs: ElixirSense.Core.Compiler.State.specs_t(),
26+
structs: ElixirSense.Core.Compiler.State.structs_t(),
27+
records: ElixirSense.Core.Compiler.State.records_t(),
2828
error: nil | term,
2929
first_alias_positions: map(),
3030
moduledoc_positions: map()

lib/elixir_sense/core/state/attribute_info.ex

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ defmodule ElixirSense.Core.State.AttributeInfo do
44
"""
55
@type t :: %ElixirSense.Core.State.AttributeInfo{
66
name: atom,
7-
positions: list(ElixirSense.Core.State.position_t()),
8-
type: ElixirSense.Core.State.var_type()
7+
positions: list(ElixirSense.Core.Compiler.State.position_t()),
8+
type: ElixirSense.Core.Compiler.State.var_type()
99
}
1010
defstruct name: nil, positions: [], type: nil
1111
end

lib/elixir_sense/core/state/env.ex

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ defmodule ElixirSense.Core.State.Env do
77
functions: [{module, [{atom, arity}]}],
88
macros: [{module, [{atom, arity}]}],
99
requires: list(module),
10-
aliases: list(ElixirSense.Core.State.alias_t()),
10+
aliases: list(ElixirSense.Core.Compiler.State.alias_t()),
1111
macro_aliases: [{module, {term, module}}],
1212
context: nil | :match | :guard,
1313
module: nil | module,
1414
function: nil | {atom, arity},
15-
protocol: nil | ElixirSense.Core.State.protocol_t(),
15+
protocol: nil | ElixirSense.Core.Compiler.State.protocol_t(),
1616
versioned_vars: %{optional({atom, atom}) => non_neg_integer},
1717
vars: list(ElixirSense.Core.State.VarInfo.t()),
1818
attributes: list(ElixirSense.Core.State.AttributeInfo.t()),
1919
behaviours: list(module),
2020
context_modules: list(module),
2121
typespec: nil | {atom, arity},
22-
scope_id: nil | ElixirSense.Core.State.scope_id_t()
22+
scope_id: nil | ElixirSense.Core.Compiler.State.scope_id_t()
2323
}
2424
defstruct functions: [],
2525
macros: [],

lib/elixir_sense/core/state/mod_fun_info.ex

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ defmodule ElixirSense.Core.State.ModFunInfo do
77

88
@type t :: %ElixirSense.Core.State.ModFunInfo{
99
params: list(list(term)),
10-
positions: list(ElixirSense.Core.State.position_t()),
11-
end_positions: list(ElixirSense.Core.State.position_t() | nil),
10+
positions: list(ElixirSense.Core.Compiler.State.position_t()),
11+
end_positions: list(ElixirSense.Core.Compiler.State.position_t() | nil),
1212
target: nil | {module, atom},
1313
overridable: false | {true, module},
1414
generated: list(boolean),

lib/elixir_sense/core/state/spec_info.ex

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ defmodule ElixirSense.Core.State.SpecInfo do
77
args: list(list(String.t())),
88
specs: [String.t()],
99
kind: :spec | :callback | :macrocallback,
10-
positions: [ElixirSense.Core.State.position_t()],
11-
end_positions: [ElixirSense.Core.State.position_t() | nil],
10+
positions: [ElixirSense.Core.Compiler.State.position_t()],
11+
end_positions: [ElixirSense.Core.Compiler.State.position_t() | nil],
1212
doc: String.t(),
1313
meta: map(),
1414
generated: list(boolean)

lib/elixir_sense/core/state/type_info.ex

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ defmodule ElixirSense.Core.State.TypeInfo do
77
args: list(list(String.t())),
88
specs: [String.t()],
99
kind: :type | :typep | :opaque,
10-
positions: [ElixirSense.Core.State.position_t()],
11-
end_positions: [ElixirSense.Core.State.position_t() | nil],
10+
positions: [ElixirSense.Core.Compiler.State.position_t()],
11+
end_positions: [ElixirSense.Core.Compiler.State.position_t() | nil],
1212
doc: String.t(),
1313
meta: map(),
1414
generated: list(boolean)

lib/elixir_sense/core/state/var_info.ex

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ defmodule ElixirSense.Core.State.VarInfo do
55

66
@type t :: %ElixirSense.Core.State.VarInfo{
77
name: atom,
8-
positions: list(ElixirSense.Core.State.position_t()),
9-
scope_id: nil | ElixirSense.Core.State.scope_id_t(),
8+
positions: list(ElixirSense.Core.Compiler.State.position_t()),
9+
scope_id: nil | ElixirSense.Core.Compiler.State.scope_id_t(),
1010
version: non_neg_integer(),
11-
type: ElixirSense.Core.State.var_type()
11+
type: ElixirSense.Core.Compiler.State.var_type()
1212
}
1313
defstruct name: nil,
1414
positions: [],

lib/elixir_sense/core/struct.ex

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ defmodule ElixirSense.Core.Struct do
44
alias ElixirSense.Core.Introspection
55
alias ElixirSense.Core.State
66

7-
@spec is_struct(module | nil, State.structs_t()) :: boolean
7+
@spec is_struct(module | nil, ElixirSense.Core.Compiler.State.structs_t()) :: boolean
88
def is_struct(nil, _metadata_structs), do: false
99

1010
def is_struct(module, metadata_structs) do
1111
Map.has_key?(metadata_structs, module) or Introspection.module_is_struct?(module)
1212
end
1313

14-
@spec get_fields(module, State.structs_t()) :: [atom]
14+
@spec get_fields(module, ElixirSense.Core.Compiler.State.structs_t()) :: [atom]
1515
def get_fields(module, metadata_structs) do
1616
case metadata_structs[module] do
1717
%State.StructInfo{fields: fields} ->

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

-9
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,6 @@ defmodule ElixirSense.Providers.Completion.Reducers.TypeSpecs do
7676
end
7777
end
7878

79-
defp expand({{:variable, _, _} = type, hint}, env, aliases) do
80-
# TODO Binding should return expanded aliases
81-
# TODO use Macro.Env
82-
case Binding.expand(env, type) do
83-
{:atom, module} -> {Introspection.expand_alias(module, aliases), hint}
84-
_ -> {nil, ""}
85-
end
86-
end
87-
8879
defp expand({type, hint}, _env, _aliases) do
8980
{type, hint}
9081
end

lib/elixir_sense/providers/completion/suggestion.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ defmodule ElixirSense.Providers.Completion.Suggestion do
103103

104104
@add_opts_for [:populate_complete_engine]
105105

106-
@spec suggestions(String.t(), pos_integer, pos_integer, keyword()) :: [Suggestion.suggestion()]
106+
@spec suggestions(String.t(), pos_integer, pos_integer, keyword()) :: [suggestion()]
107107
def suggestions(code, line, column, options \\ []) do
108108
{prefix = hint, suffix} = Source.prefix_suffix(code, line, column)
109109

0 commit comments

Comments
 (0)