@@ -2,7 +2,7 @@
Loading
2 2
using CSTParser
3 3
using CSTParser.Tokenize
4 4
import CSTParser.Tokenize.Tokens
5 -
using CSTParser: typof, kindof, EXPR
5 +
using CSTParser: headof, valof, EXPR
6 6
using FilePathsBase
7 7
8 8
const default_options = (4, true, true, true, true, true, true, true, true, false, true, "none")
@@ -158,8 +158,8 @@
Loading
158 158
159 159
function pass(x, state, f=(x, state) -> nothing)
160 160
    f(x, state)
161 -
    if x.args isa Vector{EXPR}
162 -
        for a in x.args
161 +
    if length(x) > 0
162 +
        for a in x
163 163
            pass(a, state, f)
164 164
        end
165 165
    else

@@ -1,36 +1,36 @@
Loading
1 1
function operator_pass(x, state)
2 -
    if typof(x) === CSTParser.BinaryOpCall
3 -
        if (CSTParser.precedence(x.args[2]) in (8, 13, 14, 16) && x.args[2].kind !== CSTParser.Tokens.ANON_FUNC) || x.args[2].fullspan == 0
4 -
            ensure_no_space_after(x.args[1], state, state.offset)
5 -
            ensure_no_space_after(x.args[2], state, state.offset + x.args[1].fullspan)
2 +
    if CSTParser.isbinarycall(x) || (CSTParser.isbinarysyntax(x) && headof(x).fullspan > 0)
3 +
        if (CSTParser.AllPrecs[valof(x[2])] in (CSTParser.ColonOp, CSTParser.PowerOp, CSTParser.DeclarationOp, CSTParser.DotOp) && valof(x[2]) != "->") || x[2].fullspan == 0
4 +
            ensure_no_space_after(x[1], state, state.offset)
5 +
            ensure_no_space_after(x[2], state, state.offset + x[1].fullspan)
6 6
        else
7 -
            ensure_single_space_after(x.args[1], state, state.offset)
8 -
            ensure_single_space_after(x.args[2], state, state.offset + x.args[1].fullspan)
7 +
            ensure_single_space_after(x[1], state, state.offset)
8 +
            ensure_single_space_after(x[2], state, state.offset + x[1].fullspan)
9 9
        end
10 -
    elseif typof(x) === CSTParser.WhereOpCall
11 -
        ensure_single_space_after(x.args[2], state, state.offset + x.args[1].fullspan)
12 -
        n = length(x.args)
13 -
        offset = state.offset + x.args[1].fullspan + x.args[2].fullspan
10 +
    elseif CSTParser.iswhere(x)
11 +
        ensure_single_space_after(x[2], state, state.offset + x[1].fullspan)
12 +
        n = length(x)
13 +
        offset = state.offset + x[1].fullspan + x[2].fullspan
14 14
        for i = 3:n
15 -
            a = x.args[i]
15 +
            a = x[i]
16 16
            if i != n
17 17
                ensure_no_space_after(a, state, offset)
18 18
            end
19 19
            offset += a.fullspan
20 20
        end
21 -
    elseif typof(x) === CSTParser.ColonOpCall
21 +
    elseif CSTParser.iscall(x) && CSTParser.isoperator(x[2]) && valof(x[2]) == ":"
22 22
        offset = state.offset
23 -
        n = length(x.args)
24 -
        for (i, a) in enumerate(x.args)
23 +
        n = length(x)
24 +
        for (i, a) in enumerate(x)
25 25
            if i != n
26 26
                ensure_no_space_after(a, state, offset)
27 27
            end
28 28
            offset += a.fullspan
29 29
        end
30 -
    elseif typof(x) === CSTParser.ChainOpCall || typof(x) == CSTParser.Comparison
30 +
    elseif (headof(x) === :call && valof(x.args[1]) in ("+", "*") && length(x) > 3) || headof(x) == :comparison
31 31
        offset = state.offset
32 -
        n = length(x.args)
