1
- *quickfix.txt* For Vim version 9.1. Last change: 2024 Nov 28
1
+ *quickfix.txt* For Vim version 9.1. Last change: 2024 Dec 16
2
2
3
3
4
4
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1349,7 +1349,7 @@ It scans the Java bytecode of all classes in the currently open buffer.
1349
1349
(Therefore, `:compiler! spotbugs` is not supported.)
1350
1350
1351
1351
Commonly used compiler options can be added to 'makeprg' by setting the
1352
- "b:" or "g:spotbugs_makeprg_params" variable. For example: >
1352
+ "b:" or "g:spotbugs_makeprg_params" variable. For example: >vim
1353
1353
1354
1354
let b:spotbugs_makeprg_params = "-longBugCodes -effort:max -low"
1355
1355
@@ -1359,22 +1359,25 @@ By default, the class files are searched in the directory where the source
1359
1359
files are placed. However, typical Java projects use distinct directories
1360
1360
for source files and class files. To make both known to SpotBugs, assign
1361
1361
their paths (distinct and relative to their common root directory) to the
1362
- following properties (using the example of a common Maven project): >
1362
+ following properties (using the example of a common Maven project): >vim
1363
1363
1364
1364
let g:spotbugs_properties = {
1365
- \ 'sourceDirPath': 'src/main/java',
1366
- \ 'classDirPath': 'target/classes',
1367
- \ 'testSourceDirPath': 'src/test/java',
1368
- \ 'testClassDirPath': 'target/test-classes',
1365
+ \ 'sourceDirPath': [ 'src/main/java'] ,
1366
+ \ 'classDirPath': [ 'target/classes'] ,
1367
+ \ 'testSourceDirPath': [ 'src/test/java'] ,
1368
+ \ 'testClassDirPath': [ 'target/test-classes'] ,
1369
1369
\ }
1370
1370
1371
+ Note that source and class path entries are expected to come in pairs: define
1372
+ both "sourceDirPath" and "classDirPath" when you are considering at least one,
1373
+ and apply the same logic to "testSourceDirPath" and "testClassDirPath".
1371
1374
Note that values for the path keys describe only for SpotBugs where to look
1372
1375
for files; refer to the documentation for particular compiler plugins for more
1373
1376
information.
1374
1377
1375
1378
The default pre- and post-compiler actions are provided for Ant, Maven, and
1376
1379
Javac compiler plugins and can be selected by assigning the name of a compiler
1377
- plugin to the "compiler" key: >
1380
+ plugin ( `ant` , `maven` , or `javac` ) to the "compiler" key: >vim
1378
1381
1379
1382
let g:spotbugs_properties = {
1380
1383
\ 'compiler' : 'maven' ,
@@ -1384,7 +1387,7 @@ This single setting is essentially equivalent to all the settings below, with
1384
1387
the exception made for the "PreCompilerAction" and "PreCompilerTestAction"
1385
1388
values: their listed | Funcref | s will obtain no-op implementations whereas the
1386
1389
implicit Funcrefs of the "compiler" key will obtain the requested defaults if
1387
- available. >
1390
+ available. >vim
1388
1391
1389
1392
let g:spotbugs_properties = {
1390
1393
\ 'PreCompilerAction':
@@ -1393,34 +1396,53 @@ available. >
1393
1396
\ function('spotbugs#DefaultPreCompilerTestAction'),
1394
1397
\ 'PostCompilerAction':
1395
1398
\ function('spotbugs#DefaultPostCompilerAction'),
1396
- \ 'sourceDirPath': 'src/main/java',
1397
- \ 'classDirPath': 'target/classes',
1398
- \ 'testSourceDirPath': 'src/test/java',
1399
- \ 'testClassDirPath': 'target/test-classes',
1399
+ \ 'sourceDirPath': [ 'src/main/java'] ,
1400
+ \ 'classDirPath': [ 'target/classes'] ,
1401
+ \ 'testSourceDirPath': [ 'src/test/java'] ,
1402
+ \ 'testClassDirPath': [ 'target/test-classes'] ,
1400
1403
\ }
1401
1404
1402
1405
With default actions, the compiler of choice will attempt to rebuild the class
1403
1406
files for the buffer (and possibly for the whole project) as soon as a Java
1404
1407
syntax file is loaded; then, `spotbugs` will attempt to analyze the quality of
1405
1408
the compilation unit of the buffer.
1406
1409
1407
- When default actions are not suited to a desired workflow, consider writing
1408
- arbitrary functions yourself and matching their | Funcref | s to the supported
1410
+ Vim commands proficient in 'makeprg' [0] can be composed with default actions.
1411
+ Begin by considering which of the supported keys, "DefaultPreCompilerCommand",
1412
+ "DefaultPreCompilerTestCommand", or "DefaultPostCompilerCommand", you need to
1413
+ write an implementation for, observing that each of these keys corresponds to
1414
+ a particular "*Action" key. Follow it by defining a new function that always
1415
+ declares an only parameter of type string and puts to use a command equivalent
1416
+ of | :make | , and assigning its | Funcref | to the selected key. For example:
1417
+ >vim
1418
+ function! GenericPostCompilerCommand(arguments) abort
1419
+ execute 'make ' . a:arguments
1420
+ endfunction
1421
+
1422
+ let g:spotbugs_properties = {
1423
+ \ 'DefaultPostCompilerCommand':
1424
+ \ function('GenericPostCompilerCommand'),
1425
+ \ }
1426
+
1427
+ When default actions are not suited to a desired workflow, proceed by writing
1428
+ arbitrary functions yourself and matching their Funcrefs to the supported
1409
1429
keys: "PreCompilerAction", "PreCompilerTestAction", and "PostCompilerAction".
1410
1430
1411
1431
The next example re-implements the default pre-compiler actions for a Maven
1412
- project and requests other default Maven settings with the "compiler" entry: >
1413
-
1432
+ project and requests other default Maven settings with the "compiler" entry:
1433
+ >vim
1414
1434
function! MavenPreCompilerAction() abort
1415
1435
call spotbugs#DeleteClassFiles()
1416
1436
compiler maven
1417
1437
make compile
1438
+ cc
1418
1439
endfunction
1419
1440
1420
1441
function! MavenPreCompilerTestAction() abort
1421
1442
call spotbugs#DeleteClassFiles()
1422
1443
compiler maven
1423
1444
make test-compile
1445
+ cc
1424
1446
endfunction
1425
1447
1426
1448
let g:spotbugs_properties = {
@@ -1433,14 +1455,46 @@ project and requests other default Maven settings with the "compiler" entry: >
1433
1455
1434
1456
Note that all entered custom settings will take precedence over the matching
1435
1457
default settings in "g:spotbugs_properties".
1458
+ Note that it is necessary to notify the plugin of the result of a pre-compiler
1459
+ action before further work can be undertaken. Using | :cc | after | :make | (or
1460
+ | :ll | after | :lmake | ) as the last command of an action is the supported means
1461
+ of such communication.
1462
+
1463
+ Two commands, "SpotBugsRemoveBufferAutocmd" and "SpotBugsDefineBufferAutocmd",
1464
+ are provided to toggle actions for buffer-local autocommands. For example, to
1465
+ also run actions on any | BufWritePost | and | SigUSR1 | event, add these lines to
1466
+ `~/.vim/after/ftplugin/java.vim ` : >vim
1467
+
1468
+ if exists(':SpotBugsDefineBufferAutocmd') == 2
1469
+ SpotBugsDefineBufferAutocmd BufWritePost SigUSR1
1470
+ endif
1471
+
1472
+ Otherwise, you can turn to `:doautocmd java_spotbugs User` at any time.
1436
1473
1437
1474
The "g:spotbugs_properties" variable is consulted by the Java filetype plugin
1438
1475
(| ft-java-plugin | ) to arrange for the described automation, and, therefore, it
1439
1476
must be defined before | FileType | events can take place for the buffers loaded
1440
1477
with Java source files. It could, for example, be set in a project-local
1441
- | vimrc | loaded by [0].
1478
+ | vimrc | loaded by [1].
1479
+
1480
+ Both "g:spotbugs_properties" and "b:spotbugs_properties" are recognized and
1481
+ must be modifiable (| :unlockvar | ). The "*Command" entries are always treated
1482
+ as global functions to be shared among all Java buffers.
1483
+
1484
+ The SpotBugs Java library and, by extension, its distributed shell scripts do
1485
+ not support in the `- textui` mode listed pathnames with directory filenames
1486
+ that contain blank characters [2]. To work around this limitation, consider
1487
+ making a symbolic link to such a directory from a directory that does not have
1488
+ blank characters in its name and passing this information to SpotBugs: >vim
1489
+
1490
+ let g:spotbugs_alternative_path = {
1491
+ \ 'fromPath': 'path/to/dir_without_blanks',
1492
+ \ 'toPath': 'path/to/dir with blanks',
1493
+ \ }
1442
1494
1443
- [0] https://github.com/MarcWeber/vim-addon-local-vimrc/
1495
+ [0] https://github.com/Konfekt/vim-compilers
1496
+ [1] https://github.com/MarcWeber/vim-addon-local-vimrc
1497
+ [2] https://github.com/spotbugs/spotbugs/issues/909
1444
1498
1445
1499
GNU MAKE *compiler-make*
1446
1500
0 commit comments