Checker_Framework_Eclipse_Plugin_MD

官方教程: 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).

select_nullness.png

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.

扫描二维码关注公众号,回复: 2806212 查看本文章

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”

赞赏码

猜你喜欢

转载自blog.csdn.net/fanxiaobin577328725/article/details/78688482