@@ -246,20 +246,23 @@ defmodule Code.Fragment do
246
246
end
247
247
end
248
248
249
- defp call_to_cursor_context ( { [ ?. , h | t ] , spaces } ) when h not in @ non_identifier do
250
- case identifier_to_cursor_context ( [ h | t ] , spaces , true ) do
251
- { { :local_or_var , acc } , count } -> { { :anonymous_call , { :var , acc } } , count + 1 }
252
- { { :module_attribute , _ } = attr , count } -> { { :anonymous_call , attr } , count + 1 }
253
- { _ , _ } -> { :none , 0 }
254
- end
255
- end
256
-
257
249
defp call_to_cursor_context ( { reverse , spaces } ) do
258
- case identifier_to_cursor_context ( reverse , spaces , true ) do
259
- { { :local_or_var , acc } , count } -> { { :local_call , acc } , count }
260
- { { :dot , base , acc } , count } -> { { :dot_call , base , acc } , count }
261
- { { :operator , acc } , count } -> { { :operator_call , acc } , count }
262
- { _ , _ } -> { :none , 0 }
250
+ with [ ?. | rest ] <- reverse ,
251
+ { rest , spaces } = strip_spaces ( rest , spaces ) ,
252
+ [ h | _ ] when h not in @ non_identifier <- rest do
253
+ case identifier_to_cursor_context ( rest , spaces , true ) do
254
+ { { :local_or_var , acc } , count } -> { { :anonymous_call , { :var , acc } } , count + 1 }
255
+ { { :module_attribute , _ } = attr , count } -> { { :anonymous_call , attr } , count + 1 }
256
+ { _ , _ } -> { :none , 0 }
257
+ end
258
+ else
259
+ _ ->
260
+ case identifier_to_cursor_context ( reverse , spaces , true ) do
261
+ { { :local_or_var , acc } , count } -> { { :local_call , acc } , count }
262
+ { { :dot , base , acc } , count } -> { { :dot_call , base , acc } , count }
263
+ { { :operator , acc } , count } -> { { :operator_call , acc } , count }
264
+ { _ , _ } -> { :none , 0 }
265
+ end
263
266
end
264
267
end
265
268
0 commit comments