mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-30 14:45:29 +08:00
Close #3333 - Add an ALECompletePost event
Add an `ALECompletePost` event along with everything needed to make it useful for its primary purpose: fixing code after inserting completions. * `ALEFix` can now be called with a bang (`!`) to suppress errors. * A new `ALELintStop` command lets you stop linting, and start it later.
This commit is contained in:
@@ -407,41 +407,75 @@ Execute(HandleUserData should call ale#code_action#HandleCodeAction):
|
||||
AssertEqual g:handle_code_action_called, 0
|
||||
|
||||
call ale#completion#HandleUserData({
|
||||
\ 'user_data': ''
|
||||
\ 'user_data': ''
|
||||
\})
|
||||
AssertEqual g:handle_code_action_called, 0
|
||||
|
||||
call ale#completion#HandleUserData({
|
||||
\ 'user_data': '{}'
|
||||
\ 'user_data': json_encode({}),
|
||||
\})
|
||||
AssertEqual g:handle_code_action_called, 0
|
||||
|
||||
call ale#completion#HandleUserData({
|
||||
\ 'user_data': '{"codeActions": []}'
|
||||
\ 'user_data': json_encode({
|
||||
\ '_ale_completion_item': 1,
|
||||
\ 'code_actions': [],
|
||||
\ }),
|
||||
\})
|
||||
AssertEqual g:handle_code_action_called, 0
|
||||
|
||||
call ale#completion#HandleUserData({
|
||||
\ 'user_data': '{"codeActions": [{"description":"", "changes": []}]}'
|
||||
\ 'user_data': json_encode({
|
||||
\ '_ale_completion_item': 1,
|
||||
\ 'code_actions': [
|
||||
\ {'description': '', 'changes': []},
|
||||
\ ],
|
||||
\ }),
|
||||
\})
|
||||
AssertEqual g:handle_code_action_called, 1
|
||||
|
||||
let b:ale_completion_info = {'source': 'ale-automatic'}
|
||||
call ale#completion#HandleUserData({
|
||||
\ 'user_data': '{"codeActions": [{"description":"", "changes": []}]}'
|
||||
\ 'user_data': json_encode({
|
||||
\ '_ale_completion_item': 1,
|
||||
\ 'code_actions': [
|
||||
\ {'description': '', 'changes': []},
|
||||
\ ],
|
||||
\ }),
|
||||
\})
|
||||
AssertEqual g:handle_code_action_called, 2
|
||||
|
||||
let b:ale_completion_info = {'source': 'ale-callback'}
|
||||
call ale#completion#HandleUserData({
|
||||
\ 'user_data': '{"codeActions": [{"description":"", "changes": []}]}'
|
||||
\ 'user_data': json_encode({
|
||||
\ '_ale_completion_item': 1,
|
||||
\ 'code_actions': [
|
||||
\ {'description': '', 'changes': []},
|
||||
\ ],
|
||||
\ }),
|
||||
\})
|
||||
AssertEqual g:handle_code_action_called, 3
|
||||
|
||||
let b:ale_completion_info = {'source': 'ale-omnifunc'}
|
||||
call ale#completion#HandleUserData({
|
||||
\ 'user_data': json_encode({
|
||||
\ '_ale_completion_item': 1,
|
||||
\ 'code_actions': [
|
||||
\ {'description': '', 'changes': []},
|
||||
\ ],
|
||||
\ }),
|
||||
\})
|
||||
AssertEqual g:handle_code_action_called, 4
|
||||
|
||||
Execute(ale#code_action#HandleCodeAction should not be called when when source is not ALE):
|
||||
call MockHandleCodeAction()
|
||||
let b:ale_completion_info = {'source': 'syntastic'}
|
||||
call ale#completion#HandleUserData({
|
||||
\ 'user_data': '{"codeActions": [{"description":"", "changes": []}]}'
|
||||
\ 'user_data': json_encode({
|
||||
\ '_ale_completion_item': 1,
|
||||
\ 'code_actions': [
|
||||
\ {'description': '', 'changes': []},
|
||||
\ ],
|
||||
\ }),
|
||||
\})
|
||||
AssertEqual g:handle_code_action_called, 0
|
||||
|
||||
Reference in New Issue
Block a user