@@ -871,6 +871,19 @@ defmodule ElixirSense.Core.Compiler do
871871 { expanded_fun , state , _ } = expand ( fun , state , % { env | function: fa } )
872872 { expanded_fun , state }
873873
874+ # sometimes cursor turns the AST around and transforms function head node into a 2-tuple
875+ { { :__cursor__ , cursor_meta , [ { fun , _ , context } ] } , meta , args }
876+ when ( is_atom ( fun ) and is_atom ( context ) and is_list ( args ) ) or is_atom ( args ) ->
877+ fa = { fun , if ( is_list ( args ) , do: length ( args ) , else: 0 ) }
878+
879+ { expanded_fun , state , _ } =
880+ expand ( { :__cursor__ , cursor_meta , [ { fun , meta , args } ] } , state , % {
881+ env
882+ | function: fa
883+ } )
884+
885+ { expanded_fun , state }
886+
874887 _ ->
875888 { fun , state }
876889 end
@@ -1065,11 +1078,12 @@ defmodule ElixirSense.Core.Compiler do
10651078
10661079 { arg , state , env } = expand ( arg , state , env )
10671080
1068- state = if Keyword . keyword? ( arg ) do
1069- State . register_optional_callbacks ( state , arg )
1070- else
1071- state
1072- end
1081+ state =
1082+ if Keyword . keyword? ( arg ) do
1083+ State . register_optional_callbacks ( state , arg )
1084+ else
1085+ state
1086+ end
10731087
10741088 { { :@ , meta , [ { :optional_callbacks , doc_meta , [ arg ] } ] } , state , env }
10751089 end
@@ -1719,6 +1733,19 @@ defmodule ElixirSense.Core.Compiler do
17191733 { expanded_call , state , _ } = expand ( call , state , % { env | function: fa } )
17201734 { expanded_call , state }
17211735
1736+ # sometimes cursor turns the AST around and transforms function head node into a 2-tuple
1737+ { { :__cursor__ , cursor_meta , [ { fun , _ , context } ] } , meta , args }
1738+ when ( is_atom ( fun ) and is_atom ( context ) and is_list ( args ) ) or is_atom ( args ) ->
1739+ fa = { fun , if ( is_list ( args ) , do: length ( args ) , else: 0 ) }
1740+
1741+ { expanded_call , state , _ } =
1742+ expand ( { :__cursor__ , cursor_meta , [ { fun , meta , args } ] } , state , % {
1743+ env
1744+ | function: fa
1745+ } )
1746+
1747+ { expanded_call , state }
1748+
17221749 _ ->
17231750 { call , state }
17241751 end
0 commit comments