33 -
        for (i, a) in enumerate(x.args)
32 +
        n = length(x)
33 +
        for (i, a) in enumerate(x)
34 34
            if i != n
35 35
                ensure_single_space_after(a, state, offset)
36 36
            end
@@ -40,14 +40,14 @@
Loading
40 40
end
41 41
42 42
function tuple_pass(x, state)
43 -
    if typof(x) === CSTParser.TupleH
43 +
    if headof(x) === :tuple
44 44
        offset = state.offset
45 45
        n = length(x)
46 46
        for (i, a) in enumerate(x)
47 47
            i == n && continue
48 -
            if typof(a) === CSTParser.PUNCTUATION && kindof(a) === Tokens.COMMA && !(typof(x.args[i + 1]) === CSTParser.PUNCTUATION)
48 +
            if headof(a) === :COMMA && !(CSTParser.ispunctuation(x[i + 1]))
49 49
                ensure_single_space_after(a, state, offset)
50 -
            elseif !(typof(x.args[i + 1]) === CSTParser.Parameters)
50 +
            elseif !(headof(x[i + 1]) === :parameters)
51 51
                ensure_no_space_after(a, state, offset)
52 52
            end
53 53
            offset += a.fullspan
@@ -56,7 +56,7 @@
Loading
56 56
end
57 57
58 58
function curly_pass(x, state)
59 -
    if typof(x) === CSTParser.Curly
59 +
    if headof(x) === :curly
60 60
        offset = state.offset
61 61
        n = length(x)
62 62
        for (i, a) in enumerate(x)
@@ -69,15 +69,16 @@
Loading
69 69
end
70 70
71 71
function call_pass(x, state)
72 -
    if typof(x) === CSTParser.Call
72 +
    if headof(x) === :call && !(CSTParser.isbinarycall(x) || CSTParser.ischainedcall(x) || (CSTParser.isoperator(x.args[1]) && valof(x.args[1]) == ":"))
73 +
        CSTParser.iscolon
73 74
        if issameline(state.offset, state.offset + x.span, state.lines)
74 -
            offset = state.offset + x.args[1].fullspan
75 +
            offset = state.offset + x[1].fullspan
75 76
            n = length(x)
76 77
            for (i, a) in enumerate(x)
77 78
                i == 1 && continue
78 -
                if typof(a) === CSTParser.PUNCTUATION && kindof(a) === Tokens.COMMA
79 +
                if headof(a) === :COMMA
79 80
                    ensure_single_space_after(a, state, offset)
80 -
                elseif i != n && !(typof(x.args[i + 1]) === CSTParser.Parameters)
81 +
                elseif i != n && !(headof(x[i + 1]) === :parameters)
81 82
                    ensure_no_space_after(a, state, offset)
82 83
                end
83 84
                offset += a.fullspan
@@ -85,27 +86,27 @@
Loading
85 86
        else
86 87
            # space holder for splitting calls across lines
87 88
        end
88 -
    elseif typof(x) === CSTParser.Kw
89 +
    elseif headof(x) === :kw
89 90
        if state.opts.kwarg === "none"
90 -
            ensure_no_space_after(x.args[1], state, state.offset)
91 -
            ensure_no_space_after(x.args[2], state, state.offset + x.args[1].fullspan)
91 +
            ensure_no_space_after(x[1], state, state.offset)
92 +
            ensure_no_space_after(x[2], state, state.offset + x[1].fullspan)
92 93
        elseif state.opts.kwarg === "single"
93 -
            ensure_exactly_single_space_after(x.args[1], state, state.offset)
94 -
            ensure_exactly_single_space_after(x.args[2], state, state.offset + x.args[1].fullspan)
94 +
            ensure_exactly_single_space_after(x[1], state, state.offset)
95 +
            ensure_exactly_single_space_after(x[2], state, state.offset + x[1].fullspan)
95 96
        end
96 97
    end
97 98
end
98 99
99 100
function forloop_pass(x, state)
100 -
    if typof(x) === CSTParser.For
