mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-28 23:06:51 +08:00
Fix #825 - Downgrade signs when problems change
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
Execute (Parsing English signs should work):
|
||||
AssertEqual
|
||||
\ [[9, 1000001, 'ALEWarningSign']],
|
||||
\ [0, [[9, 1000001, 'ALEWarningSign']]],
|
||||
\ ale#sign#ParseSigns([
|
||||
\ 'Signs for app.js:',
|
||||
\ ' line=9 id=1000001 name=ALEWarningSign',
|
||||
@@ -8,20 +8,28 @@ Execute (Parsing English signs should work):
|
||||
|
||||
Execute (Parsing Russian signs should work):
|
||||
AssertEqual
|
||||
\ [[1, 1000001, 'ALEErrorSign']],
|
||||
\ [0, [[1, 1000001, 'ALEErrorSign']]],
|
||||
\ ale#sign#ParseSigns([' строка=1 id=1000001 имя=ALEErrorSign'])
|
||||
|
||||
Execute (Parsing Japanese signs should work):
|
||||
AssertEqual
|
||||
\ [[1, 1000001, 'ALEWarningSign']],
|
||||
\ [0, [[1, 1000001, 'ALEWarningSign']]],
|
||||
\ ale#sign#ParseSigns([' 行=1 識別子=1000001 名前=ALEWarningSign'])
|
||||
|
||||
Execute (Parsing Spanish signs should work):
|
||||
AssertEqual
|
||||
\ [[12, 1000001, 'ALEWarningSign']],
|
||||
\ [0, [[12, 1000001, 'ALEWarningSign']]],
|
||||
\ ale#sign#ParseSigns([' línea=12 id=1000001 nombre=ALEWarningSign'])
|
||||
|
||||
Execute (Parsing Italian signs should work):
|
||||
AssertEqual
|
||||
\ [[1, 1000001, 'ALEWarningSign']],
|
||||
\ [0, [[1, 1000001, 'ALEWarningSign']]],
|
||||
\ ale#sign#ParseSigns([' riga=1 id=1000001, nome=ALEWarningSign'])
|
||||
\
|
||||
Execute (The sign parser should indicate if the dummy sign is set):
|
||||
AssertEqual
|
||||
\ [1, [[1, 1000001, 'ALEErrorSign']]],
|
||||
\ ale#sign#ParseSigns([
|
||||
\ ' строка=1 id=1000001 имя=ALEErrorSign',
|
||||
\ ' line=1 id=1000000 name=ALEDummySign',
|
||||
\ ])
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
Before:
|
||||
Save g:ale_set_signs
|
||||
|
||||
let g:ale_set_signs = 1
|
||||
|
||||
function! GenerateResults(buffer, output)
|
||||
return [
|
||||
\ {
|
||||
@@ -65,41 +69,43 @@ Before:
|
||||
\})
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
unlet! g:loclist
|
||||
delfunction GenerateResults
|
||||
delfunction ParseSigns
|
||||
call ale#linter#Reset()
|
||||
sign unplace *
|
||||
|
||||
Execute(ale#sign#GetSignType should return the right sign types):
|
||||
AssertEqual 'ALEErrorSign', ale#sign#GetSignType([{'type': 'E'}])
|
||||
AssertEqual 'ALEStyleErrorSign', ale#sign#GetSignType([{'type': 'E', 'sub_type': 'style'}])
|
||||
AssertEqual 'ALEWarningSign', ale#sign#GetSignType([{'type': 'W'}])
|
||||
AssertEqual 'ALEStyleWarningSign', ale#sign#GetSignType([{'type': 'W', 'sub_type': 'style'}])
|
||||
AssertEqual 'ALEInfoSign', ale#sign#GetSignType([{'type': 'I'}])
|
||||
AssertEqual 'ALEErrorSign', ale#sign#GetSignType([
|
||||
Execute(ale#sign#GetSignName should return the right sign names):
|
||||
AssertEqual 'ALEErrorSign', ale#sign#GetSignName([{'type': 'E'}])
|
||||
AssertEqual 'ALEStyleErrorSign', ale#sign#GetSignName([{'type': 'E', 'sub_type': 'style'}])
|
||||
AssertEqual 'ALEWarningSign', ale#sign#GetSignName([{'type': 'W'}])
|
||||
AssertEqual 'ALEStyleWarningSign', ale#sign#GetSignName([{'type': 'W', 'sub_type': 'style'}])
|
||||
AssertEqual 'ALEInfoSign', ale#sign#GetSignName([{'type': 'I'}])
|
||||
AssertEqual 'ALEErrorSign', ale#sign#GetSignName([
|
||||
\ {'type': 'E'},
|
||||
\ {'type': 'W'},
|
||||
\ {'type': 'I'},
|
||||
\ {'type': 'E', 'sub_type': 'style'},
|
||||
\ {'type': 'W', 'sub_type': 'style'},
|
||||
\])
|
||||
AssertEqual 'ALEWarningSign', ale#sign#GetSignType([
|
||||
AssertEqual 'ALEWarningSign', ale#sign#GetSignName([
|
||||
\ {'type': 'W'},
|
||||
\ {'type': 'I'},
|
||||
\ {'type': 'E', 'sub_type': 'style'},
|
||||
\ {'type': 'W', 'sub_type': 'style'},
|
||||
\])
|
||||
AssertEqual 'ALEInfoSign', ale#sign#GetSignType([
|
||||
AssertEqual 'ALEInfoSign', ale#sign#GetSignName([
|
||||
\ {'type': 'I'},
|
||||
\ {'type': 'E', 'sub_type': 'style'},
|
||||
\ {'type': 'W', 'sub_type': 'style'},
|
||||
\])
|
||||
AssertEqual 'ALEStyleErrorSign', ale#sign#GetSignType([
|
||||
AssertEqual 'ALEStyleErrorSign', ale#sign#GetSignName([
|
||||
\ {'type': 'E', 'sub_type': 'style'},
|
||||
\ {'type': 'W', 'sub_type': 'style'},
|
||||
\])
|
||||
AssertEqual 'ALEStyleWarningSign', ale#sign#GetSignType([
|
||||
AssertEqual 'ALEStyleWarningSign', ale#sign#GetSignName([
|
||||
\ {'type': 'W', 'sub_type': 'style'},
|
||||
\])
|
||||
|
||||
@@ -125,9 +131,9 @@ Execute(The current signs should be set for running a job):
|
||||
\ ParseSigns()
|
||||
|
||||
Execute(Loclist items with sign_id values should be kept):
|
||||
exec 'sign place 1000347 line=3 name=ALEErrorSign buffer=' . bufnr('%')
|
||||
exec 'sign place 1000348 line=15 name=ALEErrorSign buffer=' . bufnr('%')
|
||||
exec 'sign place 1000349 line=16 name=ALEWarningSign buffer=' . bufnr('%')
|
||||
exec 'sign place 1000347 line=3 name=ALEErrorSign buffer=' . bufnr('')
|
||||
exec 'sign place 1000348 line=15 name=ALEErrorSign buffer=' . bufnr('')
|
||||
exec 'sign place 1000349 line=16 name=ALEWarningSign buffer=' . bufnr('')
|
||||
|
||||
let g:loclist = [
|
||||
\ {'bufnr': bufnr(''), 'lnum': 1, 'col': 1, 'type': 'E', 'text': 'a', 'sign_id': 1000348},
|
||||
@@ -138,8 +144,7 @@ Execute(Loclist items with sign_id values should be kept):
|
||||
\ {'bufnr': bufnr(''), 'lnum': 16, 'col': 2, 'type': 'E', 'text': 'f'},
|
||||
\]
|
||||
|
||||
call ale#sign#SetSigns(bufnr('%'), g:loclist)
|
||||
call ale#sign#RemoveDummySignIfNeeded(bufnr('%'))
|
||||
call ale#sign#SetSigns(bufnr(''), g:loclist)
|
||||
|
||||
" Sign IDs from before should be kept, and new signs should use
|
||||
" IDs that haven't been used yet.
|
||||
@@ -147,10 +152,10 @@ Execute(Loclist items with sign_id values should be kept):
|
||||
\ [
|
||||
\ {'bufnr': bufnr(''), 'lnum': 3, 'col': 1, 'type': 'E', 'text': 'c', 'sign_id': 1000347},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 4, 'col': 1, 'type': 'W', 'text': 'd', 'sign_id': 1000350},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 15, 'col': 1, 'type': 'E', 'text': 'a', 'sign_id': 1000351},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e', 'sign_id': 1000351},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 16, 'col': 1, 'type': 'W', 'text': 'b', 'sign_id': 1000352},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 16, 'col': 2, 'type': 'E', 'text': 'f', 'sign_id': 1000352},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 15, 'col': 1, 'type': 'E', 'text': 'a', 'sign_id': 1000348},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e', 'sign_id': 1000348},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 16, 'col': 1, 'type': 'W', 'text': 'b', 'sign_id': 1000351},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 16, 'col': 2, 'type': 'E', 'text': 'f', 'sign_id': 1000351},
|
||||
\ ],
|
||||
\ g:loclist
|
||||
|
||||
@@ -160,9 +165,7 @@ Execute(Loclist items with sign_id values should be kept):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ ['15', '1000348', 'ALEErrorSign'],
|
||||
\ ['15', '1000351', 'ALEErrorSign'],
|
||||
\ ['16', '1000349', 'ALEWarningSign'],
|
||||
\ ['16', '1000352', 'ALEErrorSign'],
|
||||
\ ['16', '1000351', 'ALEErrorSign'],
|
||||
\ ['3', '1000347', 'ALEErrorSign'],
|
||||
\ ['4', '1000350', 'ALEWarningSign'],
|
||||
\ ],
|
||||
@@ -182,7 +185,6 @@ Execute(Items for other buffers should be ignored):
|
||||
\]
|
||||
|
||||
call ale#sign#SetSigns(bufnr(''), g:loclist)
|
||||
call ale#sign#RemoveDummySignIfNeeded(bufnr(''))
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
@@ -195,5 +197,72 @@ Execute(Items for other buffers should be ignored):
|
||||
\ ],
|
||||
\ sort(ParseSigns())
|
||||
|
||||
Execute(No excpetions should be thrown when setting signs for invalid buffers):
|
||||
Execute(Signs should be downgraded correctly):
|
||||
call ale#sign#SetSigns(bufnr(''), [
|
||||
\ {'bufnr': bufnr(''), 'lnum': 1, 'col': 1, 'type': 'E', 'text': 'x'},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 2, 'col': 1, 'type': 'W', 'text': 'x'},
|
||||
\])
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ ['1', '1000001', 'ALEErrorSign'],
|
||||
\ ['2', '1000002', 'ALEWarningSign'],
|
||||
\ ],
|
||||
\ sort(ParseSigns())
|
||||
|
||||
call ale#sign#SetSigns(bufnr(''), [
|
||||
\ {'bufnr': bufnr(''), 'lnum': 1, 'col': 1, 'type': 'W', 'text': 'x'},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 2, 'col': 1, 'type': 'I', 'text': 'x'},
|
||||
\])
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ ['1', '1000003', 'ALEWarningSign'],
|
||||
\ ['2', '1000004', 'ALEInfoSign'],
|
||||
\ ],
|
||||
\ sort(ParseSigns())
|
||||
|
||||
Execute(Signs should be upgraded correctly):
|
||||
call ale#sign#SetSigns(bufnr(''), [
|
||||
\ {'bufnr': bufnr(''), 'lnum': 1, 'col': 1, 'type': 'W', 'text': 'x'},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 2, 'col': 1, 'type': 'I', 'text': 'x'},
|
||||
\])
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ ['1', '1000001', 'ALEWarningSign'],
|
||||
\ ['2', '1000002', 'ALEInfoSign'],
|
||||
\ ],
|
||||
\ sort(ParseSigns())
|
||||
|
||||
call ale#sign#SetSigns(bufnr(''), [
|
||||
\ {'bufnr': bufnr(''), 'lnum': 1, 'col': 1, 'type': 'E', 'text': 'x'},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 2, 'col': 1, 'type': 'W', 'text': 'x'},
|
||||
\])
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ ['1', '1000003', 'ALEErrorSign'],
|
||||
\ ['2', '1000004', 'ALEWarningSign'],
|
||||
\ ],
|
||||
\ sort(ParseSigns())
|
||||
|
||||
Execute(It should be possible to clear signs with empty lists):
|
||||
let g:loclist = [
|
||||
\ {'bufnr': bufnr(''), 'lnum': 16, 'col': 2, 'type': 'E', 'text': 'f'},
|
||||
\]
|
||||
|
||||
call ale#sign#SetSigns(bufnr(''), g:loclist)
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ ['16', '1000001', 'ALEErrorSign'],
|
||||
\ ],
|
||||
\ sort(ParseSigns())
|
||||
|
||||
call ale#sign#SetSigns(bufnr(''), [])
|
||||
|
||||
AssertEqual [], ParseSigns()
|
||||
|
||||
Execute(No exceptions should be thrown when setting signs for invalid buffers):
|
||||
call ale#sign#SetSigns(123456789, [{'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e'}])
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
Before:
|
||||
Save g:ale_buffer_info
|
||||
Save g:ale_set_signs
|
||||
Save g:ale_set_lists_synchronously
|
||||
|
||||
let g:ale_set_signs = 1
|
||||
let g:ale_set_lists_synchronously = 1
|
||||
|
||||
let g:ale_buffer_info = {}
|
||||
let g:expected_loclist = [{
|
||||
@@ -67,6 +72,8 @@ Before:
|
||||
\ 'read_buffer': 0,
|
||||
\})
|
||||
|
||||
sign unplace *
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
@@ -96,7 +103,7 @@ Execute(ALEToggle should reset everything and then run again):
|
||||
|
||||
" First check that everything is there...
|
||||
AssertEqual g:expected_loclist, getloclist(0)
|
||||
AssertEqual [[2, 1000001, 'ALEErrorSign']], ale#sign#FindCurrentSigns(bufnr('%'))
|
||||
AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%'))
|
||||
AssertEqual
|
||||
\ [{'group': 'ALEError', 'pos1': [2, 3, 1]}],
|
||||
\ map(getmatches(), '{''group'': v:val.group, ''pos1'': v:val.pos1}')
|
||||
@@ -109,7 +116,7 @@ Execute(ALEToggle should reset everything and then run again):
|
||||
" Everything should be cleared.
|
||||
Assert !has_key(g:ale_buffer_info, bufnr('')), 'The g:ale_buffer_info Dictionary was not removed'
|
||||
AssertEqual [], getloclist(0), 'The loclist was not cleared'
|
||||
AssertEqual [], ale#sign#FindCurrentSigns(bufnr('%')), 'The signs were not cleared'
|
||||
AssertEqual [0, []], ale#sign#FindCurrentSigns(bufnr('%')), 'The signs were not cleared'
|
||||
AssertEqual [], getmatches(), 'The highlights were not cleared'
|
||||
AssertEqual ['ALECleanupGroup', 'ALEHighlightBufferGroup'], ParseAuGroups()
|
||||
|
||||
@@ -118,7 +125,7 @@ Execute(ALEToggle should reset everything and then run again):
|
||||
call ale#engine#WaitForJobs(2000)
|
||||
|
||||
AssertEqual g:expected_loclist, getloclist(0)
|
||||
AssertEqual [[2, 1000001, 'ALEErrorSign']], ale#sign#FindCurrentSigns(bufnr('%'))
|
||||
AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%'))
|
||||
AssertEqual
|
||||
\ [{'group': 'ALEError', 'pos1': [2, 3, 1]}],
|
||||
\ map(getmatches(), '{''group'': v:val.group, ''pos1'': v:val.pos1}')
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
Before:
|
||||
Save g:ale_set_signs
|
||||
let g:ale_set_signs = 1
|
||||
|
||||
let g:expected_data = [
|
||||
\ {
|
||||
\ 'lnum': 1,
|
||||
@@ -49,7 +52,11 @@ Before:
|
||||
\ 'read_buffer': 0,
|
||||
\})
|
||||
|
||||
sign unplace *
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
delfunction TestCallback
|
||||
|
||||
unlet! g:expected_data
|
||||
|
||||
Reference in New Issue
Block a user