summaryrefslogtreecommitdiff
path: root/runtime/queries/dart/indents.scm
blob: cdb96ae8e1320473abf5cf9c9957f42d43d08fce (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
; things surrounded by ({[]})
[
  (template_substitution)
  (list_literal)
  (set_or_map_literal)
  (parenthesized_expression)
  (arguments)
  (index_selector)
  (block)
  (assertion_arguments)
  (switch_block)
  (catch_parameters)
  (for_loop_parts)
  (configuration_uri_condition)
  (enum_body)
  (class_body)
  (extension_body)
  (parameter_type_list)
  (optional_positional_parameter_types)
  (named_parameter_types)
  (formal_parameter_list)
  (optional_formal_parameters)
] @indent

; control flow statement which accept one line as body

(for_statement
  body: _ @indent
  (#not-kind-eq? @indent block)
  (#set! "scope" "all")
)

(while_statement
  body: _ @indent
  (#not-kind-eq? @indent block)
  (#set! "scope" "all")
)

(do_statement
  body: _ @indent
  (#not-kind-eq? @indent block)
  (#set! "scope" "all")
)

(if_statement
  consequence: _ @indent
  (#not-kind-eq? @indent block)
  (#set! "scope" "all")
)
(if_statement
  alternative: _ @indent
  (#not-kind-eq? @indent if_statement)
  (#not-kind-eq? @indent block)
  (#set! "scope" "all")
)
(if_statement
  "else" @else
  alternative: (if_statement) @indent
  (#not-same-line? @indent @else)
  (#set! "scope" "all")
)

(if_element
  consequence: _ @indent
  (#set! "scope" "all")
)
(if_element
  alternative: _ @indent
  (#not-kind-eq? @indent if_element)
  (#set! "scope" "all")
)
(if_element
  "else" @else
  alternative: (if_element) @indent
  (#not-same-line? @indent @else)
  (#set! "scope" "all")
)

(for_element
  body: _ @indent
  (#set! "scope" "all")
)

; simple statements
[
  (local_variable_declaration)
  (break_statement)
  (continue_statement)
  (return_statement)
  (yield_statement)
  (yield_each_statement)
  (expression_statement)
] @indent

[
  "}"
  "]"
  ")"
] @outdent