101 -
        offset = state.offset + x.args[1].fullspan
102 -
        for a in x.args[2]
101 +
    if headof(x) === :for
102 +
        offset = state.offset + x[1].fullspan
103 +
        for a in x[2]
103 104
            # convert iter = I into iter in I
104 -
            if typof(a) === CSTParser.BinaryOpCall && CSTParser.is_eq(a.args[2])
105 -
                offset += a.args[1].fullspan
105 +
            if CSTParser.isassignment(a) && (a.trivia === nothing || isempty(a.trivia))
106 +
                offset += a[1].fullspan
106 107
                push!(state.edits, Edit(offset + 1:offset + 2, "in "))
107 -
                offset += a.args[2].fullspan
108 -
                offset += a.args[3].fullspan
108 +
                offset += a[2].fullspan
109 +
                offset += a[3].fullspan
109 110
            else
110 111
                offset += a.fullspan
111 112
            end
@@ -115,19 +116,19 @@
Loading
115 116
116 117
# TODO: move this to CSTParser?
117 118
function str_value(x)
118 -
    if typof(x) === CSTParser.PUNCTUATION
119 -
        kindof(x) == Tokens.LPAREN && return "("
120 -
        kindof(x) == Tokens.LBRACE && return "{"
121 -
        kindof(x) == Tokens.LSQUARE && return "["
122 -
        kindof(x) == Tokens.RPAREN && return ")"
123 -
        kindof(x) == Tokens.RBRACE && return "}"
124 -
        kindof(x) == Tokens.RSQUARE && return "]"
125 -
        kindof(x) == Tokens.COMMA && return ","
126 -
        kindof(x) == Tokens.SEMICOLON && return ";"
127 -
        kindof(x) == Tokens.AT_SIGN && return "@"
128 -
        kindof(x) == Tokens.DOT && return "."
119 +
    if CSTParser.ispunctuation(x)
120 +
        headof(x) === :LPAREN && return "("
121 +
        headof(x) === :LBRACE && return "{"
122 +
        headof(x) === :LSQUARE && return "["
123 +
        headof(x) === :RPAREN && return ")"
124 +
        headof(x) === :RBRACE && return "}"
125 +
        headof(x) === :RSQUARE && return "]"
126 +
        headof(x) === :COMMA && return ","
127 +
        headof(x) === :SEMICOLON && return ";"
128 +
        headof(x) === :AT_SIGN && return "@"
129 +
        headof(x) === :DOT && return "."
129 130
        return ""
130 -
    elseif typof(x) === CSTParser.IDENTIFIER || typof(x) === CSTParser.LITERAL || typof(x) === CSTParser.OPERATOR || typof(x) === CSTParser.KEYWORD
131 +
    elseif headof(x) === :IDENTIFIER || CSTParser.isliteral(x) || CSTParser.isoperator(x) || CSTParser.iskeyword(x)
131 132
        return CSTParser.str_value(x)
132 133
    else
133 134
        s = ""
@@ -141,7 +142,7 @@
Loading
141 142
142 143
function doc_pass(x, state)
143 144
    return
144 -
    if typof(x) === CSTParser.MacroCall && typof(x.args[1]) === CSTParser.GlobalRefDoc
145 +
    if headof(x) === :macrocall && headof(x[1]) === :globalrefdoc
145 146
        # Align global docstring to:
146 147
        #
147 148
        # """
@@ -149,8 +150,8 @@
Loading
149 150
        # """
150 151
        #
151 152
        # If the doc is single quoted i.e. "doc", they will be replaced with triple quotes.
152 -
        offset = state.offset + x.args[1].fullspan
153 -
        doc = x.args[2]
153 +
        offset = state.offset + x[1].fullspan
154 +
        doc = x[2]
154 155
155 156
        val = str_value(doc)
156 157
@@ -169,28 +170,28 @@
Loading
169 170
end
170 171
171 172
function kw_pass(x, state)
172 -
    if typof(x) === CSTParser.KEYWORD &&
