From d400959d7eeadd99ae4ebd57a95bd75fa177de6c Mon Sep 17 00:00:00 2001
From: Tobias Hunger <tobias.hunger@theqtcompany.com>
Date: Fri, 12 Feb 2016 12:30:55 +0100
Subject: [PATCH] CMakeCbpParser: Small cleanups

* Do follow-up fixes to CMakeTool

Change-Id: Ia3c587acb85d613499e91988200d8bbae32eca3d
Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
---
 .../cmakeprojectmanager/cmakecbpparser.cpp       |  8 ++++----
 src/plugins/cmakeprojectmanager/cmakecbpparser.h | 16 +++++++++++-----
 src/plugins/cmakeprojectmanager/cmaketool.cpp    |  6 ++++--
 src/plugins/cmakeprojectmanager/cmaketool.h      |  4 ++--
 4 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/src/plugins/cmakeprojectmanager/cmakecbpparser.cpp b/src/plugins/cmakeprojectmanager/cmakecbpparser.cpp
index bafcbb436d0..bae8620997e 100644
--- a/src/plugins/cmakeprojectmanager/cmakecbpparser.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakecbpparser.cpp
@@ -151,7 +151,7 @@ void CMakeCbpParser::sortFiles()
         qCDebug(log) << target.title << target.sourceDirectory << target.includeFiles << target.defines << target.files << "\n";
 }
 
-bool CMakeCbpParser::parseCbpFile(Kit *kit, const QString &fileName, const QString &sourceDirectory)
+bool CMakeCbpParser::parseCbpFile(const Kit *const kit, const QString &fileName, const QString &sourceDirectory)
 {
     m_kit = kit;
     m_buildDirectory = QFileInfo(fileName).absolutePath();
@@ -437,14 +437,14 @@ void CMakeCbpParser::parseUnit()
         fileName = FileName::fromUserInput(mappedFile);
     }
 
