InspectionManagerEx inspectionManager = (InspectionManagerEx) InspectionManager.getInstance(myProject);
final GlobalInspectionContextImpl globalContext = inspectionManager.createNewGlobalContext(true);
globalContext.setCurrentScope(scope);
if (runDeadCodeFirst) {
runTool(new DeadCodeInspection(), scope, globalContext, inspectionManager);
}
runTool(tool, scope, globalContext, inspectionManager);
}