173 -
        kindof(x) in (CSTParser.Tokens.ABSTRACT,
174 -
                      CSTParser.Tokens.BAREMODULE,
175 -
                      CSTParser.Tokens.CONST,
176 -
                      CSTParser.Tokens.DO,
177 -
                      CSTParser.Tokens.ELSEIF,
178 -
                      CSTParser.Tokens.EXPORT,
179 -
                      CSTParser.Tokens.FOR,
180 -
                      CSTParser.Tokens.FUNCTION,
181 -
                      CSTParser.Tokens.GLOBAL,
182 -
                      CSTParser.Tokens.IF,
183 -
                      CSTParser.Tokens.IMPORT,
184 -
                      CSTParser.Tokens.LOCAL,
185 -
                      CSTParser.Tokens.MACRO,
186 -
                      CSTParser.Tokens.MODULE,
187 -
                      CSTParser.Tokens.MUTABLE,
188 -
                      CSTParser.Tokens.OUTER,
189 -
                      CSTParser.Tokens.PRIMITIVE,
190 -
                      CSTParser.Tokens.STRUCT,
191 -
                      CSTParser.Tokens.TYPE,
192 -
                      CSTParser.Tokens.USING,
193 -
                      CSTParser.Tokens.WHILE)
173 +
    if CSTParser.iskeyword(x) &&
174 +
        headof(x) in (:ABSTRACT,
175 +
                      :BAREMODULE,
176 +
                      :CONST,
177 +
                      :DO,
178 +
                      :ELSEIF,
179 +
                      :EXPORT,
180 +
                      :FOR,
181 +
                      :FUNCTION,
182 +
                      :GLOBAL,
183 +
                      :IF,
184 +
                      :IMPORT,
185 +
                      :LOCAL,
186 +
                      :MACRO,
187 +
                      :MODULE,
188 +
                      :MUTABLE,
189 +
                      :OUTER,
190 +
                      :PRIMITIVE,
191 +
                      :STRUCT,
192 +
                      :TYPE,
193 +
                      :USING,
194 +
                      :WHILE)
194 195
        ensure_exactly_single_space_after(x, state, state.offset)
195 196
    end
196 197
end
@@ -244,7 +245,7 @@
Loading
244 245
                pc = read(io, UInt8)
245 246
            end
246 247
            if i1 != i2 && (y = get_expr(x, n - i1); y isa CSTParser.EXPR ?
247 -
                !(y.typ == CSTParser.LITERAL && y.kind in (CSTParser.Tokens.STRING, CSTParser.Tokens.TRIPLE_STRING, CSTParser.Tokens.CMD, CSTParser.Tokens.TRIPLE_CMD)) : true)
248 +
                !(headof(y) in (:STRING, :TRIPLE_STRING, :CMD, :TRIPLE_CMD)) : true)
248 249
                push!(state.edits, Edit((n - i2) + 1:(n - i1), ""))
249 250
            end
250 251
        end

@@ -6,66 +6,80 @@
Loading
6 6
end
7 7
8 8
function indent_pass(x, state)
9 -
    if typof(x) === CSTParser.FileH
10 -
        if x.args isa Vector{EXPR}
11 -
            for a in x.args
9 +
    if headof(x) === :file
10 +
        if length(x) > 0
11 +
            for a in x
12 12
                check_indent(a, state)
13 13
                indent_pass(a, state)
14 14
            end
15 15
        end
16 -
    elseif typof(x) === CSTParser.Begin || (typof(x) === CSTParser.Quote && typof(x.args[1]) === CSTParser.KEYWORD && kindof(x.args[1]) == Tokens.QUOTE)
17 -
        state.offset += x.args[1].fullspan
16 +
    elseif length(x) == 3 && (headof(x) === :block && headof(x[1]) == :BEGIN) || (headof(x) === :quote && headof(x[1]) === :QUOTE)
17 +
        state.offset += x[1].fullspan
