Skip to content

Commit 8a2cf34

Browse files
azizkprincemaple
authored andcommitted
Elixir: fixed modules_or_ids_or_calls context
Created common `member_or_call_pop` context and simplified others.
1 parent 15303de commit 8a2cf34

File tree

2 files changed

+59
-56
lines changed

2 files changed

+59
-56
lines changed

syntaxes/Elixir.sublime-syntax

Lines changed: 50 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -357,17 +357,9 @@ contexts:
357357
scope: punctuation.accessor.dot.elixir
358358
set:
359359
- include: arguments_paren_param_pop
360-
- include: atom_keyword
361360
- include: module_function_call_param_pop
362-
- include: unquote_call_pop
363361
- include: id_or_operator_call_param_pop
364-
- include: id_member_pop
365-
- include: module_name_pop
366-
- include: arguments_pop
367-
- include: quoted_remote_call_pop
368-
- include: quoted_member_pop
369-
- include: tuple_call_pop
370-
- include: if_non_space_or_eol_pop
362+
- include: member_or_call_pop
371363

372364
function_call_param:
373365
- match: (?=\.(?!\.))
@@ -1786,38 +1778,31 @@ contexts:
17861778
module_name:
17871779
- match: '{{module_name}}{{no_key_suffix}}'
17881780
scope: constant.other.module.elixir
1789-
- match: (?x)(:(["'])) ((?>\\\\|\\\2|(?!\2).)*?) (\2) (?=\s*\.(?!\.))
1790-
captures:
1791-
1: punctuation.definition.constant.begin.elixir
1792-
3: constant.other.module.elixir
1793-
4: punctuation.definition.constant.end.elixir
1794-
- match: (:)({{atom_symbol}})(?=\s*\.(?!\.))
1795-
captures:
1796-
1: punctuation.definition.constant.begin.elixir
1797-
2: constant.other.module.elixir
1781+
- include: atom_module_name
1782+
17981783
module_name_pop:
17991784
- match: '{{module_name}}{{no_key_suffix}}'
18001785
scope: constant.other.module.elixir
18011786
pop: 1
18021787

18031788
module_function_call_pop:
1804-
- match: ({{module_name}})\s*(\.(?!\.))
1789+
- match: ({{module_name}})(?=\s*\.(?!\.))
18051790
comment: always a function call after a module
1806-
captures:
1807-
1: constant.other.module.elixir
1808-
2: punctuation.accessor.dot.elixir
1809-
set: member_call_pop
1791+
scope: constant.other.module.elixir
1792+
set: module_member_pop
18101793

1811-
member_call_pop:
1812-
# - include: sql_or_fragment
1813-
- include: quoted_remote_call_pop
1814-
- include: quoted_member_pop
1815-
- include: unquote_call_pop
1816-
- match: '{{member}}'
1817-
scope: variable.function.elixir
1818-
set: arguments_or_pop
1819-
- include: tuple_call_pop
1820-
- include: if_non_space_or_eol_pop
1794+
module_member_pop:
1795+
- match: \.(?!\.)
1796+
scope: punctuation.accessor.dot.elixir
1797+
set:
1798+
- match: '{{member}}'
1799+
comment: always a function after module name
1800+
scope: variable.function.elixir
1801+
set: arguments_or_pop
1802+
- match: (?=\()
1803+
comment: no ".()" style arguments after module name
1804+
pop: 1
1805+
- include: member_or_call_pop
18211806

18221807
id_or_operator_call_pop:
18231808
- match: ({{member}})(?=\s*\.\s*\(|{{has_arguments}})
@@ -1872,19 +1857,32 @@ contexts:
18721857
captures:
18731858
1: constant.character.escape.char.elixir
18741859

1875-
modules_or_ids_or_calls:
1860+
atom_module_name:
18761861
- match: (?x)(:(["'])) ((?>\\\\|\\\2|(?!\2).)*?) (\2) (?=\s*\.(?!\.))
18771862
captures:
18781863
1: punctuation.definition.constant.begin.elixir
18791864
3: constant.other.module.elixir
18801865
4: punctuation.definition.constant.end.elixir
1881-
push: member_call_pop
1882-
- match: (:)({{atom_symbol}})\s*(\.(?!\.))
1866+
- match: (:)({{atom_symbol}})(?=\s*\.(?!\.))
18831867
captures:
18841868
1: punctuation.definition.constant.begin.elixir
18851869
2: constant.other.module.elixir
1886-
3: punctuation.accessor.dot.elixir
1887-
push: member_call_pop
1870+
1871+
atom_module_name_call:
1872+
- match: (?x)(:(["'])) ((?>\\\\|\\\2|(?!\2).)*?) (\2) (?=\s*\.(?!\.))
1873+
captures:
1874+
1: punctuation.definition.constant.begin.elixir
1875+
3: constant.other.module.elixir
1876+
4: punctuation.definition.constant.end.elixir
1877+
push: module_member_pop
1878+
- match: (:)({{atom_symbol}})(?=\s*\.(?!\.))
1879+
captures:
1880+
1: punctuation.definition.constant.begin.elixir
1881+
2: constant.other.module.elixir
1882+
push: module_member_pop
1883+
1884+
modules_or_ids_or_calls:
1885+
- include: atom_module_name_call
18881886
- match: (?={{module_name}}|{{identifier}})
18891887
push:
18901888
- include: module_function_call_pop
@@ -1916,18 +1914,19 @@ contexts:
19161914
dot_accessor:
19171915
- match: \.(?!\.)
19181916
scope: punctuation.accessor.dot.elixir
1919-
push:
1920-
- include: atom_keyword
1921-
- include: module_function_call_pop
1922-
- include: unquote_call_pop
1923-
- include: id_or_operator_call_pop
1924-
- include: id_member_pop
1925-
- include: module_name_pop
1926-
- include: arguments_pop
1927-
- include: quoted_remote_call_pop
1928-
- include: quoted_member_pop
1929-
- include: tuple_call_pop
1930-
- include: if_non_space_or_eol_pop
1917+
push: member_or_call_pop
1918+
1919+
member_or_call_pop:
1920+
- include: module_function_call_pop
1921+
- include: unquote_call_pop
1922+
- include: id_or_operator_call_pop
1923+
- include: id_member_pop
1924+
- include: module_name_pop
1925+
- include: arguments_pop
1926+
- include: quoted_remote_call_pop
1927+
- include: quoted_member_pop
1928+
- include: tuple_call_pop
1929+
- include: if_non_space_or_eol_pop
19311930

19321931
## Module attributes
19331932

@@ -2339,16 +2338,11 @@ contexts:
23392338
- match: (?=\.(?!\.))
23402339
set:
23412340
- include: dot_operator
2342-
- include: arguments_pop
23432341
- include: capture_name_pop
2344-
- include: id_or_operator_call_pop
2345-
- include: quoted_remote_call_pop
2346-
- include: quoted_member_pop
23472342
- match: (?={{member}}{{no_id_key_suffix}})
23482343
push: id_member_pop
2349-
- include: tuple_call_pop
23502344
- include: if_closing_token_pop
2351-
- include: if_non_space_or_eol_pop
2345+
- include: member_or_call_pop
23522346
- include: capture_name_pop
23532347
- include: special_form
23542348
- match: (?={{identifier}}\s*\.(?!\.|\s*\())

tests/syntax_test_function_calls.ex

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,15 @@ raise"msg"
344344
# ^ punctuation.section.arguments.begin
345345
# ^^^ variable.function
346346

347+
:"Elixir.Kernel".in 1, [1, 2, 3]
348+
# ^^ variable.function
349+
# ^ punctuation.accessor.dot
350+
# ^^^^^^^^^^^^^ constant.other.module
351+
:"Elixir.Kernel"."@" expr
352+
# ^^^^^ meta.function-call.arguments
353+
# ^ variable.function
354+
# ^^^ meta.function-call
355+
347356
%{} |> Kernel.|> Map.put(:key, :value)
348357
# ^ punctuation.section.arguments.end
349358
# ^ punctuation.section.arguments.begin

0 commit comments

Comments
 (0)