]> git.wincent.com - docvim.git/blob - tests/fixtures/parser/integration-ferret-private.golden
Add parser tests to integration tests
[docvim.git] / tests / fixtures / parser / integration-ferret-private.golden
1 Project
2   [ Project
3       [ Unit
4           [ FunctionDeclaration
5               { functionBang = True
6               , functionName = "s:delete"
7               , functionArguments =
8                   ArgumentList [ Argument "first" , Argument "last" ]
9               , functionAttributes = []
10               , functionBody =
11                   [ LetStatement { letLexpr = "l:list" , letValue = "getqflist()" }
12                   , LetStatement { letLexpr = "l:line" , letValue = "a:first" }
13                   , GenericStatement "while l:line >= a:first && l:line <= a:last"
14                   , LetStatement { letLexpr = "l:list[l:line - 1]" , letValue = "0" }
15                   , LetStatement { letLexpr = "l:line" , letValue = "l:line + 1" }
16                   , GenericStatement "endwhile"
17                   , GenericStatement "call setqflist(l:list, 'r')"
18                   , GenericStatement "execute 'cc ' . a:first"
19                   , GenericStatement "execute \"normal \\<C-W>\\<C-P>\""
20                   ]
21               }
22           , FunctionDeclaration
23               { functionBang = True
24               , functionName = "s:dispatch"
25               , functionArguments = ArgumentList []
26               , functionAttributes = []
27               , functionBody =
28                   [ Empty
29                   , LetStatement
30                       { letLexpr = "l:dispatch"
31                       , letValue = "get(g:, 'FerretDispatch', 1)"
32                       }
33                   , GenericStatement "return l:dispatch && exists(':Make') == 2"
34                   ]
35               }
36           , FunctionDeclaration
37               { functionBang = True
38               , functionName = "s:error"
39               , functionArguments = ArgumentList [ Argument "message" ]
40               , functionAttributes = [ "abort" ]
41               , functionBody =
42                   [ GenericStatement "call inputsave()"
43                   , GenericStatement "echohl ErrorMsg"
44                   , GenericStatement
45                       "call input(a:message . ': press ENTER to continue')"
46                   , GenericStatement "echohl NONE"
47                   , GenericStatement "call inputrestore()"
48                   , GenericStatement "echo"
49                   ]
50               }
51           , FunctionDeclaration
52               { functionBang = True
53               , functionName = "s:parse"
54               , functionArguments = ArgumentList [ Argument "arg" ]
55               , functionAttributes = [ "abort" ]
56               , functionBody =
57                   [ GenericStatement "if exists('g:ferret_lastsearch')"
58                   , UnletStatement
59                       { unletBang = False , unletBody = "g:ferret_lastsearch" }
60                   , GenericStatement "endif"
61                   , LetStatement
62                       { letLexpr = "l:escaped_spaces_replaced_with_markers"
63                       , letValue = "substitute(a:arg, '\\\\ ', '<!!S!!>', 'g')"
64                       }
65                   , LetStatement
66                       { letLexpr = "l:split_on_spaces"
67                       , letValue = "split(l:escaped_spaces_replaced_with_markers)"
68                       }
69                   , LetStatement { letLexpr = "l:expanded_args" , letValue = "[]" }
70                   , GenericStatement "for l:arg in l:split_on_spaces"
71                   , GenericStatement "if l:arg =~# '^-'"
72                   , GenericStatement "call add(l:expanded_args, l:arg)"
73                   , GenericStatement "elseif exists('g:ferret_lastsearch')"
74                   , LetStatement
75                       { letLexpr = "l:file_args"
76                       , letValue =
77                           "glob(l:arg, 1, 1) \" Ignore 'wildignore', return a list."
78                       }
79                   , GenericStatement "if len(l:file_args)"
80                   , GenericStatement "call extend(l:expanded_args, l:file_args)"
81                   , GenericStatement "else"
82                   , GenericStatement "call add(l:expanded_args, l:arg)"
83                   , GenericStatement "endif"
84                   , GenericStatement "else"
85                   , LetStatement
86                       { letLexpr = "g:ferret_lastsearch"
87                       , letValue = "substitute(l:arg, '<!!S!!>', ' ', 'g')"
88                       }
89                   , GenericStatement "call add(l:expanded_args, l:arg)"
90                   , GenericStatement "endif"
91                   , GenericStatement "endfor"
92                   , LetStatement
93                       { letLexpr = "l:each_word_shell_escaped"
94                       , letValue = "map(l:expanded_args, 'shellescape(v:val)')"
95                       }
96                   , LetStatement
97                       { letLexpr = "l:joined"
98                       , letValue = "join(l:each_word_shell_escaped)"
99                       }
100                   , GenericStatement
101                       "return substitute(l:joined, '<!!S!!>', ' ', 'g')"
102                   ]
103               }
104           , FunctionDeclaration
105               { functionBang = True
106               , functionName = "ferret#private#post"
107               , functionArguments = ArgumentList [ Argument "type" ]
108               , functionAttributes = [ "abort" ]
109               , functionBody =
110                   [ GenericStatement "if has('autocmd')"
111                   , GenericStatement "augroup FerretPostQF"
112                   , GenericStatement "autocmd!"
113                   , GenericStatement "augroup END"
114                   , GenericStatement "endif"
115                   , LetStatement
116                       { letLexpr = "l:lastsearch "
117                       , letValue = "get(g:, 'ferret_lastsearch', '')"
118                       }
119                   , LetStatement
120                       { letLexpr = "l:qflist "
121                       , letValue = "a:type == 'qf' ? getqflist() : getloclist(0)"
122                       }
123                   , LetStatement
124                       { letLexpr = "l:tip "
125                       , letValue = "' [see `:help ferret-quotes`]'"
126                       }
127                   , GenericStatement "if len(l:qflist) == 0"
128                   , LetStatement
129                       { letLexpr = "l:base "
130                       , letValue =
131                           "'No results for search pattern `' . l:lastsearch . '`'"
132                       }
133                   , GenericStatement
134                       "if l:lastsearch =~ '\\v^([' . \"'\" . '\"])[^ \\1]+\\1$'"
135                   , GenericStatement "call s:error(l:base . l:tip)"
136                   , GenericStatement "else"
137                   , GenericStatement "call s:error(l:base)"
138                   , GenericStatement "endif"
139                   , GenericStatement "else"
140                   , LetStatement
141                       { letLexpr = "l:invalid "
142                       , letValue = "filter(copy(l:qflist), 'v:val.valid == 0')"
143                       }
144                   , GenericStatement "if len(l:invalid) == len(l:qflist)"
145                   , GenericStatement "redraw!"
146                   , GenericStatement "echohl ErrorMsg"
147                   , GenericStatement "for l:item in l:invalid"
148                   , GenericStatement "echomsg l:item.text"
149                   , GenericStatement "endfor"
150                   , GenericStatement "echohl NONE"
151                   , LetStatement
152                       { letLexpr = "l:base "
153                       , letValue = "'Search for `' . l:lastsearch . '` failed'"
154                       }
155                   , LetStatement
156                       { letLexpr = "l:suffix "
157                       , letValue = "a:type == 'qf' && s:dispatch() ?"
158                       }
159                   , GenericStatement "\\ ' (run `:messages` to see details)' : ''"
160                   , GenericStatement
161                       "if l:lastsearch =~ '\\v^[' . \"'\" . '\"].+[^' . \"'\" . '\"]$'"
162                   , GenericStatement "call s:error(l:base . l:tip . l:suffix)"
163                   , GenericStatement "else"
164                   , GenericStatement "call s:error(l:base . l:suffix)"
165                   , GenericStatement "endif"
166                   , GenericStatement "endif"
167                   , GenericStatement "endif"
168                   ]
169               }
170           , FunctionDeclaration
171               { functionBang = True
172               , functionName = "ferret#private#ack"
173               , functionArguments = ArgumentList [ Argument "command" ]
174               , functionAttributes = [ "abort" ]
175               , functionBody =
176                   [ LetStatement
177                       { letLexpr = "l:command" , letValue = "s:parse(a:command)" }
178                   , GenericStatement "call ferret#private#hlsearch()"
179                   , GenericStatement "if empty(&grepprg)"
180                   , GenericStatement "return"
181                   , GenericStatement "endif"
182                   , GenericStatement "if s:dispatch()"
183                   , GenericStatement "if has('autocmd')"
184                   , GenericStatement "augroup FerretPostQF"
185                   , GenericStatement "autocmd!"
186                   , GenericStatement
187                       "autocmd QuickfixCmdPost cgetfile call ferret#private#post('qf')"
188                   , GenericStatement "augroup END"
189                   , GenericStatement "endif"
190                   , LetStatement
191                       { letLexpr = "l:original_makeprg" , letValue = "&l:makeprg" }
192                   , LetStatement
193                       { letLexpr = "l:original_errorformat"
194                       , letValue = "&l:errorformat"
195                       }
196                   , GenericStatement "try"
197                   , LetStatement
198                       { letLexpr = "&l:makeprg"
199                       , letValue = "&grepprg . ' ' . l:command"
200                       }
201                   , LetStatement
202                       { letLexpr = "&l:errorformat" , letValue = "&grepformat" }
203                   , GenericStatement "Make"
204                   , GenericStatement "catch"
205                   , GenericStatement "if has('autocmd')"
206                   , GenericStatement "augroup! FerretPostQF"
207                   , GenericStatement "endif"
208                   , GenericStatement "finally"
209                   , LetStatement
210                       { letLexpr = "&l:makeprg" , letValue = "l:original_makeprg" }
211                   , LetStatement
212                       { letLexpr = "&l:errorformat"
213                       , letValue = "l:original_errorformat"
214                       }
215                   , GenericStatement "endtry"
216                   , GenericStatement "else"
217                   , GenericStatement "cexpr system(&grepprg . ' ' . l:command)"
218                   , GenericStatement "cwindow"
219                   , GenericStatement "call ferret#private#post('qf')"
220                   , GenericStatement "endif"
221                   ]
222               }
223           , FunctionDeclaration
224               { functionBang = True
225               , functionName = "ferret#private#lack"
226               , functionArguments = ArgumentList [ Argument "command" ]
227               , functionAttributes = [ "abort" ]
228               , functionBody =
229                   [ LetStatement
230                       { letLexpr = "l:command" , letValue = "s:parse(a:command)" }
231                   , GenericStatement "call ferret#private#hlsearch()"
232                   , GenericStatement "if empty(&grepprg)"
233                   , GenericStatement "return"
234                   , GenericStatement "endif"
235                   , LexprStatement
236                       { lexprBang = False
237                       , lexprExpr = "system(&grepprg . ' ' . l:command)"
238                       }
239                   , LwindowStatement { lwindowHeight = Nothing }
240                   , GenericStatement "call ferret#private#post('location')"
241                   ]
242               }
243           , FunctionDeclaration
244               { functionBang = True
245               , functionName = "ferret#private#hlsearch"
246               , functionArguments = ArgumentList []
247               , functionAttributes = [ "abort" ]
248               , functionBody =
249                   [ GenericStatement "if has('extra_search')"
250                   , Empty
251                   , LetStatement
252                       { letLexpr = "l:hlsearch"
253                       , letValue = "get(g:, 'FerretHlsearch', &hlsearch)"
254                       }
255                   , GenericStatement "if l:hlsearch"
256                   , LetStatement
257                       { letLexpr = "@/" , letValue = "g:ferret_lastsearch" }
258                   , GenericStatement
259                       "call feedkeys(\":let &hlsearch=1 | echo \\<CR>\", 'n')"
260                   , GenericStatement "endif"
261                   , GenericStatement "endif"
262                   ]
263               }
264           , FunctionDeclaration
265               { functionBang = True
266               , functionName = "ferret#private#acks"
267               , functionArguments = ArgumentList [ Argument "command" ]
268               , functionAttributes = [ "abort" ]
269               , functionBody =
270                   [ GenericStatement
271                       "if match(a:command, '\\v^/.+/.*/$') == -1 \" crude sanity check"
272                   , GenericStatement
273                       "echoerr 'Ferret: Expected a substitution expression (/foo/bar/); got: ' . a:command"
274                   , GenericStatement "return"
275                   , GenericStatement "endif"
276                   , LetStatement
277                       { letLexpr = "l:filenames" , letValue = "ferret#private#qargs()" }
278                   , GenericStatement "if l:filenames ==# ''"
279                   , GenericStatement
280                       "echoerr 'Ferret: Quickfix filenames must be present, but there are none'"
281                   , GenericStatement "return"
282                   , GenericStatement "endif"
283                   , GenericStatement "execute 'args' l:filenames"
284                   , GenericStatement
285                       "if v:version > 703 || v:version == 703 && has('patch438')"
286                   , GenericStatement
287                       "silent doautocmd <nomodeline> User FerretWillWrite"
288                   , GenericStatement "else"
289                   , GenericStatement "silent doautocmd User FerretWillWrite"
290                   , GenericStatement "endif"
291                   , GenericStatement
292                       "execute 'argdo' '%s' . a:command . 'ge | update'"
293                   , GenericStatement
294                       "if v:version > 703 || v:version == 703 && has('patch438')"
295                   , GenericStatement
296                       "silent doautocmd <nomodeline> User FerretDidWrite"
297                   , GenericStatement "else"
298                   , GenericStatement "silent doautocmd User FerretDidWrite"
299                   , GenericStatement "endif"
300                   ]
301               }
302           , FunctionDeclaration
303               { functionBang = True
304               , functionName = "ferret#private#qargs"
305               , functionArguments = ArgumentList []
306               , functionAttributes = [ "abort" ]
307               , functionBody =
308                   [ LetStatement { letLexpr = "l:buffer_numbers" , letValue = "{}" }
309                   , GenericStatement "for l:item in getqflist()"
310                   , LetStatement
311                       { letLexpr = "l:buffer_numbers[l:item['bufnr']]"
312                       , letValue = "bufname(l:item['bufnr'])"
313                       }
314                   , GenericStatement "endfor"
315                   , GenericStatement
316                       "return join(map(values(l:buffer_numbers), 'fnameescape(v:val)'))"
317                   ]
318               }
319           , FunctionDeclaration
320               { functionBang = True
321               , functionName = "ferret#private#qf_delete"
322               , functionArguments = ArgumentList []
323               , functionAttributes = [ "range" ]
324               , functionBody =
325                   [ GenericStatement "call s:delete(a:firstline, a:lastline)" ]
326               }
327           , FunctionDeclaration
328               { functionBang = True
329               , functionName = "ferret#private#qf_delete_motion"
330               , functionArguments =
331                   ArgumentList [ Argument "type" , Argument "..." ]
332               , functionAttributes = []
333               , functionBody =
334                   [ LetStatement
335                       { letLexpr = "l:selection" , letValue = "&selection" }
336                   , LetStatement
337                       { letLexpr = "&selection" , letValue = "'inclusive'" }
338                   , LetStatement
339                       { letLexpr = "l:firstline" , letValue = "line(\"'[\")" }
340                   , LetStatement
341                       { letLexpr = "l:lastline" , letValue = "line(\"']\")" }
342                   , GenericStatement "call s:delete(l:firstline, l:lastline)"
343                   , LetStatement
344                       { letLexpr = "&selection" , letValue = "l:selection" }
345                   ]
346               }
347           ]
348       ]
349   , OptionsAnnotation
350   , OptionAnnotation "g:FerretDispatch" "boolean" (Just "1")
351   , Paragraph
352       [ Plaintext "Controls"
353       , Whitespace
354       , Plaintext "whether"
355       , Whitespace
356       , Plaintext "to"
357       , Whitespace
358       , Plaintext "use"
359       , Whitespace
360       , Plaintext "vim-dispatch"
361       , Whitespace
362       , Plaintext "(and"
363       , Whitespace
364       , Plaintext "specifically,"
365       , Whitespace
366       , Link ":Make"
367       , Plaintext ")"
368       , Whitespace
369       , Plaintext "to"
370       , Whitespace
371       , Plaintext "run"
372       , Whitespace
373       , Link ":Ack"
374       , Whitespace
375       , Plaintext "searches"
376       , Whitespace
377       , Plaintext "asynchronously,"
378       , Whitespace
379       , Plaintext "when"
380       , Whitespace
381       , Plaintext "available."
382       , Whitespace
383       , Plaintext "To"
384       , Whitespace
385       , Plaintext "prevent"
386       , Whitespace
387       , Plaintext "vim-dispatch"
388       , Whitespace
389       , Plaintext "from"
390       , Whitespace
391       , Plaintext "being"
392       , Whitespace
393       , Plaintext "used,"
394       , Whitespace
395       , Plaintext "set"
396       , Whitespace
397       , Plaintext "to"
398       , Whitespace
399       , Plaintext "0:"
400       ]
401   , Fenced [ "let g:FerretDispatch=0" ]
402   , OptionAnnotation "g:FerretHlsearch" "boolean" Nothing
403   , Paragraph
404       [ Plaintext "Controls"
405       , Whitespace
406       , Plaintext "whether"
407       , Whitespace
408       , Plaintext "Ferret"
409       , Whitespace
410       , Plaintext "should"
411       , Whitespace
412       , Plaintext "attempt"
413       , Whitespace
414       , Plaintext "to"
415       , Whitespace
416       , Plaintext "highlight"
417       , Whitespace
418       , Plaintext "the"
419       , Whitespace
420       , Plaintext "search"
421       , Whitespace
422       , Plaintext "pattern"
423       , Whitespace
424       , Plaintext "when"
425       , Whitespace
426       , Plaintext "running"
427       , Whitespace
428       , Link ":Ack"
429       , Whitespace
430       , Plaintext "or"
431       , Whitespace
432       , Link ":Lack"
433       , Plaintext "."
434       , Whitespace
435       , Plaintext "If"
436       , Whitespace
437       , Plaintext "left"
438       , Whitespace
439       , Plaintext "unset,"
440       , Whitespace
441       , Plaintext "Ferret"
442       , Whitespace
443       , Plaintext "will"
444       , Whitespace
445       , Plaintext "respect"
446       , Whitespace
447       , Plaintext "the"
448       , Whitespace
449       , Plaintext "current"
450       , Whitespace
451       , Plaintext "'hlsearch'"
452       , Whitespace
453       , Plaintext "setting."
454       , Whitespace
455       , Plaintext "To"
456       , Whitespace
457       , Plaintext "force"
458       , Whitespace
459       , Plaintext "highlighting"
460       , Whitespace
461       , Plaintext "on"
462       , Whitespace
463       , Plaintext "or"
464       , Whitespace
465       , Plaintext "off"
466       , Whitespace
467       , Plaintext "irrespective"
468       , Whitespace
469       , Plaintext "of"
470       , Whitespace
471       , Plaintext "'hlsearch',"
472       , Whitespace
473       , Plaintext "set"
474       , Whitespace
475       , Link "g:FerretHlsearch"
476       , Whitespace
477       , Plaintext "to"
478       , Whitespace
479       , Plaintext "1"
480       , Whitespace
481       , Plaintext "(on)"
482       , Whitespace
483       , Plaintext "or"
484       , Whitespace
485       , Plaintext "0"
486       , Whitespace
487       , Plaintext "(off):"
488       ]
489   , Fenced [ "let g:FerretHlsearch=0" ]
490   ]