|
1 | 1 | let s:save_cpo = &cpoptions
|
2 | 2 | set cpoptions&vim
|
3 | 3 |
|
| 4 | +" Find all project symbols, or all symbols including a search substring. Symbol |
| 5 | +" locations are loaded in the configured selector, :help g:OmniSharp_selector_ui |
| 6 | +" Optional arguments: |
| 7 | +" symbolName: Partial name of the symbol to search for. |
| 8 | +" Callback: When a callback is passed in, it is called after the response is |
| 9 | +" returned (synchronously or asynchronously) with the found symbol |
| 10 | +" locations. |
4 | 11 | function! OmniSharp#actions#symbols#Find(...) abort
|
5 |
| - let filter = a:0 && a:1 isnot 0 ? a:1 : '' |
6 |
| - let symbolfilter = a:0 == 2 ? a:2 : 'TypeAndMember' |
| 12 | + if a:0 && type(a:1) == type('') |
| 13 | + let filter = a:1 |
| 14 | + elseif a:0 > 1 && type(a:2) == type('') |
| 15 | + let filter = a:2 |
| 16 | + else |
| 17 | + let filter = '' |
| 18 | + endif |
| 19 | + if a:0 && type(a:1) == type(function('tr')) |
| 20 | + let Callback = a:1 |
| 21 | + elseif a:0 > 1 && type(a:2) == type(function('tr')) |
| 22 | + let Callback = a:2 |
| 23 | + else |
| 24 | + let Callback = function('s:CBFindSymbol', [filter]) |
| 25 | + endif |
| 26 | + call s:Find(filter, 'TypeAndMember', Callback) |
| 27 | +endfunction |
| 28 | + |
| 29 | +" Find all project types. This function is similar to |
| 30 | +" OmniSharp#actions#symbols#Find() but returns fewer results, and can be |
| 31 | +" significanltly faster in a large codebase. |
| 32 | +function! OmniSharp#actions#symbols#FindType(...) abort |
| 33 | + if a:0 && type(a:1) == type('') |
| 34 | + let filter = a:1 |
| 35 | + elseif a:0 > 1 && type(a:2) == type('') |
| 36 | + let filter = a:2 |
| 37 | + else |
| 38 | + let filter = '' |
| 39 | + endif |
| 40 | + if a:0 && type(a:1) == type(function('tr')) |
| 41 | + let Callback = a:1 |
| 42 | + elseif a:0 > 1 && type(a:2) == type(function('tr')) |
| 43 | + let Callback = a:2 |
| 44 | + else |
| 45 | + let Callback = function('s:CBFindSymbol', [filter]) |
| 46 | + endif |
| 47 | + call s:Find(filter, 'Type', Callback) |
| 48 | +endfunction |
| 49 | + |
| 50 | +function! s:Find(filter, symbolfilter, Callback) abort |
7 | 51 | if !OmniSharp#IsServerRunning() | return | endif
|
8 | 52 | if g:OmniSharp_server_stdio
|
9 |
| - let Callback = function('s:CBFindSymbol', [filter]) |
10 |
| - call s:StdioFind(filter, symbolfilter, Callback) |
| 53 | + call s:StdioFind(a:filter, a:symbolfilter, a:Callback) |
11 | 54 | else
|
12 |
| - let locs = OmniSharp#py#Eval(printf('findSymbols(%s, %s)', string(filter), string(symbolfilter))) |
| 55 | + let locs = OmniSharp#py#Eval(printf('findSymbols(%s, %s)', string(a:filter), string(a:symbolfilter))) |
13 | 56 | if OmniSharp#py#CheckForError() | return | endif
|
14 |
| - return s:CBFindSymbol(filter, locs) |
| 57 | + return a:Callback(locs) |
15 | 58 | endif
|
16 | 59 | endfunction
|
17 | 60 |
|
|
0 commit comments