summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@theqtcompany.com>2015-06-15 13:47:58 +0200
committerMarco Bubke <marco.bubke@theqtcompany.com>2015-06-15 12:50:51 +0000
commit2fc604e699f6898cbfe4f516df4696b8a60f247b (patch)
tree4836bb17ef8318b4e1eeadbaf2f7dc6cac7b0e80
parent9f2ed3b9da7dd0d47fe151962da0058d1038fe4c (diff)
downloadqt-creator-2fc604e699f6898cbfe4f516df4696b8a60f247b.tar.gz
Clang: Fix operator <
It is actually not used but have to be implemented because QMetaType::registerComparators expect == and <. Change-Id: Ia93e2e7bd856d1962b683482e42ace4136d9bf34 Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
-rw-r--r--src/libs/codemodelbackendipc/cmbregisterprojectsforcodecompletioncommand.cpp6
-rw-r--r--src/libs/codemodelbackendipc/cmbregistertranslationunitsforcodecompletioncommand.cpp4
-rw-r--r--src/libs/codemodelbackendipc/cmbunregisterprojectsforcodecompletioncommand.cpp4
-rw-r--r--src/libs/codemodelbackendipc/cmbunregistertranslationunitsforcodecompletioncommand.cpp4
-rw-r--r--src/libs/codemodelbackendipc/codemodelbackendipc-lib.pri3
-rw-r--r--src/libs/codemodelbackendipc/container_common.h62
6 files changed, 78 insertions, 5 deletions
diff --git a/src/libs/codemodelbackendipc/cmbregisterprojectsforcodecompletioncommand.cpp b/src/libs/codemodelbackendipc/cmbregisterprojectsforcodecompletioncommand.cpp
index 8cc798cb82..e02997748f 100644
--- a/src/libs/codemodelbackendipc/cmbregisterprojectsforcodecompletioncommand.cpp
+++ b/src/libs/codemodelbackendipc/cmbregisterprojectsforcodecompletioncommand.cpp
@@ -36,6 +36,10 @@
#include <ostream>
+#include <algorithm>
+
+#include <container_common.h>
+
namespace CodeModelBackEnd {
RegisterProjectPartsForCodeCompletionCommand::RegisterProjectPartsForCodeCompletionCommand(const QVector<ProjectPartContainer> &projectContainers)
@@ -69,7 +73,7 @@ bool operator==(const RegisterProjectPartsForCodeCompletionCommand &first, const
bool operator<(const RegisterProjectPartsForCodeCompletionCommand &first, const RegisterProjectPartsForCodeCompletionCommand &second)
{
- return first.projectContainers_ < second.projectContainers_;
+ return compareContainer(first.projectContainers_, second.projectContainers_);
}
QDebug operator<<(QDebug debug, const RegisterProjectPartsForCodeCompletionCommand &command)
diff --git a/src/libs/codemodelbackendipc/cmbregistertranslationunitsforcodecompletioncommand.cpp b/src/libs/codemodelbackendipc/cmbregistertranslationunitsforcodecompletioncommand.cpp
index a138138626..a21b53f5fa 100644
--- a/src/libs/codemodelbackendipc/cmbregistertranslationunitsforcodecompletioncommand.cpp
+++ b/src/libs/codemodelbackendipc/cmbregistertranslationunitsforcodecompletioncommand.cpp
@@ -36,6 +36,8 @@
#include <ostream>
+#include <container_common.h>
+
namespace CodeModelBackEnd {
RegisterTranslationUnitForCodeCompletionCommand::RegisterTranslationUnitForCodeCompletionCommand(const QVector<FileContainer> &fileContainers)
@@ -69,7 +71,7 @@ bool operator==(const RegisterTranslationUnitForCodeCompletionCommand &first, co
bool operator<(const RegisterTranslationUnitForCodeCompletionCommand &first, const RegisterTranslationUnitForCodeCompletionCommand &second)
{
- return first.fileContainers_ < second.fileContainers_;
+ return compareContainer(first.fileContainers_, second.fileContainers_);
}
QDebug operator<<(QDebug debug, const RegisterTranslationUnitForCodeCompletionCommand &command)
diff --git a/src/libs/codemodelbackendipc/cmbunregisterprojectsforcodecompletioncommand.cpp b/src/libs/codemodelbackendipc/cmbunregisterprojectsforcodecompletioncommand.cpp
index 3389862bfa..0d6f2ddea0 100644
--- a/src/libs/codemodelbackendipc/cmbunregisterprojectsforcodecompletioncommand.cpp
+++ b/src/libs/codemodelbackendipc/cmbunregisterprojectsforcodecompletioncommand.cpp
@@ -36,6 +36,8 @@
#include <ostream>
+#include <container_common.h>
+
namespace CodeModelBackEnd {
@@ -70,7 +72,7 @@ bool operator==(const UnregisterProjectPartsForCodeCompletionCommand &first, con
bool operator<(const UnregisterProjectPartsForCodeCompletionCommand &first, const UnregisterProjectPartsForCodeCompletionCommand &second)
{
- return first.filePaths_ < second.filePaths_;
+ return compareContainer(first.filePaths_, second.filePaths_);
}
QDebug operator<<(QDebug debug, const UnregisterProjectPartsForCodeCompletionCommand &command)
diff --git a/src/libs/codemodelbackendipc/cmbunregistertranslationunitsforcodecompletioncommand.cpp b/src/libs/codemodelbackendipc/cmbunregistertranslationunitsforcodecompletioncommand.cpp
index 6bdbd8499d..27d905c00e 100644
--- a/src/libs/codemodelbackendipc/cmbunregistertranslationunitsforcodecompletioncommand.cpp
+++ b/src/libs/codemodelbackendipc/cmbunregistertranslationunitsforcodecompletioncommand.cpp
@@ -38,6 +38,8 @@
#include <QDataStream>
+#include <container_common.h>
+
namespace CodeModelBackEnd {
@@ -72,7 +74,7 @@ bool operator==(const UnregisterTranslationUnitsForCodeCompletionCommand &first,
bool operator<(const UnregisterTranslationUnitsForCodeCompletionCommand &first, const UnregisterTranslationUnitsForCodeCompletionCommand &second)
{
- return first.fileContainers_ < second.fileContainers_;
+ return compareContainer(first.fileContainers_, second.fileContainers_);
}
QDebug operator<<(QDebug debug, const UnregisterTranslationUnitsForCodeCompletionCommand &command)
diff --git a/src/libs/codemodelbackendipc/codemodelbackendipc-lib.pri b/src/libs/codemodelbackendipc/codemodelbackendipc-lib.pri
index 54068e45c1..8e1ff2fdb9 100644
--- a/src/libs/codemodelbackendipc/codemodelbackendipc-lib.pri
+++ b/src/libs/codemodelbackendipc/codemodelbackendipc-lib.pri
@@ -67,6 +67,7 @@ HEADERS += $$PWD/codemodelbackendipc_global.h \
$$PWD/translationunitdoesnotexistcommand.h \
$$PWD/codecompletionchunk.h \
$$PWD/projectpartcontainer.h \
- $$PWD/projectpartsdonotexistcommand.h
+ $$PWD/projectpartsdonotexistcommand.h \
+ $$PWD/container_common.h
contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols
diff --git a/src/libs/codemodelbackendipc/container_common.h b/src/libs/codemodelbackendipc/container_common.h
new file mode 100644
index 0000000000..61b078dadd
--- /dev/null
+++ b/src/libs/codemodelbackendipc/container_common.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms and
+** conditions see http://www.qt.io/terms-conditions. For further information
+** use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef CONTAINER_COMMON_H
+#define CONTAINER_COMMON_H
+
+
+namespace CodeModelBackEnd {
+
+template <typename Container>
+bool compareContainer(const Container &first, const Container &second)
+{
+ if (first.size() != second.size())
+ return first.size() < second.size();
+
+ Container firstCopy = first;
+ Container secondCopy = second;
+
+ std::sort(firstCopy.begin(), firstCopy.end());
+ std::sort(secondCopy.begin(), secondCopy.end());
+
+ auto isProjectPartContainerSmaller = [] (decltype(*first.cbegin()) &firstElement,
+ decltype(*second.cbegin()) &secondElement) {
+ return firstElement < secondElement;
+ };
+
+ return std::equal(firstCopy.cbegin(),
+ firstCopy.cend(),
+ secondCopy.cbegin(),
+ isProjectPartContainerSmaller);
+}
+}
+
+#endif // CONTAINER_COMMON_H
+