|
1 |
| -*quickfix.txt* For Vim version 9.1. Last change: 2024 Nov 12 |
| 1 | +*quickfix.txt* For Vim version 9.1. Last change: 2024 Nov 28 |
2 | 2 |
|
3 | 3 |
|
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar
|
@@ -1331,10 +1331,117 @@ g:compiler_gcc_ignore_unmatched_lines
|
1331 | 1331 | JAVAC *compiler-javac*
|
1332 | 1332 |
|
1333 | 1333 | Commonly used compiler options can be added to 'makeprg' by setting the
|
1334 |
| -g:javac_makeprg_params variable. For example: > |
| 1334 | +b/g:javac_makeprg_params variable. For example: > |
1335 | 1335 |
|
1336 | 1336 | let g:javac_makeprg_params = "-Xlint:all -encoding utf-8"
|
1337 |
| -< |
| 1337 | +
|
| 1338 | +MAVEN *compiler-maven* |
| 1339 | + |
| 1340 | +Commonly used compiler options can be added to 'makeprg' by setting the |
| 1341 | +b/g:maven_makeprg_params variable. For example: > |
| 1342 | +
|
| 1343 | + let g:maven_makeprg_params = "-DskipTests -U -X" |
| 1344 | +
|
| 1345 | +SPOTBUGS *compiler-spotbugs* |
| 1346 | + |
| 1347 | +SpotBugs is a static analysis tool that can be used to find bugs in Java. |
| 1348 | +It scans the Java bytecode of all classes in the currently open buffer. |
| 1349 | +(Therefore, `:compiler! spotbugs` is not supported.) |
| 1350 | + |
| 1351 | +Commonly used compiler options can be added to 'makeprg' by setting the |
| 1352 | +"b:" or "g:spotbugs_makeprg_params" variable. For example: > |
| 1353 | +
|
| 1354 | + let b:spotbugs_makeprg_params = "-longBugCodes -effort:max -low" |
| 1355 | +
|
| 1356 | +The global default is "-workHard -experimental". |
| 1357 | + |
| 1358 | +By default, the class files are searched in the directory where the source |
| 1359 | +files are placed. However, typical Java projects use distinct directories |
| 1360 | +for source files and class files. To make both known to SpotBugs, assign |
| 1361 | +their paths (distinct and relative to their common root directory) to the |
| 1362 | +following properties (using the example of a common Maven project): > |
| 1363 | +
|
| 1364 | + let g:spotbugs_properties = { |
| 1365 | + \ 'sourceDirPath': 'src/main/java', |
| 1366 | + \ 'classDirPath': 'target/classes', |
| 1367 | + \ 'testSourceDirPath': 'src/test/java', |
| 1368 | + \ 'testClassDirPath': 'target/test-classes', |
| 1369 | + \ } |
| 1370 | +
|
| 1371 | +Note that values for the path keys describe only for SpotBugs where to look |
| 1372 | +for files; refer to the documentation for particular compiler plugins for more |
| 1373 | +information. |
| 1374 | + |
| 1375 | +The default pre- and post-compiler actions are provided for Ant, Maven, and |
| 1376 | +Javac compiler plugins and can be selected by assigning the name of a compiler |
| 1377 | +plugin to the "compiler" key: > |
| 1378 | +
|
| 1379 | + let g:spotbugs_properties = { |
| 1380 | + \ 'compiler': 'maven', |
| 1381 | + \ } |
| 1382 | +
|
| 1383 | +This single setting is essentially equivalent to all the settings below, with |
| 1384 | +the exception made for the "PreCompilerAction" and "PreCompilerTestAction" |
| 1385 | +values: their listed |Funcref|s will obtain no-op implementations whereas the |
| 1386 | +implicit Funcrefs of the "compiler" key will obtain the requested defaults if |
| 1387 | +available. > |
| 1388 | +
|
| 1389 | + let g:spotbugs_properties = { |
| 1390 | + \ 'PreCompilerAction': |
| 1391 | + \ function('spotbugs#DefaultPreCompilerAction'), |
| 1392 | + \ 'PreCompilerTestAction': |
| 1393 | + \ function('spotbugs#DefaultPreCompilerTestAction'), |
| 1394 | + \ 'PostCompilerAction': |
| 1395 | + \ function('spotbugs#DefaultPostCompilerAction'), |
| 1396 | + \ 'sourceDirPath': 'src/main/java', |
| 1397 | + \ 'classDirPath': 'target/classes', |
| 1398 | + \ 'testSourceDirPath': 'src/test/java', |
| 1399 | + \ 'testClassDirPath': 'target/test-classes', |
| 1400 | + \ } |
| 1401 | +
|
| 1402 | +With default actions, the compiler of choice will attempt to rebuild the class |
| 1403 | +files for the buffer (and possibly for the whole project) as soon as a Java |
| 1404 | +syntax file is loaded; then, `spotbugs` will attempt to analyze the quality of |
| 1405 | +the compilation unit of the buffer. |
| 1406 | + |
| 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 |
| 1409 | +keys: "PreCompilerAction", "PreCompilerTestAction", and "PostCompilerAction". |
| 1410 | + |
| 1411 | +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 | +
|
| 1414 | + function! MavenPreCompilerAction() abort |
| 1415 | + call spotbugs#DeleteClassFiles() |
| 1416 | + compiler maven |
| 1417 | + make compile |
| 1418 | + endfunction |
| 1419 | +
|
| 1420 | + function! MavenPreCompilerTestAction() abort |
| 1421 | + call spotbugs#DeleteClassFiles() |
| 1422 | + compiler maven |
| 1423 | + make test-compile |
| 1424 | + endfunction |
| 1425 | +
|
| 1426 | + let g:spotbugs_properties = { |
| 1427 | + \ 'compiler': 'maven', |
| 1428 | + \ 'PreCompilerAction': |
| 1429 | + \ function('MavenPreCompilerAction'), |
| 1430 | + \ 'PreCompilerTestAction': |
| 1431 | + \ function('MavenPreCompilerTestAction'), |
| 1432 | + \ } |
| 1433 | +
|
| 1434 | +Note that all entered custom settings will take precedence over the matching |
| 1435 | +default settings in "g:spotbugs_properties". |
| 1436 | + |
| 1437 | +The "g:spotbugs_properties" variable is consulted by the Java filetype plugin |
| 1438 | +(|ft-java-plugin|) to arrange for the described automation, and, therefore, it |
| 1439 | +must be defined before |FileType| events can take place for the buffers loaded |
| 1440 | +with Java source files. It could, for example, be set in a project-local |
| 1441 | +|vimrc| loaded by [0]. |
| 1442 | + |
| 1443 | +[0] https://github.com/MarcWeber/vim-addon-local-vimrc/ |
| 1444 | + |
1338 | 1445 | GNU MAKE *compiler-make*
|
1339 | 1446 |
|
1340 | 1447 | Since the default make program is "make", the compiler plugin for make,
|
|
0 commit comments