diff --git a/src/libs/clangbackendipc/clangbackendipc-lib.pri b/src/libs/clangbackendipc/clangbackendipc-lib.pri index cbe5ad01fe3..8f4138f4301 100644 --- a/src/libs/clangbackendipc/clangbackendipc-lib.pri +++ b/src/libs/clangbackendipc/clangbackendipc-lib.pri @@ -14,7 +14,6 @@ SOURCES += $$PWD/ipcserverinterface.cpp \ $$PWD/cmbendmessage.cpp \ $$PWD/cmbalivemessage.cpp \ $$PWD/ipcclientproxy.cpp \ - $$PWD/cmbmessages.cpp \ $$PWD/writemessageblock.cpp \ $$PWD/readmessageblock.cpp \ $$PWD/ipcinterface.cpp \ @@ -57,7 +56,6 @@ HEADERS += \ $$PWD/cmbendmessage.h \ $$PWD/cmbalivemessage.h \ $$PWD/ipcclientproxy.h \ - $$PWD/cmbmessages.h \ $$PWD/writemessageblock.h \ $$PWD/readmessageblock.h \ $$PWD/ipcinterface.h \ @@ -77,7 +75,6 @@ HEADERS += \ $$PWD/codecompletionchunk.h \ $$PWD/projectpartcontainer.h \ $$PWD/projectpartsdonotexistmessage.h \ - $$PWD/container_common.h \ $$PWD/clangbackendipc_global.h \ $$PWD/lineprefixer.h \ $$PWD/clangbackendipcdebugutils.h \ @@ -93,6 +90,7 @@ HEADERS += \ $$PWD/updatetranslationunitsforeditormessage.h \ $$PWD/updatevisibletranslationunitsmessage.h \ $$PWD/highlightingchangedmessage.h \ - $$PWD/highlightingmarkcontainer.h + $$PWD/highlightingmarkcontainer.h \ + $$PWD/messageenvelop.h contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols diff --git a/src/libs/clangbackendipc/clangbackendipc_global.h b/src/libs/clangbackendipc/clangbackendipc_global.h index 152e09a7317..28e0af9da74 100644 --- a/src/libs/clangbackendipc/clangbackendipc_global.h +++ b/src/libs/clangbackendipc/clangbackendipc_global.h @@ -79,5 +79,49 @@ enum class CompletionCorrection DotToArrowCorrection }; +enum class MessageType : quint8 { + InvalidMessage, + AliveMessage, + EchoMessage, + EndMessage, + + RegisterTranslationUnitForEditorMessage, + UpdateTranslationUnitsForEditorMessage, + UnregisterTranslationUnitsForEditorMessage, + + RegisterUnsavedFilesForEditorMessage, + UnregisterUnsavedFilesForEditorMessage, + + RegisterProjectPartsForEditorMessage, + UnregisterProjectPartsForEditorMessage, + + RequestDiagnosticsMessage, + DiagnosticsChangedMessage, + + RequestHighlightingMessage, + HighlightingChangedMessage, + + UpdateVisibleTranslationUnitsMessage, + + CompleteCodeMessage, + CodeCompletedMessage, + + TranslationUnitDoesNotExistMessage, + ProjectPartsDoNotExistMessage +}; + +template +struct MessageTypeTrait; + +template +struct MessageTrait; + +#define DECLARE_MESSAGE(Message) \ +template<> \ +struct MessageTrait \ +{ \ + static const MessageType enumeration = MessageType::Message; \ +}; + } #endif // CLANGBACKENDIPC_GLOBAL_H diff --git a/src/libs/clangbackendipc/cmbalivemessage.cpp b/src/libs/clangbackendipc/cmbalivemessage.cpp index dddfd8730a6..8fea9d9f43d 100644 --- a/src/libs/clangbackendipc/cmbalivemessage.cpp +++ b/src/libs/clangbackendipc/cmbalivemessage.cpp @@ -45,11 +45,6 @@ bool operator==(const AliveMessage &/*first*/, const AliveMessage &/*second*/) return true; } -bool operator<(const AliveMessage &/*first*/, const AliveMessage &/*second*/) -{ - return true; -} - QDebug operator<<(QDebug debug, const AliveMessage &/*message*/) { return debug.nospace() << "AliveMessage()"; diff --git a/src/libs/clangbackendipc/cmbalivemessage.h b/src/libs/clangbackendipc/cmbalivemessage.h index 2e1ac519a90..a28aa986d3b 100644 --- a/src/libs/clangbackendipc/cmbalivemessage.h +++ b/src/libs/clangbackendipc/cmbalivemessage.h @@ -28,8 +28,6 @@ #include "clangbackendipc_global.h" -#include - namespace ClangBackEnd { class CMBIPC_EXPORT AliveMessage @@ -39,12 +37,10 @@ class CMBIPC_EXPORT AliveMessage CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const AliveMessage &message); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, AliveMessage &message); CMBIPC_EXPORT bool operator==(const AliveMessage &first, const AliveMessage &second); -CMBIPC_EXPORT bool operator<(const AliveMessage &first, const AliveMessage &second); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const AliveMessage &message); +DECLARE_MESSAGE(AliveMessage) } -Q_DECLARE_METATYPE(ClangBackEnd::AliveMessage) - #endif // CMBALIVEMESSAGE_H diff --git a/src/libs/clangbackendipc/cmbcodecompletedmessage.cpp b/src/libs/clangbackendipc/cmbcodecompletedmessage.cpp index 8083392bc6b..ea857646f5e 100644 --- a/src/libs/clangbackendipc/cmbcodecompletedmessage.cpp +++ b/src/libs/clangbackendipc/cmbcodecompletedmessage.cpp @@ -86,11 +86,6 @@ bool operator==(const CodeCompletedMessage &first, const CodeCompletedMessage &s && first.codeCompletions_ == second.codeCompletions_; } -bool operator<(const CodeCompletedMessage &first, const CodeCompletedMessage &second) -{ - return first.ticketNumber_ < second.ticketNumber_; -} - #define RETURN_TEXT_FOR_CASE(enumValue) case CompletionCorrection::enumValue: return #enumValue static const char *completionCorrectionToText(CompletionCorrection correction) { diff --git a/src/libs/clangbackendipc/cmbcodecompletedmessage.h b/src/libs/clangbackendipc/cmbcodecompletedmessage.h index edeeeee31bb..e0e8109222c 100644 --- a/src/libs/clangbackendipc/cmbcodecompletedmessage.h +++ b/src/libs/clangbackendipc/cmbcodecompletedmessage.h @@ -28,7 +28,6 @@ #include "codecompletion.h" -#include #include namespace ClangBackEnd { @@ -38,7 +37,6 @@ class CMBIPC_EXPORT CodeCompletedMessage friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CodeCompletedMessage &message); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CodeCompletedMessage &message); friend CMBIPC_EXPORT bool operator==(const CodeCompletedMessage &first, const CodeCompletedMessage &second); - friend CMBIPC_EXPORT bool operator<(const CodeCompletedMessage &first, const CodeCompletedMessage &second); friend CMBIPC_EXPORT QDebug operator<<(QDebug debug, const CodeCompletedMessage &message); friend void PrintTo(const CodeCompletedMessage &message, ::std::ostream* os); public: @@ -64,13 +62,11 @@ private: CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CodeCompletedMessage &message); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CodeCompletedMessage &message); CMBIPC_EXPORT bool operator==(const CodeCompletedMessage &first, const CodeCompletedMessage &second); -CMBIPC_EXPORT bool operator<(const CodeCompletedMessage &first, const CodeCompletedMessage &second); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const CodeCompletedMessage &message); void PrintTo(const CodeCompletedMessage &message, ::std::ostream* os); +DECLARE_MESSAGE(CodeCompletedMessage) } // namespace ClangBackEnd -Q_DECLARE_METATYPE(ClangBackEnd::CodeCompletedMessage) - #endif // CLANGBACKEND_CODECOMPLETEDMESSAGE_H diff --git a/src/libs/clangbackendipc/cmbcompletecodemessage.cpp b/src/libs/clangbackendipc/cmbcompletecodemessage.cpp index bb210f8f18e..da8aa21223a 100644 --- a/src/libs/clangbackendipc/cmbcompletecodemessage.cpp +++ b/src/libs/clangbackendipc/cmbcompletecodemessage.cpp @@ -99,15 +99,6 @@ bool operator==(const CompleteCodeMessage &first, const CompleteCodeMessage &sec && first.column_ == second.column_; } -bool operator<(const CompleteCodeMessage &first, const CompleteCodeMessage &second) -{ - return first.ticketNumber_ < second.ticketNumber_ - && first.filePath_ < second.filePath_ - && first.projectPartId_ < second.projectPartId_ - && first.line_ < second.line_ - && first.column_ < second.column_; -} - QDebug operator<<(QDebug debug, const CompleteCodeMessage &message) { debug.nospace() << "CompleteCodeMessage("; diff --git a/src/libs/clangbackendipc/cmbcompletecodemessage.h b/src/libs/clangbackendipc/cmbcompletecodemessage.h index 0887c948792..cd9aec2075e 100644 --- a/src/libs/clangbackendipc/cmbcompletecodemessage.h +++ b/src/libs/clangbackendipc/cmbcompletecodemessage.h @@ -30,8 +30,6 @@ #include -#include - namespace ClangBackEnd { class CMBIPC_EXPORT CompleteCodeMessage @@ -39,7 +37,6 @@ class CMBIPC_EXPORT CompleteCodeMessage friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CompleteCodeMessage &message); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CompleteCodeMessage &message); friend CMBIPC_EXPORT bool operator==(const CompleteCodeMessage &first, const CompleteCodeMessage &second); - friend CMBIPC_EXPORT bool operator<(const CompleteCodeMessage &first, const CompleteCodeMessage &second); friend CMBIPC_EXPORT QDebug operator<<(QDebug debug, const CompleteCodeMessage &message); friend void PrintTo(const CompleteCodeMessage &message, ::std::ostream* os); @@ -70,13 +67,11 @@ private: CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CompleteCodeMessage &message); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CompleteCodeMessage &message); CMBIPC_EXPORT bool operator==(const CompleteCodeMessage &first, const CompleteCodeMessage &second); -CMBIPC_EXPORT bool operator<(const CompleteCodeMessage &first, const CompleteCodeMessage &second); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const CompleteCodeMessage &message); void PrintTo(const CompleteCodeMessage &message, ::std::ostream* os); +DECLARE_MESSAGE(CompleteCodeMessage); } // namespace ClangBackEnd -Q_DECLARE_METATYPE(ClangBackEnd::CompleteCodeMessage) - #endif // CLANGBACKEND_COMPLETECODEMESSAGE_H diff --git a/src/libs/clangbackendipc/cmbechomessage.cpp b/src/libs/clangbackendipc/cmbechomessage.cpp index 9fddc28dd2a..bf75b49262e 100644 --- a/src/libs/clangbackendipc/cmbechomessage.cpp +++ b/src/libs/clangbackendipc/cmbechomessage.cpp @@ -32,13 +32,12 @@ namespace ClangBackEnd { -EchoMessage::EchoMessage(const QVariant &message) +EchoMessage::EchoMessage(const MessageEnvelop &message) : message_(message) { - } -const QVariant &EchoMessage::message() const +const MessageEnvelop &EchoMessage::message() const { return message_; } @@ -62,24 +61,14 @@ bool operator==(const EchoMessage &first, const EchoMessage &second) return first.message_ == second.message_; } -bool operator<(const EchoMessage &first, const EchoMessage &second) +QDebug operator<<(QDebug debug, const EchoMessage &) { - return first.message_ < second.message_; + return debug.nospace() << "EchoMessage()"; } -QDebug operator<<(QDebug debug, const EchoMessage &message) +void PrintTo(const EchoMessage &, ::std::ostream* os) { - return debug.nospace() << "EchoMessage(" << message.message() << ")"; -} - -void PrintTo(const EchoMessage &message, ::std::ostream* os) -{ - QString output; - QDebug debug(&output); - - debug << message; - - *os << output.toUtf8().constData(); + *os << "EchoMessage()"; } } // namespace ClangBackEnd diff --git a/src/libs/clangbackendipc/cmbechomessage.h b/src/libs/clangbackendipc/cmbechomessage.h index ebd8bac7680..b1bc061d552 100644 --- a/src/libs/clangbackendipc/cmbechomessage.h +++ b/src/libs/clangbackendipc/cmbechomessage.h @@ -28,8 +28,7 @@ #include "clangbackendipc_global.h" -#include -#include +#include "messageenvelop.h" namespace ClangBackEnd { @@ -37,27 +36,24 @@ class CMBIPC_EXPORT EchoMessage { friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, EchoMessage &message); friend CMBIPC_EXPORT bool operator==(const EchoMessage &first, const EchoMessage &second); - friend CMBIPC_EXPORT bool operator<(const EchoMessage &first, const EchoMessage &second); public: EchoMessage() = default; - explicit EchoMessage(const QVariant &message); + explicit EchoMessage(const MessageEnvelop &message); - const QVariant &message() const; + const MessageEnvelop &message() const; private: - QVariant message_; + MessageEnvelop message_; }; CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const EchoMessage &message); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, EchoMessage &message); CMBIPC_EXPORT bool operator==(const EchoMessage &first, const EchoMessage &second); -CMBIPC_EXPORT bool operator<(const EchoMessage &first, const EchoMessage &second); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const EchoMessage &message); void PrintTo(const EchoMessage &message, ::std::ostream* os); +DECLARE_MESSAGE(EchoMessage) } // namespace ClangBackEnd -Q_DECLARE_METATYPE(ClangBackEnd::EchoMessage) - #endif // CLANGBACKEND_ECHOMESSAGE_H diff --git a/src/libs/clangbackendipc/cmbendmessage.cpp b/src/libs/clangbackendipc/cmbendmessage.cpp index 1e62bd5aa4c..7b37196f82f 100644 --- a/src/libs/clangbackendipc/cmbendmessage.cpp +++ b/src/libs/clangbackendipc/cmbendmessage.cpp @@ -47,11 +47,6 @@ bool operator==(const EndMessage &/*first*/, const EndMessage &/*second*/) return true; } -bool operator<(const EndMessage &/*first*/, const EndMessage &/*second*/) -{ - return true; -} - QDebug operator<<(QDebug debug, const EndMessage &/*message*/) { return debug.nospace() << "EndMessage()"; @@ -61,5 +56,6 @@ void PrintTo(const EndMessage &/*message*/, ::std::ostream* os) { *os << "EndMessage()"; } + } diff --git a/src/libs/clangbackendipc/cmbendmessage.h b/src/libs/clangbackendipc/cmbendmessage.h index f7128a42d56..91029d52b4f 100644 --- a/src/libs/clangbackendipc/cmbendmessage.h +++ b/src/libs/clangbackendipc/cmbendmessage.h @@ -28,8 +28,6 @@ #include "clangbackendipc_global.h" -#include - namespace ClangBackEnd { class CMBIPC_EXPORT EndMessage @@ -39,12 +37,11 @@ class CMBIPC_EXPORT EndMessage CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const EndMessage &message); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, EndMessage &message); CMBIPC_EXPORT bool operator==(const EndMessage &first, const EndMessage &second); -CMBIPC_EXPORT bool operator<(const EndMessage &first, const EndMessage &second); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const EndMessage &message); void PrintTo(const EndMessage &message, ::std::ostream* os); + +DECLARE_MESSAGE(EndMessage) } -Q_DECLARE_METATYPE(ClangBackEnd::EndMessage) - #endif // CMBENDMESSAGE_H diff --git a/src/libs/clangbackendipc/cmbmessages.cpp b/src/libs/clangbackendipc/cmbmessages.cpp deleted file mode 100644 index 000bb1a1f6b..00000000000 --- a/src/libs/clangbackendipc/cmbmessages.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "cmbmessages.h" - -#include "cmbalivemessage.h" -#include "cmbendmessage.h" -#include "cmbechomessage.h" -#include "cmbregistertranslationunitsforeditormessage.h" -#include "cmbunregistertranslationunitsforeditormessage.h" -#include "cmbregisterprojectsforeditormessage.h" -#include "cmbunregisterprojectsforeditormessage.h" -#include "cmbcompletecodemessage.h" -#include "cmbcodecompletedmessage.h" -#include "diagnosticcontainer.h" -#include "diagnosticschangedmessage.h" -#include "registerunsavedfilesforeditormessage.h" -#include "requestdiagnosticsmessage.h" -#include "requesthighlightingmessage.h" -#include "highlightingchangedmessage.h" -#include "highlightingmarkcontainer.h" -#include "projectpartsdonotexistmessage.h" -#include "sourcelocationcontainer.h" -#include "sourcerangecontainer.h" -#include "translationunitdoesnotexistmessage.h" -#include "unregisterunsavedfilesforeditormessage.h" -#include "updatetranslationunitsforeditormessage.h" -#include "updatevisibletranslationunitsmessage.h" - -#include - -template -static void registerMetaType() -{ - qRegisterMetaType(); - qRegisterMetaTypeStreamOperators(); - QMetaType::registerComparators(); -} - -namespace ClangBackEnd { - -void Messages::registerMessages() -{ - // Messages - registerMetaType(); - registerMetaType(); - registerMetaType(); - - registerMetaType(); - registerMetaType(); - registerMetaType(); - - registerMetaType(); - registerMetaType(); - - registerMetaType(); - registerMetaType(); - - registerMetaType(); - registerMetaType(); - - registerMetaType(); - registerMetaType(); - - registerMetaType(); - - registerMetaType(); - registerMetaType(); - registerMetaType(); - - registerMetaType(); - registerMetaType(); - - // Containers - registerMetaType(); - registerMetaType(); - registerMetaType(); - registerMetaType(); - registerMetaType(); - registerMetaType(); -} - -} // namespace ClangBackEnd - diff --git a/src/libs/clangbackendipc/cmbmessages.h b/src/libs/clangbackendipc/cmbmessages.h deleted file mode 100644 index ade7568ce55..00000000000 --- a/src/libs/clangbackendipc/cmbmessages.h +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#ifndef CLANGBACKEND_MESSAGES_H -#define CLANGBACKEND_MESSAGES_H - -#include - -namespace ClangBackEnd { - -namespace Messages -{ -CMBIPC_EXPORT void registerMessages(); -} - -} // namespace ClangBackEnd - -#endif // CLANGBACKEND_MESSAGES_H diff --git a/src/libs/clangbackendipc/cmbregisterprojectsforeditormessage.cpp b/src/libs/clangbackendipc/cmbregisterprojectsforeditormessage.cpp index 64cbc0d4d48..30f5bdcaa8e 100644 --- a/src/libs/clangbackendipc/cmbregisterprojectsforeditormessage.cpp +++ b/src/libs/clangbackendipc/cmbregisterprojectsforeditormessage.cpp @@ -25,8 +25,6 @@ #include "cmbregisterprojectsforeditormessage.h" -#include "container_common.h" - #include #include @@ -64,11 +62,6 @@ bool operator==(const RegisterProjectPartsForEditorMessage &first, const Registe return first.projectContainers_ == second.projectContainers_; } -bool operator<(const RegisterProjectPartsForEditorMessage &first, const RegisterProjectPartsForEditorMessage &second) -{ - return compareContainer(first.projectContainers_, second.projectContainers_); -} - QDebug operator<<(QDebug debug, const RegisterProjectPartsForEditorMessage &message) { debug.nospace() << "RegisterProjectPartsForEditorMessage("; diff --git a/src/libs/clangbackendipc/cmbregisterprojectsforeditormessage.h b/src/libs/clangbackendipc/cmbregisterprojectsforeditormessage.h index 98f044ecf7e..253167e119e 100644 --- a/src/libs/clangbackendipc/cmbregisterprojectsforeditormessage.h +++ b/src/libs/clangbackendipc/cmbregisterprojectsforeditormessage.h @@ -28,7 +28,6 @@ #include "projectpartcontainer.h" -#include #include namespace ClangBackEnd { @@ -38,7 +37,6 @@ class CMBIPC_EXPORT RegisterProjectPartsForEditorMessage friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RegisterProjectPartsForEditorMessage &message); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RegisterProjectPartsForEditorMessage &message); friend CMBIPC_EXPORT bool operator==(const RegisterProjectPartsForEditorMessage &first, const RegisterProjectPartsForEditorMessage &second); - friend CMBIPC_EXPORT bool operator<(const RegisterProjectPartsForEditorMessage &first, const RegisterProjectPartsForEditorMessage &second); friend void PrintTo(const RegisterProjectPartsForEditorMessage &message, ::std::ostream* os); public: RegisterProjectPartsForEditorMessage() = default; @@ -53,12 +51,11 @@ private: CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RegisterProjectPartsForEditorMessage &message); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RegisterProjectPartsForEditorMessage &message); CMBIPC_EXPORT bool operator==(const RegisterProjectPartsForEditorMessage &first, const RegisterProjectPartsForEditorMessage &second); -CMBIPC_EXPORT bool operator<(const RegisterProjectPartsForEditorMessage &first, const RegisterProjectPartsForEditorMessage &second); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const RegisterProjectPartsForEditorMessage &message); void PrintTo(const RegisterProjectPartsForEditorMessage &message, ::std::ostream* os); + +DECLARE_MESSAGE(RegisterProjectPartsForEditorMessage); } // namespace ClangBackEnd -Q_DECLARE_METATYPE(ClangBackEnd::RegisterProjectPartsForEditorMessage) - #endif // CLANGBACKEND_REGISTERPROJECTSFOREDITORMESSAGE_H diff --git a/src/libs/clangbackendipc/cmbregistertranslationunitsforeditormessage.cpp b/src/libs/clangbackendipc/cmbregistertranslationunitsforeditormessage.cpp index 612b5c48451..2eadad185be 100644 --- a/src/libs/clangbackendipc/cmbregistertranslationunitsforeditormessage.cpp +++ b/src/libs/clangbackendipc/cmbregistertranslationunitsforeditormessage.cpp @@ -25,8 +25,6 @@ #include "cmbregistertranslationunitsforeditormessage.h" -#include "container_common.h" - #include #include @@ -82,13 +80,6 @@ bool operator==(const RegisterTranslationUnitForEditorMessage &first, const Regi && first.visibleEditorFilePaths_ == second.visibleEditorFilePaths_; } -bool operator<(const RegisterTranslationUnitForEditorMessage &first, const RegisterTranslationUnitForEditorMessage &second) -{ - return compareContainer(first.fileContainers_, second.fileContainers_) - && first.currentEditorFilePath_ < second.currentEditorFilePath_ - && compareContainer(first.visibleEditorFilePaths_, second.visibleEditorFilePaths_); -} - QDebug operator<<(QDebug debug, const RegisterTranslationUnitForEditorMessage &message) { debug.nospace() << "RegisterTranslationUnitForEditorMessage("; diff --git a/src/libs/clangbackendipc/cmbregistertranslationunitsforeditormessage.h b/src/libs/clangbackendipc/cmbregistertranslationunitsforeditormessage.h index e18ae02887b..5295b130fb8 100644 --- a/src/libs/clangbackendipc/cmbregistertranslationunitsforeditormessage.h +++ b/src/libs/clangbackendipc/cmbregistertranslationunitsforeditormessage.h @@ -28,7 +28,6 @@ #include "filecontainer.h" -#include #include namespace ClangBackEnd { @@ -38,7 +37,6 @@ class CMBIPC_EXPORT RegisterTranslationUnitForEditorMessage friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RegisterTranslationUnitForEditorMessage &message); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RegisterTranslationUnitForEditorMessage &message); friend CMBIPC_EXPORT bool operator==(const RegisterTranslationUnitForEditorMessage &first, const RegisterTranslationUnitForEditorMessage &second); - friend CMBIPC_EXPORT bool operator<(const RegisterTranslationUnitForEditorMessage &first, const RegisterTranslationUnitForEditorMessage &second); friend void PrintTo(const RegisterTranslationUnitForEditorMessage &message, ::std::ostream* os); public: RegisterTranslationUnitForEditorMessage() = default; @@ -59,12 +57,11 @@ private: CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RegisterTranslationUnitForEditorMessage &message); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RegisterTranslationUnitForEditorMessage &message); CMBIPC_EXPORT bool operator==(const RegisterTranslationUnitForEditorMessage &first, const RegisterTranslationUnitForEditorMessage &second); -CMBIPC_EXPORT bool operator<(const RegisterTranslationUnitForEditorMessage &first, const RegisterTranslationUnitForEditorMessage &second); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const RegisterTranslationUnitForEditorMessage &message); void PrintTo(const RegisterTranslationUnitForEditorMessage &message, ::std::ostream* os); + +DECLARE_MESSAGE(RegisterTranslationUnitForEditorMessage); } // namespace ClangBackEnd -Q_DECLARE_METATYPE(ClangBackEnd::RegisterTranslationUnitForEditorMessage) - #endif // CLANGBACKEND_REGISTERFILEFORCODECOMPLITION_H diff --git a/src/libs/clangbackendipc/cmbunregisterprojectsforeditormessage.cpp b/src/libs/clangbackendipc/cmbunregisterprojectsforeditormessage.cpp index 5abddab857a..2b4bcf7ee8f 100644 --- a/src/libs/clangbackendipc/cmbunregisterprojectsforeditormessage.cpp +++ b/src/libs/clangbackendipc/cmbunregisterprojectsforeditormessage.cpp @@ -25,8 +25,6 @@ #include "cmbunregisterprojectsforeditormessage.h" -#include "container_common.h" - #include #include @@ -65,11 +63,6 @@ bool operator==(const UnregisterProjectPartsForEditorMessage &first, const Unreg return first.projectPartIds_ == second.projectPartIds_; } -bool operator<(const UnregisterProjectPartsForEditorMessage &first, const UnregisterProjectPartsForEditorMessage &second) -{ - return compareContainer(first.projectPartIds_, second.projectPartIds_); -} - QDebug operator<<(QDebug debug, const UnregisterProjectPartsForEditorMessage &message) { debug.nospace() << "UnregisterProjectPartsForEditorMessage("; diff --git a/src/libs/clangbackendipc/cmbunregisterprojectsforeditormessage.h b/src/libs/clangbackendipc/cmbunregisterprojectsforeditormessage.h index 7992093e377..142c914f8e1 100644 --- a/src/libs/clangbackendipc/cmbunregisterprojectsforeditormessage.h +++ b/src/libs/clangbackendipc/cmbunregisterprojectsforeditormessage.h @@ -30,8 +30,6 @@ #include -#include - namespace ClangBackEnd { class CMBIPC_EXPORT UnregisterProjectPartsForEditorMessage @@ -39,7 +37,6 @@ class CMBIPC_EXPORT UnregisterProjectPartsForEditorMessage friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UnregisterProjectPartsForEditorMessage &message); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UnregisterProjectPartsForEditorMessage &message); friend CMBIPC_EXPORT bool operator==(const UnregisterProjectPartsForEditorMessage &first, const UnregisterProjectPartsForEditorMessage &second); - friend CMBIPC_EXPORT bool operator<(const UnregisterProjectPartsForEditorMessage &first, const UnregisterProjectPartsForEditorMessage &second); friend void PrintTo(const UnregisterProjectPartsForEditorMessage &message, ::std::ostream* os); public: @@ -55,12 +52,11 @@ private: CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UnregisterProjectPartsForEditorMessage &message); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UnregisterProjectPartsForEditorMessage &message); CMBIPC_EXPORT bool operator==(const UnregisterProjectPartsForEditorMessage &first, const UnregisterProjectPartsForEditorMessage &second); -CMBIPC_EXPORT bool operator<(const UnregisterProjectPartsForEditorMessage &first, const UnregisterProjectPartsForEditorMessage &second); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const UnregisterProjectPartsForEditorMessage &message); void PrintTo(const UnregisterProjectPartsForEditorMessage &message, ::std::ostream* os); + +DECLARE_MESSAGE(UnregisterProjectPartsForEditorMessage); } // namespace ClangBackEnd -Q_DECLARE_METATYPE(ClangBackEnd::UnregisterProjectPartsForEditorMessage) - #endif // CLANGBACKEND_UNREGISTERPROJECTSFOREDITOR_H diff --git a/src/libs/clangbackendipc/cmbunregistertranslationunitsforeditormessage.cpp b/src/libs/clangbackendipc/cmbunregistertranslationunitsforeditormessage.cpp index 323506e0205..ee4295832d9 100644 --- a/src/libs/clangbackendipc/cmbunregistertranslationunitsforeditormessage.cpp +++ b/src/libs/clangbackendipc/cmbunregistertranslationunitsforeditormessage.cpp @@ -25,8 +25,6 @@ #include "cmbunregistertranslationunitsforeditormessage.h" -#include "container_common.h" - #ifdef CLANGBACKEND_TESTS #include #endif @@ -66,11 +64,6 @@ bool operator==(const UnregisterTranslationUnitsForEditorMessage &first, const U return first.fileContainers_ == second.fileContainers_; } -bool operator<(const UnregisterTranslationUnitsForEditorMessage &first, const UnregisterTranslationUnitsForEditorMessage &second) -{ - return compareContainer(first.fileContainers_, second.fileContainers_); -} - QDebug operator<<(QDebug debug, const UnregisterTranslationUnitsForEditorMessage &message) { debug.nospace() << "UnregisterTranslationUnitsForEditorMessage("; diff --git a/src/libs/clangbackendipc/cmbunregistertranslationunitsforeditormessage.h b/src/libs/clangbackendipc/cmbunregistertranslationunitsforeditormessage.h index 8a2dda3435f..a40bc33e74b 100644 --- a/src/libs/clangbackendipc/cmbunregistertranslationunitsforeditormessage.h +++ b/src/libs/clangbackendipc/cmbunregistertranslationunitsforeditormessage.h @@ -30,7 +30,6 @@ #include "filecontainer.h" -#include #include namespace ClangBackEnd { @@ -40,7 +39,6 @@ class CMBIPC_EXPORT UnregisterTranslationUnitsForEditorMessage friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UnregisterTranslationUnitsForEditorMessage &message); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UnregisterTranslationUnitsForEditorMessage &message); friend CMBIPC_EXPORT bool operator==(const UnregisterTranslationUnitsForEditorMessage &first, const UnregisterTranslationUnitsForEditorMessage &second); - friend CMBIPC_EXPORT bool operator<(const UnregisterTranslationUnitsForEditorMessage &first, const UnregisterTranslationUnitsForEditorMessage &second); friend void PrintTo(const UnregisterTranslationUnitsForEditorMessage &message, ::std::ostream* os); public: @@ -56,14 +54,13 @@ private: CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UnregisterTranslationUnitsForEditorMessage &message); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UnregisterTranslationUnitsForEditorMessage &message); CMBIPC_EXPORT bool operator==(const UnregisterTranslationUnitsForEditorMessage &first, const UnregisterTranslationUnitsForEditorMessage &second); -CMBIPC_EXPORT bool operator<(const UnregisterTranslationUnitsForEditorMessage &first, const UnregisterTranslationUnitsForEditorMessage &second); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const UnregisterTranslationUnitsForEditorMessage &message); #ifdef CLANGBACKEND_TESTS void PrintTo(const UnregisterTranslationUnitsForEditorMessage &message, ::std::ostream* os); #endif + +DECLARE_MESSAGE(UnregisterTranslationUnitsForEditorMessage); } // namespace ClangBackEnd -Q_DECLARE_METATYPE(ClangBackEnd::UnregisterTranslationUnitsForEditorMessage) - #endif // CLANGBACKEND_UNRegisterTranslationUnitForEditorMessage_H diff --git a/src/libs/clangbackendipc/codecompletion.cpp b/src/libs/clangbackendipc/codecompletion.cpp index f6ddfdcffa4..8ad39d080e4 100644 --- a/src/libs/clangbackendipc/codecompletion.cpp +++ b/src/libs/clangbackendipc/codecompletion.cpp @@ -157,11 +157,6 @@ bool operator==(const CodeCompletion &first, const CodeCompletion &second) && first.completionKind_ == second.completionKind_; } -bool operator<(const CodeCompletion &first, const CodeCompletion &second) -{ - return first.text_ < second.text_; -} - static const char *completionKindToString(CodeCompletion::Kind kind) { switch (kind) { diff --git a/src/libs/clangbackendipc/codecompletion.h b/src/libs/clangbackendipc/codecompletion.h index d783dba3c10..83d4babbb81 100644 --- a/src/libs/clangbackendipc/codecompletion.h +++ b/src/libs/clangbackendipc/codecompletion.h @@ -31,7 +31,6 @@ #include -#include #include namespace ClangBackEnd { @@ -44,7 +43,6 @@ class CMBIPC_EXPORT CodeCompletion friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CodeCompletion &message); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CodeCompletion &message); friend CMBIPC_EXPORT bool operator==(const CodeCompletion &first, const CodeCompletion &second); - friend CMBIPC_EXPORT bool operator<(const CodeCompletion &first, const CodeCompletion &second); friend CMBIPC_EXPORT QDebug operator<<(QDebug debug, const CodeCompletion &message); friend void PrintTo(const CodeCompletion &message, ::std::ostream* os); @@ -123,7 +121,6 @@ private: CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CodeCompletion &message); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CodeCompletion &message); CMBIPC_EXPORT bool operator==(const CodeCompletion &first, const CodeCompletion &second); -CMBIPC_EXPORT bool operator<(const CodeCompletion &first, const CodeCompletion &second); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const CodeCompletion &message); CMBIPC_EXPORT QDebug operator<<(QDebug debug, CodeCompletion::Kind kind); @@ -133,6 +130,4 @@ void PrintTo(CodeCompletion::Kind kind, ::std::ostream *os); void PrintTo(CodeCompletion::Availability availability, ::std::ostream *os); } // namespace ClangBackEnd -Q_DECLARE_METATYPE(ClangBackEnd::CodeCompletion) - #endif // CLANGBACKEND_CODECOMPLETION_H diff --git a/src/libs/clangbackendipc/container_common.h b/src/libs/clangbackendipc/container_common.h deleted file mode 100644 index 0b231095118..00000000000 --- a/src/libs/clangbackendipc/container_common.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#ifndef CONTAINER_COMMON_H -#define CONTAINER_COMMON_H - - -namespace ClangBackEnd { - -template -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 - diff --git a/src/libs/clangbackendipc/diagnosticcontainer.cpp b/src/libs/clangbackendipc/diagnosticcontainer.cpp index e8812b219b5..1161a773265 100644 --- a/src/libs/clangbackendipc/diagnosticcontainer.cpp +++ b/src/libs/clangbackendipc/diagnosticcontainer.cpp @@ -138,12 +138,6 @@ bool operator==(const DiagnosticContainer &first, const DiagnosticContainer &sec && first.location_ == second.location_; } -bool operator<(const DiagnosticContainer &first, const DiagnosticContainer &second) -{ - return first.text_ < second.text_ - || (first.text_ == second.text_ && first.location_ < second.location_); -} - static const char *severityToText(DiagnosticSeverity severity) { switch (severity) { diff --git a/src/libs/clangbackendipc/diagnosticcontainer.h b/src/libs/clangbackendipc/diagnosticcontainer.h index 203bbcc4cde..d71bd4b87e8 100644 --- a/src/libs/clangbackendipc/diagnosticcontainer.h +++ b/src/libs/clangbackendipc/diagnosticcontainer.h @@ -40,7 +40,6 @@ class CMBIPC_EXPORT DiagnosticContainer friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const DiagnosticContainer &container); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, DiagnosticContainer &container); friend CMBIPC_EXPORT bool operator==(const DiagnosticContainer &first, const DiagnosticContainer &second); - friend CMBIPC_EXPORT bool operator<(const DiagnosticContainer &first, const DiagnosticContainer &second); public: DiagnosticContainer() = default; @@ -81,13 +80,10 @@ private: CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const DiagnosticContainer &container); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, DiagnosticContainer &container); CMBIPC_EXPORT bool operator==(const DiagnosticContainer &first, const DiagnosticContainer &second); -CMBIPC_EXPORT bool operator<(const DiagnosticContainer &first, const DiagnosticContainer &second); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const DiagnosticContainer &container); void PrintTo(const DiagnosticContainer &container, ::std::ostream* os); } // namespace ClangBackEnd -Q_DECLARE_METATYPE(ClangBackEnd::DiagnosticContainer) - #endif // CLANGBACKEND_DIAGNOSTICCONTAINER_H diff --git a/src/libs/clangbackendipc/diagnosticschangedmessage.cpp b/src/libs/clangbackendipc/diagnosticschangedmessage.cpp index 4e1d2fbb199..2f706851ae8 100644 --- a/src/libs/clangbackendipc/diagnosticschangedmessage.cpp +++ b/src/libs/clangbackendipc/diagnosticschangedmessage.cpp @@ -25,8 +25,6 @@ #include "diagnosticschangedmessage.h" -#include "container_common.h" - #include #include @@ -73,12 +71,6 @@ bool operator==(const DiagnosticsChangedMessage &first, const DiagnosticsChanged && first.diagnostics_ == second.diagnostics_; } -bool operator<(const DiagnosticsChangedMessage &first, const DiagnosticsChangedMessage &second) -{ - return first.file_ < second.file_ - && compareContainer(first.diagnostics_, second.diagnostics_); -} - QDebug operator<<(QDebug debug, const DiagnosticsChangedMessage &message) { debug.nospace() << "DiagnosticsChangedMessage(" diff --git a/src/libs/clangbackendipc/diagnosticschangedmessage.h b/src/libs/clangbackendipc/diagnosticschangedmessage.h index d16fe91671a..8654b3c32df 100644 --- a/src/libs/clangbackendipc/diagnosticschangedmessage.h +++ b/src/libs/clangbackendipc/diagnosticschangedmessage.h @@ -39,7 +39,6 @@ class CMBIPC_EXPORT DiagnosticsChangedMessage friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const DiagnosticsChangedMessage &message); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, DiagnosticsChangedMessage &message); friend CMBIPC_EXPORT bool operator==(const DiagnosticsChangedMessage &first, const DiagnosticsChangedMessage &second); - friend CMBIPC_EXPORT bool operator<(const DiagnosticsChangedMessage &first, const DiagnosticsChangedMessage &second); friend CMBIPC_EXPORT QDebug operator<<(QDebug debug, const DiagnosticsChangedMessage &message); friend void PrintTo(const DiagnosticsChangedMessage &message, ::std::ostream* os); @@ -59,13 +58,11 @@ private: CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const DiagnosticsChangedMessage &message); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, DiagnosticsChangedMessage &message); CMBIPC_EXPORT bool operator==(const DiagnosticsChangedMessage &first, const DiagnosticsChangedMessage &second); -CMBIPC_EXPORT bool operator<(const DiagnosticsChangedMessage &first, const DiagnosticsChangedMessage &second); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const DiagnosticsChangedMessage &message); void PrintTo(const DiagnosticsChangedMessage &message, ::std::ostream* os); +DECLARE_MESSAGE(DiagnosticsChangedMessage) } // namespace ClangBackEnd -Q_DECLARE_METATYPE(ClangBackEnd::DiagnosticsChangedMessage) - #endif // CLANGBACKEND_DIAGNOSTICSCHANGEDMESSAGE_H diff --git a/src/libs/clangbackendipc/filecontainer.cpp b/src/libs/clangbackendipc/filecontainer.cpp index da3f65330e4..21cedc33718 100644 --- a/src/libs/clangbackendipc/filecontainer.cpp +++ b/src/libs/clangbackendipc/filecontainer.cpp @@ -118,14 +118,6 @@ bool operator==(const FileContainer &first, const FileContainer &second) return first.filePath_ == second.filePath_ && first.projectPartId_ == second.projectPartId_; } -bool operator<(const FileContainer &first, const FileContainer &second) -{ - if (first.filePath_ == second.filePath_) - return first.projectPartId_ < second.projectPartId_; - - return first.filePath_ < second.filePath_; -} - QDebug operator<<(QDebug debug, const FileContainer &container) { debug.nospace() << "FileContainer(" diff --git a/src/libs/clangbackendipc/filecontainer.h b/src/libs/clangbackendipc/filecontainer.h index a7af59342dc..205b0803d62 100644 --- a/src/libs/clangbackendipc/filecontainer.h +++ b/src/libs/clangbackendipc/filecontainer.h @@ -31,8 +31,6 @@ #include #include -#include - namespace ClangBackEnd { class CMBIPC_EXPORT FileContainer @@ -40,7 +38,6 @@ class CMBIPC_EXPORT FileContainer friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const FileContainer &container); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, FileContainer &container); friend CMBIPC_EXPORT bool operator==(const FileContainer &first, const FileContainer &second); - friend CMBIPC_EXPORT bool operator<(const FileContainer &first, const FileContainer &second); public: FileContainer() = default; FileContainer(const Utf8String &filePath, @@ -72,13 +69,10 @@ private: CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const FileContainer &container); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, FileContainer &container); CMBIPC_EXPORT bool operator==(const FileContainer &first, const FileContainer &second); -CMBIPC_EXPORT bool operator<(const FileContainer &first, const FileContainer &second); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const FileContainer &container); void PrintTo(const FileContainer &container, ::std::ostream* os); } // namespace ClangBackEnd -Q_DECLARE_METATYPE(ClangBackEnd::FileContainer) - #endif // CLANGBACKEND_FILECONTAINER_H diff --git a/src/libs/clangbackendipc/fixitcontainer.cpp b/src/libs/clangbackendipc/fixitcontainer.cpp index 97fdf73e5cc..89ecb38242a 100644 --- a/src/libs/clangbackendipc/fixitcontainer.cpp +++ b/src/libs/clangbackendipc/fixitcontainer.cpp @@ -70,11 +70,6 @@ bool operator==(const FixItContainer &first, const FixItContainer &second) return first.text_ == second.text_ && first.range_ == second.range_; } -bool operator<(const FixItContainer &first, const FixItContainer &second) -{ - return first.range_ < second.range_; -} - QDebug operator<<(QDebug debug, const FixItContainer &container) { debug.nospace() << "FixItContainer(" diff --git a/src/libs/clangbackendipc/fixitcontainer.h b/src/libs/clangbackendipc/fixitcontainer.h index 5868bc286f4..7e4d89890e5 100644 --- a/src/libs/clangbackendipc/fixitcontainer.h +++ b/src/libs/clangbackendipc/fixitcontainer.h @@ -35,8 +35,6 @@ class CMBIPC_EXPORT FixItContainer friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const FixItContainer &container); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, FixItContainer &container); friend CMBIPC_EXPORT bool operator==(const FixItContainer &first, const FixItContainer &second); - friend CMBIPC_EXPORT bool operator<(const FixItContainer &first, const FixItContainer &second); - public: FixItContainer() = default; FixItContainer(const Utf8String &text, @@ -53,7 +51,6 @@ private: CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const FixItContainer &container); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, FixItContainer &container); CMBIPC_EXPORT bool operator==(const FixItContainer &first, const FixItContainer &second); -CMBIPC_EXPORT bool operator<(const FixItContainer &first, const FixItContainer &second); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const FixItContainer &container); void PrintTo(const FixItContainer &container, ::std::ostream* os); diff --git a/src/libs/clangbackendipc/highlightingchangedmessage.cpp b/src/libs/clangbackendipc/highlightingchangedmessage.cpp index f4df6a4e7ff..2ecfb15414f 100644 --- a/src/libs/clangbackendipc/highlightingchangedmessage.cpp +++ b/src/libs/clangbackendipc/highlightingchangedmessage.cpp @@ -25,8 +25,6 @@ #include "highlightingchangedmessage.h" -#include "container_common.h" - #include #include @@ -83,13 +81,6 @@ bool operator==(const HighlightingChangedMessage &first, const HighlightingChang && first.skippedPreprocessorRanges_ == second.skippedPreprocessorRanges_; } -bool operator<(const HighlightingChangedMessage &first, const HighlightingChangedMessage &second) -{ - return first.file_ < second.file_ - && compareContainer(first.highlightingMarks_, second.highlightingMarks_) - && compareContainer(first.skippedPreprocessorRanges_, second.skippedPreprocessorRanges_); -} - QDebug operator<<(QDebug debug, const HighlightingChangedMessage &message) { debug.nospace() << "HighlightingChangedMessage(" diff --git a/src/libs/clangbackendipc/highlightingchangedmessage.h b/src/libs/clangbackendipc/highlightingchangedmessage.h index 0c79c699876..b4ae93b001a 100644 --- a/src/libs/clangbackendipc/highlightingchangedmessage.h +++ b/src/libs/clangbackendipc/highlightingchangedmessage.h @@ -40,7 +40,6 @@ class CMBIPC_EXPORT HighlightingChangedMessage friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const HighlightingChangedMessage &message); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, HighlightingChangedMessage &message); friend CMBIPC_EXPORT bool operator==(const HighlightingChangedMessage &first, const HighlightingChangedMessage &second); - friend CMBIPC_EXPORT bool operator<(const HighlightingChangedMessage &first, const HighlightingChangedMessage &second); friend CMBIPC_EXPORT QDebug operator<<(QDebug debug, const HighlightingChangedMessage &message); friend void PrintTo(const HighlightingChangedMessage &message, ::std::ostream* os); @@ -63,13 +62,11 @@ private: CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const HighlightingChangedMessage &message); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, HighlightingChangedMessage &message); CMBIPC_EXPORT bool operator==(const HighlightingChangedMessage &first, const HighlightingChangedMessage &second); -CMBIPC_EXPORT bool operator<(const HighlightingChangedMessage &first, const HighlightingChangedMessage &second); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const HighlightingChangedMessage &message); void PrintTo(const HighlightingChangedMessage &message, ::std::ostream* os); +DECLARE_MESSAGE(HighlightingChangedMessage) } // namespace ClangBackEnd -Q_DECLARE_METATYPE(ClangBackEnd::HighlightingChangedMessage) - #endif // CLANGBACKEND_HIGHLIGHTINGCHANGEDMESSAGE_H diff --git a/src/libs/clangbackendipc/highlightingmarkcontainer.cpp b/src/libs/clangbackendipc/highlightingmarkcontainer.cpp index 822ea6c59e7..d8ca90f31c2 100644 --- a/src/libs/clangbackendipc/highlightingmarkcontainer.cpp +++ b/src/libs/clangbackendipc/highlightingmarkcontainer.cpp @@ -96,21 +96,6 @@ bool operator==(const HighlightingMarkContainer &first, const HighlightingMarkCo && first.type_ == second.type_; } -bool operator<(const HighlightingMarkContainer &first, const HighlightingMarkContainer &second) -{ - if (first.line() == second.line()) { - if (first.column() == second.column()) { - if (first.length() == second.length()) - return first.type() < second.type(); - return first.length() < second.length(); - } - - return first.column() < second.column(); - } - - return first.line() < second.line(); -} - #define RETURN_TEXT_FOR_CASE(enumValue) case HighlightingType::enumValue: return #enumValue static const char *highlightingTypeToCStringLiteral(HighlightingType type) { diff --git a/src/libs/clangbackendipc/highlightingmarkcontainer.h b/src/libs/clangbackendipc/highlightingmarkcontainer.h index b047005906b..b4a89dd1fe1 100644 --- a/src/libs/clangbackendipc/highlightingmarkcontainer.h +++ b/src/libs/clangbackendipc/highlightingmarkcontainer.h @@ -28,8 +28,6 @@ #include "clangbackendipc_global.h" -#include - namespace ClangBackEnd { class CMBIPC_EXPORT HighlightingMarkContainer @@ -37,8 +35,6 @@ class CMBIPC_EXPORT HighlightingMarkContainer friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const HighlightingMarkContainer &container); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, HighlightingMarkContainer &container); friend CMBIPC_EXPORT bool operator==(const HighlightingMarkContainer &first, const HighlightingMarkContainer &second); - friend CMBIPC_EXPORT bool operator<(const HighlightingMarkContainer &first, const HighlightingMarkContainer &second); - public: HighlightingMarkContainer() = default; HighlightingMarkContainer(uint line, uint column, uint length, HighlightingType type); @@ -61,7 +57,6 @@ private: CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const HighlightingMarkContainer &container); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, HighlightingMarkContainer &container); CMBIPC_EXPORT bool operator==(const HighlightingMarkContainer &first, const HighlightingMarkContainer &second); -CMBIPC_EXPORT bool operator<(const HighlightingMarkContainer &first, const HighlightingMarkContainer &second); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const HighlightingMarkContainer &container); CMBIPC_EXPORT void PrintTo(HighlightingType highlightingType, ::std::ostream *os); @@ -69,6 +64,4 @@ void PrintTo(const HighlightingMarkContainer &container, ::std::ostream *os); } // namespace ClangBackEnd -Q_DECLARE_METATYPE(ClangBackEnd::HighlightingMarkContainer) - #endif // CLANGBACKEND_HIGHLIGHTINGMARKCONTAINER_H diff --git a/src/libs/clangbackendipc/ipcclientinterface.cpp b/src/libs/clangbackendipc/ipcclientinterface.cpp index 7a967490ab9..261df139f33 100644 --- a/src/libs/clangbackendipc/ipcclientinterface.cpp +++ b/src/libs/clangbackendipc/ipcclientinterface.cpp @@ -27,6 +27,7 @@ #include "cmbcodecompletedmessage.h" #include "cmbechomessage.h" +#include "messageenvelop.h" #include "projectpartsdonotexistmessage.h" #include "translationunitdoesnotexistmessage.h" #include "diagnosticschangedmessage.h" @@ -37,35 +38,33 @@ namespace ClangBackEnd { - -void IpcClientInterface::dispatch(const QVariant &message) +void IpcClientInterface::dispatch(const MessageEnvelop &messageEnvelop) { - static const int aliveMessageType = QMetaType::type("ClangBackEnd::AliveMessage"); - static const int echoMessageType = QMetaType::type("ClangBackEnd::EchoMessage"); - static const int codeCompletedMessageType = QMetaType::type("ClangBackEnd::CodeCompletedMessage"); - static const int translationUnitDoesNotExistMessage = QMetaType::type("ClangBackEnd::TranslationUnitDoesNotExistMessage"); - static const int projectPartsDoNotExistMessage = QMetaType::type("ClangBackEnd::ProjectPartsDoNotExistMessage"); - static const int diagnosticsChangedMessage = QMetaType::type("ClangBackEnd::DiagnosticsChangedMessage"); - static const int highlightingChangedMessage = QMetaType::type("ClangBackEnd::HighlightingChangedMessage"); - - int type = message.userType(); - - if (type == aliveMessageType) - alive(); - else if (type == echoMessageType) - echo(message.value()); - else if (type == codeCompletedMessageType) - codeCompleted(message.value()); - else if (type == translationUnitDoesNotExistMessage) - translationUnitDoesNotExist(message.value()); - else if (type == projectPartsDoNotExistMessage) - projectPartsDoNotExist(message.value()); - else if (type == diagnosticsChangedMessage) - diagnosticsChanged(message.value()); - else if (type == highlightingChangedMessage) - highlightingChanged(message.value()); - else - qWarning() << "Unknown IpcClientMessage"; + switch (messageEnvelop.messageType()) { + case MessageType::AliveMessage: + alive(); + break; + case MessageType::EchoMessage: + echo(messageEnvelop.message()); + break; + case MessageType::CodeCompletedMessage: + codeCompleted(messageEnvelop.message()); + break; + case MessageType::TranslationUnitDoesNotExistMessage: + translationUnitDoesNotExist(messageEnvelop.message()); + break; + case MessageType::ProjectPartsDoNotExistMessage: + projectPartsDoNotExist(messageEnvelop.message()); + break; + case MessageType::DiagnosticsChangedMessage: + diagnosticsChanged(messageEnvelop.message()); + break; + case MessageType::HighlightingChangedMessage: + highlightingChanged(messageEnvelop.message()); + break; + default: + qWarning() << "Unknown IpcClientMessage"; + } } } // namespace ClangBackEnd diff --git a/src/libs/clangbackendipc/ipcclientinterface.h b/src/libs/clangbackendipc/ipcclientinterface.h index 9dea934bde0..def01ac5e1b 100644 --- a/src/libs/clangbackendipc/ipcclientinterface.h +++ b/src/libs/clangbackendipc/ipcclientinterface.h @@ -52,7 +52,7 @@ class HighlightingChangedMessage; class CMBIPC_EXPORT IpcClientInterface : public IpcInterface { public: - void dispatch(const QVariant &message) override; + void dispatch(const MessageEnvelop &messageEnvelop) override; virtual void alive() = 0; virtual void echo(const EchoMessage &message) = 0; diff --git a/src/libs/clangbackendipc/ipcclientproxy.cpp b/src/libs/clangbackendipc/ipcclientproxy.cpp index e21be8c5872..9a0058bb20d 100644 --- a/src/libs/clangbackendipc/ipcclientproxy.cpp +++ b/src/libs/clangbackendipc/ipcclientproxy.cpp @@ -32,6 +32,7 @@ #include "diagnosticschangedmessage.h" #include "highlightingchangedmessage.h" #include "ipcserverinterface.h" +#include "messageenvelop.h" #include "projectpartsdonotexistmessage.h" #include "translationunitdoesnotexistmessage.h" @@ -72,42 +73,42 @@ IpcClientProxy &IpcClientProxy::operator=(IpcClientProxy &&other) void IpcClientProxy::alive() { - writeMessageBlock.write(QVariant::fromValue(AliveMessage())); + writeMessageBlock.write(AliveMessage()); } void IpcClientProxy::echo(const EchoMessage &message) { - writeMessageBlock.write(QVariant::fromValue(message)); + writeMessageBlock.write(message); } void IpcClientProxy::codeCompleted(const CodeCompletedMessage &message) { - writeMessageBlock.write(QVariant::fromValue(message)); + writeMessageBlock.write(message); } void IpcClientProxy::translationUnitDoesNotExist(const TranslationUnitDoesNotExistMessage &message) { - writeMessageBlock.write(QVariant::fromValue(message)); + writeMessageBlock.write(message); } void IpcClientProxy::projectPartsDoNotExist(const ProjectPartsDoNotExistMessage &message) { - writeMessageBlock.write(QVariant::fromValue(message)); + writeMessageBlock.write(message); } void IpcClientProxy::diagnosticsChanged(const DiagnosticsChangedMessage &message) { - writeMessageBlock.write(QVariant::fromValue(message)); + writeMessageBlock.write(message); } void IpcClientProxy::highlightingChanged(const HighlightingChangedMessage &message) { - writeMessageBlock.write(QVariant::fromValue(message)); + writeMessageBlock.write(message); } void IpcClientProxy::readMessages() { - for (const QVariant &message : readMessageBlock.readAll()) + for (const MessageEnvelop &message : readMessageBlock.readAll()) server->dispatch(message); } diff --git a/src/libs/clangbackendipc/ipcinterface.h b/src/libs/clangbackendipc/ipcinterface.h index b407cede7e9..f868d6db3ab 100644 --- a/src/libs/clangbackendipc/ipcinterface.h +++ b/src/libs/clangbackendipc/ipcinterface.h @@ -30,17 +30,15 @@ #include -QT_BEGIN_NAMESPACE -class QVariant; -QT_END_NAMESPACE - namespace ClangBackEnd { +class MessageEnvelop; + class CMBIPC_EXPORT IpcInterface { public: virtual ~IpcInterface(); - virtual void dispatch(const QVariant &message) = 0; + virtual void dispatch(const MessageEnvelop &messageEnvelop) = 0; }; } // namespace ClangBackEnd diff --git a/src/libs/clangbackendipc/ipcserverinterface.cpp b/src/libs/clangbackendipc/ipcserverinterface.cpp index f610061d4df..888ae27c6b8 100644 --- a/src/libs/clangbackendipc/ipcserverinterface.cpp +++ b/src/libs/clangbackendipc/ipcserverinterface.cpp @@ -30,6 +30,7 @@ #include "cmbregistertranslationunitsforeditormessage.h" #include "cmbunregisterprojectsforeditormessage.h" #include "cmbunregistertranslationunitsforeditormessage.h" +#include "messageenvelop.h" #include "registerunsavedfilesforeditormessage.h" #include "requestdiagnosticsmessage.h" #include "requesthighlightingmessage.h" @@ -42,49 +43,48 @@ namespace ClangBackEnd { -void IpcServerInterface::dispatch(const QVariant &message) +void IpcServerInterface::dispatch(const MessageEnvelop &messageEnvelop) { - static const int endMessageType = QMetaType::type("ClangBackEnd::EndMessage"); - static const int registerTranslationUnitsForEditorMessageType = QMetaType::type("ClangBackEnd::RegisterTranslationUnitForEditorMessage"); - static const int updateTranslationUnitsForEditorMessageType = QMetaType::type("ClangBackEnd::UpdateTranslationUnitsForEditorMessage"); - static const int unregisterTranslationUnitsForEditorMessageType = QMetaType::type("ClangBackEnd::UnregisterTranslationUnitsForEditorMessage"); - static const int registerProjectPartsForEditorMessageType = QMetaType::type("ClangBackEnd::RegisterProjectPartsForEditorMessage"); - static const int unregisterProjectPartsForEditorMessageType = QMetaType::type("ClangBackEnd::UnregisterProjectPartsForEditorMessage"); - static const int registerUnsavedFilesForEditorMessageType = QMetaType::type("ClangBackEnd::RegisterUnsavedFilesForEditorMessage"); - static const int unregisterUnsavedFilesForEditorMessageType = QMetaType::type("ClangBackEnd::UnregisterUnsavedFilesForEditorMessage"); - static const int completeCodeMessageType = QMetaType::type("ClangBackEnd::CompleteCodeMessage"); - static const int requestDiagnosticsMessageType = QMetaType::type("ClangBackEnd::RequestDiagnosticsMessage"); - static const int requestHighlightingTypeMessage = QMetaType::type("ClangBackEnd::RequestHighlightingMessage"); - static const int updateVisibleTranslationUnitsMessageType = QMetaType::type("ClangBackEnd::UpdateVisibleTranslationUnitsMessage"); - - int type = message.userType(); - - if (type == endMessageType) - end(); - else if (type == registerTranslationUnitsForEditorMessageType) - registerTranslationUnitsForEditor(message.value()); - else if (type == updateTranslationUnitsForEditorMessageType) - updateTranslationUnitsForEditor(message.value()); - else if (type == unregisterTranslationUnitsForEditorMessageType) - unregisterTranslationUnitsForEditor(message.value()); - else if (type == registerProjectPartsForEditorMessageType) - registerProjectPartsForEditor(message.value()); - else if (type == unregisterProjectPartsForEditorMessageType) - unregisterProjectPartsForEditor(message.value()); - else if (type == registerUnsavedFilesForEditorMessageType) - registerUnsavedFilesForEditor(message.value()); - else if (type == unregisterUnsavedFilesForEditorMessageType) - unregisterUnsavedFilesForEditor(message.value()); - else if (type == completeCodeMessageType) - completeCode(message.value()); - else if (type == requestDiagnosticsMessageType) - requestDiagnostics(message.value()); - else if (type == requestHighlightingTypeMessage) - requestHighlighting(message.value()); - else if (type == updateVisibleTranslationUnitsMessageType) - updateVisibleTranslationUnits(message.value()); - else - qWarning() << "Unknown IpcServerMessage"; + switch (messageEnvelop.messageType()) { + case MessageType::EndMessage: + end(); + break; + case MessageType::RegisterTranslationUnitForEditorMessage: + registerTranslationUnitsForEditor(messageEnvelop.message()); + break; + case MessageType::UpdateTranslationUnitsForEditorMessage: + updateTranslationUnitsForEditor(messageEnvelop.message()); + break; + case MessageType::UnregisterTranslationUnitsForEditorMessage: + unregisterTranslationUnitsForEditor(messageEnvelop.message()); + break; + case MessageType::RegisterProjectPartsForEditorMessage: + registerProjectPartsForEditor(messageEnvelop.message()); + break; + case MessageType::UnregisterProjectPartsForEditorMessage: + unregisterProjectPartsForEditor(messageEnvelop.message()); + break; + case MessageType::RegisterUnsavedFilesForEditorMessage: + registerUnsavedFilesForEditor(messageEnvelop.message()); + break; + case MessageType::UnregisterUnsavedFilesForEditorMessage: + unregisterUnsavedFilesForEditor(messageEnvelop.message()); + break; + case MessageType::CompleteCodeMessage: + completeCode(messageEnvelop.message()); + break; + case MessageType::RequestDiagnosticsMessage: + requestDiagnostics(messageEnvelop.message()); + break; + case MessageType::RequestHighlightingMessage: + requestHighlighting(messageEnvelop.message()); + break; + case MessageType::UpdateVisibleTranslationUnitsMessage: + updateVisibleTranslationUnits(messageEnvelop.message()); + break; + default: + qWarning() << "Unknown IpcServerMessage"; + } } void IpcServerInterface::addClient(IpcClientInterface *client) diff --git a/src/libs/clangbackendipc/ipcserverinterface.h b/src/libs/clangbackendipc/ipcserverinterface.h index c0e925a11f5..dd9886d58c3 100644 --- a/src/libs/clangbackendipc/ipcserverinterface.h +++ b/src/libs/clangbackendipc/ipcserverinterface.h @@ -37,7 +37,7 @@ class IpcClientInterface; class CMBIPC_EXPORT IpcServerInterface : public IpcInterface { public: - void dispatch(const QVariant &message) override; + void dispatch(const MessageEnvelop &messageEnvelop) override; virtual void end() = 0; virtual void registerTranslationUnitsForEditor(const RegisterTranslationUnitForEditorMessage &message) = 0; diff --git a/src/libs/clangbackendipc/ipcserverproxy.cpp b/src/libs/clangbackendipc/ipcserverproxy.cpp index 4147d776324..0520993e665 100644 --- a/src/libs/clangbackendipc/ipcserverproxy.cpp +++ b/src/libs/clangbackendipc/ipcserverproxy.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -56,7 +57,7 @@ IpcServerProxy::IpcServerProxy(IpcClientInterface *client, QIODevice *ioDevice) void IpcServerProxy::readMessages() { - for (const QVariant &message : readMessageBlock.readAll()) + for (const auto &message : readMessageBlock.readAll()) client->dispatch(message); } @@ -68,62 +69,62 @@ void IpcServerProxy::resetCounter() void IpcServerProxy::end() { - writeMessageBlock.write(QVariant::fromValue(EndMessage())); + writeMessageBlock.write(EndMessage()); } void IpcServerProxy::registerTranslationUnitsForEditor(const RegisterTranslationUnitForEditorMessage &message) { - writeMessageBlock.write(QVariant::fromValue(message)); + writeMessageBlock.write(message); } void IpcServerProxy::updateTranslationUnitsForEditor(const ClangBackEnd::UpdateTranslationUnitsForEditorMessage &message) { - writeMessageBlock.write(QVariant::fromValue(message)); + writeMessageBlock.write(message); } void IpcServerProxy::unregisterTranslationUnitsForEditor(const UnregisterTranslationUnitsForEditorMessage &message) { - writeMessageBlock.write(QVariant::fromValue(message)); + writeMessageBlock.write(message); } void IpcServerProxy::registerProjectPartsForEditor(const RegisterProjectPartsForEditorMessage &message) { - writeMessageBlock.write(QVariant::fromValue(message)); + writeMessageBlock.write(message); } void IpcServerProxy::unregisterProjectPartsForEditor(const UnregisterProjectPartsForEditorMessage &message) { - writeMessageBlock.write(QVariant::fromValue(message)); + writeMessageBlock.write(message); } void ClangBackEnd::IpcServerProxy::registerUnsavedFilesForEditor(const ClangBackEnd::RegisterUnsavedFilesForEditorMessage &message) { - writeMessageBlock.write(QVariant::fromValue(message)); + writeMessageBlock.write(message); } void ClangBackEnd::IpcServerProxy::unregisterUnsavedFilesForEditor(const ClangBackEnd::UnregisterUnsavedFilesForEditorMessage &message) { - writeMessageBlock.write(QVariant::fromValue(message)); + writeMessageBlock.write(message); } void IpcServerProxy::completeCode(const CompleteCodeMessage &message) { - writeMessageBlock.write(QVariant::fromValue(message)); + writeMessageBlock.write(message); } void IpcServerProxy::requestDiagnostics(const ClangBackEnd::RequestDiagnosticsMessage &message) { - writeMessageBlock.write(QVariant::fromValue(message)); + writeMessageBlock.write(message); } void IpcServerProxy::requestHighlighting(const RequestHighlightingMessage &message) { - writeMessageBlock.write(QVariant::fromValue(message)); + writeMessageBlock.write(message); } void IpcServerProxy::updateVisibleTranslationUnits(const UpdateVisibleTranslationUnitsMessage &message) { - writeMessageBlock.write(QVariant::fromValue(message)); + writeMessageBlock.write(message); } } // namespace ClangBackEnd diff --git a/src/libs/clangbackendipc/messageenvelop.h b/src/libs/clangbackendipc/messageenvelop.h new file mode 100644 index 00000000000..93dd2a0f247 --- /dev/null +++ b/src/libs/clangbackendipc/messageenvelop.h @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#ifndef CLANGBACKEND_MESSAGEENVELOP_H +#define CLANGBACKEND_MESSAGEENVELOP_H + +#include "clangbackendipc_global.h" + +#include +#include + +namespace ClangBackEnd { + +class MessageEnvelop +{ +public: + MessageEnvelop() = default; + + template + MessageEnvelop(const Message &message) + : messageType_(MessageTrait::enumeration) + { + QDataStream stream(&data, QIODevice::WriteOnly); + stream << message; + } + + template + Message message() const + { + Message message; + + QDataStream stream(&data, QIODevice::ReadOnly); + stream >> message; + + return message; + } + + MessageType messageType() const + { + return messageType_; + } + + bool isValid() const + { + return messageType_ != MessageType::InvalidMessage; + } + + friend + QDataStream &operator >>(QDataStream& in, MessageType& messageType) + { + quint32 messageTypeAsInt; + in >> messageTypeAsInt; + messageType = MessageType(messageTypeAsInt); + + return in; + } + + friend + QDataStream &operator<<(QDataStream &out, const MessageEnvelop &messageEnvelop) + { + out << reinterpret_cast(messageEnvelop.messageType_); + out << messageEnvelop.data; + + return out; + } + + friend + QDataStream &operator>>(QDataStream &in, MessageEnvelop &messageEnvelop) + { + in >> reinterpret_cast(messageEnvelop.messageType_); + in >> messageEnvelop.data; + + return in; + } + + friend + bool operator==(const MessageEnvelop &first, const MessageEnvelop &second) + { + return first.messageType_ == second.messageType_ + && first.data == second.data; + } + +private: + mutable QByteArray data; + MessageType messageType_ = MessageType::InvalidMessage; +}; + +} // namespace ClangBackEnd + +#endif // CLANGBACKEND_MESSAGEENVELOP_H diff --git a/src/libs/clangbackendipc/projectpartcontainer.cpp b/src/libs/clangbackendipc/projectpartcontainer.cpp index 8922257928f..443b7039a20 100644 --- a/src/libs/clangbackendipc/projectpartcontainer.cpp +++ b/src/libs/clangbackendipc/projectpartcontainer.cpp @@ -73,11 +73,6 @@ bool operator==(const ProjectPartContainer &first, const ProjectPartContainer &s return first.projectPartId_ == second.projectPartId_; } -bool operator<(const ProjectPartContainer &first, const ProjectPartContainer &second) -{ - return first.projectPartId_ < second.projectPartId_; -} - static Utf8String quotedArguments(const Utf8StringVector &arguments) { const Utf8String quote = Utf8String::fromUtf8("\""); diff --git a/src/libs/clangbackendipc/projectpartcontainer.h b/src/libs/clangbackendipc/projectpartcontainer.h index 5c1fdf6dc61..75a6b5142ae 100644 --- a/src/libs/clangbackendipc/projectpartcontainer.h +++ b/src/libs/clangbackendipc/projectpartcontainer.h @@ -30,8 +30,6 @@ #include -#include - namespace ClangBackEnd { class CMBIPC_EXPORT ProjectPartContainer @@ -39,7 +37,6 @@ class CMBIPC_EXPORT ProjectPartContainer friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const ProjectPartContainer &container); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, ProjectPartContainer &container); friend CMBIPC_EXPORT bool operator==(const ProjectPartContainer &first, const ProjectPartContainer &second); - friend CMBIPC_EXPORT bool operator<(const ProjectPartContainer &first, const ProjectPartContainer &second); public: ProjectPartContainer() = default; ProjectPartContainer(const Utf8String &projectPartId, @@ -56,13 +53,10 @@ private: CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const ProjectPartContainer &container); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, ProjectPartContainer &container); CMBIPC_EXPORT bool operator==(const ProjectPartContainer &first, const ProjectPartContainer &second); -CMBIPC_EXPORT bool operator<(const ProjectPartContainer &first, const ProjectPartContainer &second); QDebug operator<<(QDebug debug, const ProjectPartContainer &container); void PrintTo(const ProjectPartContainer &container, ::std::ostream* os); } // namespace ClangBackEnd -Q_DECLARE_METATYPE(ClangBackEnd::ProjectPartContainer) - #endif // CLANGBACKEND_PROJECTCONTAINER_H diff --git a/src/libs/clangbackendipc/projectpartsdonotexistmessage.cpp b/src/libs/clangbackendipc/projectpartsdonotexistmessage.cpp index 273d302ec22..c30f90b81ec 100644 --- a/src/libs/clangbackendipc/projectpartsdonotexistmessage.cpp +++ b/src/libs/clangbackendipc/projectpartsdonotexistmessage.cpp @@ -28,8 +28,6 @@ #include #include -#include - #include namespace ClangBackEnd { @@ -64,11 +62,6 @@ bool operator==(const ProjectPartsDoNotExistMessage &first, const ProjectPartsDo return first.projectPartIds_ == second.projectPartIds_; } -bool operator<(const ProjectPartsDoNotExistMessage &first, const ProjectPartsDoNotExistMessage &second) -{ - return compareContainer(first.projectPartIds_, second.projectPartIds_); -} - QDebug operator<<(QDebug debug, const ProjectPartsDoNotExistMessage &message) { debug.nospace() << "ProjectPartDoesNotExistMessage("; diff --git a/src/libs/clangbackendipc/projectpartsdonotexistmessage.h b/src/libs/clangbackendipc/projectpartsdonotexistmessage.h index 4bfce6af5b3..f79e658ff5f 100644 --- a/src/libs/clangbackendipc/projectpartsdonotexistmessage.h +++ b/src/libs/clangbackendipc/projectpartsdonotexistmessage.h @@ -30,8 +30,6 @@ #include -#include - namespace ClangBackEnd { class CMBIPC_EXPORT ProjectPartsDoNotExistMessage @@ -39,7 +37,6 @@ class CMBIPC_EXPORT ProjectPartsDoNotExistMessage friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const ProjectPartsDoNotExistMessage &message); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, ProjectPartsDoNotExistMessage &message); friend CMBIPC_EXPORT bool operator==(const ProjectPartsDoNotExistMessage &first, const ProjectPartsDoNotExistMessage &second); - friend CMBIPC_EXPORT bool operator<(const ProjectPartsDoNotExistMessage &first, const ProjectPartsDoNotExistMessage &second); friend CMBIPC_EXPORT QDebug operator<<(QDebug debug, const ProjectPartsDoNotExistMessage &message); friend void PrintTo(const ProjectPartsDoNotExistMessage &message, ::std::ostream* os); public: @@ -55,13 +52,11 @@ private: CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const ProjectPartsDoNotExistMessage &message); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, ProjectPartsDoNotExistMessage &message); CMBIPC_EXPORT bool operator==(const ProjectPartsDoNotExistMessage &first, const ProjectPartsDoNotExistMessage &second); -CMBIPC_EXPORT bool operator<(const ProjectPartsDoNotExistMessage &first, const ProjectPartsDoNotExistMessage &second); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const ProjectPartsDoNotExistMessage &message); void PrintTo(const ProjectPartsDoNotExistMessage &message, ::std::ostream* os); +DECLARE_MESSAGE(ProjectPartsDoNotExistMessage) } // namespace ClangBackEnd -Q_DECLARE_METATYPE(ClangBackEnd::ProjectPartsDoNotExistMessage) - #endif // CLANGBACKEND_PROJECTPARTSDONOTEXISTMESSAGE_H diff --git a/src/libs/clangbackendipc/readmessageblock.cpp b/src/libs/clangbackendipc/readmessageblock.cpp index cd83d1a2baa..e7ff43ffef5 100644 --- a/src/libs/clangbackendipc/readmessageblock.cpp +++ b/src/libs/clangbackendipc/readmessageblock.cpp @@ -25,6 +25,8 @@ #include "readmessageblock.h" +#include "messageenvelop.h" + #include #include #include @@ -54,11 +56,11 @@ void ReadMessageBlock::checkIfMessageIsLost(QDataStream &in) messageCounter = currentMessageCounter; } -QVariant ReadMessageBlock::read() +MessageEnvelop ReadMessageBlock::read() { QDataStream in(ioDevice); - QVariant message; + MessageEnvelop message; if (isTheWholeMessageReadable(in)) { checkIfMessageIsLost(in); @@ -68,12 +70,12 @@ QVariant ReadMessageBlock::read() return message; } -QVector ReadMessageBlock::readAll() +QVector ReadMessageBlock::readAll() { - QVector messages; + QVector messages; while (true) { - const QVariant message = read(); + const MessageEnvelop message = read(); if (message.isValid()) messages.append(message); else diff --git a/src/libs/clangbackendipc/readmessageblock.h b/src/libs/clangbackendipc/readmessageblock.h index d36ec4fd75d..1b5ddf2fb5b 100644 --- a/src/libs/clangbackendipc/readmessageblock.h +++ b/src/libs/clangbackendipc/readmessageblock.h @@ -29,20 +29,21 @@ #include QT_BEGIN_NAMESPACE -class QVariant; class QDataStream; class QIODevice; QT_END_NAMESPACE namespace ClangBackEnd { +class MessageEnvelop; + class ReadMessageBlock { public: ReadMessageBlock(QIODevice *ioDevice = nullptr); - QVariant read(); - QVector readAll(); + MessageEnvelop read(); + QVector readAll(); void resetCounter(); diff --git a/src/libs/clangbackendipc/registerunsavedfilesforeditormessage.cpp b/src/libs/clangbackendipc/registerunsavedfilesforeditormessage.cpp index d62b8838598..f0a4e176a44 100644 --- a/src/libs/clangbackendipc/registerunsavedfilesforeditormessage.cpp +++ b/src/libs/clangbackendipc/registerunsavedfilesforeditormessage.cpp @@ -25,8 +25,6 @@ #include "registerunsavedfilesforeditormessage.h" -#include "container_common.h" - #include #include @@ -63,11 +61,6 @@ bool operator==(const RegisterUnsavedFilesForEditorMessage &first, const Registe return first.fileContainers_ == second.fileContainers_; } -bool operator<(const RegisterUnsavedFilesForEditorMessage &first, const RegisterUnsavedFilesForEditorMessage &second) -{ - return compareContainer(first.fileContainers_, second.fileContainers_); -} - QDebug operator<<(QDebug debug, const RegisterUnsavedFilesForEditorMessage &message) { debug.nospace() << "RegisterUnsavedFilesForEditorMessage("; diff --git a/src/libs/clangbackendipc/registerunsavedfilesforeditormessage.h b/src/libs/clangbackendipc/registerunsavedfilesforeditormessage.h index 308d2757ae8..f5ff3730040 100644 --- a/src/libs/clangbackendipc/registerunsavedfilesforeditormessage.h +++ b/src/libs/clangbackendipc/registerunsavedfilesforeditormessage.h @@ -28,7 +28,6 @@ #include "filecontainer.h" -#include #include namespace ClangBackEnd { @@ -38,7 +37,6 @@ class CMBIPC_EXPORT RegisterUnsavedFilesForEditorMessage friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RegisterUnsavedFilesForEditorMessage &message); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RegisterUnsavedFilesForEditorMessage &message); friend CMBIPC_EXPORT bool operator==(const RegisterUnsavedFilesForEditorMessage &first, const RegisterUnsavedFilesForEditorMessage &second); - friend CMBIPC_EXPORT bool operator<(const RegisterUnsavedFilesForEditorMessage &first, const RegisterUnsavedFilesForEditorMessage &second); friend void PrintTo(const RegisterUnsavedFilesForEditorMessage &message, ::std::ostream* os); public: RegisterUnsavedFilesForEditorMessage() = default; @@ -53,12 +51,11 @@ private: CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RegisterUnsavedFilesForEditorMessage &message); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RegisterUnsavedFilesForEditorMessage &message); CMBIPC_EXPORT bool operator==(const RegisterUnsavedFilesForEditorMessage &first, const RegisterUnsavedFilesForEditorMessage &second); -CMBIPC_EXPORT bool operator<(const RegisterUnsavedFilesForEditorMessage &first, const RegisterUnsavedFilesForEditorMessage &second); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const RegisterUnsavedFilesForEditorMessage &message); void PrintTo(const RegisterUnsavedFilesForEditorMessage &message, ::std::ostream* os); + +DECLARE_MESSAGE(RegisterUnsavedFilesForEditorMessage); } // namespace ClangBackEnd -Q_DECLARE_METATYPE(ClangBackEnd::RegisterUnsavedFilesForEditorMessage) - #endif // CLANGBACKEND_REGISTERUNSAVEDFILESFOREDITORMESSAGE_H diff --git a/src/libs/clangbackendipc/requestdiagnosticsmessage.cpp b/src/libs/clangbackendipc/requestdiagnosticsmessage.cpp index 5da99c0426f..c5fb864e75b 100644 --- a/src/libs/clangbackendipc/requestdiagnosticsmessage.cpp +++ b/src/libs/clangbackendipc/requestdiagnosticsmessage.cpp @@ -61,11 +61,6 @@ bool operator==(const RequestDiagnosticsMessage &first, const RequestDiagnostics return first.file_ == second.file_; } -bool operator<(const RequestDiagnosticsMessage &first, const RequestDiagnosticsMessage &second) -{ - return first.file_ < second.file_; -} - QDebug operator<<(QDebug debug, const RequestDiagnosticsMessage &message) { debug.nospace() << "RequestDiagnosticsMessage(" diff --git a/src/libs/clangbackendipc/requestdiagnosticsmessage.h b/src/libs/clangbackendipc/requestdiagnosticsmessage.h index 2f9485ea39a..308060962a7 100644 --- a/src/libs/clangbackendipc/requestdiagnosticsmessage.h +++ b/src/libs/clangbackendipc/requestdiagnosticsmessage.h @@ -35,7 +35,6 @@ class CMBIPC_EXPORT RequestDiagnosticsMessage friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RequestDiagnosticsMessage &message); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RequestDiagnosticsMessage &message); friend CMBIPC_EXPORT bool operator==(const RequestDiagnosticsMessage &first, const RequestDiagnosticsMessage &second); - friend CMBIPC_EXPORT bool operator<(const RequestDiagnosticsMessage &first, const RequestDiagnosticsMessage &second); friend CMBIPC_EXPORT QDebug operator<<(QDebug debug, const RequestDiagnosticsMessage &message); friend void PrintTo(const RequestDiagnosticsMessage &message, ::std::ostream* os); @@ -53,13 +52,11 @@ private: CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RequestDiagnosticsMessage &message); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RequestDiagnosticsMessage &message); CMBIPC_EXPORT bool operator==(const RequestDiagnosticsMessage &first, const RequestDiagnosticsMessage &second); -CMBIPC_EXPORT bool operator<(const RequestDiagnosticsMessage &first, const RequestDiagnosticsMessage &second); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const RequestDiagnosticsMessage &message); void PrintTo(const RequestDiagnosticsMessage &message, ::std::ostream* os); +DECLARE_MESSAGE(RequestDiagnosticsMessage); } // namespace ClangBackEnd -Q_DECLARE_METATYPE(ClangBackEnd::RequestDiagnosticsMessage) - #endif // CLANGBACKEND_REQUESTDIAGNOSTICSMESSAGE_H diff --git a/src/libs/clangbackendipc/requesthighlightingmessage.cpp b/src/libs/clangbackendipc/requesthighlightingmessage.cpp index af7e7ded0f0..c849f10f510 100644 --- a/src/libs/clangbackendipc/requesthighlightingmessage.cpp +++ b/src/libs/clangbackendipc/requesthighlightingmessage.cpp @@ -61,11 +61,6 @@ bool operator==(const RequestHighlightingMessage &first, const RequestHighlighti return first.fileContainer_ == second.fileContainer_; } -bool operator<(const RequestHighlightingMessage &first, const RequestHighlightingMessage &second) -{ - return first.fileContainer_ < second.fileContainer_; -} - QDebug operator<<(QDebug debug, const RequestHighlightingMessage &message) { debug.nospace() << "RequestHighlightingMessage(" diff --git a/src/libs/clangbackendipc/requesthighlightingmessage.h b/src/libs/clangbackendipc/requesthighlightingmessage.h index 9efac734f17..f135f35bb84 100644 --- a/src/libs/clangbackendipc/requesthighlightingmessage.h +++ b/src/libs/clangbackendipc/requesthighlightingmessage.h @@ -35,7 +35,6 @@ class CMBIPC_EXPORT RequestHighlightingMessage friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RequestHighlightingMessage &message); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RequestHighlightingMessage &message); friend CMBIPC_EXPORT bool operator==(const RequestHighlightingMessage &first, const RequestHighlightingMessage &second); - friend CMBIPC_EXPORT bool operator<(const RequestHighlightingMessage &first, const RequestHighlightingMessage &second); friend CMBIPC_EXPORT QDebug operator<<(QDebug debug, const RequestHighlightingMessage &message); friend void PrintTo(const RequestHighlightingMessage &message, ::std::ostream* os); @@ -52,13 +51,11 @@ private: CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RequestHighlightingMessage &message); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RequestHighlightingMessage &message); CMBIPC_EXPORT bool operator==(const RequestHighlightingMessage &first, const RequestHighlightingMessage &second); -CMBIPC_EXPORT bool operator<(const RequestHighlightingMessage &first, const RequestHighlightingMessage &second); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const RequestHighlightingMessage &message); void PrintTo(const RequestHighlightingMessage &message, ::std::ostream* os); +DECLARE_MESSAGE(RequestHighlightingMessage) } // namespace ClangBackEnd -Q_DECLARE_METATYPE(ClangBackEnd::RequestHighlightingMessage) - #endif // CLANGBACKEND_REQUESTHIGHLIGHTING_H diff --git a/src/libs/clangbackendipc/sourcelocationcontainer.cpp b/src/libs/clangbackendipc/sourcelocationcontainer.cpp index 7879e8334dd..f274eb3e59f 100644 --- a/src/libs/clangbackendipc/sourcelocationcontainer.cpp +++ b/src/libs/clangbackendipc/sourcelocationcontainer.cpp @@ -87,13 +87,6 @@ bool operator!=(const SourceLocationContainer &first, const SourceLocationContai || first.filePath_ != second.filePath_; } -bool operator<(const SourceLocationContainer &first, const SourceLocationContainer &second) -{ - return first.filePath_ < second.filePath_ - || (first.filePath_ == second.filePath_ && first.line_ < second.line_) - || (first.filePath_ == second.filePath_ && first.line_ == second.line_ && first.column_ < second.column_); -} - QDebug operator<<(QDebug debug, const SourceLocationContainer &container) { debug.nospace() << "SourceLocationContainer(" diff --git a/src/libs/clangbackendipc/sourcelocationcontainer.h b/src/libs/clangbackendipc/sourcelocationcontainer.h index 5ff1ec059a6..954c6753848 100644 --- a/src/libs/clangbackendipc/sourcelocationcontainer.h +++ b/src/libs/clangbackendipc/sourcelocationcontainer.h @@ -30,8 +30,6 @@ #include -#include - namespace ClangBackEnd { class CMBIPC_EXPORT SourceLocationContainer @@ -40,8 +38,6 @@ class CMBIPC_EXPORT SourceLocationContainer friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, SourceLocationContainer &container); friend CMBIPC_EXPORT bool operator==(const SourceLocationContainer &first, const SourceLocationContainer &second); friend CMBIPC_EXPORT bool operator!=(const SourceLocationContainer &first, const SourceLocationContainer &second); - friend CMBIPC_EXPORT bool operator<(const SourceLocationContainer &first, const SourceLocationContainer &second); - public: SourceLocationContainer() = default; SourceLocationContainer(const Utf8String &filePath, @@ -62,13 +58,10 @@ CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const SourceLocationCont CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, SourceLocationContainer &container); CMBIPC_EXPORT bool operator==(const SourceLocationContainer &first, const SourceLocationContainer &second); CMBIPC_EXPORT bool operator!=(const SourceLocationContainer &first, const SourceLocationContainer &second); -CMBIPC_EXPORT bool operator<(const SourceLocationContainer &first, const SourceLocationContainer &second); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const SourceLocationContainer &container); void PrintTo(const SourceLocationContainer &container, ::std::ostream* os); } // namespace ClangBackEnd -Q_DECLARE_METATYPE(ClangBackEnd::SourceLocationContainer) - #endif // CLANGBACKEND_SOURCELOCATIONCONTAINER_H diff --git a/src/libs/clangbackendipc/sourcerangecontainer.cpp b/src/libs/clangbackendipc/sourcerangecontainer.cpp index 273f80199d3..dceb741e124 100644 --- a/src/libs/clangbackendipc/sourcerangecontainer.cpp +++ b/src/libs/clangbackendipc/sourcerangecontainer.cpp @@ -69,12 +69,6 @@ bool operator==(const SourceRangeContainer &first, const SourceRangeContainer &s return first.start_ == second.start_ && first.end_ == second.end_; } -bool operator<(const SourceRangeContainer &first, const SourceRangeContainer &second) -{ - return first.start_ < second.start_ - || (first.start_ == second.start_ && first.end_ < second.end_); -} - QDebug operator<<(QDebug debug, const SourceRangeContainer &container) { debug.nospace() << "SourceRangeContainer(" diff --git a/src/libs/clangbackendipc/sourcerangecontainer.h b/src/libs/clangbackendipc/sourcerangecontainer.h index c70ab970536..63dccbd2ad0 100644 --- a/src/libs/clangbackendipc/sourcerangecontainer.h +++ b/src/libs/clangbackendipc/sourcerangecontainer.h @@ -35,8 +35,6 @@ class CMBIPC_EXPORT SourceRangeContainer friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const SourceRangeContainer &container); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, SourceRangeContainer &container); friend CMBIPC_EXPORT bool operator==(const SourceRangeContainer &first, const SourceRangeContainer &second); - friend CMBIPC_EXPORT bool operator<(const SourceRangeContainer &first, const SourceRangeContainer &second); - public: SourceRangeContainer() = default; SourceRangeContainer(SourceLocationContainer start, @@ -54,13 +52,10 @@ private: CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const SourceRangeContainer &container); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, SourceRangeContainer &container); CMBIPC_EXPORT bool operator==(const SourceRangeContainer &first, const SourceRangeContainer &second); -CMBIPC_EXPORT bool operator<(const SourceRangeContainer &first, const SourceRangeContainer &second); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const SourceRangeContainer &container); void PrintTo(const SourceRangeContainer &container, ::std::ostream* os); } // namespace ClangBackEnd -Q_DECLARE_METATYPE(ClangBackEnd::SourceRangeContainer) - #endif // CLANGBACKEND_SOURCERANGECONTAINER_H diff --git a/src/libs/clangbackendipc/translationunitdoesnotexistmessage.cpp b/src/libs/clangbackendipc/translationunitdoesnotexistmessage.cpp index e4674bbb3b9..6146e27b819 100644 --- a/src/libs/clangbackendipc/translationunitdoesnotexistmessage.cpp +++ b/src/libs/clangbackendipc/translationunitdoesnotexistmessage.cpp @@ -76,11 +76,6 @@ bool operator==(const TranslationUnitDoesNotExistMessage &first, const Translati return first.fileContainer_ == second.fileContainer_; } -bool operator<(const TranslationUnitDoesNotExistMessage &first, const TranslationUnitDoesNotExistMessage &second) -{ - return first.fileContainer_ < second.fileContainer_; -} - QDebug operator<<(QDebug debug, const TranslationUnitDoesNotExistMessage &message) { debug.nospace() << "TranslationUnitDoesNotExistMessage("; diff --git a/src/libs/clangbackendipc/translationunitdoesnotexistmessage.h b/src/libs/clangbackendipc/translationunitdoesnotexistmessage.h index 119e0def497..08f2a54fc1b 100644 --- a/src/libs/clangbackendipc/translationunitdoesnotexistmessage.h +++ b/src/libs/clangbackendipc/translationunitdoesnotexistmessage.h @@ -28,8 +28,6 @@ #include "filecontainer.h" -#include - namespace ClangBackEnd { class CMBIPC_EXPORT TranslationUnitDoesNotExistMessage @@ -37,7 +35,6 @@ class CMBIPC_EXPORT TranslationUnitDoesNotExistMessage friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const TranslationUnitDoesNotExistMessage &message); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, TranslationUnitDoesNotExistMessage &message); friend CMBIPC_EXPORT bool operator==(const TranslationUnitDoesNotExistMessage &first, const TranslationUnitDoesNotExistMessage &second); - friend CMBIPC_EXPORT bool operator<(const TranslationUnitDoesNotExistMessage &first, const TranslationUnitDoesNotExistMessage &second); friend CMBIPC_EXPORT QDebug operator<<(QDebug debug, const TranslationUnitDoesNotExistMessage &message); friend void PrintTo(const TranslationUnitDoesNotExistMessage &message, ::std::ostream* os); public: @@ -56,13 +53,11 @@ private: CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const TranslationUnitDoesNotExistMessage &message); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, TranslationUnitDoesNotExistMessage &message); CMBIPC_EXPORT bool operator==(const TranslationUnitDoesNotExistMessage &first, const TranslationUnitDoesNotExistMessage &second); -CMBIPC_EXPORT bool operator<(const TranslationUnitDoesNotExistMessage &first, const TranslationUnitDoesNotExistMessage &second); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const TranslationUnitDoesNotExistMessage &message); void PrintTo(const TranslationUnitDoesNotExistMessage &message, ::std::ostream* os); +DECLARE_MESSAGE(TranslationUnitDoesNotExistMessage) } // namespace ClangBackEnd -Q_DECLARE_METATYPE(ClangBackEnd::TranslationUnitDoesNotExistMessage) - #endif // CLANGBACKEND_TRANSLATIONUNITDOESNOTEXISTSMESSAGE_H diff --git a/src/libs/clangbackendipc/unregisterunsavedfilesforeditormessage.cpp b/src/libs/clangbackendipc/unregisterunsavedfilesforeditormessage.cpp index f3bd58a1254..5420842057b 100644 --- a/src/libs/clangbackendipc/unregisterunsavedfilesforeditormessage.cpp +++ b/src/libs/clangbackendipc/unregisterunsavedfilesforeditormessage.cpp @@ -25,8 +25,6 @@ #include "unregisterunsavedfilesforeditormessage.h" -#include "container_common.h" - #include #include @@ -63,11 +61,6 @@ bool operator==(const UnregisterUnsavedFilesForEditorMessage &first, const Unreg return first.fileContainers_ == second.fileContainers_; } -bool operator<(const UnregisterUnsavedFilesForEditorMessage &first, const UnregisterUnsavedFilesForEditorMessage &second) -{ - return compareContainer(first.fileContainers_, second.fileContainers_); -} - QDebug operator<<(QDebug debug, const UnregisterUnsavedFilesForEditorMessage &message) { debug.nospace() << "UnregisterUnsavedFilesForEditorMessage("; diff --git a/src/libs/clangbackendipc/unregisterunsavedfilesforeditormessage.h b/src/libs/clangbackendipc/unregisterunsavedfilesforeditormessage.h index cb69bc58420..a993c0a97d6 100644 --- a/src/libs/clangbackendipc/unregisterunsavedfilesforeditormessage.h +++ b/src/libs/clangbackendipc/unregisterunsavedfilesforeditormessage.h @@ -28,7 +28,6 @@ #include "filecontainer.h" -#include #include namespace ClangBackEnd { @@ -38,7 +37,6 @@ class CMBIPC_EXPORT UnregisterUnsavedFilesForEditorMessage friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UnregisterUnsavedFilesForEditorMessage &message); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UnregisterUnsavedFilesForEditorMessage &message); friend CMBIPC_EXPORT bool operator==(const UnregisterUnsavedFilesForEditorMessage &first, const UnregisterUnsavedFilesForEditorMessage &second); - friend CMBIPC_EXPORT bool operator<(const UnregisterUnsavedFilesForEditorMessage &first, const UnregisterUnsavedFilesForEditorMessage &second); friend void PrintTo(const UnregisterUnsavedFilesForEditorMessage &message, ::std::ostream* os); public: UnregisterUnsavedFilesForEditorMessage() = default; @@ -53,12 +51,11 @@ private: CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UnregisterUnsavedFilesForEditorMessage &message); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UnregisterUnsavedFilesForEditorMessage &message); CMBIPC_EXPORT bool operator==(const UnregisterUnsavedFilesForEditorMessage &first, const UnregisterUnsavedFilesForEditorMessage &second); -CMBIPC_EXPORT bool operator<(const UnregisterUnsavedFilesForEditorMessage &first, const UnregisterUnsavedFilesForEditorMessage &second); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const UnregisterUnsavedFilesForEditorMessage &message); void PrintTo(const UnregisterUnsavedFilesForEditorMessage &message, ::std::ostream* os); + +DECLARE_MESSAGE(UnregisterUnsavedFilesForEditorMessage) } // namespace ClangBackEnd -Q_DECLARE_METATYPE(ClangBackEnd::UnregisterUnsavedFilesForEditorMessage) - #endif // CLANGBACKEND_UNREGISTERTRANSLATIONUNITSFOREDITORMESSAGE_H diff --git a/src/libs/clangbackendipc/updatetranslationunitsforeditormessage.cpp b/src/libs/clangbackendipc/updatetranslationunitsforeditormessage.cpp index 6d506b4aa46..08f50c16b3f 100644 --- a/src/libs/clangbackendipc/updatetranslationunitsforeditormessage.cpp +++ b/src/libs/clangbackendipc/updatetranslationunitsforeditormessage.cpp @@ -25,8 +25,6 @@ #include "updatetranslationunitsforeditormessage.h" -#include "container_common.h" - #include #include @@ -63,11 +61,6 @@ bool operator==(const UpdateTranslationUnitsForEditorMessage &first, const Updat return first.fileContainers_ == second.fileContainers_; } -bool operator<(const UpdateTranslationUnitsForEditorMessage &first, const UpdateTranslationUnitsForEditorMessage &second) -{ - return compareContainer(first.fileContainers_, second.fileContainers_); -} - QDebug operator<<(QDebug debug, const UpdateTranslationUnitsForEditorMessage &message) { debug.nospace() << "UpdateTranslationUnitsForEditorMessage("; diff --git a/src/libs/clangbackendipc/updatetranslationunitsforeditormessage.h b/src/libs/clangbackendipc/updatetranslationunitsforeditormessage.h index 5412a98cbd3..ea99fe43a2b 100644 --- a/src/libs/clangbackendipc/updatetranslationunitsforeditormessage.h +++ b/src/libs/clangbackendipc/updatetranslationunitsforeditormessage.h @@ -28,7 +28,6 @@ #include "filecontainer.h" -#include #include namespace ClangBackEnd { @@ -38,7 +37,6 @@ class CMBIPC_EXPORT UpdateTranslationUnitsForEditorMessage friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UpdateTranslationUnitsForEditorMessage &message); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UpdateTranslationUnitsForEditorMessage &message); friend CMBIPC_EXPORT bool operator==(const UpdateTranslationUnitsForEditorMessage &first, const UpdateTranslationUnitsForEditorMessage &second); - friend CMBIPC_EXPORT bool operator<(const UpdateTranslationUnitsForEditorMessage &first, const UpdateTranslationUnitsForEditorMessage &second); friend void PrintTo(const UpdateTranslationUnitsForEditorMessage &message, ::std::ostream* os); public: UpdateTranslationUnitsForEditorMessage() = default; @@ -53,12 +51,11 @@ private: CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UpdateTranslationUnitsForEditorMessage &message); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UpdateTranslationUnitsForEditorMessage &message); CMBIPC_EXPORT bool operator==(const UpdateTranslationUnitsForEditorMessage &first, const UpdateTranslationUnitsForEditorMessage &second); -CMBIPC_EXPORT bool operator<(const UpdateTranslationUnitsForEditorMessage &first, const UpdateTranslationUnitsForEditorMessage &second); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const UpdateTranslationUnitsForEditorMessage &message); void PrintTo(const UpdateTranslationUnitsForEditorMessage &message, ::std::ostream* os); + +DECLARE_MESSAGE(UpdateTranslationUnitsForEditorMessage) } // namespace ClangBackEnd -Q_DECLARE_METATYPE(ClangBackEnd::UpdateTranslationUnitsForEditorMessage) - #endif // CLANGBACKEND_UPDATEFILEFOREDITOR_H diff --git a/src/libs/clangbackendipc/updatevisibletranslationunitsmessage.cpp b/src/libs/clangbackendipc/updatevisibletranslationunitsmessage.cpp index 1976cc2333d..f142089ee0f 100644 --- a/src/libs/clangbackendipc/updatevisibletranslationunitsmessage.cpp +++ b/src/libs/clangbackendipc/updatevisibletranslationunitsmessage.cpp @@ -25,8 +25,6 @@ #include "updatevisibletranslationunitsmessage.h" -#include "container_common.h" - #include #include @@ -76,12 +74,6 @@ bool operator==(const UpdateVisibleTranslationUnitsMessage &first, const UpdateV && first.visibleEditorFilePaths_ == second.visibleEditorFilePaths_; } -bool operator<(const UpdateVisibleTranslationUnitsMessage &first, const UpdateVisibleTranslationUnitsMessage &second) -{ - return first.currentEditorFilePath_ < second.currentEditorFilePath_ - && compareContainer(first.visibleEditorFilePaths_, second.visibleEditorFilePaths_); -} - QDebug operator<<(QDebug debug, const UpdateVisibleTranslationUnitsMessage &message) { debug.nospace() << "UpdateVisibleTranslationUnitsMessage("; diff --git a/src/libs/clangbackendipc/updatevisibletranslationunitsmessage.h b/src/libs/clangbackendipc/updatevisibletranslationunitsmessage.h index 9842caa6321..f43b905ec2c 100644 --- a/src/libs/clangbackendipc/updatevisibletranslationunitsmessage.h +++ b/src/libs/clangbackendipc/updatevisibletranslationunitsmessage.h @@ -30,8 +30,6 @@ #include -#include - namespace ClangBackEnd { class CMBIPC_EXPORT UpdateVisibleTranslationUnitsMessage @@ -39,8 +37,6 @@ class CMBIPC_EXPORT UpdateVisibleTranslationUnitsMessage friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UpdateVisibleTranslationUnitsMessage &message); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UpdateVisibleTranslationUnitsMessage &message); friend CMBIPC_EXPORT bool operator==(const UpdateVisibleTranslationUnitsMessage &first, const UpdateVisibleTranslationUnitsMessage &second); - friend CMBIPC_EXPORT bool operator<(const UpdateVisibleTranslationUnitsMessage &first, const UpdateVisibleTranslationUnitsMessage &second); - public: UpdateVisibleTranslationUnitsMessage() = default; UpdateVisibleTranslationUnitsMessage(const Utf8String ¤tEditorFilePath, @@ -57,12 +53,11 @@ private: CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UpdateVisibleTranslationUnitsMessage &message); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UpdateVisibleTranslationUnitsMessage &message); CMBIPC_EXPORT bool operator==(const UpdateVisibleTranslationUnitsMessage &first, const UpdateVisibleTranslationUnitsMessage &second); -CMBIPC_EXPORT bool operator<(const UpdateVisibleTranslationUnitsMessage &first, const UpdateVisibleTranslationUnitsMessage &second); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const UpdateVisibleTranslationUnitsMessage &message); void PrintTo(const UpdateVisibleTranslationUnitsMessage &message, ::std::ostream* os); + +DECLARE_MESSAGE(UpdateVisibleTranslationUnitsMessage) } // namespace ClangBackEnd -Q_DECLARE_METATYPE(ClangBackEnd::UpdateVisibleTranslationUnitsMessage) - #endif // CLANGBACKEND_UPDATEVISIBLETRANSLATIONUNITSMESSAGE_H diff --git a/src/libs/clangbackendipc/writemessageblock.cpp b/src/libs/clangbackendipc/writemessageblock.cpp index eb142a539d3..de3d6ca6439 100644 --- a/src/libs/clangbackendipc/writemessageblock.cpp +++ b/src/libs/clangbackendipc/writemessageblock.cpp @@ -25,6 +25,8 @@ #include "writemessageblock.h" +#include "messageenvelop.h" + #include #include #include @@ -38,7 +40,7 @@ WriteMessageBlock::WriteMessageBlock(QIODevice *ioDevice) { } -void WriteMessageBlock::write(const QVariant &message) +void WriteMessageBlock::write(const MessageEnvelop &message) { QByteArray block; QDataStream out(&block, QIODevice::WriteOnly); diff --git a/src/libs/clangbackendipc/writemessageblock.h b/src/libs/clangbackendipc/writemessageblock.h index 4e523be03b6..4b611a2475a 100644 --- a/src/libs/clangbackendipc/writemessageblock.h +++ b/src/libs/clangbackendipc/writemessageblock.h @@ -36,12 +36,14 @@ QT_END_NAMESPACE namespace ClangBackEnd { +class MessageEnvelop; + class WriteMessageBlock { public: WriteMessageBlock(QIODevice *ioDevice = nullptr); - void write(const QVariant &message); + void write(const MessageEnvelop &message); qint64 counter() const; diff --git a/src/plugins/clangcodemodel/clangbackendipcintegration.cpp b/src/plugins/clangcodemodel/clangbackendipcintegration.cpp index 371f64ed762..2fc53500cc2 100644 --- a/src/plugins/clangcodemodel/clangbackendipcintegration.cpp +++ b/src/plugins/clangcodemodel/clangbackendipcintegration.cpp @@ -57,7 +57,6 @@ #include #include #include -#include #include #include #include @@ -323,15 +322,8 @@ IpcCommunicator::IpcCommunicator() initializeBackend(); } -static bool areMessagesRegistered = false; - void IpcCommunicator::initializeBackend() { - if (!areMessagesRegistered) { - areMessagesRegistered = true; - Messages::registerMessages(); - } - const QString clangBackEndProcessPath = backendProcessPath(); qCDebug(log) << "Starting" << clangBackEndProcessPath; QTC_ASSERT(QFileInfo(clangBackEndProcessPath).exists(), return); diff --git a/src/tools/clangbackend/clangbackendmain.cpp b/src/tools/clangbackend/clangbackendmain.cpp index 2a7e4e1804f..427a548f609 100644 --- a/src/tools/clangbackend/clangbackendmain.cpp +++ b/src/tools/clangbackend/clangbackendmain.cpp @@ -28,7 +28,6 @@ #include #include -#include #include QString processArguments(QCoreApplication &application) @@ -60,8 +59,6 @@ int main(int argc, char *argv[]) const QString connection = processArguments(application); - ClangBackEnd::Messages::registerMessages(); - clang_toggleCrashRecovery(true); clang_enableStackTraces(); diff --git a/tests/unit/echoserver/echoipcserver.cpp b/tests/unit/echoserver/echoipcserver.cpp index a42b731de59..42cfc517d73 100644 --- a/tests/unit/echoserver/echoipcserver.cpp +++ b/tests/unit/echoserver/echoipcserver.cpp @@ -47,7 +47,7 @@ namespace ClangBackEnd { -void EchoIpcServer::dispatch(const QVariant &message) +void EchoIpcServer::dispatch(const MessageEnvelop &message) { IpcServerInterface::dispatch(message); } @@ -60,60 +60,60 @@ void EchoIpcServer::end() void EchoIpcServer::registerTranslationUnitsForEditor(const RegisterTranslationUnitForEditorMessage &message) { - echoMessage(QVariant::fromValue(message)); + echoMessage(message); } void EchoIpcServer::updateTranslationUnitsForEditor(const UpdateTranslationUnitsForEditorMessage &message) { - echoMessage(QVariant::fromValue(message)); + echoMessage(message); } void EchoIpcServer::unregisterTranslationUnitsForEditor(const UnregisterTranslationUnitsForEditorMessage &message) { - echoMessage(QVariant::fromValue(message)); + echoMessage(message); } void EchoIpcServer::registerProjectPartsForEditor(const RegisterProjectPartsForEditorMessage &message) { - echoMessage(QVariant::fromValue(message)); + echoMessage(message); } void EchoIpcServer::unregisterProjectPartsForEditor(const UnregisterProjectPartsForEditorMessage &message) { - echoMessage(QVariant::fromValue(message)); + echoMessage(message); } void EchoIpcServer::registerUnsavedFilesForEditor(const RegisterUnsavedFilesForEditorMessage &message) { - echoMessage(QVariant::fromValue(message)); + echoMessage(message); } void EchoIpcServer::unregisterUnsavedFilesForEditor(const UnregisterUnsavedFilesForEditorMessage &message) { - echoMessage(QVariant::fromValue(message)); + echoMessage(message); } void EchoIpcServer::completeCode(const CompleteCodeMessage &message) { - echoMessage(QVariant::fromValue(message)); + echoMessage(message); } void EchoIpcServer::requestDiagnostics(const RequestDiagnosticsMessage &message) { - echoMessage(QVariant::fromValue(message)); + echoMessage(message); } void EchoIpcServer::requestHighlighting(const RequestHighlightingMessage &message) { - echoMessage(QVariant::fromValue(message)); + echoMessage(message); } void EchoIpcServer::updateVisibleTranslationUnits(const UpdateVisibleTranslationUnitsMessage &message) { - echoMessage(QVariant::fromValue(message)); + echoMessage(message); } -void EchoIpcServer::echoMessage(const QVariant &message) +void EchoIpcServer::echoMessage(const MessageEnvelop &message) { client()->echo(EchoMessage(message)); } diff --git a/tests/unit/echoserver/echoipcserver.h b/tests/unit/echoserver/echoipcserver.h index 409461b3f1a..debc1560381 100644 --- a/tests/unit/echoserver/echoipcserver.h +++ b/tests/unit/echoserver/echoipcserver.h @@ -33,7 +33,7 @@ namespace ClangBackEnd { class EchoIpcServer : public IpcServerInterface { public: - void dispatch(const QVariant &message) override; + void dispatch(const MessageEnvelop &message) override; void end() override; void registerTranslationUnitsForEditor(const RegisterTranslationUnitForEditorMessage &message) override; void updateTranslationUnitsForEditor(const UpdateTranslationUnitsForEditorMessage &message) override; @@ -48,7 +48,7 @@ public: void updateVisibleTranslationUnits(const UpdateVisibleTranslationUnitsMessage &message) override; private: - void echoMessage(const QVariant &message); + void echoMessage(const MessageEnvelop &message); }; } // namespace ClangBackEnd diff --git a/tests/unit/echoserver/echoserverprocessmain.cpp b/tests/unit/echoserver/echoserverprocessmain.cpp index dcdc51be0ee..d2d4b9fe899 100644 --- a/tests/unit/echoserver/echoserverprocessmain.cpp +++ b/tests/unit/echoserver/echoserverprocessmain.cpp @@ -25,7 +25,6 @@ #include "echoipcserver.h" -#include #include #include @@ -44,8 +43,6 @@ int main(int argc, char *argv[]) return 1; } - ClangBackEnd::Messages::registerMessages(); - ClangBackEnd::EchoIpcServer echoIpcServer; ClangBackEnd::ConnectionServer connectionServer(application.arguments()[1]); connectionServer.start(); diff --git a/tests/unit/unittest/clientserverinprocesstest.cpp b/tests/unit/unittest/clientserverinprocesstest.cpp index 7535e74ac48..98fd3f23125 100644 --- a/tests/unit/unittest/clientserverinprocesstest.cpp +++ b/tests/unit/unittest/clientserverinprocesstest.cpp @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include diff --git a/tests/unit/unittest/clientserveroutsideprocess.cpp b/tests/unit/unittest/clientserveroutsideprocess.cpp index 658965d2279..40e7e9b35ab 100644 --- a/tests/unit/unittest/clientserveroutsideprocess.cpp +++ b/tests/unit/unittest/clientserveroutsideprocess.cpp @@ -27,7 +27,6 @@ #include #include -#include #include #include #include @@ -115,7 +114,7 @@ TEST_F(ClientServerOutsideProcess, SendRegisterTranslationUnitForEditorMessage) ClangBackEnd::RegisterTranslationUnitForEditorMessage registerTranslationUnitForEditorMessage({fileContainer}, filePath, {filePath}); - EchoMessage echoMessage(QVariant::fromValue(registerTranslationUnitForEditorMessage)); + EchoMessage echoMessage(registerTranslationUnitForEditorMessage); EXPECT_CALL(mockIpcClient, echo(echoMessage)) .Times(1); @@ -128,7 +127,7 @@ TEST_F(ClientServerOutsideProcess, SendUnregisterTranslationUnitsForEditorMessag { FileContainer fileContainer(Utf8StringLiteral("foo.cpp"), Utf8StringLiteral("projectId")); ClangBackEnd::UnregisterTranslationUnitsForEditorMessage unregisterTranslationUnitsForEditorMessage ({fileContainer}); - EchoMessage echoMessage(QVariant::fromValue(unregisterTranslationUnitsForEditorMessage)); + EchoMessage echoMessage(unregisterTranslationUnitsForEditorMessage); EXPECT_CALL(mockIpcClient, echo(echoMessage)) .Times(1); @@ -140,7 +139,7 @@ TEST_F(ClientServerOutsideProcess, SendUnregisterTranslationUnitsForEditorMessag TEST_F(ClientServerOutsideProcess, SendCompleteCodeMessage) { CompleteCodeMessage codeCompleteMessage(Utf8StringLiteral("foo.cpp"), 24, 33, Utf8StringLiteral("do what I want")); - EchoMessage echoMessage(QVariant::fromValue(codeCompleteMessage)); + EchoMessage echoMessage(codeCompleteMessage); EXPECT_CALL(mockIpcClient, echo(echoMessage)) .Times(1); @@ -153,7 +152,7 @@ TEST_F(ClientServerOutsideProcess, SendRegisterProjectPartsForEditorMessage) { ClangBackEnd::ProjectPartContainer projectContainer(Utf8StringLiteral(TESTDATA_DIR"/complete.pro")); ClangBackEnd::RegisterProjectPartsForEditorMessage registerProjectPartsForEditorMessage({projectContainer}); - EchoMessage echoMessage(QVariant::fromValue(registerProjectPartsForEditorMessage)); + EchoMessage echoMessage(registerProjectPartsForEditorMessage); EXPECT_CALL(mockIpcClient, echo(echoMessage)) .Times(1); @@ -165,7 +164,7 @@ TEST_F(ClientServerOutsideProcess, SendRegisterProjectPartsForEditorMessage) TEST_F(ClientServerOutsideProcess, SendUnregisterProjectPartsForEditorMessage) { ClangBackEnd::UnregisterProjectPartsForEditorMessage unregisterProjectPartsForEditorMessage({Utf8StringLiteral(TESTDATA_DIR"/complete.pro")}); - EchoMessage echoMessage(QVariant::fromValue(unregisterProjectPartsForEditorMessage)); + EchoMessage echoMessage(unregisterProjectPartsForEditorMessage); EXPECT_CALL(mockIpcClient, echo(echoMessage)) .Times(1); diff --git a/tests/unit/unittest/main.cpp b/tests/unit/unittest/main.cpp index eaf22a9e785..97c0f189083 100644 --- a/tests/unit/unittest/main.cpp +++ b/tests/unit/unittest/main.cpp @@ -25,8 +25,6 @@ #include -#include - #include #include @@ -35,7 +33,6 @@ int main(int argc, char *argv[]) { - ClangBackEnd::Messages::registerMessages(); Sqlite::registerTypes(); QCoreApplication application(argc, argv); diff --git a/tests/unit/unittest/readandwritemessageblocktest.cpp b/tests/unit/unittest/readandwritemessageblocktest.cpp index 109f50c10c7..5a5aeede030 100644 --- a/tests/unit/unittest/readandwritemessageblocktest.cpp +++ b/tests/unit/unittest/readandwritemessageblocktest.cpp @@ -27,13 +27,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include #include #include @@ -68,7 +68,7 @@ protected: template void CompareMessage(const Type &message); - QVariant writeCodeCompletedMessage(); + ClangBackEnd::MessageEnvelop writeCodeCompletedMessage(); void popLastCharacterFromBuffer(); void pushLastCharacterToBuffer(); void readPartialMessage(); @@ -106,31 +106,31 @@ void ReadAndWriteMessageBlock::TearDown() TEST_F(ReadAndWriteMessageBlock, WriteMessageAndTestSize) { - writeMessageBlock.write(QVariant::fromValue(ClangBackEnd::EndMessage())); + writeMessageBlock.write(ClangBackEnd::EndMessage()); - ASSERT_EQ(46, buffer.size()); + ASSERT_EQ(17, buffer.size()); } TEST_F(ReadAndWriteMessageBlock, WriteSecondMessageAndTestSize) { - writeMessageBlock.write(QVariant::fromValue(ClangBackEnd::EndMessage())); + writeMessageBlock.write(ClangBackEnd::EndMessage()); - ASSERT_EQ(46, buffer.size()); + ASSERT_EQ(17, buffer.size()); } TEST_F(ReadAndWriteMessageBlock, WriteTwoMessagesAndTestCount) { - writeMessageBlock.write(QVariant::fromValue(ClangBackEnd::EndMessage())); - writeMessageBlock.write(QVariant::fromValue(ClangBackEnd::EndMessage())); + writeMessageBlock.write(ClangBackEnd::EndMessage()); + writeMessageBlock.write(ClangBackEnd::EndMessage()); ASSERT_EQ(2, writeMessageBlock.counter()); } TEST_F(ReadAndWriteMessageBlock, ReadThreeMessagesAndTestCount) { - writeMessageBlock.write(QVariant::fromValue(ClangBackEnd::EndMessage())); - writeMessageBlock.write(QVariant::fromValue(ClangBackEnd::EndMessage())); - writeMessageBlock.write(QVariant::fromValue(ClangBackEnd::EndMessage())); + writeMessageBlock.write(ClangBackEnd::EndMessage()); + writeMessageBlock.write(ClangBackEnd::EndMessage()); + writeMessageBlock.write(ClangBackEnd::EndMessage()); buffer.seek(0); ASSERT_EQ(3, readMessageBlock.readAll().count()); @@ -232,7 +232,7 @@ TEST_F(ReadAndWriteMessageBlock, GetInvalidMessageForAPartialBuffer) TEST_F(ReadAndWriteMessageBlock, ReadMessageAfterInterruption) { - const QVariant writeMessage = writeCodeCompletedMessage(); + const auto writeMessage = writeCodeCompletedMessage(); popLastCharacterFromBuffer(); buffer.seek(0); readPartialMessage(); @@ -241,16 +241,16 @@ TEST_F(ReadAndWriteMessageBlock, ReadMessageAfterInterruption) ASSERT_EQ(readMessageBlock.read(), writeMessage); } -QVariant ReadAndWriteMessageBlock::writeCodeCompletedMessage() +ClangBackEnd::MessageEnvelop ReadAndWriteMessageBlock::writeCodeCompletedMessage() { ClangBackEnd::CodeCompletedMessage message( ClangBackEnd::CodeCompletions({Utf8StringLiteral("newFunction()")}), ClangBackEnd::CompletionCorrection::NoCorrection, 1); - const QVariant writeMessage = QVariant::fromValue(message); - writeMessageBlock.write(writeMessage); - return writeMessage; + writeMessageBlock.write(message); + + return message; } void ReadAndWriteMessageBlock::popLastCharacterFromBuffer() @@ -267,7 +267,7 @@ void ReadAndWriteMessageBlock::pushLastCharacterToBuffer() void ReadAndWriteMessageBlock::readPartialMessage() { - QVariant readMessage = readMessageBlock.read(); + const ClangBackEnd::MessageEnvelop readMessage = readMessageBlock.read(); ASSERT_FALSE(readMessage.isValid()); } @@ -275,11 +275,11 @@ void ReadAndWriteMessageBlock::readPartialMessage() template void ReadAndWriteMessageBlock::CompareMessage(const Type &message) { - const QVariant writeMessage = QVariant::fromValue(message); + const ClangBackEnd::MessageEnvelop writeMessage = message; writeMessageBlock.write(writeMessage); buffer.seek(0); - const QVariant readMessage = readMessageBlock.read(); + const ClangBackEnd::MessageEnvelop readMessage = readMessageBlock.read(); ASSERT_EQ(writeMessage, readMessage); }