protected void runTool(
      final String testDir,
      final String jdkName,
      boolean runDeadCodeFirst,
      final InspectionTool tool,
      InspectionTool... additional) {
    final VirtualFile[] sourceDir = new VirtualFile[1];
    ApplicationManager.getApplication()
        .runWriteAction(
            new Runnable() {
              @Override
              public void run() {
                try {
                  setupRootModel(testDir, sourceDir, jdkName);
                } catch (Exception e) {
                  LOG.error(e);
                }
              }
            });
    AnalysisScope scope = createAnalysisScope(sourceDir[0].getParent());

    InspectionManagerEx inspectionManager =
        (InspectionManagerEx) InspectionManager.getInstance(getProject());
    InspectionTool[] tools =
        runDeadCodeFirst
            ? new InspectionTool[] {new UnusedDeclarationInspection(), tool}
            : new InspectionTool[] {tool};
    tools = ArrayUtil.mergeArrays(tools, additional);
    final GlobalInspectionContextImpl globalContext =
        CodeInsightTestFixtureImpl.createGlobalContextForTool(
            scope, getProject(), inspectionManager, tools);

    InspectionTestUtil.runTool(tool, scope, globalContext, inspectionManager);
  }
  public void doTest(
      @NonNls String folderName,
      InspectionTool tool,
      @NonNls final String jdkName,
      boolean checkRange,
      boolean runDeadCodeFirst,
      InspectionTool... additional) {
    final String testDir = getTestDataPath() + "/" + folderName;
    runTool(testDir, jdkName, runDeadCodeFirst, tool, additional);

    InspectionTestUtil.compareToolResults(tool, checkRange, testDir);
  }