Add eclipselsp jdt:// support for textDocument/definition (#4030)

This patch adds support for opening jdt:// links on "go to definition" requests returned by Java language servers.

Co-authored-by: w0rp <devw0rp@gmail.com>
This commit is contained in:
yoshi1123 2022-03-04 14:03:27 -05:00 committed by GitHub
parent b42153eb17
commit e490e87a60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 322 additions and 147 deletions

View File

@ -192,4 +192,9 @@ call ale#linter#Define('java', {
\ 'command': function('ale_linters#java#eclipselsp#RunWithVersionCheck'),
\ 'language': 'java',
\ 'project_root': function('ale#java#FindProjectRoot'),
\ 'initialization_options': {
\ 'extendedClientCapabilities': {
\ 'classFileContentsSupport': v:true
\ }
\ }
\})

View File

@ -278,7 +278,7 @@ function! ale#code_action#BuildChangesList(changes_map) abort
endfor
call add(l:changes, {
\ 'fileName': ale#path#FromURI(l:file_name),
\ 'fileName': ale#util#ToResource(l:file_name),
\ 'textChanges': l:text_changes,
\})
endfor

View File

@ -68,18 +68,27 @@ function! ale#definition#HandleLSPResponse(conn_id, response) abort
for l:item in l:result
if has_key(l:item, 'targetUri')
" LocationLink items use targetUri
let l:filename = ale#path#FromURI(l:item.targetUri)
let l:uri = l:item.targetUri
let l:line = l:item.targetRange.start.line + 1
let l:column = l:item.targetRange.start.character + 1
else
" LocationLink items use uri
let l:filename = ale#path#FromURI(l:item.uri)
let l:uri = l:item.uri
let l:line = l:item.range.start.line + 1
let l:column = l:item.range.start.character + 1
endif
call ale#definition#UpdateTagStack()
call ale#util#Open(l:filename, l:line, l:column, l:options)
let l:uri_handler = ale#uri#GetURIHandler(l:uri)
if l:uri_handler is# v:null
let l:filename = ale#path#FromFileURI(l:uri)
call ale#util#Open(l:filename, l:line, l:column, l:options)
else
call l:uri_handler.OpenURILink(l:uri, l:line, l:column, l:options, a:conn_id)
endif
break
endfor
endif

View File

@ -156,4 +156,10 @@ function! ale#events#Init() abort
endif
endif
augroup END
augroup AleURISchemes
autocmd!
autocmd BufNewFile,BufReadPre jdt://** call ale#uri#jdt#ReadJDTLink(expand('<amatch>'))
augroup END
endfunction

View File