18 18
        state.edits.indent += 1
19 -
        if x.args isa Vector{EXPR} && length(x.args) > 1 && x.args[2].args isa Vector{EXPR}
20 -
            for a in x.args[2].args
19 +
        if length(x) > 2
20 +
            for i = 2:length(x) - 1
21 +
                a = x[i]
21 22
                check_indent(a, state)
22 23
                indent_pass(a, state)
23 24
            end
24 25
        end
25 26
        state.edits.indent -= 1
26 -
        check_indent(x.args[3], state)
27 -
        state.offset += x.args[3].fullspan
28 -
    elseif typof(x) in (CSTParser.FunctionDef, CSTParser.Macro, CSTParser.For, CSTParser.While, CSTParser.Struct)
29 -
        state.offset += x.args[1].fullspan + x.args[2].fullspan
30 -
        if typof(x.args[3]) === CSTParser.Block
27 +
        check_indent(x[3], state)
28 +
        state.offset += x[3].fullspan
29 +
    elseif headof(x) == :struct
30 +
        state.offset += x[1].fullspan + x.args[2].fullspan
31 +
        if length(x.trivia) > 2 #mutable
32 +
            state.offset += x.trivia[2].fullspan
33 +
        end
34 +
        if headof(x.args[3]) === :block && length(x.args[3]) > 0
35 +
            state.edits.indent += 1
36 +
            for a in x.args[3]
37 +
                check_indent(a, state)
38 +
                indent_pass(a, state)
39 +
            end
40 +
            state.edits.indent -= 1
41 +
            check_indent(last(x.trivia), state)
42 +
            state.offset += last(x.trivia).fullspan
43 +
        end
44 +
    elseif headof(x) in (:function, :macro, :for, :while)
45 +
        state.offset += x[1].fullspan + x[2].fullspan
46 +
        if headof(x[3]) === :block
31 47
            state.edits.indent += 1
32 -
            if x.args[3].args isa Vector{EXPR}
33 -
                for a in x.args[3].args
48 +
            if length(x[3]) > 0
49 +
                for a in x[3]
34 50
                    check_indent(a, state)
35 51
                    indent_pass(a, state)
36 52
                end
37 53
            end
38 54
            state.edits.indent -= 1
39 -
            check_indent(x.args[4], state)
40 -
            state.offset += x.args[4].fullspan
55 +
            check_indent(x[4], state)
56 +
            state.offset += x[4].fullspan
41 57
        else
42 -
            check_indent(x.args[3], state)
43 -
            state.offset += x.args[3].fullspan
58 +
            check_indent(x[3], state)
59 +
            state.offset += x[3].fullspan
44 60
        end
45 -
    elseif typof(x) === CSTParser.Do
46 -
        state.offset += x.args[1].fullspan + x.args[2].fullspan + x.args[3].fullspan
47 -
        if typof(x.args[4]) === CSTParser.Block
61 +
    elseif headof(x) === :do
62 +
        state.offset += x[1].fullspan + x[2].fullspan + x[3][1].fullspan
63 +
        if headof(x[3][3]) === :block
48 64
            state.edits.indent += 1
49 -
            if x.args[4].args isa Vector{EXPR}
50 -
                for a in x.args[4].args
65 +
            if length(x[3][3]) > 0
66 +
                for a in x[3][3]
51 67
                    check_indent(a, state)
52 68
                    indent_pass(a, state)
53 69
                end
54 70
            end
55 71
            state.edits.indent -= 1
56 -
            check_indent(x.args[5], state)
57 -
            state.offset += x.args[5].fullspan
72 +
            check_indent(x[4], state)
73 +
            state.offset += x[4].fullspan
58 74
        else
59 -
            check_indent(x.args[4], state)
60 -
            state.offset += x.args[4].fullspan
75 +
            check_indent(x[4], state)
76 +
            state.offset += x[4].fullspan
61 77
        end
62 -
    elseif typof(x) === CSTParser.MacroCall
