@@ -2277,78 +2277,80 @@ defmodule ElixirLS.LanguageServer.Providers.References.LocatorTest do
22772277 end
22782278 end
22792279
2280- test "local vs remote references" do
2281- exclude = [
2282- { :elixir_utils , :noop , 0 } ,
2283- { :elixir_def , :store_definition , 3 } ,
2284- { Enum , nil , nil } ,
2285- { Enum , :reduce , 3 } ,
2286- { Kernel.Utils , :announce_struct , 1 } ,
2287- { Kernel.Utils , :defstruct , 4 } ,
2288- { Kernel.Utils , nil , nil } ,
2289- { Protocol , :__derive__ , 3 } ,
2290- { Protocol , nil , nil } ,
2291- { :elixir_bootstrap , :def , 2 } ,
2292- { Kernel.Typespec , :deftypespec , 6 } ,
2293- { Kernel.Typespec , nil , nil } ,
2294- { Module , :__put_attribute__ , 5 } ,
2295- { Module , nil , nil } ,
2296- { Module , :make_overridable , 2 } ,
2297- { Module , :compile_definition_attributes , 6 }
2298- ]
2299-
2300- for file <- [
2301- "test/support/references/simple_module.ex" ,
2302- "test/support/references/module_with_def.ex" ,
2303- "test/support/references/module_with_defmacro.ex" ,
2304- "test/support/references/require.ex" ,
2305- "test/support/references/require_as.ex" ,
2306- "test/support/references/local_call.ex" ,
2307- "test/support/references/local_macro_call.ex" ,
2308- "test/support/references/remote_call.ex" ,
2309- "test/support/references/alias.ex" ,
2310- "test/support/references/import.ex" ,
2311- "test/support/references/struct.ex" ,
2312- "test/support/references/captures.ex" ,
2313- # "test/support/references/super.ex",
2314- "test/support/references/quoted.ex"
2315- ] do
2316- Code . compile_file ( file )
2317- trace = Tracer . get ( )
2318-
2319- filtered_trace =
2320- trace
2321- |> Enum . map ( fn { key , list } ->
2322- filtered_list =
2280+ if System . version ( ) >= "1.18.0" do
2281+ test "local vs remote references" do
2282+ exclude = [
2283+ { :elixir_utils , :noop , 0 } ,
2284+ { :elixir_def , :store_definition , 3 } ,
2285+ { Enum , nil , nil } ,
2286+ { Enum , :reduce , 3 } ,
2287+ { Kernel.Utils , :announce_struct , 1 } ,
2288+ { Kernel.Utils , :defstruct , 4 } ,
2289+ { Kernel.Utils , nil , nil } ,
2290+ { Protocol , :__derive__ , 3 } ,
2291+ { Protocol , nil , nil } ,
2292+ { :elixir_bootstrap , :def , 2 } ,
2293+ { Kernel.Typespec , :deftypespec , 6 } ,
2294+ { Kernel.Typespec , nil , nil } ,
2295+ { Module , :__put_attribute__ , 5 } ,
2296+ { Module , nil , nil } ,
2297+ { Module , :make_overridable , 2 } ,
2298+ { Module , :compile_definition_attributes , 6 }
2299+ ]
2300+
2301+ for file <- [
2302+ "test/support/references/simple_module.ex" ,
2303+ "test/support/references/module_with_def.ex" ,
2304+ "test/support/references/module_with_defmacro.ex" ,
2305+ "test/support/references/require.ex" ,
2306+ "test/support/references/require_as.ex" ,
2307+ "test/support/references/local_call.ex" ,
2308+ "test/support/references/local_macro_call.ex" ,
2309+ "test/support/references/remote_call.ex" ,
2310+ "test/support/references/alias.ex" ,
2311+ "test/support/references/import.ex" ,
2312+ "test/support/references/struct.ex" ,
2313+ "test/support/references/captures.ex" ,
2314+ # "test/support/references/super.ex",
2315+ "test/support/references/quoted.ex"
2316+ ] do
2317+ Code . compile_file ( file )
2318+ trace = Tracer . get ( )
2319+
2320+ filtered_trace =
2321+ trace
2322+ |> Enum . map ( fn { key , list } ->
2323+ filtered_list =
2324+ list
2325+ |> Enum . filter ( fn t -> t . file == file end )
2326+ |> Enum . sort_by ( fn t -> { t . line , t . column , t . kind } end )
2327+
2328+ { key , filtered_list }
2329+ end )
2330+ |> Enum . filter ( fn { key , list } -> list != [ ] and key not in exclude end )
2331+ |> Map . new ( )
2332+
2333+ metadata = ElixirSense.Core.Parser . parse_file ( file , false , false , { 1 , 1 } )
2334+
2335+ grouped_calls =
2336+ metadata . calls
2337+ |> Enum . flat_map ( fn { _ , list } ->
23232338 list
2324- |> Enum . filter ( fn t -> t . file == file end )
2339+ |> Enum . map ( fn % ElixirSense.Core.State.CallInfo { } = ci ->
2340+ % {
2341+ line: ci . position |> elem ( 0 ) ,
2342+ file: file ,
2343+ column: ci . position |> elem ( 1 ) ,
2344+ callee: { ci . mod , ci . func , ci . arity } ,
2345+ kind: ci . kind
2346+ }
2347+ end )
23252348 |> Enum . sort_by ( fn t -> { t . line , t . column , t . kind } end )
2326-
2327- { key , filtered_list }
2328- end )
2329- |> Enum . filter ( fn { key , list } -> list != [ ] and key not in exclude end )
2330- |> Map . new ( )
2331-
2332- metadata = ElixirSense.Core.Parser . parse_file ( file , false , false , { 1 , 1 } )
2333-
2334- grouped_calls =
2335- metadata . calls
2336- |> Enum . flat_map ( fn { _ , list } ->
2337- list
2338- |> Enum . map ( fn % ElixirSense.Core.State.CallInfo { } = ci ->
2339- % {
2340- line: ci . position |> elem ( 0 ) ,
2341- file: file ,
2342- column: ci . position |> elem ( 1 ) ,
2343- callee: { ci . mod , ci . func , ci . arity } ,
2344- kind: ci . kind
2345- }
23462349 end )
2347- |> Enum . sort_by ( fn t -> { t . line , t . column , t . kind } end )
2348- end )
2349- |> Enum . group_by ( fn item -> item . callee end )
2350+ |> Enum . group_by ( fn item -> item . callee end )
23502351
2351- assert grouped_calls == filtered_trace
2352+ assert grouped_calls == filtered_trace
2353+ end
23522354 end
23532355 end
23542356
0 commit comments