@@ -133,6 +133,60 @@ register 'xpcall' {
133
133
end
134
134
}
135
135
136
+ register ' local' {
137
+ function (state , source , callback )
138
+ if source .type ~= ' getglobal'
139
+ and source .type ~= ' getfield'
140
+ and source .type ~= ' getmethod'
141
+ and source .type ~= ' getindex'
142
+ and source .type ~= ' getlocal'
143
+ and source .type ~= ' call'
144
+ and source .type ~= ' table' then
145
+ return
146
+ end
147
+ local subber = subString (state )
148
+ callback (string.format (' local $1 = %s$0'
149
+ , subber (source .start + 1 , source .finish )
150
+ ))
151
+ end
152
+ }
153
+
154
+ register ' ipairs' {
155
+ function (state , source , callback )
156
+ if source .type ~= ' getglobal'
157
+ and source .type ~= ' getfield'
158
+ and source .type ~= ' getmethod'
159
+ and source .type ~= ' getindex'
160
+ and source .type ~= ' getlocal'
161
+ and source .type ~= ' call'
162
+ and source .type ~= ' table' then
163
+ return
164
+ end
165
+ local subber = subString (state )
166
+ callback (string.format (' for ${1:i}, ${2:v} in ipairs(%s) do\n\t $0\n end'
167
+ , subber (source .start + 1 , source .finish )
168
+ ))
169
+ end
170
+ }
171
+
172
+ register ' pairs' {
173
+ function (state , source , callback )
174
+ if source .type ~= ' getglobal'
175
+ and source .type ~= ' getfield'
176
+ and source .type ~= ' getmethod'
177
+ and source .type ~= ' getindex'
178
+ and source .type ~= ' getlocal'
179
+ and source .type ~= ' call'
180
+ and source .type ~= ' table' then
181
+ return
182
+ end
183
+ local subber = subString (state )
184
+ callback (string.format (' for ${1:k}, ${2:v} in pairs(%s) do\n\t $0\n end'
185
+ , subber (source .start + 1 , source .finish )
186
+ ))
187
+ end
188
+ }
189
+
136
190
register ' insert' {
137
191
function (state , source , callback )
138
192
if source .type ~= ' getglobal'
0 commit comments