63 -
        if typof(x.args[1]) === CSTParser.GlobalRefDoc
64 -
            state.offset += x.args[1].fullspan
65 -
66 -
            doc = x.args[2]
78 +
    elseif headof(x) === :macrocall
79 +
        if headof(x[1]) === :globalrefdoc
80 +
            state.offset += x[1].fullspan
81 +
            doc = x[2]
67 82
            doc_strs = split(str_value(doc), "\n")
68 -
69 83
            state.offset += 4
70 84
            for (i, s) in enumerate(doc_strs)
71 85
                # Skip indenting lines of "".
@@ -74,153 +88,151 @@
Loading
74 88
                if s == "" && i != length(doc_strs)
75 89
                    state.offset += 1
76 90
                else
77 -
                    a = CSTParser.mLITERAL(length(s) + 1, length(s), String(s), Tokens.STRING)
91 +
                    a = EXPR(:STRING, length(s) + 1, length(s), String(s))
78 92
                    check_indent(a, state)
79 93
                    indent_pass(a, state)
80 94
                end
81 95
            end
82 96
            state.offset += 3
83 97
84 -
            check_indent(x.args[3], state)
85 -
            indent_pass(x.args[3], state)
86 -
        else
87 -
            for a in x.args
98 +
            check_indent(x[3], state)
99 +
            indent_pass(x[3], state)
100 +
        elseif length(x) > 0
101 +
            for a in x
88 102
                indent_pass(a, state)
89 103
            end
90 104
        end
91 -
    elseif typof(x) === CSTParser.Mutable
92 -
        state.offset += x.args[1].fullspan + x.args[2].fullspan + x.args[3].fullspan
93 -
        if typof(x.args[4]) === CSTParser.Block
105 +
    elseif headof(x) === :mutable
106 +
        state.offset += x[1].fullspan + x[2].fullspan + x[3].fullspan
107 +
        if headof(x[4]) === :block
94 108
            state.edits.indent += 1
95 -
            if x.args[4].args isa Vector{EXPR}
96 -
                for a in x.args[4].args
109 +
            if length(x[4]) > 0
110 +
                for a in x[4]
97 111
                    check_indent(a, state)
98 112
                    indent_pass(a, state)
99 113
                end
100 114
            end
101 115
            state.edits.indent -= 1
102 -
            check_indent(x.args[5], state)
103 -
            state.offset += x.args[5].fullspan
116 +
            check_indent(x[5], state)
117 +
            state.offset += x[5].fullspan
104 118
        else
105 -
            check_indent(x.args[3], state)
106 -
            state.offset += x.args[4].fullspan
119 +
            check_indent(x[3], state)
120 +
            state.offset += x[4].fullspan
107 121
        end
108 -
    elseif typof(x) === CSTParser.Try
109 -
        state.offset += x.args[1].fullspan
110 -
122 +
    elseif headof(x) === :try && length(x) > 5
123 +
        state.offset += x[1].fullspan
111 124
        state.edits.indent += 1
112 -
        if x.args[2].args isa Vector{EXPR}
113 -
            for a in x.args[2].args
125 +
        if length(x[2]) > 0
126 +
            for a in x[2]
114 127
                check_indent(a, state)
115 128
                indent_pass(a, state)
116 129
            end
117 130
        end
118 131
        state.edits.indent -= 1
119 -
        check_indent(x.args[3], state)
120 -
        state.offset += x.args[3].fullspan + x.args[4].fullspan
132 +
        check_indent(x[3], state)
133 +
        state.offset += x[3].fullspan + x[4].fullspan
121 134
122 135
        state.edits.indent += 1
123 -
        if x.args isa Vector{EXPR} && length(x.args) >= 5 && x.args[5].args isa Vector{EXPR}
124 -
            for a in x.args[5].args
136 +
        if length(x[5]) > 0
137 +
            for a in x[5]
125 138
                check_indent(a, state)
126 139
                indent_pass(a, state)
127 140
            end
128 141
        end
