diff --git a/doc/quickfix.jax b/doc/quickfix.jax index c8ddee3d8..a4461413b 100644 --- a/doc/quickfix.jax +++ b/doc/quickfix.jax @@ -1,4 +1,4 @@ -*quickfix.txt* For Vim バージョン 9.1. Last change: 2024 Dec 16 +*quickfix.txt* For Vim バージョン 9.1. Last change: 2024 Dec 27 VIMリファレンスマニュアル by Bram Moolenaar @@ -1374,6 +1374,70 @@ Vim コマンドは 'makeprg' [0] に習熟していると、デフォルトア \ function('GenericPostCompilerCommand'), \ } +"PostCompilerAction" が利用可能な場合、"PostCompilerActionExecutor" もサポート +される。その値は、常に文字列型の単一のパラメータを宣言し、|:cc| (または |:ll|) +の現在のステータスを確認した後、保留中のポストコンパイラアクションを含む +|:execute| をその引数にディスパッチできるかどうかを決定する関数を指す Funcref +である必要がある: >vim + + function! GenericPostCompilerActionExecutor(action) abort + try + cc + catch /\vim + function! GenericPreCompilerCommand(arguments) abort + if !exists('g:spotbugs_compilation_done') + doautocmd java_spotbugs_post User + execute 'make ' . a:arguments + " :make が同期している場合にのみ doautocmd を実行する。 + " 下記の注記を参照 + doautocmd java_spotbugs_post ShellCmdPost " XXX: (a) + let g:spotbugs_compilation_done = 1 + else + cc + endif + endfunction + + function! GenericPreCompilerTestCommand(arguments) abort + if !exists('g:spotbugs_test_compilation_done') + doautocmd java_spotbugs_post User + execute 'make ' . a:arguments + " :make が同期している場合にのみ doautocmd を実行する。 + " 下記の注記を参照 + doautocmd java_spotbugs_post ShellCmdPost " XXX: (b) + let g:spotbugs_test_compilation_done = 1 + else + cc + endif + endfunction + + let g:spotbugs_properties = { + \ 'compiler': 'maven', + \ 'DefaultPreCompilerCommand': + \ function('GenericPreCompilerCommand'), + \ 'DefaultPreCompilerTestCommand': + \ function('GenericPreCompilerTestCommand'), + \ 'PostCompilerActionExecutor': + \ function('GenericPostCompilerActionExecutor'), + \ } + +`:make` に相当するコマンドが非同期実行が可能で `ShellCmdPost` イベントを消費で +きる場合、非ブロッキング実行の順序を維持するために +`:doautocmd java_spotbugs_post ShellCmdPost` をそのような "*Action" (または +"*Command") 実装 (つまり、リストされている例の `(a)` と `(b)` の行) から削除 +し、通知 (以下を参照) を抑制する必要がある。 +`ShellCmdPost` `:autocmd` は、その名前を "augroupForPostCompilerAction" キーに +割り当てることで、任意の |:augroup| に関連付けることができる。 + デフォルトのアクションが目的のワークフローに適していない場合は、任意の関数を自 分で記述し、その Funcref をサポートされているキー "PreCompilerAction"、 "PreCompilerTestAction"、および "PostCompilerAction" に一致させて続行する。 diff --git a/en/quickfix.txt b/en/quickfix.txt index 1cd075f3e..b6d79507f 100644 --- a/en/quickfix.txt +++ b/en/quickfix.txt @@ -1,4 +1,4 @@ -*quickfix.txt* For Vim version 9.1. Last change: 2024 Dec 16 +*quickfix.txt* For Vim version 9.1. Last change: 2024 Dec 27 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1424,6 +1424,70 @@ of |:make|, and assigning its |Funcref| to the selected key. For example: \ function('GenericPostCompilerCommand'), \ } +When "PostCompilerAction" is available, "PostCompilerActionExecutor" is also +supported. Its value must be a Funcref pointing to a function that always +declares a single parameter of type string and decides whether |:execute| can +be dispatched on its argument, containing a pending post-compiler action, +after ascertaining the current status of |:cc| (or |:ll|): >vim + + function! GenericPostCompilerActionExecutor(action) abort + try + cc + catch /\vim + + function! GenericPreCompilerCommand(arguments) abort + if !exists('g:spotbugs_compilation_done') + doautocmd java_spotbugs_post User + execute 'make ' . a:arguments + " only run doautocmd when :make was synchronous + " see note below + doautocmd java_spotbugs_post ShellCmdPost " XXX: (a) + let g:spotbugs_compilation_done = 1 + else + cc + endif + endfunction + + function! GenericPreCompilerTestCommand(arguments) abort + if !exists('g:spotbugs_test_compilation_done') + doautocmd java_spotbugs_post User + execute 'make ' . a:arguments + " only run doautocmd when :make was synchronous + " see note below + doautocmd java_spotbugs_post ShellCmdPost " XXX: (b) + let g:spotbugs_test_compilation_done = 1 + else + cc + endif + endfunction + + let g:spotbugs_properties = { + \ 'compiler': 'maven', + \ 'DefaultPreCompilerCommand': + \ function('GenericPreCompilerCommand'), + \ 'DefaultPreCompilerTestCommand': + \ function('GenericPreCompilerTestCommand'), + \ 'PostCompilerActionExecutor': + \ function('GenericPostCompilerActionExecutor'), + \ } + +If a command equivalent of `:make` is capable of asynchronous execution and +consuming `ShellCmdPost` events, `:doautocmd java_spotbugs_post ShellCmdPost` +must be removed from such "*Action" (or "*Command") implementations (i.e. the +lines `(a)` and `(b)` in the listed examples) to retain a sequential order for +non-blocking execution, and any notification (see below) must be suppressed. +A `ShellCmdPost` `:autocmd` can be associated with any |:augroup| by assigning +its name to the "augroupForPostCompilerAction" key. + When default actions are not suited to a desired workflow, proceed by writing arbitrary functions yourself and matching their Funcrefs to the supported keys: "PreCompilerAction", "PreCompilerTestAction", and "PostCompilerAction".