Skip to content

Commit

Permalink
make sure tests pass on elixir master
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszsamson committed May 8, 2024
1 parent 8ec03be commit 5f2defd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
5 changes: 1 addition & 4 deletions lib/elixir_sense/core/metadata_builder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ defmodule ElixirSense.Core.MetadataBuilder do
import ElixirSense.Log

alias ElixirSense.Core.BuiltinFunctions
alias ElixirSense.Core.Introspection
alias ElixirSense.Core.Source
alias ElixirSense.Core.State
alias ElixirSense.Core.State.VarInfo
Expand Down Expand Up @@ -680,8 +679,6 @@ defmodule ElixirSense.Core.MetadataBuilder do
{:@, meta_attr, [{:moduledoc, meta, [doc_arg]}]},
state
) do
line = Keyword.fetch!(meta_attr, :line)
column = Keyword.fetch!(meta_attr, :column)
new_ast = {:@, meta_attr, [{:moduledoc, add_no_call(meta), [doc_arg]}]}
env = get_current_env(state)

Expand Down Expand Up @@ -938,7 +935,7 @@ defmodule ElixirSense.Core.MetadataBuilder do
{ast, state}
end

defp pre({:defoverridable, meta, [arg]} = ast, state) do
defp pre({:defoverridable, _meta, [_arg]} = ast, state) do
{ast, state, _env} = expand(ast, state)
{ast, state}
end
Expand Down
3 changes: 1 addition & 2 deletions lib/elixir_sense/core/state.ex
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ defmodule ElixirSense.Core.State do

def add_first_alias_positions(
%__MODULE__{} = state,
env = %{module: module, function: nil},
_env = %{module: module, function: nil},
meta
) do
# TODO shouldn't that look for end_of_expression
Expand Down Expand Up @@ -1592,7 +1592,6 @@ defmodule ElixirSense.Core.State do

def expand({:alias, meta, [arg, opts]}, state, env) do
line = Keyword.fetch!(meta, :line)
column = Keyword.fetch!(meta, :column)

{arg, state, env} = expand(arg, state, env)
# options = expand(no_alias_opts(arg), state, env, env)
Expand Down
17 changes: 10 additions & 7 deletions test/elixir_sense/core/metadata_builder_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ defmodule ElixirSense.Core.MetadataBuilderTest do
@macro_calls_support Version.match?(System.version(), "< 1.17.0-dev")
@typespec_calls_support Version.match?(System.version(), "< 1.17.0-dev")
@record_support Version.match?(System.version(), "< 1.17.0-dev")
@compiler Code.ensure_loaded?(ElixirSense.Core.Compiler)

describe "versioned_vars" do
test "in block" do
Expand Down Expand Up @@ -225,7 +226,7 @@ defmodule ElixirSense.Core.MetadataBuilderTest do
{:y, nil}
]

if Version.match?(System.version(), ">= 1.17.0-dev") do
if Version.match?(System.version(), ">= 1.17.0-dev") and @compiler do
assert [
%VarInfo{name: :y, positions: [{1, 1}, {2, 11}, {3, 11}]}
] = state |> get_line_vars(4)
Expand Down Expand Up @@ -501,7 +502,7 @@ defmodule ElixirSense.Core.MetadataBuilderTest do
"""
|> string_to_state

if Version.match?(System.version(), ">= 1.17.0-dev") do
if Version.match?(System.version(), ">= 1.17.0-dev") and @compiler do
assert Map.keys(state.lines_to_env[1].versioned_vars) == []
assert [] = state |> get_line_vars(1)

Expand Down Expand Up @@ -605,7 +606,7 @@ defmodule ElixirSense.Core.MetadataBuilderTest do
"""
|> string_to_state

if Version.match?(System.version(), ">= 1.17.0-dev") do
if Version.match?(System.version(), ">= 1.17.0-dev") and @compiler do
assert Map.keys(state.lines_to_env[1].versioned_vars) == []
assert [] = state |> get_line_vars(3)

Expand Down Expand Up @@ -660,7 +661,7 @@ defmodule ElixirSense.Core.MetadataBuilderTest do
end
end

if Version.match?(System.version(), ">= 1.17.0-dev") do
if Version.match?(System.version(), ">= 1.17.0-dev") and @compiler do
test "for bitstring" do
state =
"""
Expand Down Expand Up @@ -974,7 +975,7 @@ defmodule ElixirSense.Core.MetadataBuilderTest do

assert Map.has_key?(state.lines_to_env[5].versioned_vars, {:abc, nil})

if Version.match?(System.version(), ">= 1.17.0-dev") do
if Version.match?(System.version(), ">= 1.17.0-dev") and @compiler do
assert [%VarInfo{name: :abc, positions: [{1, 1}, {3, 11}]}] = state |> get_line_vars(5)
else
assert [%VarInfo{name: :abc, positions: [{1, 1}]}] = state |> get_line_vars(5)
Expand All @@ -997,7 +998,7 @@ defmodule ElixirSense.Core.MetadataBuilderTest do

assert Map.has_key?(state.lines_to_env[8].versioned_vars, {:abc, nil})

if Version.match?(System.version(), ">= 1.17.0-dev") do
if Version.match?(System.version(), ">= 1.17.0-dev") and @compiler do
assert [
%VarInfo{
name: :abc,
Expand All @@ -1023,7 +1024,7 @@ defmodule ElixirSense.Core.MetadataBuilderTest do
"""
|> string_to_state

if Version.match?(System.version(), ">= 1.17.0-dev") do
if Version.match?(System.version(), ">= 1.17.0-dev") and @compiler do
assert Map.keys(state.lines_to_env[6].versioned_vars) == [{:"&1", nil}, {:abc, nil}]

assert [
Expand Down Expand Up @@ -7462,6 +7463,8 @@ defmodule ElixirSense.Core.MetadataBuilderTest do
end
"""
|> string_to_state

assert state
end

defp string_to_state(string) do
Expand Down

0 comments on commit 5f2defd

Please sign in to comment.