129 142
        state.edits.indent -= 1
130 -
        check_indent(x.args[6], state)
131 -
        state.offset += x.args[6].fullspan
143 +
        check_indent(x[6], state)
144 +
        state.offset += x[6].fullspan
132 145
133 146
        if length(x) == 8
134 147
            state.edits.indent += 1
135 -
            if x.args[7].args isa Vector{EXPR}
136 -
                for a in x.args[7].args
148 +
            if length(x[7]) > 0
149 +
                for a in x[7]
137 150
                    check_indent(a, state)
138 151
                    indent_pass(a, state)
139 152
                end
140 153
            end
141 154
            state.edits.indent -= 1
142 -
            check_indent(x.args[8], state)
143 -
            state.offset += x.args[8].fullspan
155 +
            check_indent(x[8], state)
156 +
            state.offset += x[8].fullspan
144 157
        end
145 -
146 -
    elseif typof(x) === CSTParser.If
147 -
        if typof(first(x.args)) === CSTParser.KEYWORD && kindof(first(x.args)) == Tokens.IF
148 -
            state.offset += x.args[1].fullspan + x.args[2].fullspan
158 +
    elseif headof(x) === :if
159 +
        if headof(first(x)) == :IF
160 +
            state.offset += x[1].fullspan + x[2].fullspan
149 161
            state.edits.indent += 1
150 -
            if x.args[3].args isa Vector{EXPR}
151 -
                for a in x.args[3].args
162 +
            if length(x[3]) > 0
163 +
                for a in x[3]
152 164
                    check_indent(a, state)
153 165
                    indent_pass(a, state)
154 166
                end
155 167
            end
156 168
            state.edits.indent -= 1
157 -
            check_indent(x.args[4], state)
158 -
            state.offset += x.args[4].fullspan
159 -
            if length(x.args) > 4
169 +
            check_indent(x[4], state)
170 +
            state.offset += x[4].fullspan
171 +
            if length(x) > 4
160 172
                state.edits.indent += 1
161 -
                if x.args[5].args isa Vector{EXPR}
162 -
                    for a in x.args[5].args
173 +
                if length(x[5]) > 0
174 +
                    for a in x[5]
163 175
                        check_indent(a, state)
164 176
                        indent_pass(a, state)
165 177
                    end
166 178
                end
167 179
                state.edits.indent -= 1
168 -
                check_indent(x.args[6], state)
169 -
                state.offset += x.args[6].fullspan
180 +
                check_indent(x[6], state)
181 +
                state.offset += x[6].fullspan
170 182
            end
171 183
        else
172 -
            state.offset += x.args[1].fullspan
173 -
            if x.args[2].args isa Vector{EXPR}
174 -
                for a in x.args[2].args
184 +
            state.offset += x[1].fullspan
185 +
            if length(x[2]) > 0
186 +
                for a in x[2]
175 187
                    check_indent(a, state)
176 188
                    indent_pass(a, state)
177 189
                end
178 190
            end
179 -
            if length(x.args) > 2
191 +
            if length(x) > 2
180 192
                state.edits.indent -= 1
181 -
                check_indent(x.args[3], state)
182 -
                state.offset += x.args[3].fullspan
193 +
                check_indent(x[3], state)
194 +
                state.offset += x[3].fullspan
183 195
                state.edits.indent += 1
184 -
                if x.args[4].args isa Vector{EXPR}
185 -
                    for a in x.args[4].args
196 +
                if length(x[4]) > 0
197 +
                    for a in x[4]
186 198
                        check_indent(a, state)
187 199
                        indent_pass(a, state)
188 200
                    end
189 201
                end
190 202
            end
191 203
        end
192 -
    elseif typof(x) === CSTParser.Let
193 -
        if length(x.args) > 3
194 -
            state.offset += x.args[1].fullspan + x.args[2].fullspan
204 +
    elseif headof(x) === :let
205 +
        if length(x) > 3
206 +
            state.offset += x[1].fullspan + x[2].fullspan
