codan插件启动模式

时间:2019-03-17 16:17:24

标签: eclipse-plugin eclipse-cdt

我已经基于codan创建了一个Checker插件,并尝试设置启动模式。

我的检查程序扩展了org.eclipse.cdt.codan.core.cxx.model.AbstractIndexAstChecker并覆盖了initPreferences,因为我没有找到专门用于此用法的扩展点。文件plugin.xml应该提供一种声明性的方式,更好的恕我直言。

@Override
public void initPreferences( IProblemWorkingCopy problem ) {
   super.initPreferences( problem );

   final RootProblemPreference pp = (RootProblemPreference)problem.getPreference();

   final LaunchModeProblemPreference lmpp = pp.getLaunchModePreference();
   lmpp.addLaunchMode( CheckerLaunchMode.RUN_ON_FULL_BUILD, Boolean.FALSE );
   lmpp.addLaunchMode( CheckerLaunchMode.RUN_ON_INC_BUILD , Boolean.FALSE );
   lmpp.addLaunchMode( CheckerLaunchMode.RUN_ON_DEMAND    , Boolean.TRUE  );
   lmpp.addLaunchMode( CheckerLaunchMode.RUN_ON_FILE_OPEN , Boolean.FALSE );
   lmpp.addLaunchMode( CheckerLaunchMode.RUN_AS_YOU_TYPE  , Boolean.TRUE  );
   lmpp.addLaunchMode( CheckerLaunchMode.RUN_ON_FILE_SAVE , Boolean.FALSE );

   final SuppressionCommentProblemPreference scp = pp.getSuppressionCommentPreference();
   scp.setValue( "//[[derogations(" + problem.getName() + ")]]" );

   problem.setPreference((IProblemPreference)pp.clone());

   System.out.println( problem.getName() + ": " + problem.getPreference());
}

在运行时,控制台显示初始化成功:

...
RAF-LNG-020: [org.eclipse.cdt.codan.core.param.FileScopeProblemPreference@20676b19, [(boolean)RUN_ON_FULL_BUILD=false, (boolean)RUN_ON_INC_BUILD=false, (boolean)RUN_ON_FILE_OPEN=false, (boolean)RUN_ON_FILE_SAVE=false, (boolean)RUN_AS_YOU_TYPE=true, (boolean)RUN_ON_DEMAND=true], (string)suppression_comment=//[[derogations(RAF-LNG-020)]]]
RAF-LNG-030: [org.eclipse.cdt.codan.core.param.FileScopeProblemPreference@1f0ca550, [(boolean)RUN_ON_FULL_BUILD=false, (boolean)RUN_ON_INC_BUILD=false, (boolean)RUN_ON_FILE_OPEN=false, (boolean)RUN_ON_FILE_SAVE=false, (boolean)RUN_AS_YOU_TYPE=true, (boolean)RUN_ON_DEMAND=true], (string)suppression_comment=//[[derogations(RAF-LNG-030)]]]
...

1)第一个问题:

  • 窗口->首选项-> C / C ++->代码分析->自定义选定项(按钮)->启动(选项卡)显示:
[X] Run as you type
[ ] Run on file open
[ ] Run as file save
[X] Run on incremental build
[X] Run on full build
[X] Run on demand

2)第二个问题:

  • 在编辑器中打开C ++源文件时,将调用我的检查器并报告错误。

我该如何真正调整偏好设置?

0 个答案:

没有答案