All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: yoshi1123 <yoshi1@tutanota.com>
2 " Description: Functions for working with jdt:// URIs.
4 function! s:OpenJDTLink(root, uri, line, column, options, result) abort
5 if has_key(a:result, 'error')
7 echoerr a:result.error.message
12 let l:contents = a:result['result']
14 if type(l:contents) is# type(v:null)
16 echoerr 'File content not found'
19 " disable autocmd when opening buffer
20 autocmd! AleURISchemes
21 call ale#util#Open(a:uri, a:line, a:column, a:options)
22 autocmd AleURISchemes BufNewFile,BufReadPre jdt://** call ale#uri#jdt#ReadJDTLink(expand('<amatch>'))
24 if !empty(getbufvar(bufnr(''), 'ale_root', ''))
28 let b:ale_root = a:root
31 call setline(1, split(l:contents, '\n'))
32 call cursor(a:line, a:column)
35 setlocal buftype=nofile nomodified nomodifiable readonly
38 " Load new buffer with jdt:// contents and jump to line and column.
39 function! ale#uri#jdt#OpenJDTLink(encoded_uri, line, column, options, conn_id) abort
40 let l:found_eclipselsp = v:false
42 " We should only arrive here from a 'go to definition' request, so we'll
43 " assume the eclipselsp linter is enabled.
44 for l:linter in ale#linter#Get('java')
45 if l:linter.name is# 'eclipselsp'
46 let l:found_eclipselsp = v:true
50 if !l:found_eclipselsp
51 throw 'eclipselsp not running'
54 let l:root = a:conn_id[stridx(a:conn_id, ':')+1:]
55 let l:uri = a:encoded_uri
56 call ale#lsp_linter#SendRequest(
59 \ [0, 'java/classFileContents', {'uri': ale#util#ToURI(l:uri)}],
60 \ function('s:OpenJDTLink', [l:root, l:uri, a:line, a:column, a:options])
64 function! s:ReadClassFileContents(uri, result) abort
65 if has_key(a:result, 'error')
67 echoerr a:result.error.message
72 let l:contents = a:result['result']
74 if type(l:contents) is# type(v:null)
76 echoerr 'File content not found'
79 call setline(1, split(l:contents, '\n'))
81 setlocal buftype=nofile nomodified nomodifiable readonly
84 " Read jdt:// contents, as part of current project, into current buffer.
85 function! ale#uri#jdt#ReadJDTLink(encoded_uri) abort
86 if !empty(getbufvar(bufnr(''), 'ale_root', ''))
90 let l:linter_map = ale#lsp_linter#GetLSPLinterMap()
92 for [l:conn_id, l:linter] in items(l:linter_map)
93 if l:linter.name is# 'eclipselsp'
94 let l:root = l:conn_id[stridx(l:conn_id, ':')+1:]
99 throw 'eclipselsp not running'
102 let l:uri = a:encoded_uri
103 let b:ale_root = l:root
106 call ale#lsp_linter#SendRequest(
109 \ [0, 'java/classFileContents', {'uri': ale#util#ToURI(l:uri)}],
110 \ function('s:ReadClassFileContents', [l:uri])