mirror of
https://github.com/dense-analysis/ale.git
synced 2026-02-03 00:22:51 +08:00
Allows to use quickfix for references. (#4033)
* Allows to use quickfix for references. E.g. following mapping could be used to find references for item under cursor and put result into quickfix list: ``` nnoremap <leader>af :ALEFindReferences -quickfix<CR> ``` Fixes #1759 * Documentation update.
This commit is contained in:
committed by
GitHub
parent
a58b7b5efb
commit
0c276aac90
@@ -187,6 +187,57 @@ Execute(Results should be shown for tsserver responses):
|
||||
\ },
|
||||
\ g:options
|
||||
|
||||
Execute(Results should be put to quickfix for tsserver responses):
|
||||
call ale#references#SetMap(
|
||||
\ {
|
||||
\ 3: {
|
||||
\ 'ignorethis': 'x',
|
||||
\ 'open_in': 'quickfix',
|
||||
\ }
|
||||
\ }
|
||||
\)
|
||||
call ale#references#HandleTSServerResponse(1, {
|
||||
\ 'command': 'references',
|
||||
\ 'request_seq': 3,
|
||||
\ 'success': v:true,
|
||||
\ 'body': {
|
||||
\ 'symbolStartOffset': 9,
|
||||
\ 'refs': [
|
||||
\ {
|
||||
\ 'file': '/foo/bar/app.ts',
|
||||
\ 'isWriteAccess': v:true,
|
||||
\ 'lineText': 'import {doSomething} from ''./whatever''',
|
||||
\ 'end': {'offset': 24, 'line': 9},
|
||||
\ 'start': {'offset': 9, 'line': 9},
|
||||
\ 'isDefinition': v:true,
|
||||
\ },
|
||||
\ {
|
||||
\ 'file': '/foo/bar/app.ts',
|
||||
\ 'isWriteAccess': v:false,
|
||||
\ 'lineText': ' doSomething()',
|
||||
\ 'end': {'offset': 18, 'line': 804},
|
||||
\ 'start': {'offset': 3, 'line': 804},
|
||||
\ 'isDefinition': v:false,
|
||||
\ },
|
||||
\ {
|
||||
\ 'file': '/foo/bar/other/app.ts',
|
||||
\ 'isWriteAccess': v:false,
|
||||
\ 'lineText': ' doSomething()',
|
||||
\ 'end': {'offset': 18, 'line': 51},
|
||||
\ 'start': {'offset': 3, 'line': 51},
|
||||
\ 'isDefinition': v:false,
|
||||
\ },
|
||||
\ ],
|
||||
\ 'symbolDisplayString': 'import doSomething',
|
||||
\ 'symbolName': 'doSomething()',
|
||||
\ },
|
||||
\})
|
||||
|
||||
AssertEqual
|
||||
\ 3,
|
||||
\ len(getqflist())
|
||||
AssertEqual {}, ale#references#GetMap()
|
||||
|
||||
Execute(The preview window should not be opened for empty tsserver responses):
|
||||
call ale#references#SetMap({3: {}})
|
||||
call ale#references#HandleTSServerResponse(1, {
|
||||
@@ -283,6 +334,16 @@ Execute(`-vsplit` should display results in vsplits):
|
||||
|
||||
AssertEqual {'42': {'open_in': 'vsplit', 'use_relative_paths': 0}}, ale#references#GetMap()
|
||||
|
||||
Execute(`-quickfix` should display results in quickfix):
|
||||
runtime ale_linters/typescript/tsserver.vim
|
||||
call setpos('.', [bufnr(''), 2, 5, 0])
|
||||
|
||||
ALEFindReferences -quickfix
|
||||
|
||||
call g:InitCallback()
|
||||
|
||||
AssertEqual {'42': {'open_in': 'quickfix', 'use_relative_paths': 0}}, ale#references#GetMap()
|
||||
|
||||
Given python(Some Python file):
|
||||
foo
|
||||
somelongerline
|
||||
@@ -327,6 +388,33 @@ Execute(LSP reference responses should be handled):
|
||||
\ g:item_list
|
||||
AssertEqual {}, ale#references#GetMap()
|
||||
|
||||
Execute(LSP reference responses should be put to quickfix):
|
||||
call ale#references#SetMap({3: { 'open_in': 'quickfix' }})
|
||||
call ale#references#HandleLSPResponse(
|
||||
\ 1,
|
||||
\ {
|
||||
\ 'id': 3,
|
||||
\ 'result': [
|
||||
\ {
|
||||
\ 'uri': ale#path#ToURI(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')),
|
||||
\ 'range': {
|
||||
\ 'start': {'line': 7, 'character': 15},
|
||||
\ },
|
||||
\ },
|
||||
\ ],
|
||||
\ }
|
||||
\)
|
||||
|
||||
AssertEqual
|
||||
\ 2,
|
||||
\ len(getqflist())
|
||||
|
||||
Execute(Preview windows should not be opened for empty LSP reference responses):
|
||||
call ale#references#SetMap({3: {}})
|
||||
call ale#references#HandleLSPResponse(1, {'id': 3, 'result': []})
|
||||
|
||||
Reference in New Issue
Block a user