195 207
            state.edits.indent += 1
196 -
            if x.args[3].args isa Vector{EXPR}
197 -
                for a in x.args[3].args
208 +
            if length(x[3]) > 0
209 +
                for a in x[3]
198 210
                    check_indent(a, state)
199 211
                    indent_pass(a, state)
200 212
                end
201 213
            end
202 214
            state.edits.indent -= 1
203 -
            check_indent(x.args[4], state)
204 -
            state.offset += x.args[4].fullspan
215 +
            check_indent(x[4], state)
216 +
            state.offset += x[4].fullspan
205 217
        else
206 -
            state.offset += x.args[1].fullspan
218 +
            state.offset += x[1].fullspan
207 219
            state.edits.indent += 1
208 -
            if x.args[2].args isa Vector{EXPR}
209 -
                for a in x.args[2].args
220 +
            if length(x[2]) > 0
221 +
                for a in x[2]
210 222
                    check_indent(a, state)
211 223
                    indent_pass(a, state)
212 224
                end
213 225
            end
214 226
            state.edits.indent -= 1
215 -
            check_indent(x.args[3], state)
216 -
            state.offset += x.args[3].fullspan
227 +
            check_indent(x[3], state)
228 +
            state.offset += x[3].fullspan
217 229
        end
218 230
219 -
    elseif typof(x) in (CSTParser.IDENTIFIER, CSTParser.OPERATOR, CSTParser.KEYWORD, CSTParser.PUNCTUATION, CSTParser.LITERAL)
231 +
    elseif x.args === nothing
220 232
        state.offset += x.fullspan
221 233
    else
222 -
        if x.args isa Vector{EXPR}
223 -
            for a in x.args
234 +
        if length(x) > 0
235 +
            for a in x
224 236
                indent_pass(a, state)
225 237
            end
226 238
        end

@@ -44,8 +44,8 @@
Loading
44 44
    if pos > offset
45 45
        return nothing
46 46
    end
47 -
    if x.args isa Vector{EXPR}
48 -
        for a in x.args
47 +
    if length(x) > 0
48 +
        for a in x
49 49
            if pos < offset <= (pos + a.fullspan)
50 50
                return get_expr(a, offset, pos)
51 51
            end
Files Coverage
src 64.59%
Project Totals (4 files) 64.59%
codecov-umbrella
Build #480851194 -
unittests
codecov-umbrella
Build #480851194 -
unittests
codecov-umbrella
Build #480851194 -
unittests
codecov-umbrella
Build #480851194 -
unittests
codecov-umbrella
Build #480851194 -
unittests
codecov-umbrella
Build #480851194 -
unittests
codecov-umbrella
Build #480851194 -
unittests
codecov-umbrella
Build #480851194 -
unittests
codecov-umbrella
Build #480851194 -
unittests
codecov-umbrella
Build #480851194 -
unittests
codecov-umbrella
Build #480851194 -
unittests
codecov-umbrella
Build #480851194 -
unittests
codecov-umbrella
Build #480851194 -
unittests
codecov-umbrella
Build #480851194 -
unittests
codecov-umbrella
Build #480851194 -
unittests
codecov-umbrella
Build #480851194 -
unittests
codecov-umbrella
Build #480851194 -
unittests
codecov-umbrella
Build #480851194 -
unittests
codecov-umbrella
Build #480851194 -
unittests
codecov-umbrella
Build #480851194 -
unittests
codecov-umbrella
Build #480851194 -
unittests
codecov-umbrella
Build #480851194 -
unittests
codecov-umbrella
Build #480851194 -
unittests
codecov-umbrella
Build #480851194 -
unittests
codecov-umbrella
Build #480851194 -
unittests
codecov-umbrella
Build #480851194 -
unittests
codecov-umbrella
Build #480851194 -
unittests
codecov-umbrella
Build #480851194 -
unittests
codecov-umbrella
Build #480851194 -
unittests
codecov-umbrella
Build #480851194 -
unittests

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading