| 50 | } |
| 51 | |
| 52 | CompileAnalyzer::CompileAnalyzer(IPlugin* plugin, |
| 53 | const QString& toolName, const QString& toolIconName, |
| 54 | const QString& fileActionId, const QString& allActionId, |
| 55 | const QString& modelId, |
| 56 | ProblemModel::Features modelFeatures, |
| 57 | QObject* parent) |
| 58 | : QObject(parent) |
| 59 | , m_core(plugin->core()) |
| 60 | , m_toolName(toolName) |
| 61 | , m_toolIcon(QIcon::fromTheme(toolIconName)) |
| 62 | , m_modelId(modelId) |
| 63 | , m_model(new CompileAnalyzeProblemModel(toolName, this)) |
| 64 | { |
| 65 | m_model->setFeatures(modelFeatures); |
| 66 | |
| 67 | ProblemModelSet* problemModelSet = core()->languageController()->problemModelSet(); |
| 68 | problemModelSet->addModel(m_modelId, m_toolName, m_model); |
| 69 | |
| 70 | auto actionCollection = plugin->actionCollection(); |
| 71 | |
| 72 | m_checkFileAction = new QAction(m_toolIcon, |
| 73 | i18nc("@action", "Analyze Current File with %1", m_toolName), this); |
| 74 | connect(m_checkFileAction, &QAction::triggered, this, &CompileAnalyzer::runToolOnFile); |
| 75 | actionCollection->addAction(fileActionId, m_checkFileAction); |
| 76 | |
| 77 | m_checkProjectAction = new QAction(m_toolIcon, |
| 78 | i18nc("@action", "Analyze Current Project with %1", m_toolName), this); |
| 79 | connect(m_checkProjectAction, &QAction::triggered, this, &CompileAnalyzer::runToolOnAll); |
| 80 | actionCollection->addAction(allActionId, m_checkProjectAction); |
| 81 | |
| 82 | connect(core()->documentController(), &KDevelop::IDocumentController::documentClosed, |
| 83 | this, &CompileAnalyzer::updateActions); |
| 84 | connect(core()->documentController(), &KDevelop::IDocumentController::documentActivated, |
| 85 | this, &CompileAnalyzer::updateActions); |
| 86 | // TODO: updateActions() should be connected to IDocumentController::documentUrlChanged as well. However, this |
| 87 | // works incorrectly, because IProjectController::findProjectForUrl() returns nullptr for a just-renamed document. |
| 88 | // The same applies to cppcheck::Plugin::updateActions(). The delayed inclusion of a renamed file into its project |
| 89 | // negatively affects correctness of other slots connected to the documentUrlChanged signal, such as |
| 90 | // CurrentProjectSet::setCurrentDocument() and (in case of custom project formatting configuration) |
| 91 | // SourceFormatterController::updateFormatTextAction(). See also a similar TODO in |
| 92 | // ProjectManagerView::ProjectManagerView(). |
| 93 | |
| 94 | connect(core()->projectController(), &KDevelop::IProjectController::projectOpened, |
| 95 | this, &CompileAnalyzer::updateActions); |
| 96 | connect(core()->projectController(), &KDevelop::IProjectController::projectClosed, |
| 97 | this, &CompileAnalyzer::handleProjectClosed); |
| 98 | |
| 99 | connect(m_model, &CompileAnalyzeProblemModel::rerunRequested, |
| 100 | this, &CompileAnalyzer::handleRerunRequest); |
| 101 | |
| 102 | updateActions(); |
| 103 | } |
| 104 | |
| 105 | CompileAnalyzer::~CompileAnalyzer() |
| 106 | { |
nothing calls this directly
no test coverage detected