From 48e5deabb7cda02beda6f09a3dfc59a2789b4b9f Mon Sep 17 00:00:00 2001
From: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Date: Wed, 8 Jul 2015 18:41:57 +0200
Subject: [PATCH] Disable action for non-c++ projects

Change-Id: I7ccdd3d364c7761cd1206d526f4e6f7ada133ebf
Task-number: QCE-59
Reviewed-by: Andre Poenitz <andre.poenitz@theqtcompany.com>
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
---
 .../clangstaticanalyzerruncontrolfactory.cpp           | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrolfactory.cpp b/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrolfactory.cpp
index c8a24e4fcf5..5cbe9d5d3e6 100644
--- a/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrolfactory.cpp
+++ b/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrolfactory.cpp
@@ -24,6 +24,8 @@
 #include <analyzerbase/analyzerruncontrol.h>
 #include <analyzerbase/analyzerstartparameters.h>
 
+#include <coreplugin/icontext.h>
+
 #include <cpptools/cppmodelmanager.h>
 #include <cpptools/cppprojects.h>
 
@@ -31,6 +33,8 @@
 #include <projectexplorer/gcctoolchain.h>
 #include <projectexplorer/kit.h>
 #include <projectexplorer/kitinformation.h>
+#include <projectexplorer/project.h>
+#include <projectexplorer/projectexplorerconstants.h>
 #include <projectexplorer/session.h>
 #include <projectexplorer/target.h>
 #include <projectexplorer/toolchain.h>
@@ -58,6 +62,12 @@ bool ClangStaticAnalyzerRunControlFactory::canRun(RunConfiguration *runConfigura
     if (runMode != Constants::CLANGSTATICANALYZER_RUN_MODE)
         return false;
 
+    Project *project = runConfiguration->target()->project();
+    QTC_ASSERT(project, return false);
+    const Core::Context context = project->projectLanguages();
+    if (!context.contains(ProjectExplorer::Constants::LANG_CXX))
+        return false;
+
     Target *target = runConfiguration->target();
     QTC_ASSERT(target, return false);
     Kit *kit = target->kit();
-- 
GitLab