@ -35,7 +35,7 @@ function! ale#lsp#message#Initialize(root_path, options, capabilities) abort
\ 'rootPath': a:root_path,
\ 'capabilities': a:capabilities,
\ 'initializationOptions': a:options,
\ 'rootUri': ale#path#ToURI(a:root_path),
\ 'rootUri': ale#util#ToURI(a:root_path),
\}]
endfunction
@ -56,7 +56,7 @@ function! ale#lsp#message#DidOpen(buffer, language_id) abort
return [1, 'textDocument/didOpen', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')),
\ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')),
\ 'languageId': a:language_id,
\ 'version': ale#lsp#message#GetNextVersionID(),
\ 'text': join(l:lines, "\n") . "\n",
@ -70,7 +70,7 @@ function! ale#lsp#message#DidChange(buffer) abort
" For changes, we simply send the full text of the document to the server.
return [1, 'textDocument/didChange', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')),
\ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')),
\ 'version': ale#lsp#message#GetNextVersionID(),
\ },
\ 'contentChanges': [{'text': join(l:lines, "\n") . "\n"}]
@ -80,7 +80,7 @@ endfunction
function! ale#lsp#message#DidSave(buffer, includeText) abort
let l:response = [1, 'textDocument/didSave', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')),
\ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')),
\ },
\}]
@ -95,7 +95,7 @@ endfunction
function! ale#lsp#message#DidClose(buffer) abort
return [1, 'textDocument/didClose', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')),
\ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')),
\ },
\}]
endfunction
@ -106,7 +106,7 @@ let s:COMPLETION_TRIGGER_CHARACTER = 2
function! ale#lsp#message#Completion(buffer, line, column, trigger_character) abort
let l:message = [0, 'textDocument/completion', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')),
\ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')),
\ },
\ 'position': {'line': a:line - 1, 'character': a:column - 1},
\}]
@ -124,7 +124,7 @@ endfunction
function! ale#lsp#message#Definition(buffer, line, column) abort
return [0, 'textDocument/definition', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')),
\ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')),
\ },
\ 'position': {'line': a:line - 1, 'character': a:column - 1},
\}]
@ -133,7 +133,7 @@ endfunction
function! ale#lsp#message#TypeDefinition(buffer, line, column) abort
return [0, 'textDocument/typeDefinition', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')),
\ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')),
\ },
\ 'position': {'line': a:line - 1, 'character': a:column - 1},
\}]
@ -142,7 +142,7 @@ endfunction
function! ale#lsp#message#References(buffer, line, column) abort
return [0, 'textDocument/references', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')),
\ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')),
\ },
\ 'position': {'line': a:line - 1, 'character': a:column - 1},
\ 'context': {'includeDeclaration': v:false},
@ -158,7 +158,7 @@ endfunction
function! ale#lsp#message#Hover(buffer, line, column) abort
return [0, 'textDocument/hover', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')),
\ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')),
\ },
\ 'position': {'line': a:line - 1, 'character': a:column - 1},
\}]
@ -173,7 +173,7 @@ endfunction
function! ale#lsp#message#Rename(buffer, line, column, new_name) abort
return [0, 'textDocument/rename', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')),
\ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')),
\ },
\ 'position': {'line': a:line - 1, 'character': a:column - 1},
\ 'newName': a:new_name,
@ -183,7 +183,7 @@ endfunction
function! ale#lsp#message#CodeAction(buffer, line, column, end_line, end_column, diagnostics) abort
return [0, 'textDocument/codeAction', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')),
\ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')),
\ },
\ 'range': {
\ 'start': {'line': a:line - 1, 'character': a:column - 1},

View File

@ -59,7 +59,7 @@ function! ale#lsp#response#ReadDiagnostics(response) abort
\ && l:diagnostic.relatedInformation isnot v:null
let l:related = deepcopy(l:diagnostic.relatedInformation)
call map(l:related, {key, val ->
\ ale#path#FromURI(val.location.uri) .
\ ale#util#ToResource(val.location.uri) .
\ ':' . (val.location.range.start.line + 1) .
\ ':' . (val.location.range.start.character + 1) .
\ ":\n\t" . val.message

View File

@ -11,6 +11,22 @@ endif
" A Dictionary to track one-shot handlers for custom LSP requests
let s:custom_handlers_map = get(s:, 'custom_handlers_map', {})
" Clear LSP linter data for the linting engine.
function! ale#lsp_linter#ClearLSPData() abort
let s:lsp_linter_map = {}
let s:custom_handlers_map = {}
endfunction
" Only for internal use.
function! ale#lsp_linter#GetLSPLinterMap() abort
return s:lsp_linter_map
endfunction
" Just for tests.
function! ale#lsp_linter#SetLSPLinterMap(replacement_map) abort
let s:lsp_linter_map = a:replacement_map
endfunction
" Check if diagnostics for a particular linter should be ignored.
function! s:ShouldIgnore(buffer, linter_name) abort
" Ignore all diagnostics if LSP integration is disabled.
@ -33,7 +49,7 @@ endfunction
function! s:HandleLSPDiagnostics(conn_id, response) abort
let l:linter_name = s:lsp_linter_map[a:conn_id]
let l:filename = ale#path#FromURI(a:response.params.uri)
let l:filename = ale#util#ToResource(a:response.params.uri)
let l:escaped_name = escape(
\ fnameescape(l:filename),
\ has('win32') ? '^' : '^,}]'
@ -477,17 +493,6 @@ function! ale#lsp_linter#CheckWithLSP(buffer, linter) abort
return ale#lsp_linter#StartLSP(a:buffer, a:linter, function('s:CheckWithLSP'))
endfunction
" Clear LSP linter data for the linting engine.
function! ale#lsp_linter#ClearLSPData() abort
let s:lsp_linter_map = {}
let s:custom_handlers_map = {}
endfunction
" Just for tests.
function! ale#lsp_linter#SetLSPLinterMap(replacement_map) abort
let s:lsp_linter_map = a:replacement_map
endfunction
function! s:HandleLSPResponseToCustomRequests(conn_id, response) abort
if has_key(a:response, 'id')
\&& has_key(s:custom_handlers_map, a:response.id)

View File

@ -218,7 +218,7 @@ endfunction
" Convert a filesystem path to a file:// URI
" relatives paths will not be prefixed with the protocol.
" For Windows paths, the `:` in C:\ etc. will not be percent-encoded.
function! ale#path#ToURI(path) abort
function! ale#path#ToFileURI(path) abort
let l:has_drive_letter = a:path[1:2] is# ':\'
return substitute(
@ -231,7 +231,7 @@ function! ale#path#ToURI(path) abort
\)
endfunction
function! ale#path#FromURI(uri) abort
function! ale#path#FromFileURI(uri) abort
if a:uri[:6] is? 'file://'
let l:encoded_path = a:uri[7:]
elseif a:uri[:4] is? 'file:'

View File

@ -66,13 +66,13 @@ endfunction
function! ale#references#FormatLSPResponseItem(response_item, options) abort
if get(a:options, 'open_in') is# 'quickfix'
return {
\ 'filename': ale#path#FromURI(a:response_item.uri),
\ 'filename': ale#util#ToResource(a:response_item.uri),
\ 'lnum': a:response_item.range.start.line + 1,
\ 'col': a:response_item.range.start.character + 1,
\}
else
return {
\ 'filename': ale#path#FromURI(a:response_item.uri),
\ 'filename': ale#util#ToResource(a:response_item.uri),
\ 'line': a:response_item.range.start.line + 1,
\ 'column': a:response_item.range.start.character + 1,
\}

View File

@ -41,7 +41,7 @@ function! ale#symbol#HandleLSPResponse(conn_id, response) abort
let l:location = l:response_item.location
call add(l:item_list, {
\ 'filename': ale#path#FromURI(l:location.uri),
\ 'filename': ale#util#ToResource(l:location.uri),
\ 'line': l:location.range.start.line + 1,
\ 'column': l:location.range.start.character + 1,
\ 'match': l:response_item.name,

View File

@ -25,3 +25,19 @@ function! ale#uri#Decode(value) abort
\ 'g'
\)
endfunction
let s:uri_handlers = {
\ 'jdt': {
\ 'OpenURILink': function('ale#uri#jdt#OpenJDTLink'),
\ }
\}
function! ale#uri#GetURIHandler(uri) abort
for l:scheme in keys(s:uri_handlers)
if a:uri =~# '^'.l:scheme.'://'
return s:uri_handlers[scheme]
endif
endfor
return v:null
endfunction

106
autoload/ale/uri/jdt.vim Normal file
View File

@ -0,0 +1,106 @@
" Author: yoshi1123 <yoshi1@tutanota.com>
" Description: Functions for working with jdt:// URIs.
function! s:OpenJDTLink(root, uri, line, column, options, result) abort
if has_key(a:result, 'error')
execute 'echoerr a:result.error.message'
return
endif
let l:contents = a:result['result']
if type(l:contents) is# type(v:null)
execute 'echoerr ''File content not found'''
endif
" disable autocmd when opening buffer
autocmd! AleURISchemes
call ale#util#Open(a:uri, a:line, a:column, a:options)
autocmd AleURISchemes BufNewFile,BufReadPre jdt://** call ale#uri#jdt#ReadJDTLink(expand('<amatch>'))
if !empty(getbufvar(bufnr(''), 'ale_lsp_root', ''))
return
endif
let b:ale_lsp_root = a:root
set filetype=java
call setline(1, split(l:contents, '\n'))
call cursor(a:line, a:column)
normal! zz
setlocal buftype=nofile nomodified nomodifiable readonly
endfunction
" Load new buffer with jdt:// contents and jump to line and column.
function! ale#uri#jdt#OpenJDTLink(encoded_uri, line, column, options, conn_id) abort
let l:found_eclipselsp = v:false
for l:linter in ale#linter#Get('java')
if l:linter.name is# 'eclipselsp'
let l:found_eclipselsp = v:true
endif
endfor
if !l:found_eclipselsp
throw 'eclipselsp not running'
endif
let l:root = a:conn_id[stridx(a:conn_id, ':')+1:]
let l:uri = a:encoded_uri
call ale#lsp_linter#SendRequest(
\ bufnr(''),
\ 'eclipselsp',
\ [0, 'java/classFileContents', {'uri': ale#util#ToURI(l:uri)}],
\ function('s:OpenJDTLink', [l:root, l:uri, a:line, a:column, a:options])
\)
endfunction
function! s:ReadClassFileContents(uri, result) abort
if has_key(a:result, 'error')
execute 'echoerr a:result.error.message'
return
endif
let l:contents = a:result['result']
if type(l:contents) is# type(v:null)
execute 'echoerr ''File content not found'''
endif
call setline(1, split(l:contents, '\n'))
setlocal buftype=nofile nomodified nomodifiable readonly
endfunction
" Read jdt:// contents, as part of current project, into current buffer.
function! ale#uri#jdt#ReadJDTLink(encoded_uri) abort
if !empty(getbufvar(bufnr(''), 'ale_lsp_root', ''))
return
endif
let l:linter_map = ale#lsp_linter#GetLSPLinterMap()
for l:conn_id in keys(l:linter_map)
if l:linter_map[l:conn_id] is# 'eclipselsp'
let l:root = l:conn_id[stridx(l:conn_id, ':')+1:]
endif
endfor
if l:root is# v:null
throw 'eclipselsp not running'
endif
let l:uri = a:encoded_uri
let b:ale_lsp_root = l:root
set filetype=java
call ale#lsp_linter#SendRequest(
\ bufnr(''),
\ 'eclipselsp',
\ [0, 'java/classFileContents', {'uri': ale#util#ToURI(l:uri)}],
\ function('s:ReadClassFileContents', [l:uri])
\)
endfunction

View File

@ -543,3 +543,31 @@ endfunction
function! ale#util#GetBufferContents(buffer) abort
return join(getbufline(a:buffer, 1, '$'), '\n') . '\n'
endfunction
function! ale#util#ToURI(resource) abort
let l:uri_handler = ale#uri#GetURIHandler(a:resource)
if l:uri_handler is# v:null
" resource is a filesystem path
let l:uri = ale#path#ToFileURI(a:resource)
else
" resource is a URI
let l:uri = a:resource
endif
return l:uri
endfunction
function! ale#util#ToResource(uri) abort
let l:uri_handler = ale#uri#GetURIHandler(a:uri)
if l:uri_handler is# v:null
" resource is a filesystem path
let l:resource = ale#path#FromFileURI(a:uri)
else
" resource is a URI
let l:resource = a:uri
endif
return l:resource
endfunction

View File

@ -368,7 +368,7 @@ Execute(ALEImport should request imports correctly for language servers):
AssertEqual
\ [
\ [0, 'textDocument/completion', {
\ 'textDocument': {'uri': ale#path#ToURI(expand('%:p'))},
\ 'textDocument': {'uri': ale#path#ToFileURI(expand('%:p'))},
\ 'position': {'character': 6, 'line': 1}
\ }],
\ ],
@ -514,7 +514,7 @@ Execute(ALEImport should tell the user when no completions were found from a lan
AssertEqual
\ [
\ [0, 'textDocument/completion', {
\ 'textDocument': {'uri': ale#path#ToURI(expand('%:p'))},
\ 'textDocument': {'uri': ale#path#ToFileURI(expand('%:p'))},
\ 'position': {'character': 6, 'line': 1}
\ }],
\ ],

View File

@ -233,13 +233,13 @@ Execute(The right message should be sent for the initial LSP request):
\ [
\ [1, 'textDocument/didChange', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('%:p')),
\ 'uri': ale#path#ToFileURI(expand('%:p')),
\ 'version': g:ale_lsp_next_version_id - 1,
\ },
\ 'contentChanges': [{'text': join(getline(1, '$'), "\n") . "\n"}]
\ }],
\ [0, 'textDocument/completion', {
\ 'textDocument': {'uri': ale#path#ToURI(expand('%:p'))},
\ 'textDocument': {'uri': ale#path#ToFileURI(expand('%:p'))},
\ 'position': {'line': 0, 'character': 2},
\ }],
\ ],
@ -294,13 +294,13 @@ Execute(Two completion requests shouldn't be sent in a row):
\ [
\ [1, 'textDocument/didChange', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('%:p')),
\ 'uri': ale#path#ToFileURI(expand('%:p')),
\ 'version': g:ale_lsp_next_version_id - 1,
\ },
\ 'contentChanges': [{'text': join(getline(1, '$'), "\n") . "\n"}]
\ }],
\ [0, 'textDocument/completion', {
\ 'textDocument': {'uri': ale#path#ToURI(expand('%:p'))},
\ 'textDocument': {'uri': ale#path#ToFileURI(expand('%:p'))},
\ 'position': {'line': 0, 'character': 2},
\ }],
\ ],

View File

@ -63,7 +63,7 @@ Execute(A message should be sent if the document was opened):
\ [
\ ['command:/foo', 1, 'textDocument/didOpen', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('%:p')),
\ 'uri': ale#path#ToFileURI(expand('%:p')),
\ 'version': g:ale_lsp_next_version_id - 1,
\ 'languageId': 'lang',
\ 'text': "\n",
@ -71,7 +71,7 @@ Execute(A message should be sent if the document was opened):
\ }],
\ ['command:/foo', 1, 'textDocument/didClose', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('%:p')),
\ 'uri': ale#path#ToFileURI(expand('%:p')),
\ },
\ }],
\ ],
@ -106,7 +106,7 @@ Execute(Re-opening and closing the documents should work):
\ [
\ ['command:/foo', 1, 'textDocument/didOpen', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('%:p')),
\ 'uri': ale#path#ToFileURI(expand('%:p')),
\ 'version': g:ale_lsp_next_version_id - 2,
\ 'languageId': 'lang',
\ 'text': "\n",
@ -114,12 +114,12 @@ Execute(Re-opening and closing the documents should work):
\ }],
\ ['command:/foo', 1, 'textDocument/didClose', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('%:p')),
\ 'uri': ale#path#ToFileURI(expand('%:p')),
\ },
\ }],
\ ['command:/foo', 1, 'textDocument/didOpen', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('%:p')),
\ 'uri': ale#path#ToFileURI(expand('%:p')),
\ 'version': g:ale_lsp_next_version_id - 1,
\ 'languageId': 'lang',
\ 'text': "\n",
@ -127,7 +127,7 @@ Execute(Re-opening and closing the documents should work):
\ }],
\ ['command:/foo', 1, 'textDocument/didClose', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('%:p')),
\ 'uri': ale#path#ToFileURI(expand('%:p')),
\ },
\ }],
\ ],
@ -148,7 +148,7 @@ Execute(Messages for closing documents should be sent to each server):
\ [
\ ['command:/foo', 1, 'textDocument/didOpen', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('%:p')),
\ 'uri': ale#path#ToFileURI(expand('%:p')),
\ 'version': g:ale_lsp_next_version_id - 2,
\ 'languageId': 'lang',
\ 'text': "\n",
@ -156,7 +156,7 @@ Execute(Messages for closing documents should be sent to each server):
\ }],
\ ['command:/bar', 1, 'textDocument/didOpen', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('%:p')),
\ 'uri': ale#path#ToFileURI(expand('%:p')),
\ 'version': g:ale_lsp_next_version_id - 1,
\ 'languageId': 'lang',
\ 'text': "\n",
@ -164,12 +164,12 @@ Execute(Messages for closing documents should be sent to each server):
\ }],
\ ['command:/bar', 1, 'textDocument/didClose', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('%:p')),
\ 'uri': ale#path#ToFileURI(expand('%:p')),
\ },
\ }],
\ ['command:/foo', 1, 'textDocument/didClose', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('%:p')),
\ 'uri': ale#path#ToFileURI(expand('%:p')),
\ },
\ }],
\ ],

