Checker Framework - Eclipse插件

官方教程: Checker Framework Eclipse Plugin: Pluggable type-checking for Java

說明:由於框架沒有深入,所以現在只是可以瞭解基本使用即可,後期逐漸完善。

一、安裝

基本操作步驟:選中菜單欄Help → Install New Software… → Add

輸入如下信息:

選中Pluggable Type-Checking 然後就是和安裝軟件一樣即可。

Note: You may want to add checker-qual.jar to your classpath for each Eclipse project you wish to check. It provides the annotations used by the Checker Framework for its built-in type checkers.
To add the checker-qual.jar to your Eclipse project, download the jar from the above link. Then right click the project you wish to check and select Properties -> Java Build Path -> Libraries -> Add External Jars. Select checker-qual.jar from the directory in which it’s saved.

二、插件使用

2.1 Running a Built-In Checker

  1. 在項目,包或者源文件上右擊
  2. 打開”Checker Framework”子菜單
  3. 打開”Run Built-In Checker”子菜單
  4. 選擇你想運行的checker (例如: NullnessChecker).

A progress dialog will inform you as the plugin performs these steps: removing old markers, running the type-checker(s), and updating the problem list and markers.

You can select the “Problems” window to see all the type-checking errors.

In the editor, a warning marker will appears to the left of each line that has a type-checking error. You can hover over the warning marker to view the given error. The errors are also output to the console formatted as they appear when running the Checker Framework from the command line, but most users do not view the console.

You may clear all Checker Framework error markers by right-clicking on the project and selecting: (Checker Framework ‑> Clear Checker Markers).

Warning! When using the Subtyping Checker, you must provide the -Aquals argument or an error will be reported. Follow the instructions in the Additional Compiler Params section to add the -Aquals argument.

2.2 Running a Custom Checker

  1. Open the Eclipse Preferences page (usually Window‑>Preferences or Eclipse‑>Preferences depending on your platform).
  2. Select the “Checker Framework” preferences page.
  3. In the “Checkers” section there will be a table of built-in checkers. Press the “Add” button located below the table.
  4. A dialog should pop up. In the text field at the top of the dialog, type the class name of your checker without the package name (e.g., NullnessChecker, NOT org.checkerframework.checker.nullness.NullnessChecker)
  5. One or more classes should appear in a list below the text-field. Select your checker.
  6. Press “OK”.
  7. The dialog will close and your custom checker should now appear in the “Checkers” table. Press “OK” again.

Your custom checker will now appear in the menu “Run Custom Checker” when you right-click a project, package, or file and open the “Checker Framework” sub-menu. You can run your custom checker in a manner similar to that described in “Running Built-In Checkers”.

2.3 Running Multiple Checkers

If you wish to run several checkers at once follow the instructions below:

  1. Open the Eclipse Preferences page (usually Window‑>Preferences or Eclipse‑>Preferences depending on your platform).
  2. Select the “Checker Framework” preferences page.
  3. In the “Checkers” section there will be a table of built-in checkers. Place a check-mark next to each of the checkers (built-in or custom) you would like to run.
  4. Press “OK”.
  5. Right-click on the project, package, or file you would like to check.
  6. Open the “Checker Framework” sub-menu and select “Run Selected Checkers”

讚賞碼

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章