Changeset View
Changeset View
Standalone View
Standalone View
analyzers/cppcheck/plugin.cpp
Show All 36 Lines | |||||
37 | #include <kactioncollection.h> | 37 | #include <kactioncollection.h> | ||
38 | #include <kpluginfactory.h> | 38 | #include <kpluginfactory.h> | ||
39 | #include <language/interfaces/editorcontext.h> | 39 | #include <language/interfaces/editorcontext.h> | ||
40 | #include <project/projectconfigpage.h> | 40 | #include <project/projectconfigpage.h> | ||
41 | #include <project/projectmodel.h> | 41 | #include <project/projectmodel.h> | ||
42 | #include <util/jobstatus.h> | 42 | #include <util/jobstatus.h> | ||
43 | 43 | | |||
44 | #include <QAction> | 44 | #include <QAction> | ||
45 | #include <QMimeDatabase> | ||||
45 | 46 | | |||
46 | K_PLUGIN_FACTORY_WITH_JSON(CppcheckFactory, "kdevcppcheck.json", registerPlugin<cppcheck::Plugin>();) | 47 | K_PLUGIN_FACTORY_WITH_JSON(CppcheckFactory, "kdevcppcheck.json", registerPlugin<cppcheck::Plugin>();) | ||
47 | 48 | | |||
48 | namespace cppcheck | 49 | namespace cppcheck | ||
49 | { | 50 | { | ||
50 | 51 | | |||
51 | Plugin::Plugin(QObject* parent, const QVariantList&) | 52 | Plugin::Plugin(QObject* parent, const QVariantList&) | ||
52 | : IPlugin(QStringLiteral("kdevcppcheck"), parent) | 53 | : IPlugin(QStringLiteral("kdevcppcheck"), parent) | ||
▲ Show 20 Lines • Show All 165 Lines • ▼ Show 20 Line(s) | 204 | { | |||
218 | 219 | | |||
219 | updateActions(); | 220 | updateActions(); | ||
220 | } | 221 | } | ||
221 | 222 | | |||
222 | KDevelop::ContextMenuExtension Plugin::contextMenuExtension(KDevelop::Context* context) | 223 | KDevelop::ContextMenuExtension Plugin::contextMenuExtension(KDevelop::Context* context) | ||
223 | { | 224 | { | ||
224 | KDevelop::ContextMenuExtension extension = KDevelop::IPlugin::contextMenuExtension(context); | 225 | KDevelop::ContextMenuExtension extension = KDevelop::IPlugin::contextMenuExtension(context); | ||
225 | 226 | | |||
226 | if (context->hasType(KDevelop::Context::EditorContext) && | 227 | if (context->hasType(KDevelop::Context::EditorContext) && m_currentProject && !isRunning()) { | ||
227 | m_currentProject && !isRunning()) { | 228 | auto eContext = dynamic_cast<KDevelop::EditorContext*>(context); | ||
kfunk: Style: Rename to `editorContext` | |||||
229 | QMimeDatabase db; | ||||
230 | const auto mime = db.mimeTypeForUrl(eContext->url()); | ||||
kfunk: Style: Rename to `mimeType` | |||||
228 | 231 | | |||
232 | if (mime.name() == QLatin1String("text/x-c++src") || mime.name() == QLatin1String("text/x-c++hdr") || | ||||
233 | mime.name() == QLatin1String("text/x-chdr") || mime.name() == QLatin1String("text/x-csrc")) { | ||||
229 | extension.addAction(KDevelop::ContextMenuExtension::AnalyzeFileGroup, m_contextActionFile); | 234 | extension.addAction(KDevelop::ContextMenuExtension::AnalyzeFileGroup, m_contextActionFile); | ||
230 | extension.addAction(KDevelop::ContextMenuExtension::AnalyzeProjectGroup, m_contextActionProject); | 235 | extension.addAction(KDevelop::ContextMenuExtension::AnalyzeProjectGroup, m_contextActionProject); | ||
231 | } | 236 | } | ||
237 | } | ||||
232 | 238 | | |||
233 | if (context->hasType(KDevelop::Context::ProjectItemContext) && !isRunning()) { | 239 | if (context->hasType(KDevelop::Context::ProjectItemContext) && !isRunning()) { | ||
234 | auto pContext = dynamic_cast<KDevelop::ProjectItemContext*>(context); | 240 | auto pContext = dynamic_cast<KDevelop::ProjectItemContext*>(context); | ||
235 | if (pContext->items().size() != 1) { | 241 | if (pContext->items().size() != 1) { | ||
236 | return extension; | 242 | return extension; | ||
237 | } | 243 | } | ||
238 | 244 | | |||
239 | auto item = pContext->items().first(); | 245 | auto item = pContext->items().first(); | ||
Show All 35 Lines |
Style: Rename to editorContext