View File

@ -94,7 +94,7 @@ Execute(Server should be notified on save):
\ [
\ [1, 'textDocument/didChange', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('%:p')),
\ 'uri': ale#path#ToFileURI(expand('%:p')),
\ 'version': g:ale_lsp_next_version_id - 1,
\ },
\ 'contentChanges': [{'text': join(getline(1, '$'), "\n") . "\n"}],
@ -118,14 +118,14 @@ Execute(Server should be notified on save with didSave is supported by server):
\ [
\ [1, 'textDocument/didChange', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('%:p')),
\ 'uri': ale#path#ToFileURI(expand('%:p')),
\ 'version': g:ale_lsp_next_version_id - 1,
\ },
\ 'contentChanges': [{'text': join(getline(1, '$'), "\n") . "\n"}],
\ }],
\ [1, 'textDocument/didSave', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('%:p')),
\ 'uri': ale#path#ToFileURI(expand('%:p')),
\ },
\ }],
\ ],
@ -138,7 +138,7 @@ Execute(Server should be notified on change):
\ [
\ [1, 'textDocument/didChange', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('%:p')),
\ 'uri': ale#path#ToFileURI(expand('%:p')),
\ 'version': g:ale_lsp_next_version_id - 1,
\ },
\ 'contentChanges': [{'text': join(getline(1, '$'), "\n") . "\n"}],

