Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszsamson committed May 2, 2024
1 parent efa1c5f commit ba0614c
Show file tree
Hide file tree
Showing 3 changed files with 1,254 additions and 1,211 deletions.
3 changes: 1 addition & 2 deletions lib/elixir_sense/core/metadata_builder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,6 @@ defmodule ElixirSense.Core.MetadataBuilder do
)
when kind in [:type, :typep, :opaque] and is_atom(name) and
(is_nil(type_args) or is_list(type_args)) do

ast = {:@, meta_attr, [{kind, add_no_call(kind_meta), kind_args}]}
spec = expand_aliases_in_ast(state, spec)
type_args = List.wrap(type_args)
Expand Down Expand Up @@ -1033,7 +1032,7 @@ defmodule ElixirSense.Core.MetadataBuilder do
[]
end

env = get_current_env(state)
env = get_current_env(state)

state
|> add_struct_or_exception(env, type, fields, position, end_position)
Expand Down
49 changes: 41 additions & 8 deletions lib/elixir_sense/core/state.ex
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,11 @@ defmodule ElixirSense.Core.State do
meta
) do
module = env.module

case Keyword.get(meta, :end_of_expression) do
nil -> state
nil ->
state

end_of_expression ->
line_to_insert_alias = Keyword.fetch!(end_of_expression, :line) + 1
column = Keyword.get(meta, :column, 1)
Expand All @@ -415,37 +418,67 @@ defmodule ElixirSense.Core.State do
end
end

def add_first_alias_positions(%__MODULE__{} = state, env = %{module: module, function: nil}, meta) do
def add_first_alias_positions(
%__MODULE__{} = state,
env = %{module: module, function: nil},

Check warning on line 423 in lib/elixir_sense/core/state.ex

View workflow job for this annotation

GitHub Actions / mix test (Elixir 1.13.x | Erlang/OTP 24.x)

variable "env" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 423 in lib/elixir_sense/core/state.ex

View workflow job for this annotation

GitHub Actions / mix test (Elixir 1.15.x | Erlang/OTP 24.x)

variable "env" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 423 in lib/elixir_sense/core/state.ex

View workflow job for this annotation

GitHub Actions / mix test (Elixir 1.13.x | Erlang/OTP 22.x)

variable "env" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 423 in lib/elixir_sense/core/state.ex

View workflow job for this annotation

GitHub Actions / mix test (Elixir 1.13.x | Erlang/OTP 25.x)

variable "env" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 423 in lib/elixir_sense/core/state.ex

View workflow job for this annotation

GitHub Actions / mix test (Elixir 1.14.x | Erlang/OTP 24.x)

variable "env" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 423 in lib/elixir_sense/core/state.ex

View workflow job for this annotation

GitHub Actions / mix test (Elixir 1.13.x | Erlang/OTP 23.x)

variable "env" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 423 in lib/elixir_sense/core/state.ex

View workflow job for this annotation

GitHub Actions / mix test (Elixir 1.14.x | Erlang/OTP 23.x)

variable "env" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 423 in lib/elixir_sense/core/state.ex

View workflow job for this annotation

GitHub Actions / mix test (Elixir 1.14.x | Erlang/OTP 25.x)

variable "env" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 423 in lib/elixir_sense/core/state.ex

View workflow job for this annotation

GitHub Actions / mix test (Elixir 1.15.x | Erlang/OTP 26.x)

variable "env" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 423 in lib/elixir_sense/core/state.ex

View workflow job for this annotation

GitHub Actions / mix test (Elixir 1.15.x | Erlang/OTP 25.x)

variable "env" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 423 in lib/elixir_sense/core/state.ex

View workflow job for this annotation

GitHub Actions / mix test (Elixir 1.14.x | Erlang/OTP 26.x)

variable "env" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 423 in lib/elixir_sense/core/state.ex

View workflow job for this annotation

GitHub Actions / mix test windows (Elixir 1.13.x | Erlang/OTP 22.x)

variable "env" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 423 in lib/elixir_sense/core/state.ex

View workflow job for this annotation

GitHub Actions / mix test windows (Elixir 1.13.x | Erlang/OTP 24.x)

variable "env" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 423 in lib/elixir_sense/core/state.ex

View workflow job for this annotation

GitHub Actions / mix test windows (Elixir 1.13.x | Erlang/OTP 23.x)

variable "env" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 423 in lib/elixir_sense/core/state.ex

View workflow job for this annotation

GitHub Actions / mix test windows (Elixir 1.14.x | Erlang/OTP 24.x)

variable "env" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 423 in lib/elixir_sense/core/state.ex

View workflow job for this annotation

GitHub Actions / mix test windows (Elixir 1.15.x | Erlang/OTP 26.x)

variable "env" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 423 in lib/elixir_sense/core/state.ex

View workflow job for this annotation

GitHub Actions / mix test windows (Elixir 1.14.x | Erlang/OTP 25.x)

variable "env" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 423 in lib/elixir_sense/core/state.ex

View workflow job for this annotation

GitHub Actions / mix test windows (Elixir 1.13.x | Erlang/OTP 25.x)

variable "env" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 423 in lib/elixir_sense/core/state.ex

View workflow job for this annotation

GitHub Actions / mix test windows (Elixir 1.15.x | Erlang/OTP 24.x)

variable "env" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 423 in lib/elixir_sense/core/state.ex

View workflow job for this annotation

GitHub Actions / mix test windows (Elixir 1.15.x | Erlang/OTP 25.x)

variable "env" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 423 in lib/elixir_sense/core/state.ex

View workflow job for this annotation

GitHub Actions / mix test windows (Elixir 1.14.x | Erlang/OTP 26.x)

variable "env" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 423 in lib/elixir_sense/core/state.ex

View workflow job for this annotation

GitHub Actions / mix test windows (Elixir 1.14.x | Erlang/OTP 23.x)

variable "env" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 423 in lib/elixir_sense/core/state.ex

View workflow job for this annotation

GitHub Actions / static analysis (Elixir 1.15.x | Erlang/OTP 26.x)

variable "env" is unused (if the variable is not meant to be used, prefix it with an underscore)
meta
) do
# TODO shouldn't that look for end_of_expression
line = Keyword.get(meta, :line, 0)

