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