mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-16 01:07:06 +08:00
Fix mcsc paths and escaping for Windows
This commit is contained in:
@@ -1,55 +1,47 @@
|
||||
" general mcs options which are likely to stay constant across
|
||||
" source trees like -pkg:dotnet
|
||||
let g:ale_cs_mcsc_options = get(g:, 'ale_cs_mcsc_options', '')
|
||||
call ale#Set('cs_mcsc_options', '')
|
||||
call ale#Set('cs_mcsc_source', '')
|
||||
call ale#Set('cs_mcsc_assembly_path', [])
|
||||
call ale#Set('cs_mcsc_assemblies', [])
|
||||
|
||||
" path string pointing the linter to the base path of the
|
||||
" source tree to check
|
||||
let g:ale_cs_mcsc_source = get(g:, 'ale_cs_mcsc_source','.')
|
||||
function! s:GetWorkingDirectory(buffer) abort
|
||||
let l:working_directory = ale#Var(a:buffer, 'cs_mcsc_source')
|
||||
|
||||
" list of search paths for additional assemblies to consider
|
||||
let g:ale_cs_mcsc_assembly_path = get(g:, 'ale_cs_mcsc_assembly_path',[])
|
||||
if !empty(l:working_directory)
|
||||
return l:working_directory
|
||||
endif
|
||||
|
||||
return fnamemodify(bufname(a:buffer), ':p:h')
|
||||
endfunction
|
||||
|
||||
" list of assemblies to consider
|
||||
let g:ale_cs_mcsc_assemblies = get(g:, 'ale_cs_mcsc_assemblies',[])
|
||||
function! ale_linters#cs#mcsc#GetCommand(buffer) abort
|
||||
" Pass assembly paths via the -lib: parameter.
|
||||
let l:path_list = ale#Var(a:buffer, 'cs_mcsc_assembly_path')
|
||||
|
||||
" if list of assembly search paths is not empty convert it to
|
||||
" appropriate -lib: parameter of mcs
|
||||
let l:path = ale#Var(a:buffer, 'cs_mcsc_assembly_path')
|
||||
let l:lib_option = !empty(l:path_list)
|
||||
\ ? '-lib:' . join(map(copy(l:path_list), 'ale#Escape(v:val)'), ',')
|
||||
\ : ''
|
||||
|
||||
if !empty(l:path)
|
||||
let l:path = '-lib:"' . join(l:path, '","') .'"'
|
||||
else
|
||||
let l:path =''
|
||||
endif
|
||||
" Pass paths to DLL files via the -r: parameter.
|
||||
let l:assembly_list = ale#Var(a:buffer, 'cs_mcsc_assemblies')
|
||||
|
||||
" if list of assemblies to link is not empty convert it to the
|
||||
" appropriate -r: parameter of mcs
|
||||
let l:assemblies = ale#Var(a:buffer, 'cs_mcsc_assemblies')
|
||||
|
||||
if !empty(l:assemblies)
|
||||
let l:assemblies = '-r:"' . join(l:assemblies, '","') . '"'
|
||||
else
|
||||
let l:assemblies =''
|
||||
endif
|
||||
let l:r_option = !empty(l:assembly_list)
|
||||
\ ? '-r:' . join(map(copy(l:assembly_list), 'ale#Escape(v:val)'), ',')
|
||||
\ : ''
|
||||
|
||||
" register temporary module target file with ale
|
||||
let l:out = tempname()
|
||||
call ale#engine#ManageFile(a:buffer, l:out)
|
||||
|
||||
" assemble linter command string to be executed by ale
|
||||
" implicitly set -unsafe mcs flag set compilation
|
||||
" target to module (-t:module), direct mcs output to
|
||||
" temporary file (-out)
|
||||
"
|
||||
return 'cd "' . ale#Var(a:buffer, 'cs_mcsc_source') . '";'
|
||||
" The code is compiled as a module and the output is redirected to a
|
||||
" temporary file.
|
||||
return ale#path#CdString(s:GetWorkingDirectory(a:buffer))
|
||||
\ . 'mcs -unsafe'
|
||||
\ . ' ' . ale#Var(a:buffer, 'cs_mcsc_options')
|
||||
\ . ' ' . l:path
|
||||
\ . ' ' . l:assemblies
|
||||
\ . ' ' . l:lib_option
|
||||
\ . ' ' . l:r_option
|
||||
\ . ' -out:' . l:out
|
||||
\ . ' -t:module'
|
||||
\ . ' -recurse:"*.cs"'
|
||||
\ . ' -recurse:' . ale#Escape('*.cs')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#cs#mcsc#Handle(buffer, lines) abort
|
||||
@@ -62,11 +54,12 @@ function! ale_linters#cs#mcsc#Handle(buffer, lines) abort
|
||||
" path and not just the file loaded in the buffer
|
||||
let l:pattern = '^\v(.+\.cs)\((\d+),(\d+)\)\: ([^ ]+) ([^ ]+): (.+)$'
|
||||
let l:output = []
|
||||
let l:source = ale#Var(a:buffer, 'cs_mcsc_source')
|
||||
|
||||
let l:dir = s:GetWorkingDirectory(a:buffer)
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
call add(l:output, {
|
||||
\ 'filename': fnamemodify(l:source . '/' . l:match[1], ':p'),
|
||||
\ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]),
|
||||
\ 'lnum': l:match[2] + 0,
|
||||
\ 'col': l:match[3] + 0,
|
||||
\ 'type': l:match[4] is# 'error' ? 'E' : 'W',
|
||||
|
||||
Reference in New Issue
Block a user