@@ -78,6 +78,9 @@ defmodule Code.Fragment do
78
78
* `{:local_call, charlist}` - the context is a local (import or local)
79
79
call, such as `hello_world(` and `hello_world `
80
80
81
+ * `{:anonymous_call, inside_caller}` - the context is an anonymous
82
+ call, such as `fun.(` and `@fun.(`.
83
+
81
84
* `{:module_attribute, charlist}` - the context is a module attribute,
82
85
such as `@hello_wor`
83
86
@@ -140,6 +143,7 @@ defmodule Code.Fragment do
140
143
| { :local_or_var , charlist }
141
144
| { :local_arity , charlist }
142
145
| { :local_call , charlist }
146
+ | { :anonymous_call , inside_caller }
143
147
| { :module_attribute , charlist }
144
148
| { :operator , charlist }
145
149
| { :operator_arity , charlist }
@@ -164,7 +168,8 @@ defmodule Code.Fragment do
164
168
| { :alias , inside_alias , charlist }
165
169
| { :local_or_var , charlist }
166
170
| { :module_attribute , charlist }
167
- | { :dot , inside_dot , charlist }
171
+ | { :dot , inside_dot , charlist } ,
172
+ inside_caller: { :var , charlist } | { :module_attribute , charlist }
168
173
def cursor_context ( fragment , opts \\ [ ] )
169
174
170
175
def cursor_context ( fragment , opts )
@@ -241,6 +246,14 @@ defmodule Code.Fragment do
241
246
end
242
247
end
243
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
+
244
257
defp call_to_cursor_context ( { reverse , spaces } ) do
245
258
case identifier_to_cursor_context ( reverse , spaces , true ) do
246
259
{ { :local_or_var , acc } , count } -> { { :local_call , acc } , count }
0 commit comments