View File

@ -314,7 +314,7 @@ Execute(LSP diagnostics responses should be handled correctly):
\ 'jsonrpc':'2.0',
\ 'method':'textDocument/publishDiagnostics',
\ 'params': {
\ 'uri': ale#path#ToURI(expand('%:p')),
\ 'uri': ale#path#ToFileURI(expand('%:p')),
\ 'diagnostics': [
\ {
\ 'range': {
@ -403,7 +403,7 @@ Execute(LSP errors should mark linters no longer active):
call ale#lsp_linter#HandleLSPResponse(1, {
\ 'method': 'textDocument/publishDiagnostics',
\ 'params': {
\ 'uri': ale#path#ToURI(g:dir . '/filename.py'),
\ 'uri': ale#path#ToFileURI(g:dir . '/filename.py'),
\ 'diagnostics': [],
\ },
\})

View File

@ -44,7 +44,7 @@ Execute(ale#lsp#message#DidOpen() should return correct messages):
\ 'textDocument/didOpen',
\ {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(g:dir . '/foo/bar.ts'),
\ 'uri': ale#path#ToFileURI(g:dir . '/foo/bar.ts'),
\ 'languageId': 'typescript',
\ 'version': 12,
\ 'text': "foo()\nbar()\nbaz()\n",
@ -62,7 +62,7 @@ Execute(ale#lsp#message#DidChange() should return correct messages):
\ 'textDocument/didChange',
\ {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(g:dir . '/foo/bar.ts'),
\ 'uri': ale#path#ToFileURI(g:dir . '/foo/bar.ts'),
\ 'version': 34,
\ },
\ 'contentChanges': [{'text': "foo()\nbar()\nbaz()\n"}],
@ -84,7 +84,7 @@ Execute(ale#lsp#message#DidSave() should return correct messages):
\ 'textDocument/didSave',
\ {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(g:dir . '/foo/bar.ts'),
\ 'uri': ale#path#ToFileURI(g:dir . '/foo/bar.ts'),
\ },
\ }
\ ],
@ -97,7 +97,7 @@ Execute(ale#lsp#message#DidSave() should return correct message with includeText
\ 'textDocument/didSave',
\ {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(g:dir . '/foo/bar.ts'),
\ 'uri': ale#path#ToFileURI(g:dir . '/foo/bar.ts'),
\ 'version': 1,
\ },
\ 'text': ale#util#GetBufferContents(bufnr('')),
@ -112,7 +112,7 @@ Execute(ale#lsp#message#DidClose() should return correct messages):
\ 'textDocument/didClose',
\ {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(g:dir . '/foo/bar.ts'),
\ 'uri': ale#path#ToFileURI(g:dir . '/foo/bar.ts'),
\ },
\ }
\ ],
@ -125,7 +125,7 @@ Execute(ale#lsp#message#Completion() should return correct messages):
\ 'textDocument/completion',
\ {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(g:dir . '/foo/bar.ts'),
\ 'uri': ale#path#ToFileURI(g:dir . '/foo/bar.ts'),
\ },
\ 'position': {'line': 11, 'character': 33},
\ }
@ -139,7 +139,7 @@ Execute(ale#lsp#message#Completion() should return correct messages with a trigg
\ 'textDocument/completion',
\ {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(g:dir . '/foo/bar.ts'),
\ 'uri': ale#path#ToFileURI(g:dir . '/foo/bar.ts'),
\ },
\ 'position': {'line': 11, 'character': 33},
\ 'context': {'triggerKind': 2, 'triggerCharacter': '.'},
@ -154,7 +154,7 @@ Execute(ale#lsp#message#Definition() should return correct messages):
\ 'textDocument/definition',
\ {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(g:dir . '/foo/bar.ts'),
\ 'uri': ale#path#ToFileURI(g:dir . '/foo/bar.ts'),
\ },
\ 'position': {'line': 11, 'character': 33},
\ }
@ -168,7 +168,7 @@ Execute(ale#lsp#message#TypeDefinition() should return correct messages):
\ 'textDocument/typeDefinition',
\ {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(g:dir . '/foo/bar.ts'),
\ 'uri': ale#path#ToFileURI(g:dir . '/foo/bar.ts'),
\ },
\ 'position': {'line': 11, 'character': 33},
\ }
@ -182,7 +182,7 @@ Execute(ale#lsp#message#References() should return correct messages):
\ 'textDocument/references',
\ {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(g:dir . '/foo/bar.ts'),
\ 'uri': ale#path#ToFileURI(g:dir . '/foo/bar.ts'),
\ },
\ 'position': {'line': 11, 'character': 33},
\ 'context': {'includeDeclaration': v:false},
@ -208,7 +208,7 @@ Execute(ale#lsp#message#Hover() should return correct messages):
\ 'textDocument/hover',
\ {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(g:dir . '/foo/bar.ts'),
\ 'uri': ale#path#ToFileURI(g:dir . '/foo/bar.ts'),
\ },
\ 'position': {'line': 11, 'character': 33},
\ }

View File

@ -138,7 +138,7 @@ Before:
\ 'id': 1,
\ 'params': {
\ 'initializationOptions': {},
\ 'rootUri': ale#path#ToURI(a:root),
\ 'rootUri': ale#path#ToFileURI(a:root),
\ 'rootPath': a:root,
\ 'processId': getpid(),
\ 'capabilities': {
@ -253,7 +253,7 @@ Before:
\ 'jsonrpc': '2.0',
\ 'params': {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')),
\ 'uri': ale#path#ToFileURI(expand('#' . a:buffer . ':p')),
\ 'version': ale#lsp#message#GetNextVersionID() - 1,
\ 'languageId': a:language,
\ 'text': "\n",

View File

@ -511,7 +511,7 @@ Execute(LSP code action requests should be sent):
\ 'diagnostics': [{'range': {'end': {'character': 6, 'line': 1}, 'start': {'character': 4, 'line': 1}}, 'code': 2304, 'message': 'oops'}]
\ },
\ 'range': {'end': {'character': 5, 'line': 1}, 'start': {'character': 4, 'line': 1}},
\ 'textDocument': {'uri': ale#path#ToURI(expand('%:p'))}
\ 'textDocument': {'uri': ale#path#ToFileURI(expand('%:p'))}
\ }]
\ ],
\ g:message_list[-1:]
@ -543,7 +543,7 @@ Execute(LSP code action requests should be sent only for error with code):
\ 'diagnostics': [{'range': {'end': {'character': 6, 'line': 1}, 'start': {'character': 4, 'line': 1}}, 'code': 2304, 'message': 'oops'}]
\ },
\ 'range': {'end': {'character': 5, 'line': 1}, 'start': {'character': 4, 'line': 1}},
\ 'textDocument': {'uri': ale#path#ToURI(expand('%:p'))}
\ 'textDocument': {'uri': ale#path#ToFileURI(expand('%:p'))}
\ }]
\ ],
\ g:message_list[-1:]

View File

@ -357,13 +357,13 @@ Execute(LSP reference responses should be handled):
\ 'id': 3,
\ 'result': [
\ {
\ 'uri': ale#path#ToURI(ale#path#Simplify(g:dir . '/completion_dummy_file')),
\ 'uri': ale#path#ToFileURI(ale#path#Simplify(g:dir . '/completion_dummy_file')),
\ 'range': {
\ 'start': {'line': 2, 'character': 7},
\ },
\ },
\ {
\ 'uri': ale#path#ToURI(ale#path#Simplify(g:dir . '/other_file')),
\ 'uri': ale#path#ToFileURI(ale#path#Simplify(g:dir . '/other_file')),
\ 'range': {
\ 'start': {'line': 7, 'character': 15},
\ },
@ -396,13 +396,13 @@ Execute(LSP reference responses should be put to quickfix):
\ 'id': 3,
\ 'result': [
\ {
\ 'uri': ale#path#ToURI(ale#path#Simplify(g:dir . '/completion_dummy_file')),
\ 'uri': ale#path#ToFileURI(ale#path#Simplify(g:dir . '/completion_dummy_file')),
\ 'range': {
\ 'start': {'line': 2, 'character': 7},
\ },
\ },
\ {
\ 'uri': ale#path#ToURI(ale#path#Simplify(g:dir . '/other_file')),
\ 'uri': ale#path#ToFileURI(ale#path#Simplify(g:dir . '/other_file')),
\ 'range': {
\ 'start': {'line': 7, 'character': 15},
\ },
@ -453,13 +453,13 @@ Execute(LSP reference requests should be sent):
\ [
\ [1, 'textDocument/didChange', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('%:p')),
\ 'uri': ale#path#ToFileURI(expand('%:p')),
\ 'version': g:ale_lsp_next_version_id - 1,
\ },
\ 'contentChanges': [{'text': join(getline(1, '$'), "\n") . "\n"}]
\ }],
\ [0, 'textDocument/references', {
\ 'textDocument': {'uri': ale#path#ToURI(expand('%:p'))},
\ 'textDocument': {'uri': ale#path#ToFileURI(expand('%:p'))},
\ 'position': {'line': 0, 'character': 2},
\ 'context': {'includeDeclaration': v:false},
\ }],

View File

@ -327,7 +327,7 @@ Execute(Other files should be jumped to for LSP definition responses):
\ {
\ 'id': 3,
\ 'result': {
\ 'uri': ale#path#ToURI(ale#path#Simplify(g:dir . '/completion_dummy_file')),
\ 'uri': ale#path#ToFileURI(ale#path#Simplify(g:dir . '/completion_dummy_file')),
\ 'range': {
\ 'start': {'line': 2, 'character': 7},
\ },
@ -350,7 +350,7 @@ Execute(Newer LocationLink items should be supported):
\ {
\ 'id': 3,
\ 'result': {
\ 'targetUri': ale#path#ToURI(ale#path#Simplify(g:dir . '/completion_dummy_file')),
\ 'targetUri': ale#path#ToFileURI(ale#path#Simplify(g:dir . '/completion_dummy_file')),
\ 'targetRange': {
\ 'start': {'line': 2, 'character': 7},
\ },
@ -373,7 +373,7 @@ Execute(Locations inside the same file should be jumped to without using :edit):
\ {
\ 'id': 3,
\ 'result': {
\ 'uri': ale#path#ToURI(ale#path#Simplify(expand('%:p'))),
\ 'uri': ale#path#ToFileURI(ale#path#Simplify(expand('%:p'))),
\ 'range': {
\ 'start': {'line': 2, 'character': 7},
\ },
@ -395,7 +395,7 @@ Execute(Other files should be jumped to in tabs for LSP definition responses):
\ {
\ 'id': 3,
\ 'result': {
\ 'uri': ale#path#ToURI(ale#path#Simplify(g:dir . '/completion_dummy_file')),
\ 'uri': ale#path#ToFileURI(ale#path#Simplify(g:dir . '/completion_dummy_file')),
\ 'range': {
\ 'start': {'line': 2, 'character': 7},
\ },
@ -419,13 +419,13 @@ Execute(Definition responses with lists should be handled):
\ 'id': 3,
\ 'result': [
\ {
\ 'uri': ale#path#ToURI(ale#path#Simplify(g:dir . '/completion_dummy_file')),
\ 'uri': ale#path#ToFileURI(ale#path#Simplify(g:dir . '/completion_dummy_file')),
\ 'range': {
\ 'start': {'line': 2, 'character': 7},
\ },
\ },
\ {
\ 'uri': ale#path#ToURI(ale#path#Simplify(g:dir . '/other_file')),
\ 'uri': ale#path#ToFileURI(ale#path#Simplify(g:dir . '/other_file')),
\ 'range': {
\ 'start': {'line': 20, 'character': 3},
\ },
@ -470,13 +470,13 @@ Execute(LSP definition requests should be sent):
\ [
\ [1, 'textDocument/didChange', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('%:p')),
\ 'uri': ale#path#ToFileURI(expand('%:p')),
\ 'version': g:ale_lsp_next_version_id - 1,
\ },
\ 'contentChanges': [{'text': join(getline(1, '$'), "\n") . "\n"}]
\ }],
\ [0, 'textDocument/definition', {
\ 'textDocument': {'uri': ale#path#ToURI(expand('%:p'))},
\ 'textDocument': {'uri': ale#path#ToFileURI(expand('%:p'))},
\ 'position': {'line': 0, 'character': 2},
\ }],
\ ],
@ -506,13 +506,13 @@ Execute(LSP type definition requests should be sent):
\ [
\ [1, 'textDocument/didChange', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('%:p')),
\ 'uri': ale#path#ToFileURI(expand('%:p')),
\ 'version': g:ale_lsp_next_version_id - 1,
\ },
\ 'contentChanges': [{'text': join(getline(1, '$'), "\n") . "\n"}]
\ }],
\ [0, 'textDocument/typeDefinition', {
\ 'textDocument': {'uri': ale#path#ToURI(expand('%:p'))},
\ 'textDocument': {'uri': ale#path#ToFileURI(expand('%:p'))},
\ 'position': {'line': 0, 'character': 2},
\ }],
\ ],
@ -542,13 +542,13 @@ Execute(LSP tab definition requests should be sent):
\ [
\ [1, 'textDocument/didChange', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('%:p')),
\ 'uri': ale#path#ToFileURI(expand('%:p')),
\ 'version': g:ale_lsp_next_version_id - 1,
\ },
\ 'contentChanges': [{'text': join(getline(1, '$'), "\n") . "\n"}]
\ }],
\ [0, 'textDocument/definition', {
\ 'textDocument': {'uri': ale#path#ToURI(expand('%:p'))},
\ 'textDocument': {'uri': ale#path#ToFileURI(expand('%:p'))},
\ 'position': {'line': 0, 'character': 2},
\ }],
\ ],
@ -578,13 +578,13 @@ Execute(LSP tab type definition requests should be sent):
\ [
\ [1, 'textDocument/didChange', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('%:p')),
\ 'uri': ale#path#ToFileURI(expand('%:p')),
\ 'version': g:ale_lsp_next_version_id - 1,
\ },
\ 'contentChanges': [{'text': join(getline(1, '$'), "\n") . "\n"}]
\ }],
\ [0, 'textDocument/typeDefinition', {
\ 'textDocument': {'uri': ale#path#ToURI(expand('%:p'))},
\ 'textDocument': {'uri': ale#path#ToFileURI(expand('%:p'))},
\ 'position': {'line': 0, 'character': 2},
\ }],
\ ],

View File

@ -271,7 +271,7 @@ Execute(Buffer ignore lists should be applied for LSP linters):
\ 'jsonrpc': '2.0',
\ 'method': 'textDocument/publishDiagnostics',
\ 'params': {
\ 'uri': ale#path#ToURI(expand('%:p')),
\ 'uri': ale#path#ToFileURI(expand('%:p')),
\ 'diagnostics': [
\ {
\ 'severity': 1,
@ -366,7 +366,7 @@ Execute(ale_disable_lsp should be applied for LSP linters):
\ 'jsonrpc': '2.0',
\ 'method': 'textDocument/publishDiagnostics',
\ 'params': {
\ 'uri': ale#path#ToURI(expand('%:p')),
\ 'uri': ale#path#ToFileURI(expand('%:p')),
\ 'diagnostics': [
\ {
\ 'severity': 1,

View File

@ -1,73 +1,73 @@
Before:
scriptencoding utf-8
Execute(ale#path#ToURI should work for Windows paths):
AssertEqual 'file:///C:/foo/bar/baz.tst', ale#path#ToURI('C:\foo\bar\baz.tst')
AssertEqual 'foo/bar/baz.tst', ale#path#ToURI('foo\bar\baz.tst')
Execute(ale#path#ToFileURI should work for Windows paths):
AssertEqual 'file:///C:/foo/bar/baz.tst', ale#path#ToFileURI('C:\foo\bar\baz.tst')
AssertEqual 'foo/bar/baz.tst', ale#path#ToFileURI('foo\bar\baz.tst')
Execute(ale#path#FromURI should work for Unix paths):
AssertEqual '/foo/bar/baz.tst', ale#path#FromURI('file:///foo/bar/baz.tst')
AssertEqual '/foo/bar/baz.tst', ale#path#FromURI('file:/foo/bar/baz.tst')
AssertEqual '/foo/bar/baz.tst', ale#path#FromURI('FILE:///foo/bar/baz.tst')
AssertEqual '/foo/bar/baz.tst', ale#path#FromURI('FILE:/foo/bar/baz.tst')
Execute(ale#path#FromFileURI should work for Unix paths):
AssertEqual '/foo/bar/baz.tst', ale#path#FromFileURI('file:///foo/bar/baz.tst')
AssertEqual '/foo/bar/baz.tst', ale#path#FromFileURI('file:/foo/bar/baz.tst')
AssertEqual '/foo/bar/baz.tst', ale#path#FromFileURI('FILE:///foo/bar/baz.tst')
AssertEqual '/foo/bar/baz.tst', ale#path#FromFileURI('FILE:/foo/bar/baz.tst')
Execute(ale#path#FromURI should work for Windows paths):
Execute(ale#path#FromFileURI should work for Windows paths):
if has('win32')
AssertEqual 'C:\foo\bar\baz.tst', ale#path#FromURI('file:///C:/foo/bar/baz.tst')
AssertEqual 'C:\foo\bar\baz.tst', ale#path#FromURI('file:/C:/foo/bar/baz.tst')
AssertEqual 'c:\foo\bar\baz.tst', ale#path#FromURI('file:///c:/foo/bar/baz.tst')
AssertEqual 'c:\foo\bar\baz.tst', ale#path#FromURI('file:/c:/foo/bar/baz.tst')
AssertEqual 'C:\foo\bar\baz.tst', ale#path#FromURI('FILE:///C:/foo/bar/baz.tst')
AssertEqual 'C:\foo\bar\baz.tst', ale#path#FromURI('FILE:/C:/foo/bar/baz.tst')
AssertEqual 'C:\foo\bar\baz.tst', ale#path#FromFileURI('file:///C:/foo/bar/baz.tst')
AssertEqual 'C:\foo\bar\baz.tst', ale#path#FromFileURI('file:/C:/foo/bar/baz.tst')
AssertEqual 'c:\foo\bar\baz.tst', ale#path#FromFileURI('file:///c:/foo/bar/baz.tst')
AssertEqual 'c:\foo\bar\baz.tst', ale#path#FromFileURI('file:/c:/foo/bar/baz.tst')
AssertEqual 'C:\foo\bar\baz.tst', ale#path#FromFileURI('FILE:///C:/foo/bar/baz.tst')
AssertEqual 'C:\foo\bar\baz.tst', ale#path#FromFileURI('FILE:/C:/foo/bar/baz.tst')
else
AssertEqual '/C:/foo/bar/baz.tst', ale#path#FromURI('file:///C:/foo/bar/baz.tst')
AssertEqual '/C:/foo/bar/baz.tst', ale#path#FromURI('file:/C:/foo/bar/baz.tst')
AssertEqual '/c:/foo/bar/baz.tst', ale#path#FromURI('file:///c:/foo/bar/baz.tst')
AssertEqual '/c:/foo/bar/baz.tst', ale#path#FromURI('file:/c:/foo/bar/baz.tst')
AssertEqual '/C:/foo/bar/baz.tst', ale#path#FromURI('FILE:///C:/foo/bar/baz.tst')
AssertEqual '/C:/foo/bar/baz.tst', ale#path#FromURI('FILE:/C:/foo/bar/baz.tst')
AssertEqual '/C:/foo/bar/baz.tst', ale#path#FromFileURI('file:///C:/foo/bar/baz.tst')
AssertEqual '/C:/foo/bar/baz.tst', ale#path#FromFileURI('file:/C:/foo/bar/baz.tst')
AssertEqual '/c:/foo/bar/baz.tst', ale#path#FromFileURI('file:///c:/foo/bar/baz.tst')
AssertEqual '/c:/foo/bar/baz.tst', ale#path#FromFileURI('file:/c:/foo/bar/baz.tst')
AssertEqual '/C:/foo/bar/baz.tst', ale#path#FromFileURI('FILE:///C:/foo/bar/baz.tst')
AssertEqual '/C:/foo/bar/baz.tst', ale#path#FromFileURI('FILE:/C:/foo/bar/baz.tst')
endif
Execute(ale#path#FromURI parse Windows paths with a pipe):
Execute(ale#path#FromFileURI parse Windows paths with a pipe):
if has('win32')
AssertEqual 'C:\foo\bar\baz.tst', ale#path#FromURI('file:///C|/foo/bar/baz.tst')
AssertEqual 'C:\foo\bar\baz.tst', ale#path#FromURI('file:/C|/foo/bar/baz.tst')
AssertEqual 'c:\foo\bar\baz.tst', ale#path#FromURI('file:///c|/foo/bar/baz.tst')
AssertEqual 'c:\foo\bar\baz.tst', ale#path#FromURI('file:/c|/foo/bar/baz.tst')
AssertEqual 'C:\foo\bar\baz.tst', ale#path#FromURI('FILE:///C|/foo/bar/baz.tst')
AssertEqual 'C:\foo\bar\baz.tst', ale#path#FromURI('FILE:/C|/foo/bar/baz.tst')
AssertEqual 'C:\foo\bar\baz.tst', ale#path#FromFileURI('file:///C|/foo/bar/baz.tst')
AssertEqual 'C:\foo\bar\baz.tst', ale#path#FromFileURI('file:/C|/foo/bar/baz.tst')
AssertEqual 'c:\foo\bar\baz.tst', ale#path#FromFileURI('file:///c|/foo/bar/baz.tst')
AssertEqual 'c:\foo\bar\baz.tst', ale#path#FromFileURI('file:/c|/foo/bar/baz.tst')
AssertEqual 'C:\foo\bar\baz.tst', ale#path#FromFileURI('FILE:///C|/foo/bar/baz.tst')
AssertEqual 'C:\foo\bar\baz.tst', ale#path#FromFileURI('FILE:/C|/foo/bar/baz.tst')
else
AssertEqual '/C|/foo/bar/baz.tst', ale#path#FromURI('file:///C|/foo/bar/baz.tst')
AssertEqual '/C|/foo/bar/baz.tst', ale#path#FromURI('file:/C|/foo/bar/baz.tst')
AssertEqual '/c|/foo/bar/baz.tst', ale#path#FromURI('file:///c|/foo/bar/baz.tst')
AssertEqual '/c|/foo/bar/baz.tst', ale#path#FromURI('file:/c|/foo/bar/baz.tst')
AssertEqual '/C|/foo/bar/baz.tst', ale#path#FromURI('FILE:///C|/foo/bar/baz.tst')
AssertEqual '/C|/foo/bar/baz.tst', ale#path#FromURI('FILE:/C|/foo/bar/baz.tst')
AssertEqual '/C|/foo/bar/baz.tst', ale#path#FromFileURI('file:///C|/foo/bar/baz.tst')
AssertEqual '/C|/foo/bar/baz.tst', ale#path#FromFileURI('file:/C|/foo/bar/baz.tst')
AssertEqual '/c|/foo/bar/baz.tst', ale#path#FromFileURI('file:///c|/foo/bar/baz.tst')
AssertEqual '/c|/foo/bar/baz.tst', ale#path#FromFileURI('file:/c|/foo/bar/baz.tst')
AssertEqual '/C|/foo/bar/baz.tst', ale#path#FromFileURI('FILE:///C|/foo/bar/baz.tst')
AssertEqual '/C|/foo/bar/baz.tst', ale#path#FromFileURI('FILE:/C|/foo/bar/baz.tst')
endif
Execute(ale#path#FromURI should handle the colon for the drive letter being encoded):
Execute(ale#path#FromFileURI should handle the colon for the drive letter being encoded):
" These URIs shouldn't be created, but we'll handle them anyway.
if has('win32')
AssertEqual 'C:\foo\bar\baz.tst', ale#path#FromURI('file:///C%3A/foo/bar/baz.tst')
AssertEqual 'C:\foo\bar\baz.tst', ale#path#FromFileURI('file:///C%3A/foo/bar/baz.tst')
else
AssertEqual '/C:/foo/bar/baz.tst', ale#path#FromURI('file:///C%3A/foo/bar/baz.tst')
AssertEqual '/C:/foo/bar/baz.tst', ale#path#FromFileURI('file:///C%3A/foo/bar/baz.tst')
endif
Execute(ale#path#ToURI should work for Unix paths):
AssertEqual 'file:///foo/bar/baz.tst', ale#path#ToURI('/foo/bar/baz.tst')
AssertEqual 'foo/bar/baz.tst', ale#path#ToURI('foo/bar/baz.tst')
Execute(ale#path#ToFileURI should work for Unix paths):
AssertEqual 'file:///foo/bar/baz.tst', ale#path#ToFileURI('/foo/bar/baz.tst')
AssertEqual 'foo/bar/baz.tst', ale#path#ToFileURI('foo/bar/baz.tst')
Execute(ale#path#ToURI should keep safe characters):
AssertEqual '//a-zA-Z0-9$-_.!*''(),', ale#path#ToURI('\/a-zA-Z0-9$-_.!*''(),')
Execute(ale#path#ToFileURI should keep safe characters):
AssertEqual '//a-zA-Z0-9$-_.!*''(),', ale#path#ToFileURI('\/a-zA-Z0-9$-_.!*''(),')
Execute(ale#path#ToURI should percent encode unsafe characters):
AssertEqual '%20%2b%3a%3f%26%3d', ale#path#ToURI(' +:?&=')
Execute(ale#path#ToFileURI should percent encode unsafe characters):
AssertEqual '%20%2b%3a%3f%26%3d', ale#path#ToFileURI(' +:?&=')
Execute(ale#path#FromURI should decode percent encodings):
AssertEqual ' +:?&=', ale#path#FromURI('%20%2b%3a%3f%26%3d')
Execute(ale#path#FromFileURI should decode percent encodings):
AssertEqual ' +:?&=', ale#path#FromFileURI('%20%2b%3a%3f%26%3d')
Execute(ale#path#ToURI should handle UTF-8):
AssertEqual 'file:///T%c3%a9l%c3%a9chargement', ale#path#ToURI('/Téléchargement')
Execute(ale#path#ToFileURI should handle UTF-8):
AssertEqual 'file:///T%c3%a9l%c3%a9chargement', ale#path#ToFileURI('/Téléchargement')
Execute(ale#path#FromURI should handle UTF-8):
AssertEqual '/Téléchargement', ale#path#FromURI('file:///T%C3%A9l%C3%A9chargement')
Execute(ale#path#FromFileURI should handle UTF-8):
AssertEqual '/Téléchargement', ale#path#FromFileURI('file:///T%C3%A9l%C3%A9chargement')

View File

@ -487,13 +487,13 @@ Execute(LSP rename requests should be sent):
\ [
\ [1, 'textDocument/didChange', {
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('%:p')),
\ 'uri': ale#path#ToFileURI(expand('%:p')),
\ 'version': g:ale_lsp_next_version_id - 1,
\ },
\ 'contentChanges': [{'text': join(getline(1, '$'), "\n") . "\n"}]
\ }],
\ [0, 'textDocument/rename', {
\ 'textDocument': {'uri': ale#path#ToURI(expand('%:p'))},
\ 'textDocument': {'uri': ale#path#ToFileURI(expand('%:p'))},
\ 'position': {'line': 0, 'character': 2},
\ 'newName': 'a-new-name',
\ }],

View File

@ -94,7 +94,7 @@ Execute(LSP symbol responses should be handled):
\ {
\ 'name': 'foo',
\ 'location': {
\ 'uri': ale#path#ToURI(ale#path#Simplify(g:dir . '/completion_dummy_file')),
\ 'uri': ale#path#ToFileURI(ale#path#Simplify(g:dir . '/completion_dummy_file')),
\ 'range': {
\ 'start': {'line': 2, 'character': 7},
\ },
@ -103,7 +103,7 @@ Execute(LSP symbol responses should be handled):
\ {
\ 'name': 'foobar',
\ 'location': {
\ 'uri': ale#path#ToURI(ale#path#Simplify(g:dir . '/other_file')),
\ 'uri': ale#path#ToFileURI(ale#path#Simplify(g:dir . '/other_file')),
\ 'range': {
\ 'start': {'line': 7, 'character': 15},
\ },