-    m_parsingCmakeUnit = false;
+    m_parsingCMakeUnit = false;
     m_unitTarget.clear();
     while (!atEnd()) {
         readNext();
         if (isEndElement()) {
             if (!fileName.endsWith(QLatin1String(".rule")) && !m_processedUnits.contains(fileName)) {
                 // Now check whether we found a virtual element beneath
-                if (m_parsingCmakeUnit) {
+                if (m_parsingCMakeUnit) {
                     m_cmakeFileList.append( new ProjectExplorer::FileNode(fileName, ProjectExplorer::ProjectFileType, false));
                 } else {
                     bool generated = false;
@@ -475,7 +475,7 @@ void CMakeCbpParser::parseUnit()
 void CMakeCbpParser::parseUnitOption()
 {
     const QXmlStreamAttributes optionAttributes = attributes();
-    m_parsingCmakeUnit = optionAttributes.hasAttribute(QLatin1String("virtualFolder"));
+    m_parsingCMakeUnit = optionAttributes.hasAttribute(QLatin1String("virtualFolder"));
     m_unitTarget = optionAttributes.value(QLatin1String("target")).toString();
 
     while (!atEnd()) {
diff --git a/src/plugins/cmakeprojectmanager/cmakecbpparser.h b/src/plugins/cmakeprojectmanager/cmakecbpparser.h
index 045bdecd1f4..d9dfa771c92 100644
--- a/src/plugins/cmakeprojectmanager/cmakecbpparser.h
+++ b/src/plugins/cmakeprojectmanager/cmakecbpparser.h
@@ -27,13 +27,18 @@
 
 #include "cmakeproject.h"
 
-#include <QXmlStreamReader>
+#include <utils/fileutils.h>
 
+#include <QList>
+#include <QMap>
+#include <QSet>
+#include <QString>
+#include <QXmlStreamReader>
 
 namespace ProjectExplorer {
 class FileNode;
 class Kit;
-}
+} // namespace ProjectExplorer
 
 namespace CMakeProjectManager {
 namespace Internal {
@@ -41,7 +46,8 @@ namespace Internal {
 class CMakeCbpParser : public QXmlStreamReader
 {
 public:
-    bool parseCbpFile(ProjectExplorer::Kit *kit, const QString &fileName, const QString &sourceDirectory);
+    bool parseCbpFile(const ProjectExplorer::Kit *const kit, const QString &fileName,
+                      const QString &sourceDirectory);
     QList<ProjectExplorer::FileNode *> fileList();
     QList<ProjectExplorer::FileNode *> cmakeFileList();
     QList<CMakeBuildTarget> buildTargets();
@@ -67,11 +73,11 @@ private:
     void sortFiles();
 
     QMap<Utils::FileName, QString> m_unitTargetMap;
-    ProjectExplorer::Kit *m_kit = 0;
+    const ProjectExplorer::Kit *m_kit = 0;
     QList<ProjectExplorer::FileNode *> m_fileList;
     QList<ProjectExplorer::FileNode *> m_cmakeFileList;
     QSet<Utils::FileName> m_processedUnits;
-    bool m_parsingCmakeUnit;
+    bool m_parsingCMakeUnit;
 
     CMakeBuildTarget m_buildTarget;
     QList<CMakeBuildTarget> m_buildTargets;
diff --git a/src/plugins/cmakeprojectmanager/cmaketool.cpp b/src/plugins/cmakeprojectmanager/cmaketool.cpp
index d8c2b742c85..8ea7fdead90 100644
--- a/src/plugins/cmakeprojectmanager/cmaketool.cpp
+++ b/src/plugins/cmakeprojectmanager/cmaketool.cpp
@@ -37,7 +37,7 @@
 #include <QUuid>
 #include <QVariantMap>
 
-using namespace CMakeProjectManager;
+namespace CMakeProjectManager {
 
 const char CMAKE_INFORMATION_ID[] = "Id";
 const char CMAKE_INFORMATION_COMMAND[] = "Binary";
@@ -223,7 +223,7 @@ void CMakeTool::setPathMapper(const CMakeTool::PathMapper &pathMapper)
     m_pathMapper = pathMapper;
 }
 
-QString CMakeTool::mapAllPaths(ProjectExplorer::Kit *kit, const QString &in) const
+QString CMakeTool::mapAllPaths(const ProjectExplorer::Kit *kit, const QString &in) const
 {
     if (m_pathMapper)
         return m_pathMapper(kit, in);
@@ -318,3 +318,5 @@ QStringList CMakeTool::parseVariableOutput(const QString &output)
     }
     return result;
 }
+
+} // namespace CMakeProjectManager
diff --git a/src/plugins/cmakeprojectmanager/cmaketool.h b/src/plugins/cmakeprojectmanager/cmaketool.h
index eb085bf9db6..bef9f23c353 100644
--- a/src/plugins/cmakeprojectmanager/cmaketool.h
+++ b/src/plugins/cmakeprojectmanager/cmaketool.h
@@ -52,7 +52,7 @@ public:
         AutoDetection
     };
 
-    typedef std::function<QString (ProjectExplorer::Kit *, const QString &)> PathMapper;
+    typedef std::function<QString (const ProjectExplorer::Kit *, const QString &)> PathMapper;
 
     explicit CMakeTool(Detection d, const Core::Id &id);
     explicit CMakeTool(const QVariantMap &map, bool fromSdk);
@@ -78,7 +78,7 @@ public:
     void setDisplayName(const QString &displayName);
 
     void setPathMapper(const PathMapper &includePathMapper);
-    QString mapAllPaths(ProjectExplorer::Kit *kit, const QString &in) const;
+    QString mapAllPaths(const ProjectExplorer::Kit *kit, const QString &in) const;
 
 private:
     Utils::SynchronousProcessResponse run(const QString &arg) const;
-- 
GitLab