if line > 0 do
column = Keyword.get(meta, :column, 1)

%__MODULE__{
state
| first_alias_positions:
Map.put_new(state.first_alias_positions, module, {line, column})
| first_alias_positions: Map.put_new(state.first_alias_positions, module, {line, column})
}
else
state
end
end

def add_first_alias_positions(%__MODULE__{} = state, _env, _meta), do: state

# TODO remove this
def add_call_to_line(%__MODULE__{} = state, {nil, :__block__, _}, _position), do: state

def add_call_to_line(%__MODULE__{} = state, {{:@, _meta, [{name, _name_meta, _args}]}, func, arity}, {_line, _column} = position) when is_atom(name) do
def add_call_to_line(
%__MODULE__{} = state,
{{:@, _meta, [{name, _name_meta, _args}]}, func, arity},
{_line, _column} = position
)
when is_atom(name) do
add_call_to_line(state, {{:attribute, name}, func, arity}, position)
end
def add_call_to_line(%__MODULE__{} = state, {{name, _name_meta, args}, func, arity}, {_line, _column} = position) when is_atom(args) do

def add_call_to_line(
%__MODULE__{} = state,
{{name, _name_meta, args}, func, arity},
{_line, _column} = position
)
when is_atom(args) do
add_call_to_line(state, {{:variable, name}, func, arity}, position)
end
def add_call_to_line(%__MODULE__{} = state, {nil, {:@, _meta, [{name, _name_meta, _args}]}, arity}, {_line, _column} = position) when is_atom(name) do

def add_call_to_line(
%__MODULE__{} = state,
{nil, {:@, _meta, [{name, _name_meta, _args}]}, arity},
{_line, _column} = position
)
when is_atom(name) do
add_call_to_line(state, {nil, {:attribute, name}, arity}, position)
end
def add_call_to_line(%__MODULE__{} = state, {nil, {name, _name_meta, args}, arity}, {_line, _column} = position) when is_atom(args) do

def add_call_to_line(
%__MODULE__{} = state,
{nil, {name, _name_meta, args}, arity},
{_line, _column} = position
)
when is_atom(args) do
add_call_to_line(state, {nil, {:variable, name}, arity}, position)
end

def add_call_to_line(%__MODULE__{} = state, {mod, func, arity}, {line, _column} = position) do
call = %CallInfo{mod: mod, func: func, arity: arity, position: position}

Expand Down
Loading

0 comments on commit ba0614c

Please sign in to comment.