Clang: Rename command in message

Change-Id: I1e2671d15b0db3c670b86dd0d4bed5ee09e866f1
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
Marco Bubke
2015-08-19 12:36:43 +02:00
parent 66df65b2dd
commit ec4d002857
68 changed files with 1296 additions and 1296 deletions

View File

@@ -13,29 +13,29 @@ INCLUDEPATH += $$PWD
SOURCES += $$PWD/ipcserverinterface.cpp \ SOURCES += $$PWD/ipcserverinterface.cpp \
$$PWD/ipcserverproxy.cpp \ $$PWD/ipcserverproxy.cpp \
$$PWD/ipcclientinterface.cpp \ $$PWD/ipcclientinterface.cpp \
$$PWD/cmbendcommand.cpp \ $$PWD/cmbendmessage.cpp \
$$PWD/cmbalivecommand.cpp \ $$PWD/cmbalivemessage.cpp \
$$PWD/ipcclientproxy.cpp \ $$PWD/ipcclientproxy.cpp \
$$PWD/cmbcommands.cpp \ $$PWD/cmbmessages.cpp \
$$PWD/writecommandblock.cpp \ $$PWD/writemessageblock.cpp \
$$PWD/readcommandblock.cpp \ $$PWD/readmessageblock.cpp \
$$PWD/ipcinterface.cpp \ $$PWD/ipcinterface.cpp \
$$PWD/connectionserver.cpp \ $$PWD/connectionserver.cpp \
$$PWD/connectionclient.cpp \ $$PWD/connectionclient.cpp \
$$PWD/cmbechocommand.cpp \ $$PWD/cmbechomessage.cpp \
$$PWD/ipcclientdispatcher.cpp \ $$PWD/ipcclientdispatcher.cpp \
$$PWD/cmbregistertranslationunitsforcodecompletioncommand.cpp \ $$PWD/cmbregistertranslationunitsforcodecompletionmessage.cpp \
$$PWD/filecontainer.cpp \ $$PWD/filecontainer.cpp \
$$PWD/cmbunregistertranslationunitsforcodecompletioncommand.cpp \ $$PWD/cmbunregistertranslationunitsforcodecompletionmessage.cpp \
$$PWD/cmbcompletecodecommand.cpp \ $$PWD/cmbcompletecodemessage.cpp \
$$PWD/cmbcodecompletedcommand.cpp \ $$PWD/cmbcodecompletedmessage.cpp \
$$PWD/codecompletion.cpp \ $$PWD/codecompletion.cpp \
$$PWD/cmbregisterprojectsforcodecompletioncommand.cpp \ $$PWD/cmbregisterprojectsforcodecompletionmessage.cpp \
$$PWD/cmbunregisterprojectsforcodecompletioncommand.cpp \ $$PWD/cmbunregisterprojectsforcodecompletionmessage.cpp \
$$PWD/translationunitdoesnotexistcommand.cpp \ $$PWD/translationunitdoesnotexistmessage.cpp \
$$PWD/codecompletionchunk.cpp \ $$PWD/codecompletionchunk.cpp \
$$PWD/projectpartcontainer.cpp \ $$PWD/projectpartcontainer.cpp \
$$PWD/projectpartsdonotexistcommand.cpp \ $$PWD/projectpartsdonotexistmessage.cpp \
$$PWD/lineprefixer.cpp \ $$PWD/lineprefixer.cpp \
$$PWD/clangbackendipcdebugutils.cpp $$PWD/clangbackendipcdebugutils.cpp
@@ -43,29 +43,29 @@ HEADERS += \
$$PWD/ipcserverinterface.h \ $$PWD/ipcserverinterface.h \
$$PWD/ipcserverproxy.h \ $$PWD/ipcserverproxy.h \
$$PWD/ipcclientinterface.h \ $$PWD/ipcclientinterface.h \
$$PWD/cmbendcommand.h \ $$PWD/cmbendmessage.h \
$$PWD/cmbalivecommand.h \ $$PWD/cmbalivemessage.h \
$$PWD/ipcclientproxy.h \ $$PWD/ipcclientproxy.h \
$$PWD/cmbcommands.h \ $$PWD/cmbmessages.h \
$$PWD/writecommandblock.h \ $$PWD/writemessageblock.h \
$$PWD/readcommandblock.h \ $$PWD/readmessageblock.h \
$$PWD/ipcinterface.h \ $$PWD/ipcinterface.h \
$$PWD/connectionserver.h \ $$PWD/connectionserver.h \
$$PWD/connectionclient.h \ $$PWD/connectionclient.h \
$$PWD/cmbechocommand.h \ $$PWD/cmbechomessage.h \
$$PWD/ipcclientdispatcher.h \ $$PWD/ipcclientdispatcher.h \
$$PWD/cmbregistertranslationunitsforcodecompletioncommand.h \ $$PWD/cmbregistertranslationunitsforcodecompletionmessage.h \
$$PWD/filecontainer.h \ $$PWD/filecontainer.h \
$$PWD/cmbunregistertranslationunitsforcodecompletioncommand.h \ $$PWD/cmbunregistertranslationunitsforcodecompletionmessage.h \
$$PWD/cmbcompletecodecommand.h \ $$PWD/cmbcompletecodemessage.h \
$$PWD/cmbcodecompletedcommand.h \ $$PWD/cmbcodecompletedmessage.h \
$$PWD/codecompletion.h \ $$PWD/codecompletion.h \
$$PWD/cmbregisterprojectsforcodecompletioncommand.h \ $$PWD/cmbregisterprojectsforcodecompletionmessage.h \
$$PWD/cmbunregisterprojectsforcodecompletioncommand.h \ $$PWD/cmbunregisterprojectsforcodecompletionmessage.h \
$$PWD/translationunitdoesnotexistcommand.h \ $$PWD/translationunitdoesnotexistmessage.h \
$$PWD/codecompletionchunk.h \ $$PWD/codecompletionchunk.h \
$$PWD/projectpartcontainer.h \ $$PWD/projectpartcontainer.h \
$$PWD/projectpartsdonotexistcommand.h \ $$PWD/projectpartsdonotexistmessage.h \
$$PWD/container_common.h \ $$PWD/container_common.h \
$$PWD/clangbackendipc_global.h \ $$PWD/clangbackendipc_global.h \
$$PWD/lineprefixer.h \ $$PWD/lineprefixer.h \

View File

@@ -28,36 +28,36 @@
** **
****************************************************************************/ ****************************************************************************/
#include "cmbalivecommand.h" #include "cmbalivemessage.h"
#include <QDataStream> #include <QDataStream>
#include <QDebug> #include <QDebug>
namespace ClangBackEnd { namespace ClangBackEnd {
QDataStream &operator<<(QDataStream &out, const AliveCommand &/*command*/) QDataStream &operator<<(QDataStream &out, const AliveMessage &/*message*/)
{ {
return out; return out;
} }
QDataStream &operator>>(QDataStream &in, AliveCommand &/*command*/) QDataStream &operator>>(QDataStream &in, AliveMessage &/*message*/)
{ {
return in; return in;
} }
bool operator==(const AliveCommand &/*first*/, const AliveCommand &/*second*/) bool operator==(const AliveMessage &/*first*/, const AliveMessage &/*second*/)
{ {
return true; return true;
} }
bool operator<(const AliveCommand &/*first*/, const AliveCommand &/*second*/) bool operator<(const AliveMessage &/*first*/, const AliveMessage &/*second*/)
{ {
return true; return true;
} }
QDebug operator<<(QDebug debug, const AliveCommand &/*command*/) QDebug operator<<(QDebug debug, const AliveMessage &/*message*/)
{ {
return debug.nospace() << "AliveCommand()"; return debug.nospace() << "AliveMessage()";
} }
} }

View File

@@ -28,8 +28,8 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef CMBALIVECOMMAND_H #ifndef CMBALIVEMESSAGE_H
#define CMBALIVECOMMAND_H #define CMBALIVEMESSAGE_H
#include "clangbackendipc_global.h" #include "clangbackendipc_global.h"
@@ -37,19 +37,19 @@
namespace ClangBackEnd { namespace ClangBackEnd {
class CMBIPC_EXPORT AliveCommand class CMBIPC_EXPORT AliveMessage
{ {
}; };
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const AliveCommand &command); CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const AliveMessage &message);
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, AliveCommand &command); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, AliveMessage &message);
CMBIPC_EXPORT bool operator==(const AliveCommand &first, const AliveCommand &second); CMBIPC_EXPORT bool operator==(const AliveMessage &first, const AliveMessage &second);
CMBIPC_EXPORT bool operator<(const AliveCommand &first, const AliveCommand &second); CMBIPC_EXPORT bool operator<(const AliveMessage &first, const AliveMessage &second);
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const AliveCommand &command); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const AliveMessage &message);
} }
Q_DECLARE_METATYPE(ClangBackEnd::AliveCommand) Q_DECLARE_METATYPE(ClangBackEnd::AliveMessage)
#endif // CMBALIVECOMMAND_H #endif // CMBALIVEMESSAGE_H

View File

@@ -28,7 +28,7 @@
** **
****************************************************************************/ ****************************************************************************/
#include "cmbcodecompletedcommand.h" #include "cmbcodecompletedmessage.h"
#include <QDataStream> #include <QDataStream>
#include <QDebug> #include <QDebug>
@@ -37,66 +37,66 @@
namespace ClangBackEnd { namespace ClangBackEnd {
CodeCompletedCommand::CodeCompletedCommand(const CodeCompletions &codeCompletions, quint64 ticketNumber) CodeCompletedMessage::CodeCompletedMessage(const CodeCompletions &codeCompletions, quint64 ticketNumber)
: codeCompletions_(codeCompletions), : codeCompletions_(codeCompletions),
ticketNumber_(ticketNumber) ticketNumber_(ticketNumber)
{ {
} }
const CodeCompletions &CodeCompletedCommand::codeCompletions() const const CodeCompletions &CodeCompletedMessage::codeCompletions() const
{ {
return codeCompletions_; return codeCompletions_;
} }
quint64 CodeCompletedCommand::ticketNumber() const quint64 CodeCompletedMessage::ticketNumber() const
{ {
return ticketNumber_; return ticketNumber_;
} }
QDataStream &operator<<(QDataStream &out, const CodeCompletedCommand &command) QDataStream &operator<<(QDataStream &out, const CodeCompletedMessage &message)
{ {
out << command.codeCompletions_; out << message.codeCompletions_;
out << command.ticketNumber_; out << message.ticketNumber_;
return out; return out;
} }
QDataStream &operator>>(QDataStream &in, CodeCompletedCommand &command) QDataStream &operator>>(QDataStream &in, CodeCompletedMessage &message)
{ {
in >> command.codeCompletions_; in >> message.codeCompletions_;
in >> command.ticketNumber_; in >> message.ticketNumber_;
return in; return in;
} }
bool operator==(const CodeCompletedCommand &first, const CodeCompletedCommand &second) bool operator==(const CodeCompletedMessage &first, const CodeCompletedMessage &second)
{ {
return first.ticketNumber_ == second.ticketNumber_ return first.ticketNumber_ == second.ticketNumber_
&& first.codeCompletions_ == second.codeCompletions_; && first.codeCompletions_ == second.codeCompletions_;
} }
bool operator<(const CodeCompletedCommand &first, const CodeCompletedCommand &second) bool operator<(const CodeCompletedMessage &first, const CodeCompletedMessage &second)
{ {
return first.ticketNumber_ < second.ticketNumber_; return first.ticketNumber_ < second.ticketNumber_;
} }
QDebug operator<<(QDebug debug, const CodeCompletedCommand &command) QDebug operator<<(QDebug debug, const CodeCompletedMessage &message)
{ {
debug.nospace() << "CodeCompletedCommand("; debug.nospace() << "CodeCompletedMessage(";
debug.nospace() << command.codeCompletions_ << ", " << command.ticketNumber_; debug.nospace() << message.codeCompletions_ << ", " << message.ticketNumber_;
debug.nospace() << ")"; debug.nospace() << ")";
return debug; return debug;
} }
void PrintTo(const CodeCompletedCommand &command, ::std::ostream* os) void PrintTo(const CodeCompletedMessage &message, ::std::ostream* os)
{ {
QString output; QString output;
QDebug debug(&output); QDebug debug(&output);
debug << command; debug << message;
*os << output.toUtf8().constData(); *os << output.toUtf8().constData();
} }

View File

@@ -28,8 +28,8 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef CLANGBACKEND_CODECOMPLETEDCOMMAND_H #ifndef CLANGBACKEND_CODECOMPLETEDMESSAGE_H
#define CLANGBACKEND_CODECOMPLETEDCOMMAND_H #define CLANGBACKEND_CODECOMPLETEDMESSAGE_H
#include "codecompletion.h" #include "codecompletion.h"
@@ -38,17 +38,17 @@
namespace ClangBackEnd { namespace ClangBackEnd {
class CMBIPC_EXPORT CodeCompletedCommand class CMBIPC_EXPORT CodeCompletedMessage
{ {
friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CodeCompletedCommand &command); friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CodeCompletedMessage &message);
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CodeCompletedCommand &command); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CodeCompletedMessage &message);
friend CMBIPC_EXPORT bool operator==(const CodeCompletedCommand &first, const CodeCompletedCommand &second); friend CMBIPC_EXPORT bool operator==(const CodeCompletedMessage &first, const CodeCompletedMessage &second);
friend CMBIPC_EXPORT bool operator<(const CodeCompletedCommand &first, const CodeCompletedCommand &second); friend CMBIPC_EXPORT bool operator<(const CodeCompletedMessage &first, const CodeCompletedMessage &second);
friend CMBIPC_EXPORT QDebug operator<<(QDebug debug, const CodeCompletedCommand &command); friend CMBIPC_EXPORT QDebug operator<<(QDebug debug, const CodeCompletedMessage &message);
friend void PrintTo(const CodeCompletedCommand &command, ::std::ostream* os); friend void PrintTo(const CodeCompletedMessage &message, ::std::ostream* os);
public: public:
CodeCompletedCommand() = default; CodeCompletedMessage() = default;
CodeCompletedCommand(const CodeCompletions &codeCompletions, quint64 ticketNumber); CodeCompletedMessage(const CodeCompletions &codeCompletions, quint64 ticketNumber);
const CodeCompletions &codeCompletions() const; const CodeCompletions &codeCompletions() const;
@@ -59,16 +59,16 @@ private:
quint64 ticketNumber_ = 0; quint64 ticketNumber_ = 0;
}; };
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CodeCompletedCommand &command); CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CodeCompletedMessage &message);
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CodeCompletedCommand &command); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CodeCompletedMessage &message);
CMBIPC_EXPORT bool operator==(const CodeCompletedCommand &first, const CodeCompletedCommand &second); CMBIPC_EXPORT bool operator==(const CodeCompletedMessage &first, const CodeCompletedMessage &second);
CMBIPC_EXPORT bool operator<(const CodeCompletedCommand &first, const CodeCompletedCommand &second); CMBIPC_EXPORT bool operator<(const CodeCompletedMessage &first, const CodeCompletedMessage &second);
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const CodeCompletedCommand &command); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const CodeCompletedMessage &message);
void PrintTo(const CodeCompletedCommand &command, ::std::ostream* os); void PrintTo(const CodeCompletedMessage &message, ::std::ostream* os);
} // namespace ClangBackEnd } // namespace ClangBackEnd
Q_DECLARE_METATYPE(ClangBackEnd::CodeCompletedCommand) Q_DECLARE_METATYPE(ClangBackEnd::CodeCompletedMessage)
#endif // CLANGBACKEND_CODECOMPLETEDCOMMAND_H #endif // CLANGBACKEND_CODECOMPLETEDMESSAGE_H

View File

@@ -28,7 +28,7 @@
** **
****************************************************************************/ ****************************************************************************/
#include "cmbcompletecodecommand.h" #include "cmbcompletecodemessage.h"
#include <QDataStream> #include <QDataStream>
#include <QDebug> #include <QDebug>
@@ -37,9 +37,9 @@
namespace ClangBackEnd { namespace ClangBackEnd {
quint64 CompleteCodeCommand::ticketCounter = 0; quint64 CompleteCodeMessage::ticketCounter = 0;
CompleteCodeCommand::CompleteCodeCommand(const Utf8String &filePath, quint32 line, quint32 column, const Utf8String &projectPartId) CompleteCodeMessage::CompleteCodeMessage(const Utf8String &filePath, quint32 line, quint32 column, const Utf8String &projectPartId)
: filePath_(filePath), : filePath_(filePath),
projectPartId_(projectPartId), projectPartId_(projectPartId),
ticketNumber_(++ticketCounter), ticketNumber_(++ticketCounter),
@@ -48,54 +48,54 @@ CompleteCodeCommand::CompleteCodeCommand(const Utf8String &filePath, quint32 lin
{ {
} }
const Utf8String &CompleteCodeCommand::filePath() const const Utf8String &CompleteCodeMessage::filePath() const
{ {
return filePath_; return filePath_;
} }
const Utf8String &CompleteCodeCommand::projectPartId() const const Utf8String &CompleteCodeMessage::projectPartId() const
{ {
return projectPartId_; return projectPartId_;
} }
quint32 CompleteCodeCommand::line() const quint32 CompleteCodeMessage::line() const
{ {
return line_; return line_;
} }
quint32 CompleteCodeCommand::column() const quint32 CompleteCodeMessage::column() const
{ {
return column_; return column_;
} }
quint64 CompleteCodeCommand::ticketNumber() const quint64 CompleteCodeMessage::ticketNumber() const
{ {
return ticketNumber_; return ticketNumber_;
} }
QDataStream &operator<<(QDataStream &out, const CompleteCodeCommand &command) QDataStream &operator<<(QDataStream &out, const CompleteCodeMessage &message)
{ {
out << command.filePath_; out << message.filePath_;
out << command.projectPartId_; out << message.projectPartId_;
out << command.ticketNumber_; out << message.ticketNumber_;
out << command.line_; out << message.line_;
out << command.column_; out << message.column_;
return out; return out;
} }
QDataStream &operator>>(QDataStream &in, CompleteCodeCommand &command) QDataStream &operator>>(QDataStream &in, CompleteCodeMessage &message)
{ {
in >> command.filePath_; in >> message.filePath_;
in >> command.projectPartId_; in >> message.projectPartId_;
in >> command.ticketNumber_; in >> message.ticketNumber_;
in >> command.line_; in >> message.line_;
in >> command.column_; in >> message.column_;
return in; return in;
} }
bool operator==(const CompleteCodeCommand &first, const CompleteCodeCommand &second) bool operator==(const CompleteCodeMessage &first, const CompleteCodeMessage &second)
{ {
return first.ticketNumber_ == second.ticketNumber_ return first.ticketNumber_ == second.ticketNumber_
&& first.filePath_ == second.filePath_ && first.filePath_ == second.filePath_
@@ -104,7 +104,7 @@ bool operator==(const CompleteCodeCommand &first, const CompleteCodeCommand &sec
&& first.column_ == second.column_; && first.column_ == second.column_;
} }
bool operator<(const CompleteCodeCommand &first, const CompleteCodeCommand &second) bool operator<(const CompleteCodeMessage &first, const CompleteCodeMessage &second)
{ {
return first.ticketNumber_ < second.ticketNumber_ return first.ticketNumber_ < second.ticketNumber_
&& first.filePath_ < second.filePath_ && first.filePath_ < second.filePath_
@@ -113,30 +113,30 @@ bool operator<(const CompleteCodeCommand &first, const CompleteCodeCommand &seco
&& first.column_ < second.column_; && first.column_ < second.column_;
} }
QDebug operator<<(QDebug debug, const CompleteCodeCommand &command) QDebug operator<<(QDebug debug, const CompleteCodeMessage &message)
{ {
debug.nospace() << "CompleteCodeCommand("; debug.nospace() << "CompleteCodeMessage(";
debug.nospace() << command.filePath_ << ", "; debug.nospace() << message.filePath_ << ", ";
debug.nospace() << command.line_<< ", "; debug.nospace() << message.line_<< ", ";
debug.nospace() << command.column_<< ", "; debug.nospace() << message.column_<< ", ";
debug.nospace() << command.projectPartId_ << ", "; debug.nospace() << message.projectPartId_ << ", ";
debug.nospace() << command.ticketNumber_; debug.nospace() << message.ticketNumber_;
debug.nospace() << ")"; debug.nospace() << ")";
return debug; return debug;
} }
void PrintTo(const CompleteCodeCommand &command, ::std::ostream* os) void PrintTo(const CompleteCodeMessage &message, ::std::ostream* os)
{ {
*os << "CompleteCodeCommand("; *os << "CompleteCodeMessage(";
*os << command.filePath_.constData() << ", "; *os << message.filePath_.constData() << ", ";
*os << command.line_ << ", "; *os << message.line_ << ", ";
*os << command.column_ << ", "; *os << message.column_ << ", ";
*os << command.projectPartId_.constData() << ", "; *os << message.projectPartId_.constData() << ", ";
*os << command.ticketNumber_; *os << message.ticketNumber_;
*os << ")"; *os << ")";
} }

View File

@@ -28,8 +28,8 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef CLANGBACKEND_COMPLETECODECOMMAND_H #ifndef CLANGBACKEND_COMPLETECODEMESSAGE_H
#define CLANGBACKEND_COMPLETECODECOMMAND_H #define CLANGBACKEND_COMPLETECODEMESSAGE_H
#include "clangbackendipc_global.h" #include "clangbackendipc_global.h"
@@ -39,18 +39,18 @@
namespace ClangBackEnd { namespace ClangBackEnd {
class CMBIPC_EXPORT CompleteCodeCommand class CMBIPC_EXPORT CompleteCodeMessage
{ {
friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CompleteCodeCommand &command); friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CompleteCodeMessage &message);
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CompleteCodeCommand &command); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CompleteCodeMessage &message);
friend CMBIPC_EXPORT bool operator==(const CompleteCodeCommand &first, const CompleteCodeCommand &second); friend CMBIPC_EXPORT bool operator==(const CompleteCodeMessage &first, const CompleteCodeMessage &second);
friend CMBIPC_EXPORT bool operator<(const CompleteCodeCommand &first, const CompleteCodeCommand &second); friend CMBIPC_EXPORT bool operator<(const CompleteCodeMessage &first, const CompleteCodeMessage &second);
friend CMBIPC_EXPORT QDebug operator<<(QDebug debug, const CompleteCodeCommand &command); friend CMBIPC_EXPORT QDebug operator<<(QDebug debug, const CompleteCodeMessage &message);
friend void PrintTo(const CompleteCodeCommand &command, ::std::ostream* os); friend void PrintTo(const CompleteCodeMessage &message, ::std::ostream* os);
public: public:
CompleteCodeCommand() = default; CompleteCodeMessage() = default;
CompleteCodeCommand(const Utf8String &filePath, CompleteCodeMessage(const Utf8String &filePath,
quint32 line, quint32 line,
quint32 column, quint32 column,
const Utf8String &projectPartId); const Utf8String &projectPartId);
@@ -72,16 +72,16 @@ private:
quint32 column_ = 0; quint32 column_ = 0;
}; };
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CompleteCodeCommand &command); CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CompleteCodeMessage &message);
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CompleteCodeCommand &command); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CompleteCodeMessage &message);
CMBIPC_EXPORT bool operator==(const CompleteCodeCommand &first, const CompleteCodeCommand &second); CMBIPC_EXPORT bool operator==(const CompleteCodeMessage &first, const CompleteCodeMessage &second);
CMBIPC_EXPORT bool operator<(const CompleteCodeCommand &first, const CompleteCodeCommand &second); CMBIPC_EXPORT bool operator<(const CompleteCodeMessage &first, const CompleteCodeMessage &second);
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const CompleteCodeCommand &command); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const CompleteCodeMessage &message);
void PrintTo(const CompleteCodeCommand &command, ::std::ostream* os); void PrintTo(const CompleteCodeMessage &message, ::std::ostream* os);
} // namespace ClangBackEnd } // namespace ClangBackEnd
Q_DECLARE_METATYPE(ClangBackEnd::CompleteCodeCommand) Q_DECLARE_METATYPE(ClangBackEnd::CompleteCodeMessage)
#endif // CLANGBACKEND_COMPLETECODECOMMAND_H #endif // CLANGBACKEND_COMPLETECODEMESSAGE_H

View File

@@ -28,7 +28,7 @@
** **
****************************************************************************/ ****************************************************************************/
#include "cmbechocommand.h" #include "cmbechomessage.h"
#include <QDataStream> #include <QDataStream>
#include <QDebug> #include <QDebug>
@@ -37,52 +37,52 @@
namespace ClangBackEnd { namespace ClangBackEnd {
EchoCommand::EchoCommand(const QVariant &command) EchoMessage::EchoMessage(const QVariant &message)
: command_(command) : message_(message)
{ {
} }
const QVariant &EchoCommand::command() const const QVariant &EchoMessage::message() const
{ {
return command_; return message_;
} }
QDataStream &operator<<(QDataStream &out, const EchoCommand &command) QDataStream &operator<<(QDataStream &out, const EchoMessage &message)
{ {
out << command.command(); out << message.message();
return out; return out;
} }
QDataStream &operator>>(QDataStream &in, EchoCommand &command) QDataStream &operator>>(QDataStream &in, EchoMessage &message)
{ {
in >> command.command_; in >> message.message_;
return in; return in;
} }
bool operator==(const EchoCommand &first, const EchoCommand &second) bool operator==(const EchoMessage &first, const EchoMessage &second)
{ {
return first.command_ == second.command_; return first.message_ == second.message_;
} }
bool operator<(const EchoCommand &first, const EchoCommand &second) bool operator<(const EchoMessage &first, const EchoMessage &second)
{ {
return first.command_ < second.command_; return first.message_ < second.message_;
} }
QDebug operator<<(QDebug debug, const EchoCommand &command) QDebug operator<<(QDebug debug, const EchoMessage &message)
{ {
return debug.nospace() << "EchoCommand(" << command.command() << ")"; return debug.nospace() << "EchoMessage(" << message.message() << ")";
} }
void PrintTo(const EchoCommand &command, ::std::ostream* os) void PrintTo(const EchoMessage &message, ::std::ostream* os)
{ {
QString output; QString output;
QDebug debug(&output); QDebug debug(&output);
debug << command; debug << message;
*os << output.toUtf8().constData(); *os << output.toUtf8().constData();
} }

View File

@@ -28,8 +28,8 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef CLANGBACKEND_ECHOCOMMAND_H #ifndef CLANGBACKEND_ECHOMESSAGE_H
#define CLANGBACKEND_ECHOCOMMAND_H #define CLANGBACKEND_ECHOMESSAGE_H
#include "clangbackendipc_global.h" #include "clangbackendipc_global.h"
@@ -38,31 +38,31 @@
namespace ClangBackEnd { namespace ClangBackEnd {
class CMBIPC_EXPORT EchoCommand class CMBIPC_EXPORT EchoMessage
{ {
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, EchoCommand &command); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, EchoMessage &message);
friend CMBIPC_EXPORT bool operator==(const EchoCommand &first, const EchoCommand &second); friend CMBIPC_EXPORT bool operator==(const EchoMessage &first, const EchoMessage &second);
friend CMBIPC_EXPORT bool operator<(const EchoCommand &first, const EchoCommand &second); friend CMBIPC_EXPORT bool operator<(const EchoMessage &first, const EchoMessage &second);
public: public:
EchoCommand() = default; EchoMessage() = default;
explicit EchoCommand(const QVariant &command); explicit EchoMessage(const QVariant &message);
const QVariant &command() const; const QVariant &message() const;
private: private:
QVariant command_; QVariant message_;
}; };
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const EchoCommand &command); CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const EchoMessage &message);
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, EchoCommand &command); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, EchoMessage &message);
CMBIPC_EXPORT bool operator==(const EchoCommand &first, const EchoCommand &second); CMBIPC_EXPORT bool operator==(const EchoMessage &first, const EchoMessage &second);
CMBIPC_EXPORT bool operator<(const EchoCommand &first, const EchoCommand &second); CMBIPC_EXPORT bool operator<(const EchoMessage &first, const EchoMessage &second);
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const EchoCommand &command); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const EchoMessage &message);
void PrintTo(const EchoCommand &command, ::std::ostream* os); void PrintTo(const EchoMessage &message, ::std::ostream* os);
} // namespace ClangBackEnd } // namespace ClangBackEnd
Q_DECLARE_METATYPE(ClangBackEnd::EchoCommand) Q_DECLARE_METATYPE(ClangBackEnd::EchoMessage)
#endif // CLANGBACKEND_ECHOCOMMAND_H #endif // CLANGBACKEND_ECHOMESSAGE_H

View File

@@ -28,7 +28,7 @@
** **
****************************************************************************/ ****************************************************************************/
#include "cmbendcommand.h" #include "cmbendmessage.h"
#include <QDataStream> #include <QDataStream>
#include <QDebug> #include <QDebug>
@@ -37,34 +37,34 @@
namespace ClangBackEnd { namespace ClangBackEnd {
QDataStream &operator<<(QDataStream &out, const EndCommand &/*command*/) QDataStream &operator<<(QDataStream &out, const EndMessage &/*message*/)
{ {
return out; return out;
} }
QDataStream &operator>>(QDataStream &in, EndCommand &/*command*/) QDataStream &operator>>(QDataStream &in, EndMessage &/*message*/)
{ {
return in; return in;
} }
bool operator==(const EndCommand &/*first*/, const EndCommand &/*second*/) bool operator==(const EndMessage &/*first*/, const EndMessage &/*second*/)
{ {
return true; return true;
} }
bool operator<(const EndCommand &/*first*/, const EndCommand &/*second*/) bool operator<(const EndMessage &/*first*/, const EndMessage &/*second*/)
{ {
return true; return true;
} }
QDebug operator<<(QDebug debug, const EndCommand &/*command*/) QDebug operator<<(QDebug debug, const EndMessage &/*message*/)
{ {
return debug.nospace() << "EndCommand()"; return debug.nospace() << "EndMessage()";
} }
void PrintTo(const EndCommand &/*command*/, ::std::ostream* os) void PrintTo(const EndMessage &/*message*/, ::std::ostream* os)
{ {
*os << "EndCommand()"; *os << "EndMessage()";
} }
} }

View File

@@ -28,8 +28,8 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef CMBENDCOMMAND_H #ifndef CMBENDMESSAGE_H
#define CMBENDCOMMAND_H #define CMBENDMESSAGE_H
#include "clangbackendipc_global.h" #include "clangbackendipc_global.h"
@@ -37,19 +37,19 @@
namespace ClangBackEnd { namespace ClangBackEnd {
class CMBIPC_EXPORT EndCommand class CMBIPC_EXPORT EndMessage
{ {
}; };
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const EndCommand &command); CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const EndMessage &message);
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, EndCommand &command); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, EndMessage &message);
CMBIPC_EXPORT bool operator==(const EndCommand &first, const EndCommand &second); CMBIPC_EXPORT bool operator==(const EndMessage &first, const EndMessage &second);
CMBIPC_EXPORT bool operator<(const EndCommand &first, const EndCommand &second); CMBIPC_EXPORT bool operator<(const EndMessage &first, const EndMessage &second);
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const EndCommand &command); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const EndMessage &message);
void PrintTo(const EndCommand &command, ::std::ostream* os); void PrintTo(const EndMessage &message, ::std::ostream* os);
} }
Q_DECLARE_METATYPE(ClangBackEnd::EndCommand) Q_DECLARE_METATYPE(ClangBackEnd::EndMessage)
#endif // CMBENDCOMMAND_H #endif // CMBENDMESSAGE_H

View File

@@ -28,80 +28,80 @@
** **
****************************************************************************/ ****************************************************************************/
#include "cmbcommands.h" #include "cmbmessages.h"
#include "cmbalivecommand.h" #include "cmbalivemessage.h"
#include "cmbendcommand.h" #include "cmbendmessage.h"
#include "cmbechocommand.h" #include "cmbechomessage.h"
#include "cmbregistertranslationunitsforcodecompletioncommand.h" #include "cmbregistertranslationunitsforcodecompletionmessage.h"
#include "cmbunregistertranslationunitsforcodecompletioncommand.h" #include "cmbunregistertranslationunitsforcodecompletionmessage.h"
#include "cmbregisterprojectsforcodecompletioncommand.h" #include "cmbregisterprojectsforcodecompletionmessage.h"
#include "cmbunregisterprojectsforcodecompletioncommand.h" #include "cmbunregisterprojectsforcodecompletionmessage.h"
#include "cmbcompletecodecommand.h" #include "cmbcompletecodemessage.h"
#include "cmbcodecompletedcommand.h" #include "cmbcodecompletedmessage.h"
#include "projectpartsdonotexistcommand.h" #include "projectpartsdonotexistmessage.h"
#include "translationunitdoesnotexistcommand.h" #include "translationunitdoesnotexistmessage.h"
#include <QDataStream> #include <QDataStream>
namespace ClangBackEnd { namespace ClangBackEnd {
void Commands::registerCommands() void Messages::registerMessages()
{ {
qRegisterMetaType<EndCommand>(); qRegisterMetaType<EndMessage>();
qRegisterMetaTypeStreamOperators<EndCommand>(); qRegisterMetaTypeStreamOperators<EndMessage>();
QMetaType::registerComparators<EndCommand>(); QMetaType::registerComparators<EndMessage>();
qRegisterMetaType<AliveCommand>(); qRegisterMetaType<AliveMessage>();
qRegisterMetaTypeStreamOperators<AliveCommand>(); qRegisterMetaTypeStreamOperators<AliveMessage>();
QMetaType::registerComparators<AliveCommand>(); QMetaType::registerComparators<AliveMessage>();
qRegisterMetaType<EchoCommand>(); qRegisterMetaType<EchoMessage>();
qRegisterMetaTypeStreamOperators<EchoCommand>(); qRegisterMetaTypeStreamOperators<EchoMessage>();
qRegisterMetaType<RegisterTranslationUnitForCodeCompletionCommand>(); qRegisterMetaType<RegisterTranslationUnitForCodeCompletionMessage>();
qRegisterMetaTypeStreamOperators<RegisterTranslationUnitForCodeCompletionCommand>(); qRegisterMetaTypeStreamOperators<RegisterTranslationUnitForCodeCompletionMessage>();
QMetaType::registerComparators<RegisterTranslationUnitForCodeCompletionCommand>(); QMetaType::registerComparators<RegisterTranslationUnitForCodeCompletionMessage>();
qRegisterMetaType<FileContainer>(); qRegisterMetaType<FileContainer>();
qRegisterMetaTypeStreamOperators<FileContainer>(); qRegisterMetaTypeStreamOperators<FileContainer>();
QMetaType::registerComparators<FileContainer>(); QMetaType::registerComparators<FileContainer>();
qRegisterMetaType<UnregisterTranslationUnitsForCodeCompletionCommand>(); qRegisterMetaType<UnregisterTranslationUnitsForCodeCompletionMessage>();
qRegisterMetaTypeStreamOperators<UnregisterTranslationUnitsForCodeCompletionCommand>(); qRegisterMetaTypeStreamOperators<UnregisterTranslationUnitsForCodeCompletionMessage>();
QMetaType::registerComparators<UnregisterTranslationUnitsForCodeCompletionCommand>(); QMetaType::registerComparators<UnregisterTranslationUnitsForCodeCompletionMessage>();
qRegisterMetaType<CompleteCodeCommand>(); qRegisterMetaType<CompleteCodeMessage>();
qRegisterMetaTypeStreamOperators<CompleteCodeCommand>(); qRegisterMetaTypeStreamOperators<CompleteCodeMessage>();
QMetaType::registerComparators<CompleteCodeCommand>(); QMetaType::registerComparators<CompleteCodeMessage>();
qRegisterMetaType<CodeCompletion>(); qRegisterMetaType<CodeCompletion>();
qRegisterMetaTypeStreamOperators<CodeCompletion>(); qRegisterMetaTypeStreamOperators<CodeCompletion>();
QMetaType::registerComparators<CodeCompletion>(); QMetaType::registerComparators<CodeCompletion>();
qRegisterMetaType<CodeCompletedCommand>(); qRegisterMetaType<CodeCompletedMessage>();
qRegisterMetaTypeStreamOperators<CodeCompletedCommand>(); qRegisterMetaTypeStreamOperators<CodeCompletedMessage>();
QMetaType::registerComparators<CodeCompletedCommand>(); QMetaType::registerComparators<CodeCompletedMessage>();
qRegisterMetaType<RegisterProjectPartsForCodeCompletionCommand>(); qRegisterMetaType<RegisterProjectPartsForCodeCompletionMessage>();
qRegisterMetaTypeStreamOperators<RegisterProjectPartsForCodeCompletionCommand>(); qRegisterMetaTypeStreamOperators<RegisterProjectPartsForCodeCompletionMessage>();
QMetaType::registerComparators<RegisterProjectPartsForCodeCompletionCommand>(); QMetaType::registerComparators<RegisterProjectPartsForCodeCompletionMessage>();
qRegisterMetaType<ProjectPartContainer>(); qRegisterMetaType<ProjectPartContainer>();
qRegisterMetaTypeStreamOperators<ProjectPartContainer>(); qRegisterMetaTypeStreamOperators<ProjectPartContainer>();
QMetaType::registerComparators<ProjectPartContainer>(); QMetaType::registerComparators<ProjectPartContainer>();
qRegisterMetaType<UnregisterProjectPartsForCodeCompletionCommand>(); qRegisterMetaType<UnregisterProjectPartsForCodeCompletionMessage>();
qRegisterMetaTypeStreamOperators<UnregisterProjectPartsForCodeCompletionCommand>(); qRegisterMetaTypeStreamOperators<UnregisterProjectPartsForCodeCompletionMessage>();
QMetaType::registerComparators<UnregisterProjectPartsForCodeCompletionCommand>(); QMetaType::registerComparators<UnregisterProjectPartsForCodeCompletionMessage>();
qRegisterMetaType<TranslationUnitDoesNotExistCommand>(); qRegisterMetaType<TranslationUnitDoesNotExistMessage>();
qRegisterMetaTypeStreamOperators<TranslationUnitDoesNotExistCommand>(); qRegisterMetaTypeStreamOperators<TranslationUnitDoesNotExistMessage>();
QMetaType::registerComparators<TranslationUnitDoesNotExistCommand>(); QMetaType::registerComparators<TranslationUnitDoesNotExistMessage>();
qRegisterMetaType<ProjectPartsDoNotExistCommand>(); qRegisterMetaType<ProjectPartsDoNotExistMessage>();
qRegisterMetaTypeStreamOperators<ProjectPartsDoNotExistCommand>(); qRegisterMetaTypeStreamOperators<ProjectPartsDoNotExistMessage>();
QMetaType::registerComparators<ProjectPartsDoNotExistCommand>(); QMetaType::registerComparators<ProjectPartsDoNotExistMessage>();
} }
} // namespace ClangBackEnd } // namespace ClangBackEnd

View File

@@ -28,18 +28,18 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef CLANGBACKEND_COMMANDS_H #ifndef CLANGBACKEND_MESSAGES_H
#define CLANGBACKEND_COMMANDS_H #define CLANGBACKEND_MESSAGES_H
#include <clangbackendipc_global.h> #include <clangbackendipc_global.h>
namespace ClangBackEnd { namespace ClangBackEnd {
namespace Commands namespace Messages
{ {
CMBIPC_EXPORT void registerCommands(); CMBIPC_EXPORT void registerMessages();
} }
} // namespace ClangBackEnd } // namespace ClangBackEnd
#endif // CLANGBACKEND_COMMANDS_H #endif // CLANGBACKEND_MESSAGES_H

View File

@@ -28,7 +28,7 @@
** **
****************************************************************************/ ****************************************************************************/
#include "cmbregisterprojectsforcodecompletioncommand.h" #include "cmbregisterprojectsforcodecompletionmessage.h"
#include "container_common.h" #include "container_common.h"
@@ -40,45 +40,45 @@
namespace ClangBackEnd { namespace ClangBackEnd {
RegisterProjectPartsForCodeCompletionCommand::RegisterProjectPartsForCodeCompletionCommand(const QVector<ProjectPartContainer> &projectContainers) RegisterProjectPartsForCodeCompletionMessage::RegisterProjectPartsForCodeCompletionMessage(const QVector<ProjectPartContainer> &projectContainers)
:projectContainers_(projectContainers) :projectContainers_(projectContainers)
{ {
} }
const QVector<ProjectPartContainer> &RegisterProjectPartsForCodeCompletionCommand::projectContainers() const const QVector<ProjectPartContainer> &RegisterProjectPartsForCodeCompletionMessage::projectContainers() const
{ {
return projectContainers_; return projectContainers_;
} }
QDataStream &operator<<(QDataStream &out, const RegisterProjectPartsForCodeCompletionCommand &command) QDataStream &operator<<(QDataStream &out, const RegisterProjectPartsForCodeCompletionMessage &message)
{ {
out << command.projectContainers_; out << message.projectContainers_;
return out; return out;
} }
QDataStream &operator>>(QDataStream &in, RegisterProjectPartsForCodeCompletionCommand &command) QDataStream &operator>>(QDataStream &in, RegisterProjectPartsForCodeCompletionMessage &message)
{ {
in >> command.projectContainers_; in >> message.projectContainers_;
return in; return in;
} }
bool operator==(const RegisterProjectPartsForCodeCompletionCommand &first, const RegisterProjectPartsForCodeCompletionCommand &second) bool operator==(const RegisterProjectPartsForCodeCompletionMessage &first, const RegisterProjectPartsForCodeCompletionMessage &second)
{ {
return first.projectContainers_ == second.projectContainers_; return first.projectContainers_ == second.projectContainers_;
} }
bool operator<(const RegisterProjectPartsForCodeCompletionCommand &first, const RegisterProjectPartsForCodeCompletionCommand &second) bool operator<(const RegisterProjectPartsForCodeCompletionMessage &first, const RegisterProjectPartsForCodeCompletionMessage &second)
{ {
return compareContainer(first.projectContainers_, second.projectContainers_); return compareContainer(first.projectContainers_, second.projectContainers_);
} }
QDebug operator<<(QDebug debug, const RegisterProjectPartsForCodeCompletionCommand &command) QDebug operator<<(QDebug debug, const RegisterProjectPartsForCodeCompletionMessage &message)
{ {
debug.nospace() << "RegisterProjectPartsForCodeCompletionCommand("; debug.nospace() << "RegisterProjectPartsForCodeCompletionMessage(";
for (const ProjectPartContainer &projectContainer : command.projectContainers()) for (const ProjectPartContainer &projectContainer : message.projectContainers())
debug.nospace() << projectContainer<< ", "; debug.nospace() << projectContainer<< ", ";
debug.nospace() << ")"; debug.nospace() << ")";
@@ -86,11 +86,11 @@ QDebug operator<<(QDebug debug, const RegisterProjectPartsForCodeCompletionComma
return debug; return debug;
} }
void PrintTo(const RegisterProjectPartsForCodeCompletionCommand &command, ::std::ostream* os) void PrintTo(const RegisterProjectPartsForCodeCompletionMessage &message, ::std::ostream* os)
{ {
*os << "RegisterProjectPartsForCodeCompletionCommand("; *os << "RegisterProjectPartsForCodeCompletionMessage(";
for (const ProjectPartContainer &projectContainer : command.projectContainers()) for (const ProjectPartContainer &projectContainer : message.projectContainers())
PrintTo(projectContainer, os); PrintTo(projectContainer, os);
*os << ")"; *os << ")";

View File

@@ -28,8 +28,8 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef CLANGBACKEND_REGISTERPROJECTSFORCODECOMPLETIONCOMAND_H #ifndef CLANGBACKEND_REGISTERPROJECTSFORCODECOMPLETIONMESSAGE_H
#define CLANGBACKEND_REGISTERPROJECTSFORCODECOMPLETIONCOMAND_H #define CLANGBACKEND_REGISTERPROJECTSFORCODECOMPLETIONMESSAGE_H
#include "projectpartcontainer.h" #include "projectpartcontainer.h"
@@ -38,16 +38,16 @@
namespace ClangBackEnd { namespace ClangBackEnd {
class CMBIPC_EXPORT RegisterProjectPartsForCodeCompletionCommand class CMBIPC_EXPORT RegisterProjectPartsForCodeCompletionMessage
{ {
friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RegisterProjectPartsForCodeCompletionCommand &command); friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RegisterProjectPartsForCodeCompletionMessage &message);
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RegisterProjectPartsForCodeCompletionCommand &command); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RegisterProjectPartsForCodeCompletionMessage &message);
friend CMBIPC_EXPORT bool operator==(const RegisterProjectPartsForCodeCompletionCommand &first, const RegisterProjectPartsForCodeCompletionCommand &second); friend CMBIPC_EXPORT bool operator==(const RegisterProjectPartsForCodeCompletionMessage &first, const RegisterProjectPartsForCodeCompletionMessage &second);
friend CMBIPC_EXPORT bool operator<(const RegisterProjectPartsForCodeCompletionCommand &first, const RegisterProjectPartsForCodeCompletionCommand &second); friend CMBIPC_EXPORT bool operator<(const RegisterProjectPartsForCodeCompletionMessage &first, const RegisterProjectPartsForCodeCompletionMessage &second);
friend void PrintTo(const RegisterProjectPartsForCodeCompletionCommand &command, ::std::ostream* os); friend void PrintTo(const RegisterProjectPartsForCodeCompletionMessage &message, ::std::ostream* os);
public: public:
RegisterProjectPartsForCodeCompletionCommand() = default; RegisterProjectPartsForCodeCompletionMessage() = default;
RegisterProjectPartsForCodeCompletionCommand(const QVector<ProjectPartContainer> &projectContainers); RegisterProjectPartsForCodeCompletionMessage(const QVector<ProjectPartContainer> &projectContainers);
const QVector<ProjectPartContainer> &projectContainers() const; const QVector<ProjectPartContainer> &projectContainers() const;
@@ -55,15 +55,15 @@ private:
QVector<ProjectPartContainer> projectContainers_; QVector<ProjectPartContainer> projectContainers_;
}; };
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RegisterProjectPartsForCodeCompletionCommand &command); CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RegisterProjectPartsForCodeCompletionMessage &message);
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RegisterProjectPartsForCodeCompletionCommand &command); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RegisterProjectPartsForCodeCompletionMessage &message);
CMBIPC_EXPORT bool operator==(const RegisterProjectPartsForCodeCompletionCommand &first, const RegisterProjectPartsForCodeCompletionCommand &second); CMBIPC_EXPORT bool operator==(const RegisterProjectPartsForCodeCompletionMessage &first, const RegisterProjectPartsForCodeCompletionMessage &second);
CMBIPC_EXPORT bool operator<(const RegisterProjectPartsForCodeCompletionCommand &first, const RegisterProjectPartsForCodeCompletionCommand &second); CMBIPC_EXPORT bool operator<(const RegisterProjectPartsForCodeCompletionMessage &first, const RegisterProjectPartsForCodeCompletionMessage &second);
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const RegisterProjectPartsForCodeCompletionCommand &command); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const RegisterProjectPartsForCodeCompletionMessage &message);
void PrintTo(const RegisterProjectPartsForCodeCompletionCommand &command, ::std::ostream* os); void PrintTo(const RegisterProjectPartsForCodeCompletionMessage &message, ::std::ostream* os);
} // namespace ClangBackEnd } // namespace ClangBackEnd
Q_DECLARE_METATYPE(ClangBackEnd::RegisterProjectPartsForCodeCompletionCommand) Q_DECLARE_METATYPE(ClangBackEnd::RegisterProjectPartsForCodeCompletionMessage)
#endif // CLANGBACKEND_REGISTERPROJECTSFORCODECOMPLETIONCOMAND_H #endif // CLANGBACKEND_REGISTERPROJECTSFORCODECOMPLETIONMESSAGE_H

View File

@@ -28,7 +28,7 @@
** **
****************************************************************************/ ****************************************************************************/
#include "cmbregistertranslationunitsforcodecompletioncommand.h" #include "cmbregistertranslationunitsforcodecompletionmessage.h"
#include "container_common.h" #include "container_common.h"
@@ -39,45 +39,45 @@
namespace ClangBackEnd { namespace ClangBackEnd {
RegisterTranslationUnitForCodeCompletionCommand::RegisterTranslationUnitForCodeCompletionCommand(const QVector<FileContainer> &fileContainers) RegisterTranslationUnitForCodeCompletionMessage::RegisterTranslationUnitForCodeCompletionMessage(const QVector<FileContainer> &fileContainers)
: fileContainers_(fileContainers) : fileContainers_(fileContainers)
{ {
} }
const QVector<FileContainer> &RegisterTranslationUnitForCodeCompletionCommand::fileContainers() const const QVector<FileContainer> &RegisterTranslationUnitForCodeCompletionMessage::fileContainers() const
{ {
return fileContainers_; return fileContainers_;
} }
QDataStream &operator<<(QDataStream &out, const RegisterTranslationUnitForCodeCompletionCommand &command) QDataStream &operator<<(QDataStream &out, const RegisterTranslationUnitForCodeCompletionMessage &message)
{ {
out << command.fileContainers_; out << message.fileContainers_;
return out; return out;
} }
QDataStream &operator>>(QDataStream &in, RegisterTranslationUnitForCodeCompletionCommand &command) QDataStream &operator>>(QDataStream &in, RegisterTranslationUnitForCodeCompletionMessage &message)
{ {
in >> command.fileContainers_; in >> message.fileContainers_;
return in; return in;
} }
bool operator==(const RegisterTranslationUnitForCodeCompletionCommand &first, const RegisterTranslationUnitForCodeCompletionCommand &second) bool operator==(const RegisterTranslationUnitForCodeCompletionMessage &first, const RegisterTranslationUnitForCodeCompletionMessage &second)
{ {
return first.fileContainers_ == second.fileContainers_; return first.fileContainers_ == second.fileContainers_;
} }
bool operator<(const RegisterTranslationUnitForCodeCompletionCommand &first, const RegisterTranslationUnitForCodeCompletionCommand &second) bool operator<(const RegisterTranslationUnitForCodeCompletionMessage &first, const RegisterTranslationUnitForCodeCompletionMessage &second)
{ {
return compareContainer(first.fileContainers_, second.fileContainers_); return compareContainer(first.fileContainers_, second.fileContainers_);
} }
QDebug operator<<(QDebug debug, const RegisterTranslationUnitForCodeCompletionCommand &command) QDebug operator<<(QDebug debug, const RegisterTranslationUnitForCodeCompletionMessage &message)
{ {
debug.nospace() << "RegisterTranslationUnitForCodeCompletionCommand("; debug.nospace() << "RegisterTranslationUnitForCodeCompletionMessage(";
for (const FileContainer &fileContainer : command.fileContainers()) for (const FileContainer &fileContainer : message.fileContainers())
debug.nospace() << fileContainer<< ", "; debug.nospace() << fileContainer<< ", ";
debug.nospace() << ")"; debug.nospace() << ")";
@@ -85,11 +85,11 @@ QDebug operator<<(QDebug debug, const RegisterTranslationUnitForCodeCompletionCo
return debug; return debug;
} }
void PrintTo(const RegisterTranslationUnitForCodeCompletionCommand &command, ::std::ostream* os) void PrintTo(const RegisterTranslationUnitForCodeCompletionMessage &message, ::std::ostream* os)
{ {
*os << "RegisterTranslationUnitForCodeCompletionCommand("; *os << "RegisterTranslationUnitForCodeCompletionMessage(";
for (const FileContainer &fileContainer : command.fileContainers()) for (const FileContainer &fileContainer : message.fileContainers())
PrintTo(fileContainer, os); PrintTo(fileContainer, os);
*os << ")"; *os << ")";

View File

@@ -38,16 +38,16 @@
namespace ClangBackEnd { namespace ClangBackEnd {
class CMBIPC_EXPORT RegisterTranslationUnitForCodeCompletionCommand class CMBIPC_EXPORT RegisterTranslationUnitForCodeCompletionMessage
{ {
friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RegisterTranslationUnitForCodeCompletionCommand &command); friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RegisterTranslationUnitForCodeCompletionMessage &message);
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RegisterTranslationUnitForCodeCompletionCommand &command); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RegisterTranslationUnitForCodeCompletionMessage &message);
friend CMBIPC_EXPORT bool operator==(const RegisterTranslationUnitForCodeCompletionCommand &first, const RegisterTranslationUnitForCodeCompletionCommand &second); friend CMBIPC_EXPORT bool operator==(const RegisterTranslationUnitForCodeCompletionMessage &first, const RegisterTranslationUnitForCodeCompletionMessage &second);
friend CMBIPC_EXPORT bool operator<(const RegisterTranslationUnitForCodeCompletionCommand &first, const RegisterTranslationUnitForCodeCompletionCommand &second); friend CMBIPC_EXPORT bool operator<(const RegisterTranslationUnitForCodeCompletionMessage &first, const RegisterTranslationUnitForCodeCompletionMessage &second);
friend void PrintTo(const RegisterTranslationUnitForCodeCompletionCommand &command, ::std::ostream* os); friend void PrintTo(const RegisterTranslationUnitForCodeCompletionMessage &message, ::std::ostream* os);
public: public:
RegisterTranslationUnitForCodeCompletionCommand() = default; RegisterTranslationUnitForCodeCompletionMessage() = default;
RegisterTranslationUnitForCodeCompletionCommand(const QVector<FileContainer> &fileContainers); RegisterTranslationUnitForCodeCompletionMessage(const QVector<FileContainer> &fileContainers);
const QVector<FileContainer> &fileContainers() const; const QVector<FileContainer> &fileContainers() const;
@@ -55,15 +55,15 @@ private:
QVector<FileContainer> fileContainers_; QVector<FileContainer> fileContainers_;
}; };
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RegisterTranslationUnitForCodeCompletionCommand &command); CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RegisterTranslationUnitForCodeCompletionMessage &message);
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RegisterTranslationUnitForCodeCompletionCommand &command); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RegisterTranslationUnitForCodeCompletionMessage &message);
CMBIPC_EXPORT bool operator==(const RegisterTranslationUnitForCodeCompletionCommand &first, const RegisterTranslationUnitForCodeCompletionCommand &second); CMBIPC_EXPORT bool operator==(const RegisterTranslationUnitForCodeCompletionMessage &first, const RegisterTranslationUnitForCodeCompletionMessage &second);
CMBIPC_EXPORT bool operator<(const RegisterTranslationUnitForCodeCompletionCommand &first, const RegisterTranslationUnitForCodeCompletionCommand &second); CMBIPC_EXPORT bool operator<(const RegisterTranslationUnitForCodeCompletionMessage &first, const RegisterTranslationUnitForCodeCompletionMessage &second);
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const RegisterTranslationUnitForCodeCompletionCommand &command); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const RegisterTranslationUnitForCodeCompletionMessage &message);
void PrintTo(const RegisterTranslationUnitForCodeCompletionCommand &command, ::std::ostream* os); void PrintTo(const RegisterTranslationUnitForCodeCompletionMessage &message, ::std::ostream* os);
} // namespace ClangBackEnd } // namespace ClangBackEnd
Q_DECLARE_METATYPE(ClangBackEnd::RegisterTranslationUnitForCodeCompletionCommand) Q_DECLARE_METATYPE(ClangBackEnd::RegisterTranslationUnitForCodeCompletionMessage)
#endif // CLANGBACKEND_REGISTERFILEFORCODECOMPLITION_H #endif // CLANGBACKEND_REGISTERFILEFORCODECOMPLITION_H

View File

@@ -28,7 +28,7 @@
** **
****************************************************************************/ ****************************************************************************/
#include "cmbunregisterprojectsforcodecompletioncommand.h" #include "cmbunregisterprojectsforcodecompletionmessage.h"
#include "container_common.h" #include "container_common.h"
@@ -41,45 +41,45 @@
namespace ClangBackEnd { namespace ClangBackEnd {
UnregisterProjectPartsForCodeCompletionCommand::UnregisterProjectPartsForCodeCompletionCommand(const Utf8StringVector &filePaths) UnregisterProjectPartsForCodeCompletionMessage::UnregisterProjectPartsForCodeCompletionMessage(const Utf8StringVector &filePaths)
: projectPartIds_(filePaths) : projectPartIds_(filePaths)
{ {
} }
const Utf8StringVector &UnregisterProjectPartsForCodeCompletionCommand::projectPartIds() const const Utf8StringVector &UnregisterProjectPartsForCodeCompletionMessage::projectPartIds() const
{ {
return projectPartIds_; return projectPartIds_;
} }
QDataStream &operator<<(QDataStream &out, const UnregisterProjectPartsForCodeCompletionCommand &command) QDataStream &operator<<(QDataStream &out, const UnregisterProjectPartsForCodeCompletionMessage &message)
{ {
out << command.projectPartIds_; out << message.projectPartIds_;
return out; return out;
} }
QDataStream &operator>>(QDataStream &in, UnregisterProjectPartsForCodeCompletionCommand &command) QDataStream &operator>>(QDataStream &in, UnregisterProjectPartsForCodeCompletionMessage &message)
{ {
in >> command.projectPartIds_; in >> message.projectPartIds_;
return in; return in;
} }
bool operator==(const UnregisterProjectPartsForCodeCompletionCommand &first, const UnregisterProjectPartsForCodeCompletionCommand &second) bool operator==(const UnregisterProjectPartsForCodeCompletionMessage &first, const UnregisterProjectPartsForCodeCompletionMessage &second)
{ {
return first.projectPartIds_ == second.projectPartIds_; return first.projectPartIds_ == second.projectPartIds_;
} }
bool operator<(const UnregisterProjectPartsForCodeCompletionCommand &first, const UnregisterProjectPartsForCodeCompletionCommand &second) bool operator<(const UnregisterProjectPartsForCodeCompletionMessage &first, const UnregisterProjectPartsForCodeCompletionMessage &second)
{ {
return compareContainer(first.projectPartIds_, second.projectPartIds_); return compareContainer(first.projectPartIds_, second.projectPartIds_);
} }
QDebug operator<<(QDebug debug, const UnregisterProjectPartsForCodeCompletionCommand &command) QDebug operator<<(QDebug debug, const UnregisterProjectPartsForCodeCompletionMessage &message)
{ {
debug.nospace() << "UnregisterProjectPartsForCodeCompletionCommand("; debug.nospace() << "UnregisterProjectPartsForCodeCompletionMessage(";
for (const Utf8String &fileNames_ : command.projectPartIds()) for (const Utf8String &fileNames_ : message.projectPartIds())
debug.nospace() << fileNames_ << ", "; debug.nospace() << fileNames_ << ", ";
debug.nospace() << ")"; debug.nospace() << ")";
@@ -87,11 +87,11 @@ QDebug operator<<(QDebug debug, const UnregisterProjectPartsForCodeCompletionCom
return debug; return debug;
} }
void PrintTo(const UnregisterProjectPartsForCodeCompletionCommand &command, ::std::ostream* os) void PrintTo(const UnregisterProjectPartsForCodeCompletionMessage &message, ::std::ostream* os)
{ {
*os << "UnregisterProjectPartsForCodeCompletionCommand("; *os << "UnregisterProjectPartsForCodeCompletionMessage(";
for (const Utf8String &fileNames_ : command.projectPartIds()) for (const Utf8String &fileNames_ : message.projectPartIds())
*os << fileNames_.constData() << ", "; *os << fileNames_.constData() << ", ";
*os << ")"; *os << ")";

View File

@@ -39,17 +39,17 @@
namespace ClangBackEnd { namespace ClangBackEnd {
class CMBIPC_EXPORT UnregisterProjectPartsForCodeCompletionCommand class CMBIPC_EXPORT UnregisterProjectPartsForCodeCompletionMessage
{ {
friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UnregisterProjectPartsForCodeCompletionCommand &command); friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UnregisterProjectPartsForCodeCompletionMessage &message);
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UnregisterProjectPartsForCodeCompletionCommand &command); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UnregisterProjectPartsForCodeCompletionMessage &message);
friend CMBIPC_EXPORT bool operator==(const UnregisterProjectPartsForCodeCompletionCommand &first, const UnregisterProjectPartsForCodeCompletionCommand &second); friend CMBIPC_EXPORT bool operator==(const UnregisterProjectPartsForCodeCompletionMessage &first, const UnregisterProjectPartsForCodeCompletionMessage &second);
friend CMBIPC_EXPORT bool operator<(const UnregisterProjectPartsForCodeCompletionCommand &first, const UnregisterProjectPartsForCodeCompletionCommand &second); friend CMBIPC_EXPORT bool operator<(const UnregisterProjectPartsForCodeCompletionMessage &first, const UnregisterProjectPartsForCodeCompletionMessage &second);
friend void PrintTo(const UnregisterProjectPartsForCodeCompletionCommand &command, ::std::ostream* os); friend void PrintTo(const UnregisterProjectPartsForCodeCompletionMessage &message, ::std::ostream* os);
public: public:
UnregisterProjectPartsForCodeCompletionCommand() = default; UnregisterProjectPartsForCodeCompletionMessage() = default;
UnregisterProjectPartsForCodeCompletionCommand(const Utf8StringVector &projectPartIds); UnregisterProjectPartsForCodeCompletionMessage(const Utf8StringVector &projectPartIds);
const Utf8StringVector &projectPartIds() const; const Utf8StringVector &projectPartIds() const;
@@ -57,15 +57,15 @@ private:
Utf8StringVector projectPartIds_; Utf8StringVector projectPartIds_;
}; };
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UnregisterProjectPartsForCodeCompletionCommand &command); CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UnregisterProjectPartsForCodeCompletionMessage &message);
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UnregisterProjectPartsForCodeCompletionCommand &command); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UnregisterProjectPartsForCodeCompletionMessage &message);
CMBIPC_EXPORT bool operator==(const UnregisterProjectPartsForCodeCompletionCommand &first, const UnregisterProjectPartsForCodeCompletionCommand &second); CMBIPC_EXPORT bool operator==(const UnregisterProjectPartsForCodeCompletionMessage &first, const UnregisterProjectPartsForCodeCompletionMessage &second);
CMBIPC_EXPORT bool operator<(const UnregisterProjectPartsForCodeCompletionCommand &first, const UnregisterProjectPartsForCodeCompletionCommand &second); CMBIPC_EXPORT bool operator<(const UnregisterProjectPartsForCodeCompletionMessage &first, const UnregisterProjectPartsForCodeCompletionMessage &second);
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const UnregisterProjectPartsForCodeCompletionCommand &command); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const UnregisterProjectPartsForCodeCompletionMessage &message);
void PrintTo(const UnregisterProjectPartsForCodeCompletionCommand &command, ::std::ostream* os); void PrintTo(const UnregisterProjectPartsForCodeCompletionMessage &message, ::std::ostream* os);
} // namespace ClangBackEnd } // namespace ClangBackEnd
Q_DECLARE_METATYPE(ClangBackEnd::UnregisterProjectPartsForCodeCompletionCommand) Q_DECLARE_METATYPE(ClangBackEnd::UnregisterProjectPartsForCodeCompletionMessage)
#endif // CLANGBACKEND_UNREGISTERPROJECTSFORCODECOMPLETION_H #endif // CLANGBACKEND_UNREGISTERPROJECTSFORCODECOMPLETION_H

View File

@@ -28,7 +28,7 @@
** **
****************************************************************************/ ****************************************************************************/
#include "cmbunregistertranslationunitsforcodecompletioncommand.h" #include "cmbunregistertranslationunitsforcodecompletionmessage.h"
#include "container_common.h" #include "container_common.h"
@@ -42,45 +42,45 @@
namespace ClangBackEnd { namespace ClangBackEnd {
UnregisterTranslationUnitsForCodeCompletionCommand::UnregisterTranslationUnitsForCodeCompletionCommand(const QVector<FileContainer> &fileContainers) UnregisterTranslationUnitsForCodeCompletionMessage::UnregisterTranslationUnitsForCodeCompletionMessage(const QVector<FileContainer> &fileContainers)
: fileContainers_(fileContainers) : fileContainers_(fileContainers)
{ {
} }
const QVector<FileContainer> &UnregisterTranslationUnitsForCodeCompletionCommand::fileContainers() const const QVector<FileContainer> &UnregisterTranslationUnitsForCodeCompletionMessage::fileContainers() const
{ {
return fileContainers_; return fileContainers_;
} }
QDataStream &operator<<(QDataStream &out, const UnregisterTranslationUnitsForCodeCompletionCommand &command) QDataStream &operator<<(QDataStream &out, const UnregisterTranslationUnitsForCodeCompletionMessage &message)
{ {
out << command.fileContainers_; out << message.fileContainers_;
return out; return out;
} }
QDataStream &operator>>(QDataStream &in, UnregisterTranslationUnitsForCodeCompletionCommand &command) QDataStream &operator>>(QDataStream &in, UnregisterTranslationUnitsForCodeCompletionMessage &message)
{ {
in >> command.fileContainers_; in >> message.fileContainers_;
return in; return in;
} }
bool operator==(const UnregisterTranslationUnitsForCodeCompletionCommand &first, const UnregisterTranslationUnitsForCodeCompletionCommand &second) bool operator==(const UnregisterTranslationUnitsForCodeCompletionMessage &first, const UnregisterTranslationUnitsForCodeCompletionMessage &second)
{ {
return first.fileContainers_ == second.fileContainers_; return first.fileContainers_ == second.fileContainers_;
} }
bool operator<(const UnregisterTranslationUnitsForCodeCompletionCommand &first, const UnregisterTranslationUnitsForCodeCompletionCommand &second) bool operator<(const UnregisterTranslationUnitsForCodeCompletionMessage &first, const UnregisterTranslationUnitsForCodeCompletionMessage &second)
{ {
return compareContainer(first.fileContainers_, second.fileContainers_); return compareContainer(first.fileContainers_, second.fileContainers_);
} }
QDebug operator<<(QDebug debug, const UnregisterTranslationUnitsForCodeCompletionCommand &command) QDebug operator<<(QDebug debug, const UnregisterTranslationUnitsForCodeCompletionMessage &message)
{ {
debug.nospace() << "UnregisterTranslationUnitsForCodeCompletionCommand("; debug.nospace() << "UnregisterTranslationUnitsForCodeCompletionMessage(";
for (const FileContainer &fileContainer : command.fileContainers()) for (const FileContainer &fileContainer : message.fileContainers())
debug.nospace() << fileContainer << ", "; debug.nospace() << fileContainer << ", ";
debug.nospace() << ")"; debug.nospace() << ")";
@@ -89,11 +89,11 @@ QDebug operator<<(QDebug debug, const UnregisterTranslationUnitsForCodeCompletio
} }
#ifdef CLANGBACKEND_TESTS #ifdef CLANGBACKEND_TESTS
void PrintTo(const UnregisterTranslationUnitsForCodeCompletionCommand &command, ::std::ostream* os) void PrintTo(const UnregisterTranslationUnitsForCodeCompletionMessage &message, ::std::ostream* os)
{ {
*os << "UnregisterTranslationUnitsForCodeCompletionCommand("; *os << "UnregisterTranslationUnitsForCodeCompletionMessage(";
for (const FileContainer &fileContainer : command.fileContainers()) for (const FileContainer &fileContainer : message.fileContainers())
*os << ::testing::PrintToString(fileContainer) << ", "; *os << ::testing::PrintToString(fileContainer) << ", ";
*os << ")"; *os << ")";

View File

@@ -28,8 +28,8 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef CLANGBACKEND_UNRegisterTranslationUnitForCodeCompletionCommand_H #ifndef CLANGBACKEND_UNRegisterTranslationUnitForCodeCompletionMessage_H
#define CLANGBACKEND_UNRegisterTranslationUnitForCodeCompletionCommand_H #define CLANGBACKEND_UNRegisterTranslationUnitForCodeCompletionMessage_H
#include "clangbackendipc_global.h" #include "clangbackendipc_global.h"
@@ -40,17 +40,17 @@
namespace ClangBackEnd { namespace ClangBackEnd {
class CMBIPC_EXPORT UnregisterTranslationUnitsForCodeCompletionCommand class CMBIPC_EXPORT UnregisterTranslationUnitsForCodeCompletionMessage
{ {
friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UnregisterTranslationUnitsForCodeCompletionCommand &command); friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UnregisterTranslationUnitsForCodeCompletionMessage &message);
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UnregisterTranslationUnitsForCodeCompletionCommand &command); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UnregisterTranslationUnitsForCodeCompletionMessage &message);
friend CMBIPC_EXPORT bool operator==(const UnregisterTranslationUnitsForCodeCompletionCommand &first, const UnregisterTranslationUnitsForCodeCompletionCommand &second); friend CMBIPC_EXPORT bool operator==(const UnregisterTranslationUnitsForCodeCompletionMessage &first, const UnregisterTranslationUnitsForCodeCompletionMessage &second);
friend CMBIPC_EXPORT bool operator<(const UnregisterTranslationUnitsForCodeCompletionCommand &first, const UnregisterTranslationUnitsForCodeCompletionCommand &second); friend CMBIPC_EXPORT bool operator<(const UnregisterTranslationUnitsForCodeCompletionMessage &first, const UnregisterTranslationUnitsForCodeCompletionMessage &second);
friend void PrintTo(const UnregisterTranslationUnitsForCodeCompletionCommand &command, ::std::ostream* os); friend void PrintTo(const UnregisterTranslationUnitsForCodeCompletionMessage &message, ::std::ostream* os);
public: public:
UnregisterTranslationUnitsForCodeCompletionCommand() = default; UnregisterTranslationUnitsForCodeCompletionMessage() = default;
UnregisterTranslationUnitsForCodeCompletionCommand(const QVector<FileContainer> &fileContainers); UnregisterTranslationUnitsForCodeCompletionMessage(const QVector<FileContainer> &fileContainers);
const QVector<FileContainer> &fileContainers() const; const QVector<FileContainer> &fileContainers() const;
@@ -58,17 +58,17 @@ private:
QVector<FileContainer> fileContainers_; QVector<FileContainer> fileContainers_;
}; };
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UnregisterTranslationUnitsForCodeCompletionCommand &command); CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UnregisterTranslationUnitsForCodeCompletionMessage &message);
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UnregisterTranslationUnitsForCodeCompletionCommand &command); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UnregisterTranslationUnitsForCodeCompletionMessage &message);
CMBIPC_EXPORT bool operator==(const UnregisterTranslationUnitsForCodeCompletionCommand &first, const UnregisterTranslationUnitsForCodeCompletionCommand &second); CMBIPC_EXPORT bool operator==(const UnregisterTranslationUnitsForCodeCompletionMessage &first, const UnregisterTranslationUnitsForCodeCompletionMessage &second);
CMBIPC_EXPORT bool operator<(const UnregisterTranslationUnitsForCodeCompletionCommand &first, const UnregisterTranslationUnitsForCodeCompletionCommand &second); CMBIPC_EXPORT bool operator<(const UnregisterTranslationUnitsForCodeCompletionMessage &first, const UnregisterTranslationUnitsForCodeCompletionMessage &second);
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const UnregisterTranslationUnitsForCodeCompletionCommand &command); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const UnregisterTranslationUnitsForCodeCompletionMessage &message);
#ifdef CLANGBACKEND_TESTS #ifdef CLANGBACKEND_TESTS
void PrintTo(const UnregisterTranslationUnitsForCodeCompletionCommand &command, ::std::ostream* os); void PrintTo(const UnregisterTranslationUnitsForCodeCompletionMessage &message, ::std::ostream* os);
#endif #endif
} // namespace ClangBackEnd } // namespace ClangBackEnd
Q_DECLARE_METATYPE(ClangBackEnd::UnregisterTranslationUnitsForCodeCompletionCommand) Q_DECLARE_METATYPE(ClangBackEnd::UnregisterTranslationUnitsForCodeCompletionMessage)
#endif // CLANGBACKEND_UNRegisterTranslationUnitForCodeCompletionCommand_H #endif // CLANGBACKEND_UNRegisterTranslationUnitForCodeCompletionMessage_H

View File

@@ -120,26 +120,26 @@ quint32 &CodeCompletion::availabilityAsInt()
return reinterpret_cast<quint32&>(availability_); return reinterpret_cast<quint32&>(availability_);
} }
QDataStream &operator<<(QDataStream &out, const CodeCompletion &command) QDataStream &operator<<(QDataStream &out, const CodeCompletion &message)
{ {
out << command.text_; out << message.text_;
out << command.chunks_; out << message.chunks_;
out << command.priority_; out << message.priority_;
out << command.completionKind_; out << message.completionKind_;
out << command.availability_; out << message.availability_;
out << command.hasParameters_; out << message.hasParameters_;
return out; return out;
} }
QDataStream &operator>>(QDataStream &in, CodeCompletion &command) QDataStream &operator>>(QDataStream &in, CodeCompletion &message)
{ {
in >> command.text_; in >> message.text_;
in >> command.chunks_; in >> message.chunks_;
in >> command.priority_; in >> message.priority_;
in >> command.completionKindAsInt(); in >> message.completionKindAsInt();
in >> command.availabilityAsInt(); in >> message.availabilityAsInt();
in >> command.hasParameters_; in >> message.hasParameters_;
return in; return in;
} }
@@ -191,30 +191,30 @@ static const char *availabilityToString(CodeCompletion::Availability availabilit
return nullptr; return nullptr;
} }
QDebug operator<<(QDebug debug, const CodeCompletion &command) QDebug operator<<(QDebug debug, const CodeCompletion &message)
{ {
debug.nospace() << "CodeCompletion("; debug.nospace() << "CodeCompletion(";
debug.nospace() << command.text_ << ", "; debug.nospace() << message.text_ << ", ";
debug.nospace() << command.priority_ << ", "; debug.nospace() << message.priority_ << ", ";
debug.nospace() << completionKindToString(command.completionKind_) << ", "; debug.nospace() << completionKindToString(message.completionKind_) << ", ";
debug.nospace() << availabilityToString(command.availability_) << ", "; debug.nospace() << availabilityToString(message.availability_) << ", ";
debug.nospace() << command.hasParameters_; debug.nospace() << message.hasParameters_;
debug.nospace() << ")"; debug.nospace() << ")";
return debug; return debug;
} }
void PrintTo(const CodeCompletion &command, ::std::ostream* os) void PrintTo(const CodeCompletion &message, ::std::ostream* os)
{ {
*os << "CodeCompletion("; *os << "CodeCompletion(";
*os << command.text_.constData() << ", "; *os << message.text_.constData() << ", ";
*os << command.priority_ << ", "; *os << message.priority_ << ", ";
*os << completionKindToString(command.completionKind_) << ", "; *os << completionKindToString(message.completionKind_) << ", ";
*os << availabilityToString(command.availability_) << ", "; *os << availabilityToString(message.availability_) << ", ";
*os << command.hasParameters_; *os << message.hasParameters_;
*os << ")"; *os << ")";
} }

View File

@@ -46,12 +46,12 @@ using CodeCompletions = QVector<CodeCompletion>;
class CMBIPC_EXPORT CodeCompletion class CMBIPC_EXPORT CodeCompletion
{ {
friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CodeCompletion &command); friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CodeCompletion &message);
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CodeCompletion &command); 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 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 &command); friend CMBIPC_EXPORT QDebug operator<<(QDebug debug, const CodeCompletion &message);
friend void PrintTo(const CodeCompletion &command, ::std::ostream* os); friend void PrintTo(const CodeCompletion &message, ::std::ostream* os);
public: public:
enum Kind : quint32 { enum Kind : quint32 {
@@ -120,15 +120,15 @@ private:
bool hasParameters_ = false; bool hasParameters_ = false;
}; };
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CodeCompletion &command); CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CodeCompletion &message);
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CodeCompletion &command); 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 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 &command); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const CodeCompletion &message);
CMBIPC_EXPORT QDebug operator<<(QDebug debug, CodeCompletion::Kind kind); CMBIPC_EXPORT QDebug operator<<(QDebug debug, CodeCompletion::Kind kind);
void PrintTo(const CodeCompletion &command, ::std::ostream* os); void PrintTo(const CodeCompletion &message, ::std::ostream* os);
void PrintTo(CodeCompletion::Kind kind, ::std::ostream *os); void PrintTo(CodeCompletion::Kind kind, ::std::ostream *os);
void PrintTo(CodeCompletion::Availability availability, ::std::ostream *os); void PrintTo(CodeCompletion::Availability availability, ::std::ostream *os);
} // namespace ClangBackEnd } // namespace ClangBackEnd

View File

@@ -31,9 +31,9 @@
#include "connectionclient.h" #include "connectionclient.h"
#include "clangbackendipcdebugutils.h" #include "clangbackendipcdebugutils.h"
#include "cmbcompletecodecommand.h" #include "cmbcompletecodemessage.h"
#include "cmbregistertranslationunitsforcodecompletioncommand.h" #include "cmbregistertranslationunitsforcodecompletionmessage.h"
#include "cmbunregistertranslationunitsforcodecompletioncommand.h" #include "cmbunregistertranslationunitsforcodecompletionmessage.h"
#include <QCoreApplication> #include <QCoreApplication>
#include <QProcess> #include <QProcess>
@@ -100,17 +100,17 @@ bool ConnectionClient::isConnected() const
return localSocket.state() == QLocalSocket::ConnectedState; return localSocket.state() == QLocalSocket::ConnectedState;
} }
void ConnectionClient::ensureCommandIsWritten() void ConnectionClient::ensureMessageIsWritten()
{ {
while (isConnected() && localSocket.bytesToWrite() > 0) while (isConnected() && localSocket.bytesToWrite() > 0)
localSocket.waitForBytesWritten(50); localSocket.waitForBytesWritten(50);
} }
void ConnectionClient::sendEndCommand() void ConnectionClient::sendEndMessage()
{ {
serverProxy_.end(); serverProxy_.end();
localSocket.flush(); localSocket.flush();
ensureCommandIsWritten(); ensureMessageIsWritten();
} }
void ConnectionClient::resetProcessAliveTimer() void ConnectionClient::resetProcessAliveTimer()
@@ -180,7 +180,7 @@ bool ConnectionClient::connectToLocalSocket()
void ConnectionClient::endProcess() void ConnectionClient::endProcess()
{ {
if (isProcessIsRunning()) { if (isProcessIsRunning()) {
sendEndCommand(); sendEndMessage();
process()->waitForFinished(); process()->waitForFinished();
} }
} }

View File

@@ -61,7 +61,7 @@ public:
bool disconnectFromServer(); bool disconnectFromServer();
bool isConnected() const; bool isConnected() const;
void sendEndCommand(); void sendEndMessage();
void resetProcessAliveTimer(); void resetProcessAliveTimer();
void setProcessAliveTimerInterval(int processTimerInterval); void setProcessAliveTimerInterval(int processTimerInterval);
@@ -98,7 +98,7 @@ private:
void disconnectProcessFinished() const; void disconnectProcessFinished() const;
void connectStandardOutputAndError() const; void connectStandardOutputAndError() const;
void ensureCommandIsWritten(); void ensureMessageIsWritten();
private: private:
mutable std::unique_ptr<QProcess> process_; mutable std::unique_ptr<QProcess> process_;

View File

@@ -80,7 +80,7 @@ int ConnectionServer::clientProxyCount() const
void ConnectionServer::timerEvent(QTimerEvent *timerEvent) void ConnectionServer::timerEvent(QTimerEvent *timerEvent)
{ {
if (aliveTimerId == timerEvent->timerId()) if (aliveTimerId == timerEvent->timerId())
sendAliveCommand(); sendAliveMessage();
} }
void ConnectionServer::handleNewConnection() void ConnectionServer::handleNewConnection()
@@ -96,7 +96,7 @@ void ConnectionServer::handleNewConnection()
emit newConnection(); emit newConnection();
} }
void ConnectionServer::sendAliveCommand() void ConnectionServer::sendAliveMessage()
{ {
ipcServer->client()->alive(); ipcServer->client()->alive();
} }

View File

@@ -64,7 +64,7 @@ protected:
private: private:
void handleNewConnection(); void handleNewConnection();
void sendAliveCommand(); void sendAliveMessage();
void handleSocketDisconnect(); void handleSocketDisconnect();
void removeClientProxyWithLocalSocket(QLocalSocket *localSocket); void removeClientProxyWithLocalSocket(QLocalSocket *localSocket);
QLocalSocket *nextPendingConnection(); QLocalSocket *nextPendingConnection();

View File

@@ -50,28 +50,28 @@ void IpcClientDispatcher::alive()
client->alive(); client->alive();
} }
void IpcClientDispatcher::echo(const EchoCommand &command) void IpcClientDispatcher::echo(const EchoMessage &message)
{ {
for (auto *client : clients) for (auto *client : clients)
client->echo(command); client->echo(message);
} }
void IpcClientDispatcher::codeCompleted(const CodeCompletedCommand &command) void IpcClientDispatcher::codeCompleted(const CodeCompletedMessage &message)
{ {
for (auto *client : clients) for (auto *client : clients)
client->codeCompleted(command); client->codeCompleted(message);
} }
void IpcClientDispatcher::translationUnitDoesNotExist(const TranslationUnitDoesNotExistCommand &command) void IpcClientDispatcher::translationUnitDoesNotExist(const TranslationUnitDoesNotExistMessage &message)
{ {
for (auto *client : clients) for (auto *client : clients)
client->translationUnitDoesNotExist(command); client->translationUnitDoesNotExist(message);
} }
void IpcClientDispatcher::projectPartsDoNotExist(const ProjectPartsDoNotExistCommand &command) void IpcClientDispatcher::projectPartsDoNotExist(const ProjectPartsDoNotExistMessage &message)
{ {
for (auto *client : clients) for (auto *client : clients)
client->projectPartsDoNotExist(command); client->projectPartsDoNotExist(message);
} }
} // namespace ClangBackEnd } // namespace ClangBackEnd

View File

@@ -44,10 +44,10 @@ public:
void removeClient(IpcClientInterface *client); void removeClient(IpcClientInterface *client);
void alive() override; void alive() override;
void echo(const EchoCommand &command) override; void echo(const EchoMessage &message) override;
void codeCompleted(const CodeCompletedCommand &command) override; void codeCompleted(const CodeCompletedMessage &message) override;
void translationUnitDoesNotExist(const TranslationUnitDoesNotExistCommand &command) override; void translationUnitDoesNotExist(const TranslationUnitDoesNotExistMessage &message) override;
void projectPartsDoNotExist(const ProjectPartsDoNotExistCommand &command) override; void projectPartsDoNotExist(const ProjectPartsDoNotExistMessage &message) override;
private: private:
QVector<IpcClientInterface*> clients; QVector<IpcClientInterface*> clients;

View File

@@ -30,10 +30,10 @@
#include "ipcclientinterface.h" #include "ipcclientinterface.h"
#include "cmbcodecompletedcommand.h" #include "cmbcodecompletedmessage.h"
#include "cmbechocommand.h" #include "cmbechomessage.h"
#include "projectpartsdonotexistcommand.h" #include "projectpartsdonotexistmessage.h"
#include "translationunitdoesnotexistcommand.h" #include "translationunitdoesnotexistmessage.h"
#include <QDebug> #include <QDebug>
#include <QVariant> #include <QVariant>
@@ -41,28 +41,28 @@
namespace ClangBackEnd { namespace ClangBackEnd {
void IpcClientInterface::dispatch(const QVariant &command) void IpcClientInterface::dispatch(const QVariant &message)
{ {
static const int aliveCommandType = QMetaType::type("ClangBackEnd::AliveCommand"); static const int aliveMessageType = QMetaType::type("ClangBackEnd::AliveMessage");
static const int echoCommandType = QMetaType::type("ClangBackEnd::EchoCommand"); static const int echoMessageType = QMetaType::type("ClangBackEnd::EchoMessage");
static const int codeCompletedCommandType = QMetaType::type("ClangBackEnd::CodeCompletedCommand"); static const int codeCompletedMessageType = QMetaType::type("ClangBackEnd::CodeCompletedMessage");
static const int translationUnitDoesNotExistCommand = QMetaType::type("ClangBackEnd::TranslationUnitDoesNotExistCommand"); static const int translationUnitDoesNotExistMessage = QMetaType::type("ClangBackEnd::TranslationUnitDoesNotExistMessage");
static const int projectPartsDoNotExistCommand = QMetaType::type("ClangBackEnd::ProjectPartsDoNotExistCommand"); static const int projectPartsDoNotExistMessage = QMetaType::type("ClangBackEnd::ProjectPartsDoNotExistMessage");
int type = command.userType(); int type = message.userType();
if (type == aliveCommandType) if (type == aliveMessageType)
alive(); alive();
else if (type == echoCommandType) else if (type == echoMessageType)
echo(command.value<EchoCommand>()); echo(message.value<EchoMessage>());
else if (type == codeCompletedCommandType) else if (type == codeCompletedMessageType)
codeCompleted(command.value<CodeCompletedCommand>()); codeCompleted(message.value<CodeCompletedMessage>());
else if (type == translationUnitDoesNotExistCommand) else if (type == translationUnitDoesNotExistMessage)
translationUnitDoesNotExist(command.value<TranslationUnitDoesNotExistCommand>()); translationUnitDoesNotExist(message.value<TranslationUnitDoesNotExistMessage>());
else if (type == projectPartsDoNotExistCommand) else if (type == projectPartsDoNotExistMessage)
projectPartsDoNotExist(command.value<ProjectPartsDoNotExistCommand>()); projectPartsDoNotExist(message.value<ProjectPartsDoNotExistMessage>());
else else
qWarning() << "Unknown IpcClientCommand"; qWarning() << "Unknown IpcClientMessage";
} }
} // namespace ClangBackEnd } // namespace ClangBackEnd

View File

@@ -36,26 +36,26 @@
namespace ClangBackEnd { namespace ClangBackEnd {
class IpcServerInterface; class IpcServerInterface;
class RegisterTranslationUnitForCodeCompletionCommand; class RegisterTranslationUnitForCodeCompletionMessage;
class RegisterProjectPartsForCodeCompletionCommand; class RegisterProjectPartsForCodeCompletionMessage;
class UnregisterTranslationUnitsForCodeCompletionCommand; class UnregisterTranslationUnitsForCodeCompletionMessage;
class UnregisterProjectPartsForCodeCompletionCommand; class UnregisterProjectPartsForCodeCompletionMessage;
class EchoCommand; class EchoMessage;
class CompleteCodeCommand; class CompleteCodeMessage;
class CodeCompletedCommand; class CodeCompletedMessage;
class TranslationUnitDoesNotExistCommand; class TranslationUnitDoesNotExistMessage;
class ProjectPartsDoNotExistCommand; class ProjectPartsDoNotExistMessage;
class CMBIPC_EXPORT IpcClientInterface : public IpcInterface class CMBIPC_EXPORT IpcClientInterface : public IpcInterface
{ {
public: public:
void dispatch(const QVariant &command) override; void dispatch(const QVariant &message) override;
virtual void alive() = 0; virtual void alive() = 0;
virtual void echo(const EchoCommand &command) = 0; virtual void echo(const EchoMessage &message) = 0;
virtual void codeCompleted(const CodeCompletedCommand &command) = 0; virtual void codeCompleted(const CodeCompletedMessage &message) = 0;
virtual void translationUnitDoesNotExist(const TranslationUnitDoesNotExistCommand &command) = 0; virtual void translationUnitDoesNotExist(const TranslationUnitDoesNotExistMessage &message) = 0;
virtual void projectPartsDoNotExist(const ProjectPartsDoNotExistCommand &command) = 0; virtual void projectPartsDoNotExist(const ProjectPartsDoNotExistMessage &message) = 0;
}; };
} // namespace ClangBackEnd } // namespace ClangBackEnd

View File

@@ -30,13 +30,13 @@
#include "ipcclientproxy.h" #include "ipcclientproxy.h"
#include "cmbalivecommand.h" #include "cmbalivemessage.h"
#include "cmbcodecompletedcommand.h" #include "cmbcodecompletedmessage.h"
#include "cmbechocommand.h" #include "cmbechomessage.h"
#include "cmbregistertranslationunitsforcodecompletioncommand.h" #include "cmbregistertranslationunitsforcodecompletionmessage.h"
#include "ipcserverinterface.h" #include "ipcserverinterface.h"
#include "projectpartsdonotexistcommand.h" #include "projectpartsdonotexistmessage.h"
#include "translationunitdoesnotexistcommand.h" #include "translationunitdoesnotexistmessage.h"
#include <QDebug> #include <QDebug>
#include <QIODevice> #include <QIODevice>
@@ -46,17 +46,17 @@
namespace ClangBackEnd { namespace ClangBackEnd {
IpcClientProxy::IpcClientProxy(IpcServerInterface *server, QIODevice *ioDevice) IpcClientProxy::IpcClientProxy(IpcServerInterface *server, QIODevice *ioDevice)
: writeCommandBlock(ioDevice), : writeMessageBlock(ioDevice),
readCommandBlock(ioDevice), readMessageBlock(ioDevice),
server(server), server(server),
ioDevice(ioDevice) ioDevice(ioDevice)
{ {
QObject::connect(ioDevice, &QIODevice::readyRead, [this] () {IpcClientProxy::readCommands();}); QObject::connect(ioDevice, &QIODevice::readyRead, [this] () {IpcClientProxy::readMessages();});
} }
IpcClientProxy::IpcClientProxy(IpcClientProxy &&other) IpcClientProxy::IpcClientProxy(IpcClientProxy &&other)
: writeCommandBlock(std::move(other.writeCommandBlock)), : writeMessageBlock(std::move(other.writeMessageBlock)),
readCommandBlock(std::move(other.readCommandBlock)), readMessageBlock(std::move(other.readMessageBlock)),
server(std::move(other.server)), server(std::move(other.server)),
ioDevice(std::move(other.ioDevice)) ioDevice(std::move(other.ioDevice))
{ {
@@ -65,8 +65,8 @@ IpcClientProxy::IpcClientProxy(IpcClientProxy &&other)
IpcClientProxy &IpcClientProxy::operator=(IpcClientProxy &&other) IpcClientProxy &IpcClientProxy::operator=(IpcClientProxy &&other)
{ {
writeCommandBlock = std::move(other.writeCommandBlock); writeMessageBlock = std::move(other.writeMessageBlock);
readCommandBlock = std::move(other.readCommandBlock); readMessageBlock = std::move(other.readMessageBlock);
server = std::move(other.server); server = std::move(other.server);
ioDevice = std::move(other.ioDevice); ioDevice = std::move(other.ioDevice);
@@ -75,33 +75,33 @@ IpcClientProxy &IpcClientProxy::operator=(IpcClientProxy &&other)
void IpcClientProxy::alive() void IpcClientProxy::alive()
{ {
writeCommandBlock.write(QVariant::fromValue(AliveCommand())); writeMessageBlock.write(QVariant::fromValue(AliveMessage()));
} }
void IpcClientProxy::echo(const EchoCommand &command) void IpcClientProxy::echo(const EchoMessage &message)
{ {
writeCommandBlock.write(QVariant::fromValue(command)); writeMessageBlock.write(QVariant::fromValue(message));
} }
void IpcClientProxy::codeCompleted(const CodeCompletedCommand &command) void IpcClientProxy::codeCompleted(const CodeCompletedMessage &message)
{ {
writeCommandBlock.write(QVariant::fromValue(command)); writeMessageBlock.write(QVariant::fromValue(message));
} }
void IpcClientProxy::translationUnitDoesNotExist(const TranslationUnitDoesNotExistCommand &command) void IpcClientProxy::translationUnitDoesNotExist(const TranslationUnitDoesNotExistMessage &message)
{ {
writeCommandBlock.write(QVariant::fromValue(command)); writeMessageBlock.write(QVariant::fromValue(message));
} }
void IpcClientProxy::projectPartsDoNotExist(const ProjectPartsDoNotExistCommand &command) void IpcClientProxy::projectPartsDoNotExist(const ProjectPartsDoNotExistMessage &message)
{ {
writeCommandBlock.write(QVariant::fromValue(command)); writeMessageBlock.write(QVariant::fromValue(message));
} }
void IpcClientProxy::readCommands() void IpcClientProxy::readMessages()
{ {
for (const QVariant &command : readCommandBlock.readAll()) for (const QVariant &message : readMessageBlock.readAll())
server->dispatch(command); server->dispatch(message);
} }
bool IpcClientProxy::isUsingThatIoDevice(QIODevice *ioDevice) const bool IpcClientProxy::isUsingThatIoDevice(QIODevice *ioDevice) const

View File

@@ -33,8 +33,8 @@
#include "clangbackendipc_global.h" #include "clangbackendipc_global.h"
#include "ipcclientinterface.h" #include "ipcclientinterface.h"
#include "readcommandblock.h" #include "readmessageblock.h"
#include "writecommandblock.h" #include "writemessageblock.h"
#include <QtGlobal> #include <QtGlobal>
@@ -58,18 +58,18 @@ public:
IpcClientProxy &operator=(IpcClientProxy&&other); IpcClientProxy &operator=(IpcClientProxy&&other);
void alive() override; void alive() override;
void echo(const EchoCommand &command) override; void echo(const EchoMessage &message) override;
void codeCompleted(const CodeCompletedCommand &command) override; void codeCompleted(const CodeCompletedMessage &message) override;
void translationUnitDoesNotExist(const TranslationUnitDoesNotExistCommand &command) override; void translationUnitDoesNotExist(const TranslationUnitDoesNotExistMessage &message) override;
void projectPartsDoNotExist(const ProjectPartsDoNotExistCommand &command) override; void projectPartsDoNotExist(const ProjectPartsDoNotExistMessage &message) override;
void readCommands(); void readMessages();
bool isUsingThatIoDevice(QIODevice *ioDevice) const; bool isUsingThatIoDevice(QIODevice *ioDevice) const;
private: private:
ClangBackEnd::WriteCommandBlock writeCommandBlock; ClangBackEnd::WriteMessageBlock writeMessageBlock;
ClangBackEnd::ReadCommandBlock readCommandBlock; ClangBackEnd::ReadMessageBlock readMessageBlock;
IpcServerInterface *server = nullptr; IpcServerInterface *server = nullptr;
QIODevice *ioDevice = nullptr; QIODevice *ioDevice = nullptr;
}; };

View File

@@ -45,7 +45,7 @@ class CMBIPC_EXPORT IpcInterface
{ {
public: public:
virtual ~IpcInterface(); virtual ~IpcInterface();
virtual void dispatch(const QVariant &command) = 0; virtual void dispatch(const QVariant &message) = 0;
}; };
} // namespace ClangBackEnd } // namespace ClangBackEnd

View File

@@ -30,42 +30,42 @@
#include "ipcserverinterface.h" #include "ipcserverinterface.h"
#include "cmbcompletecodecommand.h" #include "cmbcompletecodemessage.h"
#include "cmbregisterprojectsforcodecompletioncommand.h" #include "cmbregisterprojectsforcodecompletionmessage.h"
#include "cmbregistertranslationunitsforcodecompletioncommand.h" #include "cmbregistertranslationunitsforcodecompletionmessage.h"
#include "cmbunregisterprojectsforcodecompletioncommand.h" #include "cmbunregisterprojectsforcodecompletionmessage.h"
#include "cmbunregistertranslationunitsforcodecompletioncommand.h" #include "cmbunregistertranslationunitsforcodecompletionmessage.h"
#include <QDebug> #include <QDebug>
#include <QVariant> #include <QVariant>
namespace ClangBackEnd { namespace ClangBackEnd {
void IpcServerInterface::dispatch(const QVariant &command) void IpcServerInterface::dispatch(const QVariant &message)
{ {
static const int endCommandType = QMetaType::type("ClangBackEnd::EndCommand"); static const int endMessageType = QMetaType::type("ClangBackEnd::EndMessage");
static const int registerTranslationUnitsForCodeCompletionCommandType = QMetaType::type("ClangBackEnd::RegisterTranslationUnitForCodeCompletionCommand"); static const int registerTranslationUnitsForCodeCompletionMessageType = QMetaType::type("ClangBackEnd::RegisterTranslationUnitForCodeCompletionMessage");
static const int unregisterTranslationUnitsForCodeCompletionCommandType = QMetaType::type("ClangBackEnd::UnregisterTranslationUnitsForCodeCompletionCommand"); static const int unregisterTranslationUnitsForCodeCompletionMessageType = QMetaType::type("ClangBackEnd::UnregisterTranslationUnitsForCodeCompletionMessage");
static const int registerProjectPartsForCodeCompletionCommandType = QMetaType::type("ClangBackEnd::RegisterProjectPartsForCodeCompletionCommand"); static const int registerProjectPartsForCodeCompletionMessageType = QMetaType::type("ClangBackEnd::RegisterProjectPartsForCodeCompletionMessage");
static const int unregisterProjectPartsForCodeCompletionCommandType = QMetaType::type("ClangBackEnd::UnregisterProjectPartsForCodeCompletionCommand"); static const int unregisterProjectPartsForCodeCompletionMessageType = QMetaType::type("ClangBackEnd::UnregisterProjectPartsForCodeCompletionMessage");
static const int completeCodeCommandType = QMetaType::type("ClangBackEnd::CompleteCodeCommand"); static const int completeCodeMessageType = QMetaType::type("ClangBackEnd::CompleteCodeMessage");
int type = command.userType(); int type = message.userType();
if (type == endCommandType) if (type == endMessageType)
end(); end();
else if (type == registerTranslationUnitsForCodeCompletionCommandType) else if (type == registerTranslationUnitsForCodeCompletionMessageType)
registerTranslationUnitsForCodeCompletion(command.value<RegisterTranslationUnitForCodeCompletionCommand>()); registerTranslationUnitsForCodeCompletion(message.value<RegisterTranslationUnitForCodeCompletionMessage>());
else if (type == unregisterTranslationUnitsForCodeCompletionCommandType) else if (type == unregisterTranslationUnitsForCodeCompletionMessageType)
unregisterTranslationUnitsForCodeCompletion(command.value<UnregisterTranslationUnitsForCodeCompletionCommand>()); unregisterTranslationUnitsForCodeCompletion(message.value<UnregisterTranslationUnitsForCodeCompletionMessage>());
else if (type == registerProjectPartsForCodeCompletionCommandType) else if (type == registerProjectPartsForCodeCompletionMessageType)
registerProjectPartsForCodeCompletion(command.value<RegisterProjectPartsForCodeCompletionCommand>()); registerProjectPartsForCodeCompletion(message.value<RegisterProjectPartsForCodeCompletionMessage>());
else if (type == unregisterProjectPartsForCodeCompletionCommandType) else if (type == unregisterProjectPartsForCodeCompletionMessageType)
unregisterProjectPartsForCodeCompletion(command.value<UnregisterProjectPartsForCodeCompletionCommand>()); unregisterProjectPartsForCodeCompletion(message.value<UnregisterProjectPartsForCodeCompletionMessage>());
else if (type == completeCodeCommandType) else if (type == completeCodeMessageType)
completeCode(command.value<CompleteCodeCommand>()); completeCode(message.value<CompleteCodeMessage>());
else else
qWarning() << "Unknown IpcServerCommand"; qWarning() << "Unknown IpcServerMessage";
} }
void IpcServerInterface::addClient(IpcClientInterface *client) void IpcServerInterface::addClient(IpcClientInterface *client)

View File

@@ -42,14 +42,14 @@ class IpcClientInterface;
class CMBIPC_EXPORT IpcServerInterface : public IpcInterface class CMBIPC_EXPORT IpcServerInterface : public IpcInterface
{ {
public: public:
void dispatch(const QVariant &command) override; void dispatch(const QVariant &message) override;
virtual void end() = 0; virtual void end() = 0;
virtual void registerTranslationUnitsForCodeCompletion(const RegisterTranslationUnitForCodeCompletionCommand &command) = 0; virtual void registerTranslationUnitsForCodeCompletion(const RegisterTranslationUnitForCodeCompletionMessage &message) = 0;
virtual void unregisterTranslationUnitsForCodeCompletion(const UnregisterTranslationUnitsForCodeCompletionCommand &command) = 0; virtual void unregisterTranslationUnitsForCodeCompletion(const UnregisterTranslationUnitsForCodeCompletionMessage &message) = 0;
virtual void registerProjectPartsForCodeCompletion(const RegisterProjectPartsForCodeCompletionCommand &command) = 0; virtual void registerProjectPartsForCodeCompletion(const RegisterProjectPartsForCodeCompletionMessage &message) = 0;
virtual void unregisterProjectPartsForCodeCompletion(const UnregisterProjectPartsForCodeCompletionCommand &command) = 0; virtual void unregisterProjectPartsForCodeCompletion(const UnregisterProjectPartsForCodeCompletionMessage &message) = 0;
virtual void completeCode(const CompleteCodeCommand &command) = 0; virtual void completeCode(const CompleteCodeMessage &message) = 0;
void addClient(IpcClientInterface *client); void addClient(IpcClientInterface *client);
void removeClient(IpcClientInterface *client); void removeClient(IpcClientInterface *client);

View File

@@ -30,13 +30,13 @@
#include "ipcserverproxy.h" #include "ipcserverproxy.h"
#include <cmbalivecommand.h> #include <cmbalivemessage.h>
#include <cmbcompletecodecommand.h> #include <cmbcompletecodemessage.h>
#include <cmbendcommand.h> #include <cmbendmessage.h>
#include <cmbregisterprojectsforcodecompletioncommand.h> #include <cmbregisterprojectsforcodecompletionmessage.h>
#include <cmbregistertranslationunitsforcodecompletioncommand.h> #include <cmbregistertranslationunitsforcodecompletionmessage.h>
#include <cmbunregisterprojectsforcodecompletioncommand.h> #include <cmbunregisterprojectsforcodecompletionmessage.h>
#include <cmbunregistertranslationunitsforcodecompletioncommand.h> #include <cmbunregistertranslationunitsforcodecompletionmessage.h>
#include <ipcclientinterface.h> #include <ipcclientinterface.h>
#include <QLocalServer> #include <QLocalServer>
@@ -46,53 +46,53 @@
namespace ClangBackEnd { namespace ClangBackEnd {
IpcServerProxy::IpcServerProxy(IpcClientInterface *client, QIODevice *ioDevice) IpcServerProxy::IpcServerProxy(IpcClientInterface *client, QIODevice *ioDevice)
: writeCommandBlock(ioDevice), : writeMessageBlock(ioDevice),
readCommandBlock(ioDevice), readMessageBlock(ioDevice),
client(client) client(client)
{ {
QObject::connect(ioDevice, &QIODevice::readyRead, [this] () {IpcServerProxy::readCommands();}); QObject::connect(ioDevice, &QIODevice::readyRead, [this] () {IpcServerProxy::readMessages();});
} }
void IpcServerProxy::readCommands() void IpcServerProxy::readMessages()
{ {
for (const QVariant &command : readCommandBlock.readAll()) for (const QVariant &message : readMessageBlock.readAll())
client->dispatch(command); client->dispatch(message);
} }
void IpcServerProxy::resetCounter() void IpcServerProxy::resetCounter()
{ {
writeCommandBlock.resetCounter(); writeMessageBlock.resetCounter();
readCommandBlock.resetCounter(); readMessageBlock.resetCounter();
} }
void IpcServerProxy::end() void IpcServerProxy::end()
{ {
writeCommandBlock.write(QVariant::fromValue(EndCommand())); writeMessageBlock.write(QVariant::fromValue(EndMessage()));
} }
void IpcServerProxy::registerTranslationUnitsForCodeCompletion(const RegisterTranslationUnitForCodeCompletionCommand &command) void IpcServerProxy::registerTranslationUnitsForCodeCompletion(const RegisterTranslationUnitForCodeCompletionMessage &message)
{ {
writeCommandBlock.write(QVariant::fromValue(command)); writeMessageBlock.write(QVariant::fromValue(message));
} }
void IpcServerProxy::unregisterTranslationUnitsForCodeCompletion(const UnregisterTranslationUnitsForCodeCompletionCommand &command) void IpcServerProxy::unregisterTranslationUnitsForCodeCompletion(const UnregisterTranslationUnitsForCodeCompletionMessage &message)
{ {
writeCommandBlock.write(QVariant::fromValue(command)); writeMessageBlock.write(QVariant::fromValue(message));
} }
void IpcServerProxy::registerProjectPartsForCodeCompletion(const RegisterProjectPartsForCodeCompletionCommand &command) void IpcServerProxy::registerProjectPartsForCodeCompletion(const RegisterProjectPartsForCodeCompletionMessage &message)
{ {
writeCommandBlock.write(QVariant::fromValue(command)); writeMessageBlock.write(QVariant::fromValue(message));
} }
void IpcServerProxy::unregisterProjectPartsForCodeCompletion(const UnregisterProjectPartsForCodeCompletionCommand &command) void IpcServerProxy::unregisterProjectPartsForCodeCompletion(const UnregisterProjectPartsForCodeCompletionMessage &message)
{ {
writeCommandBlock.write(QVariant::fromValue(command)); writeMessageBlock.write(QVariant::fromValue(message));
} }
void IpcServerProxy::completeCode(const CompleteCodeCommand &command) void IpcServerProxy::completeCode(const CompleteCodeMessage &message)
{ {
writeCommandBlock.write(QVariant::fromValue(command)); writeMessageBlock.write(QVariant::fromValue(message));
} }
} // namespace ClangBackEnd } // namespace ClangBackEnd

View File

@@ -31,8 +31,8 @@
#ifndef CLANGBACKEND_IPCSERVERPROXY_H #ifndef CLANGBACKEND_IPCSERVERPROXY_H
#define CLANGBACKEND_IPCSERVERPROXY_H #define CLANGBACKEND_IPCSERVERPROXY_H
#include "ipcserverinterface.h" #include "ipcserverinterface.h"
#include "readcommandblock.h" #include "readmessageblock.h"
#include "writecommandblock.h" #include "writemessageblock.h"
#include <QtGlobal> #include <QtGlobal>
#include <QTimer> #include <QTimer>
@@ -56,19 +56,19 @@ public:
IpcServerProxy &operator=(const IpcServerProxy&) = delete; IpcServerProxy &operator=(const IpcServerProxy&) = delete;
void end() override; void end() override;
void registerTranslationUnitsForCodeCompletion(const RegisterTranslationUnitForCodeCompletionCommand &command) override; void registerTranslationUnitsForCodeCompletion(const RegisterTranslationUnitForCodeCompletionMessage &message) override;
void unregisterTranslationUnitsForCodeCompletion(const UnregisterTranslationUnitsForCodeCompletionCommand &command) override; void unregisterTranslationUnitsForCodeCompletion(const UnregisterTranslationUnitsForCodeCompletionMessage &message) override;
void registerProjectPartsForCodeCompletion(const RegisterProjectPartsForCodeCompletionCommand &command) override; void registerProjectPartsForCodeCompletion(const RegisterProjectPartsForCodeCompletionMessage &message) override;
void unregisterProjectPartsForCodeCompletion(const UnregisterProjectPartsForCodeCompletionCommand &command) override; void unregisterProjectPartsForCodeCompletion(const UnregisterProjectPartsForCodeCompletionMessage &message) override;
void completeCode(const CompleteCodeCommand &command) override; void completeCode(const CompleteCodeMessage &message) override;
void readCommands(); void readMessages();
void resetCounter(); void resetCounter();
private: private:
ClangBackEnd::WriteCommandBlock writeCommandBlock; ClangBackEnd::WriteMessageBlock writeMessageBlock;
ClangBackEnd::ReadCommandBlock readCommandBlock; ClangBackEnd::ReadMessageBlock readMessageBlock;
IpcClientInterface *client; IpcClientInterface *client;
}; };

View File

@@ -28,7 +28,7 @@
** **
****************************************************************************/ ****************************************************************************/
#include "projectpartsdonotexistcommand.h" #include "projectpartsdonotexistmessage.h"
#include <QDataStream> #include <QDataStream>
#include <QDebug> #include <QDebug>
@@ -39,58 +39,58 @@
namespace ClangBackEnd { namespace ClangBackEnd {
ProjectPartsDoNotExistCommand::ProjectPartsDoNotExistCommand(const Utf8StringVector &projectPartIds) ProjectPartsDoNotExistMessage::ProjectPartsDoNotExistMessage(const Utf8StringVector &projectPartIds)
: projectPartIds_(projectPartIds) : projectPartIds_(projectPartIds)
{ {
} }
const Utf8StringVector &ProjectPartsDoNotExistCommand::projectPartIds() const const Utf8StringVector &ProjectPartsDoNotExistMessage::projectPartIds() const
{ {
return projectPartIds_; return projectPartIds_;
} }
QDataStream &operator<<(QDataStream &out, const ProjectPartsDoNotExistCommand &command) QDataStream &operator<<(QDataStream &out, const ProjectPartsDoNotExistMessage &message)
{ {
out << command.projectPartIds_; out << message.projectPartIds_;
return out; return out;
} }
QDataStream &operator>>(QDataStream &in, ProjectPartsDoNotExistCommand &command) QDataStream &operator>>(QDataStream &in, ProjectPartsDoNotExistMessage &message)
{ {
in >> command.projectPartIds_; in >> message.projectPartIds_;
return in; return in;
} }
bool operator==(const ProjectPartsDoNotExistCommand &first, const ProjectPartsDoNotExistCommand &second) bool operator==(const ProjectPartsDoNotExistMessage &first, const ProjectPartsDoNotExistMessage &second)
{ {
return first.projectPartIds_ == second.projectPartIds_; return first.projectPartIds_ == second.projectPartIds_;
} }
bool operator<(const ProjectPartsDoNotExistCommand &first, const ProjectPartsDoNotExistCommand &second) bool operator<(const ProjectPartsDoNotExistMessage &first, const ProjectPartsDoNotExistMessage &second)
{ {
return compareContainer(first.projectPartIds_, second.projectPartIds_); return compareContainer(first.projectPartIds_, second.projectPartIds_);
} }
QDebug operator<<(QDebug debug, const ProjectPartsDoNotExistCommand &command) QDebug operator<<(QDebug debug, const ProjectPartsDoNotExistMessage &message)
{ {
debug.nospace() << "ProjectPartDoesNotExistCommand("; debug.nospace() << "ProjectPartDoesNotExistMessage(";
debug.nospace() << command.projectPartIds_; debug.nospace() << message.projectPartIds_;
debug.nospace() << ")"; debug.nospace() << ")";
return debug; return debug;
} }
void PrintTo(const ProjectPartsDoNotExistCommand &command, ::std::ostream* os) void PrintTo(const ProjectPartsDoNotExistMessage &message, ::std::ostream* os)
{ {
QString output; QString output;
QDebug debug(&output); QDebug debug(&output);
debug << command; debug << message;
*os << output.toUtf8().constData(); *os << output.toUtf8().constData();
} }

View File

@@ -28,8 +28,8 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef CLANGBACKEND_PROJECTPARTSDONOTEXISTCOMMAND_H #ifndef CLANGBACKEND_PROJECTPARTSDONOTEXISTMESSAGE_H
#define CLANGBACKEND_PROJECTPARTSDONOTEXISTCOMMAND_H #define CLANGBACKEND_PROJECTPARTSDONOTEXISTMESSAGE_H
#include "clangbackendipc_global.h" #include "clangbackendipc_global.h"
@@ -39,17 +39,17 @@
namespace ClangBackEnd { namespace ClangBackEnd {
class CMBIPC_EXPORT ProjectPartsDoNotExistCommand class CMBIPC_EXPORT ProjectPartsDoNotExistMessage
{ {
friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const ProjectPartsDoNotExistCommand &command); friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const ProjectPartsDoNotExistMessage &message);
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, ProjectPartsDoNotExistCommand &command); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, ProjectPartsDoNotExistMessage &message);
friend CMBIPC_EXPORT bool operator==(const ProjectPartsDoNotExistCommand &first, const ProjectPartsDoNotExistCommand &second); friend CMBIPC_EXPORT bool operator==(const ProjectPartsDoNotExistMessage &first, const ProjectPartsDoNotExistMessage &second);
friend CMBIPC_EXPORT bool operator<(const ProjectPartsDoNotExistCommand &first, const ProjectPartsDoNotExistCommand &second); friend CMBIPC_EXPORT bool operator<(const ProjectPartsDoNotExistMessage &first, const ProjectPartsDoNotExistMessage &second);
friend CMBIPC_EXPORT QDebug operator<<(QDebug debug, const ProjectPartsDoNotExistCommand &command); friend CMBIPC_EXPORT QDebug operator<<(QDebug debug, const ProjectPartsDoNotExistMessage &message);
friend void PrintTo(const ProjectPartsDoNotExistCommand &command, ::std::ostream* os); friend void PrintTo(const ProjectPartsDoNotExistMessage &message, ::std::ostream* os);
public: public:
ProjectPartsDoNotExistCommand() = default; ProjectPartsDoNotExistMessage() = default;
ProjectPartsDoNotExistCommand(const Utf8StringVector &projectPartIds); ProjectPartsDoNotExistMessage(const Utf8StringVector &projectPartIds);
const Utf8StringVector &projectPartIds() const; const Utf8StringVector &projectPartIds() const;
@@ -57,16 +57,16 @@ private:
Utf8StringVector projectPartIds_; Utf8StringVector projectPartIds_;
}; };
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const ProjectPartsDoNotExistCommand &command); CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const ProjectPartsDoNotExistMessage &message);
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, ProjectPartsDoNotExistCommand &command); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, ProjectPartsDoNotExistMessage &message);
CMBIPC_EXPORT bool operator==(const ProjectPartsDoNotExistCommand &first, const ProjectPartsDoNotExistCommand &second); CMBIPC_EXPORT bool operator==(const ProjectPartsDoNotExistMessage &first, const ProjectPartsDoNotExistMessage &second);
CMBIPC_EXPORT bool operator<(const ProjectPartsDoNotExistCommand &first, const ProjectPartsDoNotExistCommand &second); CMBIPC_EXPORT bool operator<(const ProjectPartsDoNotExistMessage &first, const ProjectPartsDoNotExistMessage &second);
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const ProjectPartsDoNotExistCommand &command); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const ProjectPartsDoNotExistMessage &message);
void PrintTo(const ProjectPartsDoNotExistCommand &command, ::std::ostream* os); void PrintTo(const ProjectPartsDoNotExistMessage &message, ::std::ostream* os);
} // namespace ClangBackEnd } // namespace ClangBackEnd
Q_DECLARE_METATYPE(ClangBackEnd::ProjectPartsDoNotExistCommand) Q_DECLARE_METATYPE(ClangBackEnd::ProjectPartsDoNotExistMessage)
#endif // CLANGBACKEND_PROJECTPARTSDONOTEXISTCOMMAND_H #endif // CLANGBACKEND_PROJECTPARTSDONOTEXISTMESSAGE_H

View File

@@ -28,7 +28,7 @@
** **
****************************************************************************/ ****************************************************************************/
#include "readcommandblock.h" #include "readmessageblock.h"
#include <QDataStream> #include <QDataStream>
#include <QDebug> #include <QDebug>
@@ -37,63 +37,63 @@
namespace ClangBackEnd { namespace ClangBackEnd {
ReadCommandBlock::ReadCommandBlock(QIODevice *ioDevice) ReadMessageBlock::ReadMessageBlock(QIODevice *ioDevice)
: ioDevice(ioDevice), : ioDevice(ioDevice),
commandCounter(0), messageCounter(0),
blockSize(0) blockSize(0)
{ {
} }
void ReadCommandBlock::checkIfCommandIsLost(QDataStream &in) void ReadMessageBlock::checkIfMessageIsLost(QDataStream &in)
{ {
qint64 currentCommandCounter; qint64 currentMessageCounter;
in >> currentCommandCounter; in >> currentMessageCounter;
#ifndef DONT_CHECK_COMMAND_COUNTER #ifndef DONT_CHECK_MESSAGE_COUNTER
bool commandLost = !((currentCommandCounter == 0 && commandCounter == 0) || (commandCounter + 1 == currentCommandCounter)); bool messageLost = !((currentMessageCounter == 0 && messageCounter == 0) || (messageCounter + 1 == currentMessageCounter));
if (commandLost) if (messageLost)
qWarning() << "client command lost: " << commandCounter << currentCommandCounter; qWarning() << "client message lost: " << messageCounter << currentMessageCounter;
#endif #endif
commandCounter = currentCommandCounter; messageCounter = currentMessageCounter;
} }
QVariant ReadCommandBlock::read() QVariant ReadMessageBlock::read()
{ {
QDataStream in(ioDevice); QDataStream in(ioDevice);
QVariant command; QVariant message;
if (isTheWholeCommandReadable(in)) { if (isTheWholeMessageReadable(in)) {
checkIfCommandIsLost(in); checkIfMessageIsLost(in);
in >> command; in >> message;
} }
return command; return message;
} }
QVector<QVariant> ReadCommandBlock::readAll() QVector<QVariant> ReadMessageBlock::readAll()
{ {
QVector<QVariant> commands; QVector<QVariant> messages;
while (true) { while (true) {
const QVariant command = read(); const QVariant message = read();
if (command.isValid()) if (message.isValid())
commands.append(command); messages.append(message);
else else
return commands; return messages;
} }
Q_UNREACHABLE(); Q_UNREACHABLE();
} }
void ReadCommandBlock::resetCounter() void ReadMessageBlock::resetCounter()
{ {
commandCounter = 0; messageCounter = 0;
} }
bool ReadCommandBlock::isTheWholeCommandReadable(QDataStream &in) bool ReadMessageBlock::isTheWholeMessageReadable(QDataStream &in)
{ {
if (ioDevice->bytesAvailable() == 0) if (ioDevice->bytesAvailable() == 0)
return false; return false;

View File

@@ -28,8 +28,8 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef CLANGBACKEND_READCOMMANDBLOCK_H #ifndef CLANGBACKEND_READMESSAGEBLOCK_H
#define CLANGBACKEND_READCOMMANDBLOCK_H #define CLANGBACKEND_READMESSAGEBLOCK_H
#include <QtGlobal> #include <QtGlobal>
@@ -41,10 +41,10 @@ QT_END_NAMESPACE
namespace ClangBackEnd { namespace ClangBackEnd {
class ReadCommandBlock class ReadMessageBlock
{ {
public: public:
ReadCommandBlock(QIODevice *ioDevice = nullptr); ReadMessageBlock(QIODevice *ioDevice = nullptr);
QVariant read(); QVariant read();
QVector<QVariant> readAll(); QVector<QVariant> readAll();
@@ -52,15 +52,15 @@ public:
void resetCounter(); void resetCounter();
private: private:
bool isTheWholeCommandReadable(QDataStream &in); bool isTheWholeMessageReadable(QDataStream &in);
void checkIfCommandIsLost(QDataStream &in); void checkIfMessageIsLost(QDataStream &in);
private: private:
QIODevice *ioDevice; QIODevice *ioDevice;
qint64 commandCounter; qint64 messageCounter;
qint32 blockSize; qint32 blockSize;
}; };
} // namespace ClangBackEnd } // namespace ClangBackEnd
#endif // CLANGBACKEND_READCOMMANDBLOCK_H #endif // CLANGBACKEND_READMESSAGEBLOCK_H

View File

@@ -28,7 +28,7 @@
** **
****************************************************************************/ ****************************************************************************/
#include "translationunitdoesnotexistcommand.h" #include "translationunitdoesnotexistmessage.h"
#include <QDataStream> #include <QDataStream>
#include <QDebug> #include <QDebug>
@@ -37,72 +37,72 @@
namespace ClangBackEnd { namespace ClangBackEnd {
TranslationUnitDoesNotExistCommand::TranslationUnitDoesNotExistCommand(const FileContainer &fileContainer) TranslationUnitDoesNotExistMessage::TranslationUnitDoesNotExistMessage(const FileContainer &fileContainer)
: fileContainer_(fileContainer) : fileContainer_(fileContainer)
{ {
} }
TranslationUnitDoesNotExistCommand::TranslationUnitDoesNotExistCommand(const Utf8String &filePath, const Utf8String &projectPartId) TranslationUnitDoesNotExistMessage::TranslationUnitDoesNotExistMessage(const Utf8String &filePath, const Utf8String &projectPartId)
: fileContainer_(filePath, projectPartId) : fileContainer_(filePath, projectPartId)
{ {
} }
const FileContainer &TranslationUnitDoesNotExistCommand::fileContainer() const const FileContainer &TranslationUnitDoesNotExistMessage::fileContainer() const
{ {
return fileContainer_; return fileContainer_;
} }
const Utf8String &TranslationUnitDoesNotExistCommand::filePath() const const Utf8String &TranslationUnitDoesNotExistMessage::filePath() const
{ {
return fileContainer_.filePath(); return fileContainer_.filePath();
} }
const Utf8String &TranslationUnitDoesNotExistCommand::projectPartId() const const Utf8String &TranslationUnitDoesNotExistMessage::projectPartId() const
{ {
return fileContainer_.projectPartId(); return fileContainer_.projectPartId();
} }
QDataStream &operator<<(QDataStream &out, const TranslationUnitDoesNotExistCommand &command) QDataStream &operator<<(QDataStream &out, const TranslationUnitDoesNotExistMessage &message)
{ {
out << command.fileContainer_; out << message.fileContainer_;
return out; return out;
} }
QDataStream &operator>>(QDataStream &in, TranslationUnitDoesNotExistCommand &command) QDataStream &operator>>(QDataStream &in, TranslationUnitDoesNotExistMessage &message)
{ {
in >> command.fileContainer_; in >> message.fileContainer_;
return in; return in;
} }
bool operator==(const TranslationUnitDoesNotExistCommand &first, const TranslationUnitDoesNotExistCommand &second) bool operator==(const TranslationUnitDoesNotExistMessage &first, const TranslationUnitDoesNotExistMessage &second)
{ {
return first.fileContainer_ == second.fileContainer_; return first.fileContainer_ == second.fileContainer_;
} }
bool operator<(const TranslationUnitDoesNotExistCommand &first, const TranslationUnitDoesNotExistCommand &second) bool operator<(const TranslationUnitDoesNotExistMessage &first, const TranslationUnitDoesNotExistMessage &second)
{ {
return first.fileContainer_ < second.fileContainer_; return first.fileContainer_ < second.fileContainer_;
} }
QDebug operator<<(QDebug debug, const TranslationUnitDoesNotExistCommand &command) QDebug operator<<(QDebug debug, const TranslationUnitDoesNotExistMessage &message)
{ {
debug.nospace() << "TranslationUnitDoesNotExistCommand("; debug.nospace() << "TranslationUnitDoesNotExistMessage(";
debug.nospace() << command.fileContainer_; debug.nospace() << message.fileContainer_;
debug.nospace() << ")"; debug.nospace() << ")";
return debug; return debug;
} }
void PrintTo(const TranslationUnitDoesNotExistCommand &command, ::std::ostream* os) void PrintTo(const TranslationUnitDoesNotExistMessage &message, ::std::ostream* os)
{ {
QString output; QString output;
QDebug debug(&output); QDebug debug(&output);
debug << command; debug << message;
*os << output.toUtf8().constData(); *os << output.toUtf8().constData();
} }

View File

@@ -28,8 +28,8 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef CLANGBACKEND_TRANSLATIONUNITDOESNOTEXISTSCOMMAND_H #ifndef CLANGBACKEND_TRANSLATIONUNITDOESNOTEXISTSMESSAGE_H
#define CLANGBACKEND_TRANSLATIONUNITDOESNOTEXISTSCOMMAND_H #define CLANGBACKEND_TRANSLATIONUNITDOESNOTEXISTSMESSAGE_H
#include "filecontainer.h" #include "filecontainer.h"
@@ -37,18 +37,18 @@
namespace ClangBackEnd { namespace ClangBackEnd {
class CMBIPC_EXPORT TranslationUnitDoesNotExistCommand class CMBIPC_EXPORT TranslationUnitDoesNotExistMessage
{ {
friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const TranslationUnitDoesNotExistCommand &command); friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const TranslationUnitDoesNotExistMessage &message);
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, TranslationUnitDoesNotExistCommand &command); friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, TranslationUnitDoesNotExistMessage &message);
friend CMBIPC_EXPORT bool operator==(const TranslationUnitDoesNotExistCommand &first, const TranslationUnitDoesNotExistCommand &second); friend CMBIPC_EXPORT bool operator==(const TranslationUnitDoesNotExistMessage &first, const TranslationUnitDoesNotExistMessage &second);
friend CMBIPC_EXPORT bool operator<(const TranslationUnitDoesNotExistCommand &first, const TranslationUnitDoesNotExistCommand &second); friend CMBIPC_EXPORT bool operator<(const TranslationUnitDoesNotExistMessage &first, const TranslationUnitDoesNotExistMessage &second);
friend CMBIPC_EXPORT QDebug operator<<(QDebug debug, const TranslationUnitDoesNotExistCommand &command); friend CMBIPC_EXPORT QDebug operator<<(QDebug debug, const TranslationUnitDoesNotExistMessage &message);
friend void PrintTo(const TranslationUnitDoesNotExistCommand &command, ::std::ostream* os); friend void PrintTo(const TranslationUnitDoesNotExistMessage &message, ::std::ostream* os);
public: public:
TranslationUnitDoesNotExistCommand() = default; TranslationUnitDoesNotExistMessage() = default;
TranslationUnitDoesNotExistCommand(const FileContainer &fileContainer); TranslationUnitDoesNotExistMessage(const FileContainer &fileContainer);
TranslationUnitDoesNotExistCommand(const Utf8String &filePath, const Utf8String &projectPartId); TranslationUnitDoesNotExistMessage(const Utf8String &filePath, const Utf8String &projectPartId);
const FileContainer &fileContainer() const; const FileContainer &fileContainer() const;
const Utf8String &filePath() const; const Utf8String &filePath() const;
@@ -58,16 +58,16 @@ private:
FileContainer fileContainer_; FileContainer fileContainer_;
}; };
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const TranslationUnitDoesNotExistCommand &command); CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const TranslationUnitDoesNotExistMessage &message);
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, TranslationUnitDoesNotExistCommand &command); CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, TranslationUnitDoesNotExistMessage &message);
CMBIPC_EXPORT bool operator==(const TranslationUnitDoesNotExistCommand &first, const TranslationUnitDoesNotExistCommand &second); CMBIPC_EXPORT bool operator==(const TranslationUnitDoesNotExistMessage &first, const TranslationUnitDoesNotExistMessage &second);
CMBIPC_EXPORT bool operator<(const TranslationUnitDoesNotExistCommand &first, const TranslationUnitDoesNotExistCommand &second); CMBIPC_EXPORT bool operator<(const TranslationUnitDoesNotExistMessage &first, const TranslationUnitDoesNotExistMessage &second);
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const TranslationUnitDoesNotExistCommand &command); CMBIPC_EXPORT QDebug operator<<(QDebug debug, const TranslationUnitDoesNotExistMessage &message);
void PrintTo(const TranslationUnitDoesNotExistCommand &command, ::std::ostream* os); void PrintTo(const TranslationUnitDoesNotExistMessage &message, ::std::ostream* os);
} // namespace ClangBackEnd } // namespace ClangBackEnd
Q_DECLARE_METATYPE(ClangBackEnd::TranslationUnitDoesNotExistCommand) Q_DECLARE_METATYPE(ClangBackEnd::TranslationUnitDoesNotExistMessage)
#endif // CLANGBACKEND_TRANSLATIONUNITDOESNOTEXISTSCOMMAND_H #endif // CLANGBACKEND_TRANSLATIONUNITDOESNOTEXISTSMESSAGE_H

View File

@@ -28,7 +28,7 @@
** **
****************************************************************************/ ****************************************************************************/
#include "writecommandblock.h" #include "writemessageblock.h"
#include <QDataStream> #include <QDataStream>
#include <QDebug> #include <QDebug>
@@ -37,13 +37,13 @@
namespace ClangBackEnd { namespace ClangBackEnd {
WriteCommandBlock::WriteCommandBlock(QIODevice *ioDevice) WriteMessageBlock::WriteMessageBlock(QIODevice *ioDevice)
: commandCounter(0), : messageCounter(0),
ioDevice(ioDevice) ioDevice(ioDevice)
{ {
} }
void WriteCommandBlock::write(const QVariant &command) void WriteMessageBlock::write(const QVariant &message)
{ {
QByteArray block; QByteArray block;
QDataStream out(&block, QIODevice::WriteOnly); QDataStream out(&block, QIODevice::WriteOnly);
@@ -51,26 +51,26 @@ void WriteCommandBlock::write(const QVariant &command)
const qint32 dummyBockSize = 0; const qint32 dummyBockSize = 0;
out << dummyBockSize; out << dummyBockSize;
out << commandCounter; out << messageCounter;
out << command; out << message;
out.device()->seek(0); out.device()->seek(0);
out << qint32(block.size() - sizeof(qint32)); out << qint32(block.size() - sizeof(qint32));
++commandCounter; ++messageCounter;
ioDevice->write(block); ioDevice->write(block);
} }
qint64 WriteCommandBlock::counter() const qint64 WriteMessageBlock::counter() const
{ {
return commandCounter; return messageCounter;
} }
void WriteCommandBlock::resetCounter() void WriteMessageBlock::resetCounter()
{ {
commandCounter = 0; messageCounter = 0;
} }

View File

@@ -28,8 +28,8 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef CLANGBACKEND_WRITECOMMANDBLOCK_H #ifndef CLANGBACKEND_WRITEMESSAGEBLOCK_H
#define CLANGBACKEND_WRITECOMMANDBLOCK_H #define CLANGBACKEND_WRITEMESSAGEBLOCK_H
#include <QtGlobal> #include <QtGlobal>
@@ -41,22 +41,22 @@ QT_END_NAMESPACE
namespace ClangBackEnd { namespace ClangBackEnd {
class WriteCommandBlock class WriteMessageBlock
{ {
public: public:
WriteCommandBlock(QIODevice *ioDevice = nullptr); WriteMessageBlock(QIODevice *ioDevice = nullptr);
void write(const QVariant &command); void write(const QVariant &message);
qint64 counter() const; qint64 counter() const;
void resetCounter(); void resetCounter();
private: private:
qint64 commandCounter; qint64 messageCounter;
QIODevice *ioDevice; QIODevice *ioDevice;
}; };
} // namespace ClangBackEnd } // namespace ClangBackEnd
#endif // CLANGBACKEND_WRITECOMMANDBLOCK_H #endif // CLANGBACKEND_WRITEMESSAGEBLOCK_H

View File

@@ -49,16 +49,16 @@
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <clangbackendipc/cmbcodecompletedcommand.h> #include <clangbackendipc/cmbcodecompletedmessage.h>
#include <clangbackendipc/cmbcompletecodecommand.h> #include <clangbackendipc/cmbcompletecodemessage.h>
#include <clangbackendipc/cmbechocommand.h> #include <clangbackendipc/cmbechomessage.h>
#include <clangbackendipc/cmbregistertranslationunitsforcodecompletioncommand.h> #include <clangbackendipc/cmbregistertranslationunitsforcodecompletionmessage.h>
#include <clangbackendipc/cmbregisterprojectsforcodecompletioncommand.h> #include <clangbackendipc/cmbregisterprojectsforcodecompletionmessage.h>
#include <clangbackendipc/cmbunregistertranslationunitsforcodecompletioncommand.h> #include <clangbackendipc/cmbunregistertranslationunitsforcodecompletionmessage.h>
#include <clangbackendipc/cmbunregisterprojectsforcodecompletioncommand.h> #include <clangbackendipc/cmbunregisterprojectsforcodecompletionmessage.h>
#include <clangbackendipc/cmbcommands.h> #include <clangbackendipc/cmbmessages.h>
#include <clangbackendipc/projectpartsdonotexistcommand.h> #include <clangbackendipc/projectpartsdonotexistmessage.h>
#include <clangbackendipc/translationunitdoesnotexistcommand.h> #include <clangbackendipc/translationunitdoesnotexistmessage.h>
#include <cplusplus/Icons.h> #include <cplusplus/Icons.h>
@@ -99,7 +99,7 @@ void IpcReceiver::setAliveHandler(const IpcReceiver::AliveHandler &handler)
m_aliveHandler = handler; m_aliveHandler = handler;
} }
void IpcReceiver::addExpectedCodeCompletedCommand( void IpcReceiver::addExpectedCodeCompletedMessage(
quint64 ticket, quint64 ticket,
ClangCompletionAssistProcessor *processor) ClangCompletionAssistProcessor *processor)
{ {
@@ -129,39 +129,39 @@ void IpcReceiver::deleteProcessorsOfEditorWidget(TextEditor::TextEditorWidget *t
void IpcReceiver::alive() void IpcReceiver::alive()
{ {
qCDebug(log) << "<<< AliveCommand"; qCDebug(log) << "<<< AliveMessage";
QTC_ASSERT(m_aliveHandler, return); QTC_ASSERT(m_aliveHandler, return);
m_aliveHandler(); m_aliveHandler();
} }
void IpcReceiver::echo(const EchoCommand &command) void IpcReceiver::echo(const EchoMessage &message)
{ {
qCDebug(log) << "<<<" << command; qCDebug(log) << "<<<" << message;
} }
void IpcReceiver::codeCompleted(const CodeCompletedCommand &command) void IpcReceiver::codeCompleted(const CodeCompletedMessage &message)
{ {
qCDebug(log) << "<<< CodeCompletedCommand with" << command.codeCompletions().size() << "items"; qCDebug(log) << "<<< CodeCompletedMessage with" << message.codeCompletions().size() << "items";
const quint64 ticket = command.ticketNumber(); const quint64 ticket = message.ticketNumber();
QScopedPointer<ClangCompletionAssistProcessor> processor(m_assistProcessorsTable.take(ticket)); QScopedPointer<ClangCompletionAssistProcessor> processor(m_assistProcessorsTable.take(ticket));
if (processor) { if (processor) {
const bool finished = processor->handleAvailableAsyncCompletions(command.codeCompletions()); const bool finished = processor->handleAvailableAsyncCompletions(message.codeCompletions());
if (!finished) if (!finished)
processor.take(); processor.take();
} }
} }
void IpcReceiver::translationUnitDoesNotExist(const TranslationUnitDoesNotExistCommand &command) void IpcReceiver::translationUnitDoesNotExist(const TranslationUnitDoesNotExistMessage &message)
{ {
QTC_CHECK(!"Got TranslationUnitDoesNotExistCommand"); QTC_CHECK(!"Got TranslationUnitDoesNotExistMessage");
qCDebug(log) << "<<< ERROR:" << command; qCDebug(log) << "<<< ERROR:" << message;
} }
void IpcReceiver::projectPartsDoNotExist(const ProjectPartsDoNotExistCommand &command) void IpcReceiver::projectPartsDoNotExist(const ProjectPartsDoNotExistMessage &message)
{ {
QTC_CHECK(!"Got ProjectPartsDoNotExistCommand"); QTC_CHECK(!"Got ProjectPartsDoNotExistMessage");
qCDebug(log) << "<<< ERROR:" << command; qCDebug(log) << "<<< ERROR:" << message;
} }
class IpcSender : public IpcSenderInterface class IpcSender : public IpcSenderInterface
@@ -172,11 +172,11 @@ public:
{} {}
void end() override; void end() override;
void registerTranslationUnitsForCodeCompletion(const ClangBackEnd::RegisterTranslationUnitForCodeCompletionCommand &command) override; void registerTranslationUnitsForCodeCompletion(const ClangBackEnd::RegisterTranslationUnitForCodeCompletionMessage &message) override;
void unregisterTranslationUnitsForCodeCompletion(const ClangBackEnd::UnregisterTranslationUnitsForCodeCompletionCommand &command) override; void unregisterTranslationUnitsForCodeCompletion(const ClangBackEnd::UnregisterTranslationUnitsForCodeCompletionMessage &message) override;
void registerProjectPartsForCodeCompletion(const ClangBackEnd::RegisterProjectPartsForCodeCompletionCommand &command) override; void registerProjectPartsForCodeCompletion(const ClangBackEnd::RegisterProjectPartsForCodeCompletionMessage &message) override;
void unregisterProjectPartsForCodeCompletion(const ClangBackEnd::UnregisterProjectPartsForCodeCompletionCommand &command) override; void unregisterProjectPartsForCodeCompletion(const ClangBackEnd::UnregisterProjectPartsForCodeCompletionMessage &message) override;
void completeCode(const ClangBackEnd::CompleteCodeCommand &command) override; void completeCode(const ClangBackEnd::CompleteCodeMessage &message) override;
private: private:
ClangBackEnd::ConnectionClient &m_connection; ClangBackEnd::ConnectionClient &m_connection;
@@ -185,37 +185,37 @@ private:
void IpcSender::end() void IpcSender::end()
{ {
QTC_CHECK(m_connection.isConnected()); QTC_CHECK(m_connection.isConnected());
m_connection.sendEndCommand(); m_connection.sendEndMessage();
} }
void IpcSender::registerTranslationUnitsForCodeCompletion(const RegisterTranslationUnitForCodeCompletionCommand &command) void IpcSender::registerTranslationUnitsForCodeCompletion(const RegisterTranslationUnitForCodeCompletionMessage &message)
{ {
QTC_CHECK(m_connection.isConnected()); QTC_CHECK(m_connection.isConnected());
m_connection.serverProxy().registerTranslationUnitsForCodeCompletion(command); m_connection.serverProxy().registerTranslationUnitsForCodeCompletion(message);
} }
void IpcSender::unregisterTranslationUnitsForCodeCompletion(const UnregisterTranslationUnitsForCodeCompletionCommand &command) void IpcSender::unregisterTranslationUnitsForCodeCompletion(const UnregisterTranslationUnitsForCodeCompletionMessage &message)
{ {
QTC_CHECK(m_connection.isConnected()); QTC_CHECK(m_connection.isConnected());
m_connection.serverProxy().unregisterTranslationUnitsForCodeCompletion(command); m_connection.serverProxy().unregisterTranslationUnitsForCodeCompletion(message);
} }
void IpcSender::registerProjectPartsForCodeCompletion(const RegisterProjectPartsForCodeCompletionCommand &command) void IpcSender::registerProjectPartsForCodeCompletion(const RegisterProjectPartsForCodeCompletionMessage &message)
{ {
QTC_CHECK(m_connection.isConnected()); QTC_CHECK(m_connection.isConnected());
m_connection.serverProxy().registerProjectPartsForCodeCompletion(command); m_connection.serverProxy().registerProjectPartsForCodeCompletion(message);
} }
void IpcSender::unregisterProjectPartsForCodeCompletion(const UnregisterProjectPartsForCodeCompletionCommand &command) void IpcSender::unregisterProjectPartsForCodeCompletion(const UnregisterProjectPartsForCodeCompletionMessage &message)
{ {
QTC_CHECK(m_connection.isConnected()); QTC_CHECK(m_connection.isConnected());
m_connection.serverProxy().unregisterProjectPartsForCodeCompletion(command); m_connection.serverProxy().unregisterProjectPartsForCodeCompletion(message);
} }
void IpcSender::completeCode(const CompleteCodeCommand &command) void IpcSender::completeCode(const CompleteCodeMessage &message)
{ {
QTC_CHECK(m_connection.isConnected()); QTC_CHECK(m_connection.isConnected());
m_connection.serverProxy().completeCode(command); m_connection.serverProxy().completeCode(message);
} }
IpcCommunicator::IpcCommunicator() IpcCommunicator::IpcCommunicator()
@@ -232,13 +232,13 @@ IpcCommunicator::IpcCommunicator()
initializeBackend(); initializeBackend();
} }
static bool areCommandsRegistered = false; static bool areMessagesRegistered = false;
void IpcCommunicator::initializeBackend() void IpcCommunicator::initializeBackend()
{ {
if (!areCommandsRegistered) { if (!areMessagesRegistered) {
areCommandsRegistered = true; areMessagesRegistered = true;
Commands::registerCommands(); Messages::registerMessages();
} }
const QString clangBackEndProcessPath = backendProcessPath(); const QString clangBackEndProcessPath = backendProcessPath();
@@ -294,7 +294,7 @@ void IpcCommunicator::registerCurrrentCodeModelUiHeaders()
updateUnsavedFile(es->fileName(), es->contents()); updateUnsavedFile(es->fileName(), es->contents());
} }
static QStringList projectPartCommandLine(const CppTools::ProjectPart::Ptr &projectPart) static QStringList projectPartMessageLine(const CppTools::ProjectPart::Ptr &projectPart)
{ {
QStringList options = ClangCodeModel::Utils::createClangOptions(projectPart, QStringList options = ClangCodeModel::Utils::createClangOptions(projectPart,
CppTools::ProjectFile::Unclassified); // No language option CppTools::ProjectFile::Unclassified); // No language option
@@ -306,7 +306,7 @@ static QStringList projectPartCommandLine(const CppTools::ProjectPart::Ptr &proj
static ClangBackEnd::ProjectPartContainer toProjectPartContainer( static ClangBackEnd::ProjectPartContainer toProjectPartContainer(
const CppTools::ProjectPart::Ptr &projectPart) const CppTools::ProjectPart::Ptr &projectPart)
{ {
const QStringList arguments = projectPartCommandLine(projectPart); const QStringList arguments = projectPartMessageLine(projectPart);
return ClangBackEnd::ProjectPartContainer(projectPart->id(), Utf8StringVector(arguments)); return ClangBackEnd::ProjectPartContainer(projectPart->id(), Utf8StringVector(arguments));
} }
@@ -387,9 +387,9 @@ void IpcCommunicator::initializeBackendWithCurrentData()
IpcSenderInterface *IpcCommunicator::setIpcSender(IpcSenderInterface *ipcSender) IpcSenderInterface *IpcCommunicator::setIpcSender(IpcSenderInterface *ipcSender)
{ {
IpcSenderInterface *previousCommandSender = m_ipcSender.take(); IpcSenderInterface *previousMessageSender = m_ipcSender.take();
m_ipcSender.reset(ipcSender); m_ipcSender.reset(ipcSender);
return previousCommandSender; return previousMessageSender;
} }
void IpcCommunicator::killBackendProcess() void IpcCommunicator::killBackendProcess()
@@ -402,9 +402,9 @@ void IpcCommunicator::registerFilesForCodeCompletion(const FileContainers &fileC
if (m_sendMode == IgnoreSendRequests) if (m_sendMode == IgnoreSendRequests)
return; return;
const RegisterTranslationUnitForCodeCompletionCommand command(fileContainers); const RegisterTranslationUnitForCodeCompletionMessage message(fileContainers);
qCDebug(log) << ">>>" << command; qCDebug(log) << ">>>" << message;
m_ipcSender->registerTranslationUnitsForCodeCompletion(command); m_ipcSender->registerTranslationUnitsForCodeCompletion(message);
} }
void IpcCommunicator::unregisterFilesForCodeCompletion(const FileContainers &fileContainers) void IpcCommunicator::unregisterFilesForCodeCompletion(const FileContainers &fileContainers)
@@ -412,9 +412,9 @@ void IpcCommunicator::unregisterFilesForCodeCompletion(const FileContainers &fil
if (m_sendMode == IgnoreSendRequests) if (m_sendMode == IgnoreSendRequests)
return; return;
const UnregisterTranslationUnitsForCodeCompletionCommand command(fileContainers); const UnregisterTranslationUnitsForCodeCompletionMessage message(fileContainers);
qCDebug(log) << ">>>" << command; qCDebug(log) << ">>>" << message;
m_ipcSender->unregisterTranslationUnitsForCodeCompletion(command); m_ipcSender->unregisterTranslationUnitsForCodeCompletion(message);
} }
void IpcCommunicator::registerProjectPartsForCodeCompletion( void IpcCommunicator::registerProjectPartsForCodeCompletion(
@@ -423,9 +423,9 @@ void IpcCommunicator::registerProjectPartsForCodeCompletion(
if (m_sendMode == IgnoreSendRequests) if (m_sendMode == IgnoreSendRequests)
return; return;
const RegisterProjectPartsForCodeCompletionCommand command(projectPartContainers); const RegisterProjectPartsForCodeCompletionMessage message(projectPartContainers);
qCDebug(log) << ">>>" << command; qCDebug(log) << ">>>" << message;
m_ipcSender->registerProjectPartsForCodeCompletion(command); m_ipcSender->registerProjectPartsForCodeCompletion(message);
} }
void IpcCommunicator::unregisterProjectPartsForCodeCompletion(const QStringList &projectPartIds) void IpcCommunicator::unregisterProjectPartsForCodeCompletion(const QStringList &projectPartIds)
@@ -433,9 +433,9 @@ void IpcCommunicator::unregisterProjectPartsForCodeCompletion(const QStringList
if (m_sendMode == IgnoreSendRequests) if (m_sendMode == IgnoreSendRequests)
return; return;
const UnregisterProjectPartsForCodeCompletionCommand command((Utf8StringVector(projectPartIds))); const UnregisterProjectPartsForCodeCompletionMessage message((Utf8StringVector(projectPartIds)));
qCDebug(log) << ">>>" << command; qCDebug(log) << ">>>" << message;
m_ipcSender->unregisterProjectPartsForCodeCompletion(command); m_ipcSender->unregisterProjectPartsForCodeCompletion(message);
} }
void IpcCommunicator::completeCode(ClangCompletionAssistProcessor *assistProcessor, void IpcCommunicator::completeCode(ClangCompletionAssistProcessor *assistProcessor,
@@ -447,8 +447,8 @@ void IpcCommunicator::completeCode(ClangCompletionAssistProcessor *assistProcess
if (m_sendMode == IgnoreSendRequests) if (m_sendMode == IgnoreSendRequests)
return; return;
const CompleteCodeCommand command(filePath, line, column, projectFilePath); const CompleteCodeMessage message(filePath, line, column, projectFilePath);
qCDebug(log) << ">>>" << command; qCDebug(log) << ">>>" << message;
m_ipcSender->completeCode(command); m_ipcSender->completeCode(message);
m_ipcReceiver.addExpectedCodeCompletedCommand(command.ticketNumber(), assistProcessor); m_ipcReceiver.addExpectedCodeCompletedMessage(message.ticketNumber(), assistProcessor);
} }

View File

@@ -67,17 +67,17 @@ public:
using AliveHandler = std::function<void ()>; using AliveHandler = std::function<void ()>;
void setAliveHandler(const AliveHandler &handler); void setAliveHandler(const AliveHandler &handler);
void addExpectedCodeCompletedCommand(quint64 ticket, ClangCompletionAssistProcessor *processor); void addExpectedCodeCompletedMessage(quint64 ticket, ClangCompletionAssistProcessor *processor);
void deleteAndClearWaitingAssistProcessors(); void deleteAndClearWaitingAssistProcessors();
void deleteProcessorsOfEditorWidget(TextEditor::TextEditorWidget *textEditorWidget); void deleteProcessorsOfEditorWidget(TextEditor::TextEditorWidget *textEditorWidget);
private: private:
void alive() override; void alive() override;
void echo(const ClangBackEnd::EchoCommand &command) override; void echo(const ClangBackEnd::EchoMessage &message) override;
void codeCompleted(const ClangBackEnd::CodeCompletedCommand &command) override; void codeCompleted(const ClangBackEnd::CodeCompletedMessage &message) override;
void translationUnitDoesNotExist(const ClangBackEnd::TranslationUnitDoesNotExistCommand &command) override; void translationUnitDoesNotExist(const ClangBackEnd::TranslationUnitDoesNotExistMessage &message) override;
void projectPartsDoNotExist(const ClangBackEnd::ProjectPartsDoNotExistCommand &command) override; void projectPartsDoNotExist(const ClangBackEnd::ProjectPartsDoNotExistMessage &message) override;
private: private:
AliveHandler m_aliveHandler; AliveHandler m_aliveHandler;
@@ -90,11 +90,11 @@ public:
virtual ~IpcSenderInterface() {} virtual ~IpcSenderInterface() {}
virtual void end() = 0; virtual void end() = 0;
virtual void registerTranslationUnitsForCodeCompletion(const ClangBackEnd::RegisterTranslationUnitForCodeCompletionCommand &command) = 0; virtual void registerTranslationUnitsForCodeCompletion(const ClangBackEnd::RegisterTranslationUnitForCodeCompletionMessage &message) = 0;
virtual void unregisterTranslationUnitsForCodeCompletion(const ClangBackEnd::UnregisterTranslationUnitsForCodeCompletionCommand &command) = 0; virtual void unregisterTranslationUnitsForCodeCompletion(const ClangBackEnd::UnregisterTranslationUnitsForCodeCompletionMessage &message) = 0;
virtual void registerProjectPartsForCodeCompletion(const ClangBackEnd::RegisterProjectPartsForCodeCompletionCommand &command) = 0; virtual void registerProjectPartsForCodeCompletion(const ClangBackEnd::RegisterProjectPartsForCodeCompletionMessage &message) = 0;
virtual void unregisterProjectPartsForCodeCompletion(const ClangBackEnd::UnregisterProjectPartsForCodeCompletionCommand &command) = 0; virtual void unregisterProjectPartsForCodeCompletion(const ClangBackEnd::UnregisterProjectPartsForCodeCompletionMessage &message) = 0;
virtual void completeCode(const ClangBackEnd::CompleteCodeCommand &command) = 0; virtual void completeCode(const ClangBackEnd::CompleteCodeMessage &message) = 0;
}; };
class IpcCommunicator : public QObject class IpcCommunicator : public QObject

View File

@@ -67,7 +67,7 @@ QStringList createOptions(const QString &filePath,
return options; return options;
} }
QString commandLine(const QStringList &options, const QString &fileName) QString messageLine(const QStringList &options, const QString &fileName)
{ {
const QStringList allOptions = QStringList(options) const QStringList allOptions = QStringList(options)
<< QLatin1String("-fsyntax-only") << fileName; << QLatin1String("-fsyntax-only") << fileName;
@@ -100,10 +100,10 @@ void ClangEditorDocumentParser::updateHelper(const BaseEditorDocumentParser::InM
state_.projectPart = determineProjectPart(filePath(), configuration(), state_); state_.projectPart = determineProjectPart(filePath(), configuration(), state_);
setState(state_); setState(state_);
// Determine command line arguments // Determine message line arguments
const QStringList options = createOptions(filePath(), state_.projectPart, true); const QStringList options = createOptions(filePath(), state_.projectPart, true);
qCDebug(log, "Reparse options (cmd line equivalent): %s", qCDebug(log, "Reparse options (cmd line equivalent): %s",
commandLine(options, filePath()).toUtf8().constData()); messageLine(options, filePath()).toUtf8().constData());
// Run // Run
QTime t; t.start(); QTime t; t.start();

View File

@@ -39,7 +39,7 @@
#include <cpptools/editordocumenthandle.h> #include <cpptools/editordocumenthandle.h>
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
#include <clangbackendipc/cmbregisterprojectsforcodecompletioncommand.h> #include <clangbackendipc/cmbregisterprojectsforcodecompletionmessage.h>
#include <clangbackendipc/filecontainer.h> #include <clangbackendipc/filecontainer.h>
#include <clangbackendipc/projectpartcontainer.h> #include <clangbackendipc/projectpartcontainer.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>

View File

@@ -74,7 +74,7 @@ UnsavedFiles createUnsavedFiles(const WorkingCopy &workingCopy,
} }
/** /**
* @brief Creates list of command-line arguments required for correct parsing * @brief Creates list of message-line arguments required for correct parsing
* @param pPart Null if file isn't part of any project * @param pPart Null if file isn't part of any project
* @param fileName Path to file, non-empty * @param fileName Path to file, non-empty
*/ */
@@ -202,7 +202,7 @@ private:
}; };
/** /**
* @brief Creates list of command-line arguments required for correct parsing * @brief Creates list of message-line arguments required for correct parsing
* @param pPart Null if file isn't part of any project * @param pPart Null if file isn't part of any project
* @param fileKind Determines language and source/header state * @param fileKind Determines language and source/header state
*/ */

View File

@@ -54,12 +54,12 @@
#include <texteditor/textdocument.h> #include <texteditor/textdocument.h>
#include <texteditor/texteditor.h> #include <texteditor/texteditor.h>
#include <clangbackendipc/cmbcompletecodecommand.h> #include <clangbackendipc/cmbcompletecodemessage.h>
#include <clangbackendipc/cmbendcommand.h> #include <clangbackendipc/cmbendmessage.h>
#include <clangbackendipc/cmbregisterprojectsforcodecompletioncommand.h> #include <clangbackendipc/cmbregisterprojectsforcodecompletionmessage.h>
#include <clangbackendipc/cmbregistertranslationunitsforcodecompletioncommand.h> #include <clangbackendipc/cmbregistertranslationunitsforcodecompletionmessage.h>
#include <clangbackendipc/cmbunregisterprojectsforcodecompletioncommand.h> #include <clangbackendipc/cmbunregisterprojectsforcodecompletionmessage.h>
#include <clangbackendipc/cmbunregistertranslationunitsforcodecompletioncommand.h> #include <clangbackendipc/cmbunregistertranslationunitsforcodecompletionmessage.h>
#include <utils/changeset.h> #include <utils/changeset.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
@@ -305,73 +305,73 @@ QString toString(const QVector<ProjectPartContainer> &projectPartContainers)
return out; return out;
} }
QString toString(const EndCommand &) QString toString(const EndMessage &)
{ {
return QLatin1String("EndCommand\n"); return QLatin1String("EndMessage\n");
} }
QString toString(const RegisterTranslationUnitForCodeCompletionCommand &command) QString toString(const RegisterTranslationUnitForCodeCompletionMessage &message)
{ {
QString out; QString out;
QTextStream ts(&out); QTextStream ts(&out);
ts << "RegisterTranslationUnitForCodeCompletionCommand\n" ts << "RegisterTranslationUnitForCodeCompletionMessage\n"
<< toString(command.fileContainers()); << toString(message.fileContainers());
return out; return out;
return QLatin1String("RegisterTranslationUnitForCodeCompletionCommand\n"); return QLatin1String("RegisterTranslationUnitForCodeCompletionMessage\n");
} }
QString toString(const UnregisterTranslationUnitsForCodeCompletionCommand &) QString toString(const UnregisterTranslationUnitsForCodeCompletionMessage &)
{ {
return QLatin1String("UnregisterTranslationUnitsForCodeCompletionCommand\n"); return QLatin1String("UnregisterTranslationUnitsForCodeCompletionMessage\n");
} }
QString toString(const RegisterProjectPartsForCodeCompletionCommand &command) QString toString(const RegisterProjectPartsForCodeCompletionMessage &message)
{ {
QString out; QString out;
QTextStream ts(&out); QTextStream ts(&out);
ts << "RegisterProjectPartsForCodeCompletionCommand\n" ts << "RegisterProjectPartsForCodeCompletionMessage\n"
<< toString(command.projectContainers()) << "\n"; << toString(message.projectContainers()) << "\n";
return out; return out;
} }
QString toString(const UnregisterProjectPartsForCodeCompletionCommand &command) QString toString(const UnregisterProjectPartsForCodeCompletionMessage &message)
{ {
QString out; QString out;
QTextStream ts(&out); QTextStream ts(&out);
ts << "UnregisterProjectPartsForCodeCompletionCommand\n" ts << "UnregisterProjectPartsForCodeCompletionMessage\n"
<< command.projectPartIds().join(Utf8String::fromUtf8(",")).toByteArray() << "\n"; << message.projectPartIds().join(Utf8String::fromUtf8(",")).toByteArray() << "\n";
return out; return out;
} }
QString toString(const CompleteCodeCommand &) QString toString(const CompleteCodeMessage &)
{ {
return QLatin1String("CompleteCodeCommand\n"); return QLatin1String("CompleteCodeMessage\n");
} }
class IpcSenderSpy : public IpcSenderInterface class IpcSenderSpy : public IpcSenderInterface
{ {
public: public:
void end() override void end() override
{ senderLog.append(toString(EndCommand())); } { senderLog.append(toString(EndMessage())); }
void registerTranslationUnitsForCodeCompletion(const RegisterTranslationUnitForCodeCompletionCommand &command) override void registerTranslationUnitsForCodeCompletion(const RegisterTranslationUnitForCodeCompletionMessage &message) override
{ senderLog.append(toString(command)); } { senderLog.append(toString(message)); }
void unregisterTranslationUnitsForCodeCompletion(const UnregisterTranslationUnitsForCodeCompletionCommand &command) override void unregisterTranslationUnitsForCodeCompletion(const UnregisterTranslationUnitsForCodeCompletionMessage &message) override
{ senderLog.append(toString(command)); } { senderLog.append(toString(message)); }
void registerProjectPartsForCodeCompletion(const RegisterProjectPartsForCodeCompletionCommand &command) override void registerProjectPartsForCodeCompletion(const RegisterProjectPartsForCodeCompletionMessage &message) override
{ senderLog.append(toString(command)); } { senderLog.append(toString(message)); }
void unregisterProjectPartsForCodeCompletion(const UnregisterProjectPartsForCodeCompletionCommand &command) override void unregisterProjectPartsForCodeCompletion(const UnregisterProjectPartsForCodeCompletionMessage &message) override
{ senderLog.append(toString(command)); } { senderLog.append(toString(message)); }
void completeCode(const CompleteCodeCommand &command) override void completeCode(const CompleteCodeMessage &message) override
{ senderLog.append(toString(command)); } { senderLog.append(toString(message)); }
public: public:
QString senderLog; QString senderLog;
@@ -1100,18 +1100,18 @@ void ClangCodeCompletionTest::testUpdateBackendAfterRestart()
OpenEditorAtCursorPosition openSource(testDocument); OpenEditorAtCursorPosition openSource(testDocument);
QVERIFY(openSource.succeeded()); QVERIFY(openSource.succeeded());
// Check commands that would have been sent // Check messages that would have been sent
QVERIFY(compare(LogOutput(spy.senderLog), QVERIFY(compare(LogOutput(spy.senderLog),
LogOutput( LogOutput(
"RegisterTranslationUnitForCodeCompletionCommand\n" "RegisterTranslationUnitForCodeCompletionMessage\n"
" Path: myheader.h ProjectPart: \n" " Path: myheader.h ProjectPart: \n"
"RegisterProjectPartsForCodeCompletionCommand\n" "RegisterProjectPartsForCodeCompletionMessage\n"
" ProjectPartContainer id: qt-widgets-app.pro qt-widgets-app\n" " ProjectPartContainer id: qt-widgets-app.pro qt-widgets-app\n"
"RegisterTranslationUnitForCodeCompletionCommand\n" "RegisterTranslationUnitForCodeCompletionMessage\n"
" Path: ui_mainwindow.h ProjectPart: \n" " Path: ui_mainwindow.h ProjectPart: \n"
"RegisterTranslationUnitForCodeCompletionCommand\n" "RegisterTranslationUnitForCodeCompletionMessage\n"
" Path: myheader.h ProjectPart: \n" " Path: myheader.h ProjectPart: \n"
"RegisterTranslationUnitForCodeCompletionCommand\n" "RegisterTranslationUnitForCodeCompletionMessage\n"
" Path: mainwindow.cpp ProjectPart: qt-widgets-app.pro qt-widgets-app\n" " Path: mainwindow.cpp ProjectPart: qt-widgets-app.pro qt-widgets-app\n"
))); )));
spy.senderLog.clear(); spy.senderLog.clear();
@@ -1126,13 +1126,13 @@ void ClangCodeCompletionTest::testUpdateBackendAfterRestart()
// ...and check if code model backend would have been provided with current data // ...and check if code model backend would have been provided with current data
QVERIFY(compare(LogOutput(spy.senderLog), QVERIFY(compare(LogOutput(spy.senderLog),
LogOutput( LogOutput(
"RegisterProjectPartsForCodeCompletionCommand\n" "RegisterProjectPartsForCodeCompletionMessage\n"
" ProjectPartContainer id: \n" " ProjectPartContainer id: \n"
"RegisterProjectPartsForCodeCompletionCommand\n" "RegisterProjectPartsForCodeCompletionMessage\n"
" ProjectPartContainer id: qt-widgets-app.pro qt-widgets-app\n" " ProjectPartContainer id: qt-widgets-app.pro qt-widgets-app\n"
"RegisterTranslationUnitForCodeCompletionCommand\n" "RegisterTranslationUnitForCodeCompletionMessage\n"
" Path: myheader.h ProjectPart: \n" " Path: myheader.h ProjectPart: \n"
"RegisterTranslationUnitForCodeCompletionCommand\n" "RegisterTranslationUnitForCodeCompletionMessage\n"
" Path: ui_mainwindow.h ProjectPart: \n" " Path: ui_mainwindow.h ProjectPart: \n"
))); )));
} }

View File

@@ -32,7 +32,7 @@
#include <QLoggingCategory> #include <QLoggingCategory>
#include <connectionserver.h> #include <connectionserver.h>
#include <cmbcommands.h> #include <cmbmessages.h>
#include <clangipcserver.h> #include <clangipcserver.h>
int main(int argc, char *argv[]) int main(int argc, char *argv[])
@@ -51,7 +51,7 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
ClangBackEnd::Commands::registerCommands(); ClangBackEnd::Messages::registerMessages();
ClangBackEnd::ClangIpcServer clangIpcServer; ClangBackEnd::ClangIpcServer clangIpcServer;
ClangBackEnd::ConnectionServer connectionServer(application.arguments()[1]); ClangBackEnd::ConnectionServer connectionServer(application.arguments()[1]);

View File

@@ -31,14 +31,14 @@
#include "clangipcserver.h" #include "clangipcserver.h"
#include <clangbackendipcdebugutils.h> #include <clangbackendipcdebugutils.h>
#include <cmbcodecompletedcommand.h> #include <cmbcodecompletedmessage.h>
#include <cmbcompletecodecommand.h> #include <cmbcompletecodemessage.h>
#include <cmbregisterprojectsforcodecompletioncommand.h> #include <cmbregisterprojectsforcodecompletionmessage.h>
#include <cmbregistertranslationunitsforcodecompletioncommand.h> #include <cmbregistertranslationunitsforcodecompletionmessage.h>
#include <cmbunregisterprojectsforcodecompletioncommand.h> #include <cmbunregisterprojectsforcodecompletionmessage.h>
#include <cmbunregistertranslationunitsforcodecompletioncommand.h> #include <cmbunregistertranslationunitsforcodecompletionmessage.h>
#include <projectpartsdonotexistcommand.h> #include <projectpartsdonotexistmessage.h>
#include <translationunitdoesnotexistcommand.h> #include <translationunitdoesnotexistmessage.h>
#include "codecompleter.h" #include "codecompleter.h"
#include "projectpartsdonotexistexception.h" #include "projectpartsdonotexistexception.h"
@@ -63,73 +63,73 @@ void ClangIpcServer::end()
QCoreApplication::exit(); QCoreApplication::exit();
} }
void ClangIpcServer::registerTranslationUnitsForCodeCompletion(const ClangBackEnd::RegisterTranslationUnitForCodeCompletionCommand &command) void ClangIpcServer::registerTranslationUnitsForCodeCompletion(const ClangBackEnd::RegisterTranslationUnitForCodeCompletionMessage &message)
{ {
TIME_SCOPE_DURATION("ClangIpcServer::registerTranslationUnitsForCodeCompletion"); TIME_SCOPE_DURATION("ClangIpcServer::registerTranslationUnitsForCodeCompletion");
try { try {
translationUnits.createOrUpdate(command.fileContainers()); translationUnits.createOrUpdate(message.fileContainers());
unsavedFiles.createOrUpdate(command.fileContainers()); unsavedFiles.createOrUpdate(message.fileContainers());
} catch (const ProjectPartDoNotExistException &exception) { } catch (const ProjectPartDoNotExistException &exception) {
client()->projectPartsDoNotExist(ProjectPartsDoNotExistCommand(exception.projectPartIds())); client()->projectPartsDoNotExist(ProjectPartsDoNotExistMessage(exception.projectPartIds()));
} catch (const std::exception &exception) { } catch (const std::exception &exception) {
qWarning() << "Error in ClangIpcServer::registerTranslationUnitsForCodeCompletion:" << exception.what(); qWarning() << "Error in ClangIpcServer::registerTranslationUnitsForCodeCompletion:" << exception.what();
} }
} }
void ClangIpcServer::unregisterTranslationUnitsForCodeCompletion(const ClangBackEnd::UnregisterTranslationUnitsForCodeCompletionCommand &command) void ClangIpcServer::unregisterTranslationUnitsForCodeCompletion(const ClangBackEnd::UnregisterTranslationUnitsForCodeCompletionMessage &message)
{ {
TIME_SCOPE_DURATION("ClangIpcServer::unregisterTranslationUnitsForCodeCompletion"); TIME_SCOPE_DURATION("ClangIpcServer::unregisterTranslationUnitsForCodeCompletion");
try { try {
translationUnits.remove(command.fileContainers()); translationUnits.remove(message.fileContainers());
} catch (const TranslationUnitDoesNotExistException &exception) { } catch (const TranslationUnitDoesNotExistException &exception) {
client()->translationUnitDoesNotExist(TranslationUnitDoesNotExistCommand(exception.fileContainer())); client()->translationUnitDoesNotExist(TranslationUnitDoesNotExistMessage(exception.fileContainer()));
} catch (const ProjectPartDoNotExistException &exception) { } catch (const ProjectPartDoNotExistException &exception) {
client()->projectPartsDoNotExist(ProjectPartsDoNotExistCommand(exception.projectPartIds())); client()->projectPartsDoNotExist(ProjectPartsDoNotExistMessage(exception.projectPartIds()));
} catch (const std::exception &exception) { } catch (const std::exception &exception) {
qWarning() << "Error in ClangIpcServer::unregisterTranslationUnitsForCodeCompletion:" << exception.what(); qWarning() << "Error in ClangIpcServer::unregisterTranslationUnitsForCodeCompletion:" << exception.what();
} }
} }
void ClangIpcServer::registerProjectPartsForCodeCompletion(const RegisterProjectPartsForCodeCompletionCommand &command) void ClangIpcServer::registerProjectPartsForCodeCompletion(const RegisterProjectPartsForCodeCompletionMessage &message)
{ {
TIME_SCOPE_DURATION("ClangIpcServer::registerProjectPartsForCodeCompletion"); TIME_SCOPE_DURATION("ClangIpcServer::registerProjectPartsForCodeCompletion");
try { try {
projects.createOrUpdate(command.projectContainers()); projects.createOrUpdate(message.projectContainers());
} catch (const std::exception &exception) { } catch (const std::exception &exception) {
qWarning() << "Error in ClangIpcServer::registerProjectPartsForCodeCompletion:" << exception.what(); qWarning() << "Error in ClangIpcServer::registerProjectPartsForCodeCompletion:" << exception.what();
} }
} }
void ClangIpcServer::unregisterProjectPartsForCodeCompletion(const UnregisterProjectPartsForCodeCompletionCommand &command) void ClangIpcServer::unregisterProjectPartsForCodeCompletion(const UnregisterProjectPartsForCodeCompletionMessage &message)
{ {
TIME_SCOPE_DURATION("ClangIpcServer::unregisterProjectPartsForCodeCompletion"); TIME_SCOPE_DURATION("ClangIpcServer::unregisterProjectPartsForCodeCompletion");
try { try {
projects.remove(command.projectPartIds()); projects.remove(message.projectPartIds());
} catch (const ProjectPartDoNotExistException &exception) { } catch (const ProjectPartDoNotExistException &exception) {
client()->projectPartsDoNotExist(ProjectPartsDoNotExistCommand(exception.projectPartIds())); client()->projectPartsDoNotExist(ProjectPartsDoNotExistMessage(exception.projectPartIds()));
} catch (const std::exception &exception) { } catch (const std::exception &exception) {
qWarning() << "Error in ClangIpcServer::unregisterProjectPartsForCodeCompletion:" << exception.what(); qWarning() << "Error in ClangIpcServer::unregisterProjectPartsForCodeCompletion:" << exception.what();
} }
} }
void ClangIpcServer::completeCode(const ClangBackEnd::CompleteCodeCommand &command) void ClangIpcServer::completeCode(const ClangBackEnd::CompleteCodeMessage &message)
{ {
TIME_SCOPE_DURATION("ClangIpcServer::completeCode"); TIME_SCOPE_DURATION("ClangIpcServer::completeCode");
try { try {
CodeCompleter codeCompleter(translationUnits.translationUnit(command.filePath(), command.projectPartId())); CodeCompleter codeCompleter(translationUnits.translationUnit(message.filePath(), message.projectPartId()));
const auto codeCompletions = codeCompleter.complete(command.line(), command.column()); const auto codeCompletions = codeCompleter.complete(message.line(), message.column());
client()->codeCompleted(CodeCompletedCommand(codeCompletions, command.ticketNumber())); client()->codeCompleted(CodeCompletedMessage(codeCompletions, message.ticketNumber()));
} catch (const TranslationUnitDoesNotExistException &exception) { } catch (const TranslationUnitDoesNotExistException &exception) {
client()->translationUnitDoesNotExist(TranslationUnitDoesNotExistCommand(exception.fileContainer())); client()->translationUnitDoesNotExist(TranslationUnitDoesNotExistMessage(exception.fileContainer()));
} catch (const ProjectPartDoNotExistException &exception) { } catch (const ProjectPartDoNotExistException &exception) {
client()->projectPartsDoNotExist(ProjectPartsDoNotExistCommand(exception.projectPartIds())); client()->projectPartsDoNotExist(ProjectPartsDoNotExistMessage(exception.projectPartIds()));
} catch (const std::exception &exception) { } catch (const std::exception &exception) {
qWarning() << "Error in ClangIpcServer::completeCode:" << exception.what(); qWarning() << "Error in ClangIpcServer::completeCode:" << exception.what();
} }

View File

@@ -51,11 +51,11 @@ public:
ClangIpcServer(); ClangIpcServer();
void end() override; void end() override;
void registerTranslationUnitsForCodeCompletion(const RegisterTranslationUnitForCodeCompletionCommand &command) override; void registerTranslationUnitsForCodeCompletion(const RegisterTranslationUnitForCodeCompletionMessage &message) override;
void unregisterTranslationUnitsForCodeCompletion(const UnregisterTranslationUnitsForCodeCompletionCommand &command) override; void unregisterTranslationUnitsForCodeCompletion(const UnregisterTranslationUnitsForCodeCompletionMessage &message) override;
void registerProjectPartsForCodeCompletion(const RegisterProjectPartsForCodeCompletionCommand &command) override; void registerProjectPartsForCodeCompletion(const RegisterProjectPartsForCodeCompletionMessage &message) override;
void unregisterProjectPartsForCodeCompletion(const UnregisterProjectPartsForCodeCompletionCommand &command) override; void unregisterProjectPartsForCodeCompletion(const UnregisterProjectPartsForCodeCompletionMessage &message) override;
void completeCode(const CompleteCodeCommand &command) override; void completeCode(const CompleteCodeMessage &message) override;
private: private:
ProjectParts projects; ProjectParts projects;

View File

@@ -30,14 +30,14 @@
#include "echoipcserver.h" #include "echoipcserver.h"
#include "cmbcodecompletedcommand.h" #include "cmbcodecompletedmessage.h"
#include "cmbcompletecodecommand.h" #include "cmbcompletecodemessage.h"
#include "cmbechocommand.h" #include "cmbechomessage.h"
#include "cmbendcommand.h" #include "cmbendmessage.h"
#include "cmbregisterprojectsforcodecompletioncommand.h" #include "cmbregisterprojectsforcodecompletionmessage.h"
#include "cmbregistertranslationunitsforcodecompletioncommand.h" #include "cmbregistertranslationunitsforcodecompletionmessage.h"
#include "cmbunregisterprojectsforcodecompletioncommand.h" #include "cmbunregisterprojectsforcodecompletionmessage.h"
#include "cmbunregistertranslationunitsforcodecompletioncommand.h" #include "cmbunregistertranslationunitsforcodecompletionmessage.h"
#include "connectionserver.h" #include "connectionserver.h"
#include <QCoreApplication> #include <QCoreApplication>
@@ -46,9 +46,9 @@
namespace ClangBackEnd { namespace ClangBackEnd {
void EchoIpcServer::dispatch(const QVariant &command) void EchoIpcServer::dispatch(const QVariant &message)
{ {
IpcServerInterface::dispatch(command); IpcServerInterface::dispatch(message);
} }
void EchoIpcServer::end() void EchoIpcServer::end()
@@ -57,34 +57,34 @@ void EchoIpcServer::end()
QCoreApplication::quit(); QCoreApplication::quit();
} }
void EchoIpcServer::registerTranslationUnitsForCodeCompletion(const RegisterTranslationUnitForCodeCompletionCommand &command) void EchoIpcServer::registerTranslationUnitsForCodeCompletion(const RegisterTranslationUnitForCodeCompletionMessage &message)
{ {
echoCommand(QVariant::fromValue(command)); echoMessage(QVariant::fromValue(message));
} }
void EchoIpcServer::unregisterTranslationUnitsForCodeCompletion(const UnregisterTranslationUnitsForCodeCompletionCommand &command) void EchoIpcServer::unregisterTranslationUnitsForCodeCompletion(const UnregisterTranslationUnitsForCodeCompletionMessage &message)
{ {
echoCommand(QVariant::fromValue(command)); echoMessage(QVariant::fromValue(message));
} }
void EchoIpcServer::registerProjectPartsForCodeCompletion(const RegisterProjectPartsForCodeCompletionCommand &command) void EchoIpcServer::registerProjectPartsForCodeCompletion(const RegisterProjectPartsForCodeCompletionMessage &message)
{ {
echoCommand(QVariant::fromValue(command)); echoMessage(QVariant::fromValue(message));
} }
void EchoIpcServer::unregisterProjectPartsForCodeCompletion(const UnregisterProjectPartsForCodeCompletionCommand &command) void EchoIpcServer::unregisterProjectPartsForCodeCompletion(const UnregisterProjectPartsForCodeCompletionMessage &message)
{ {
echoCommand(QVariant::fromValue(command)); echoMessage(QVariant::fromValue(message));
} }
void EchoIpcServer::completeCode(const CompleteCodeCommand &command) void EchoIpcServer::completeCode(const CompleteCodeMessage &message)
{ {
echoCommand(QVariant::fromValue(command)); echoMessage(QVariant::fromValue(message));
} }
void EchoIpcServer::echoCommand(const QVariant &command) void EchoIpcServer::echoMessage(const QVariant &message)
{ {
client()->echo(EchoCommand(command)); client()->echo(EchoMessage(message));
} }
} // namespace ClangBackEnd } // namespace ClangBackEnd

View File

@@ -38,16 +38,16 @@ namespace ClangBackEnd {
class EchoIpcServer : public IpcServerInterface class EchoIpcServer : public IpcServerInterface
{ {
public: public:
void dispatch(const QVariant &command) override; void dispatch(const QVariant &message) override;
void end() override; void end() override;
void registerTranslationUnitsForCodeCompletion(const RegisterTranslationUnitForCodeCompletionCommand &command) override; void registerTranslationUnitsForCodeCompletion(const RegisterTranslationUnitForCodeCompletionMessage &message) override;
void unregisterTranslationUnitsForCodeCompletion(const UnregisterTranslationUnitsForCodeCompletionCommand &command) override; void unregisterTranslationUnitsForCodeCompletion(const UnregisterTranslationUnitsForCodeCompletionMessage &message) override;
void registerProjectPartsForCodeCompletion(const RegisterProjectPartsForCodeCompletionCommand &command) override; void registerProjectPartsForCodeCompletion(const RegisterProjectPartsForCodeCompletionMessage &message) override;
void unregisterProjectPartsForCodeCompletion(const UnregisterProjectPartsForCodeCompletionCommand &command) override; void unregisterProjectPartsForCodeCompletion(const UnregisterProjectPartsForCodeCompletionMessage &message) override;
void completeCode(const CompleteCodeCommand &command) override; void completeCode(const CompleteCodeMessage &message) override;
private: private:
void echoCommand(const QVariant &command); void echoMessage(const QVariant &message);
}; };
} // namespace ClangBackEnd } // namespace ClangBackEnd

View File

@@ -23,6 +23,6 @@ HEADERS += \
echoipcserver.h echoipcserver.h
DEFINES += CLANGBACKENDIPC_TESTS DEFINES += CLANGBACKENDIPC_TESTS
DEFINES += DONT_CHECK_COMMAND_COUNTER DEFINES += DONT_CHECK_MESSAGE_COUNTER
win32:DESTDIR = .. win32:DESTDIR = ..

View File

@@ -30,7 +30,7 @@
#include "echoipcserver.h" #include "echoipcserver.h"
#include <cmbcommands.h> #include <cmbmessages.h>
#include <connectionserver.h> #include <connectionserver.h>
#include <QCoreApplication> #include <QCoreApplication>
@@ -49,7 +49,7 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
ClangBackEnd::Commands::registerCommands(); ClangBackEnd::Messages::registerMessages();
ClangBackEnd::EchoIpcServer echoIpcServer; ClangBackEnd::EchoIpcServer echoIpcServer;
ClangBackEnd::ConnectionServer connectionServer(application.arguments()[1]); ClangBackEnd::ConnectionServer connectionServer(application.arguments()[1]);

View File

@@ -36,15 +36,15 @@
#include <translationunitdoesnotexistexception.h> #include <translationunitdoesnotexistexception.h>
#include <translationunitparseerrorexception.h> #include <translationunitparseerrorexception.h>
#include <cmbcodecompletedcommand.h> #include <cmbcodecompletedmessage.h>
#include <cmbcompletecodecommand.h> #include <cmbcompletecodemessage.h>
#include <cmbechocommand.h> #include <cmbechomessage.h>
#include <cmbregisterprojectsforcodecompletioncommand.h> #include <cmbregisterprojectsforcodecompletionmessage.h>
#include <cmbregistertranslationunitsforcodecompletioncommand.h> #include <cmbregistertranslationunitsforcodecompletionmessage.h>
#include <cmbunregisterprojectsforcodecompletioncommand.h> #include <cmbunregisterprojectsforcodecompletionmessage.h>
#include <cmbunregistertranslationunitsforcodecompletioncommand.h> #include <cmbunregistertranslationunitsforcodecompletionmessage.h>
#include <projectpartsdonotexistcommand.h> #include <projectpartsdonotexistmessage.h>
#include <translationunitdoesnotexistcommand.h> #include <translationunitdoesnotexistmessage.h>
#include <QBuffer> #include <QBuffer>
#include <QFile> #include <QFile>
@@ -61,17 +61,17 @@ using testing::Eq;
namespace { namespace {
using ClangBackEnd::RegisterTranslationUnitForCodeCompletionCommand; using ClangBackEnd::RegisterTranslationUnitForCodeCompletionMessage;
using ClangBackEnd::UnregisterTranslationUnitsForCodeCompletionCommand; using ClangBackEnd::UnregisterTranslationUnitsForCodeCompletionMessage;
using ClangBackEnd::RegisterProjectPartsForCodeCompletionCommand; using ClangBackEnd::RegisterProjectPartsForCodeCompletionMessage;
using ClangBackEnd::UnregisterProjectPartsForCodeCompletionCommand; using ClangBackEnd::UnregisterProjectPartsForCodeCompletionMessage;
using ClangBackEnd::CompleteCodeCommand; using ClangBackEnd::CompleteCodeMessage;
using ClangBackEnd::CodeCompletedCommand; using ClangBackEnd::CodeCompletedMessage;
using ClangBackEnd::CodeCompletion; using ClangBackEnd::CodeCompletion;
using ClangBackEnd::FileContainer; using ClangBackEnd::FileContainer;
using ClangBackEnd::ProjectPartContainer; using ClangBackEnd::ProjectPartContainer;
using ClangBackEnd::TranslationUnitDoesNotExistCommand; using ClangBackEnd::TranslationUnitDoesNotExistMessage;
using ClangBackEnd::ProjectPartsDoNotExistCommand; using ClangBackEnd::ProjectPartsDoNotExistMessage;
class ClangIpcServer : public ::testing::Test class ClangIpcServer : public ::testing::Test
{ {
@@ -105,31 +105,31 @@ void ClangIpcServer::SetUp()
void ClangIpcServer::registerFiles() void ClangIpcServer::registerFiles()
{ {
RegisterTranslationUnitForCodeCompletionCommand command({FileContainer(functionTestFilePath, projectPartId, unsavedContent(unsavedTestFilePath), true), RegisterTranslationUnitForCodeCompletionMessage message({FileContainer(functionTestFilePath, projectPartId, unsavedContent(unsavedTestFilePath), true),
FileContainer(variableTestFilePath, projectPartId)}); FileContainer(variableTestFilePath, projectPartId)});
clangServer.registerTranslationUnitsForCodeCompletion(command); clangServer.registerTranslationUnitsForCodeCompletion(message);
} }
void ClangIpcServer::registerProjectPart() void ClangIpcServer::registerProjectPart()
{ {
RegisterProjectPartsForCodeCompletionCommand command({ProjectPartContainer(projectPartId)}); RegisterProjectPartsForCodeCompletionMessage message({ProjectPartContainer(projectPartId)});
clangServer.registerProjectPartsForCodeCompletion(command); clangServer.registerProjectPartsForCodeCompletion(message);
} }
void ClangIpcServer::changeProjectPartArguments() void ClangIpcServer::changeProjectPartArguments()
{ {
RegisterProjectPartsForCodeCompletionCommand command({ProjectPartContainer(projectPartId, {Utf8StringLiteral("-DArgumentDefinition")})}); RegisterProjectPartsForCodeCompletionMessage message({ProjectPartContainer(projectPartId, {Utf8StringLiteral("-DArgumentDefinition")})});
clangServer.registerProjectPartsForCodeCompletion(command); clangServer.registerProjectPartsForCodeCompletion(message);
} }
void ClangIpcServer::changeProjectPartArgumentsToWrongValues() void ClangIpcServer::changeProjectPartArgumentsToWrongValues()
{ {
RegisterProjectPartsForCodeCompletionCommand command({ProjectPartContainer(projectPartId, {Utf8StringLiteral("-blah")})}); RegisterProjectPartsForCodeCompletionMessage message({ProjectPartContainer(projectPartId, {Utf8StringLiteral("-blah")})});
clangServer.registerProjectPartsForCodeCompletion(command); clangServer.registerProjectPartsForCodeCompletion(message);
} }
const Utf8String ClangIpcServer::unsavedContent(const QString &unsavedFilePath) const Utf8String ClangIpcServer::unsavedContent(const QString &unsavedFilePath)
@@ -144,7 +144,7 @@ const Utf8String ClangIpcServer::unsavedContent(const QString &unsavedFilePath)
TEST_F(ClangIpcServer, GetCodeCompletion) TEST_F(ClangIpcServer, GetCodeCompletion)
{ {
CompleteCodeCommand completeCodeCommand(functionTestFilePath, CompleteCodeMessage completeCodeMessage(functionTestFilePath,
20, 20,
1, 1,
projectPartId); projectPartId);
@@ -152,15 +152,15 @@ TEST_F(ClangIpcServer, GetCodeCompletion)
34, 34,
CodeCompletion::FunctionCompletionKind); CodeCompletion::FunctionCompletionKind);
EXPECT_CALL(mockIpcClient, codeCompleted(Property(&CodeCompletedCommand::codeCompletions, Contains(codeCompletion)))) EXPECT_CALL(mockIpcClient, codeCompleted(Property(&CodeCompletedMessage::codeCompletions, Contains(codeCompletion))))
.Times(1); .Times(1);
clangServer.completeCode(completeCodeCommand); clangServer.completeCode(completeCodeMessage);
} }
TEST_F(ClangIpcServer, GetCodeCompletionDependingOnArgumets) TEST_F(ClangIpcServer, GetCodeCompletionDependingOnArgumets)
{ {
CompleteCodeCommand completeCodeCommand(variableTestFilePath, CompleteCodeMessage completeCodeMessage(variableTestFilePath,
35, 35,
1, 1,
projectPartId); projectPartId);
@@ -168,44 +168,44 @@ TEST_F(ClangIpcServer, GetCodeCompletionDependingOnArgumets)
34, 34,
CodeCompletion::VariableCompletionKind); CodeCompletion::VariableCompletionKind);
EXPECT_CALL(mockIpcClient, codeCompleted(Property(&CodeCompletedCommand::codeCompletions, Contains(codeCompletion)))) EXPECT_CALL(mockIpcClient, codeCompleted(Property(&CodeCompletedMessage::codeCompletions, Contains(codeCompletion))))
.Times(1); .Times(1);
changeProjectPartArguments(); changeProjectPartArguments();
clangServer.completeCode(completeCodeCommand); clangServer.completeCode(completeCodeMessage);
} }
TEST_F(ClangIpcServer, GetTranslationUnitDoesNotExistForCodeCompletionOnNonExistingTranslationUnit) TEST_F(ClangIpcServer, GetTranslationUnitDoesNotExistForCodeCompletionOnNonExistingTranslationUnit)
{ {
CompleteCodeCommand completeCodeCommand(Utf8StringLiteral("dontexists.cpp"), CompleteCodeMessage completeCodeMessage(Utf8StringLiteral("dontexists.cpp"),
34, 34,
1, 1,
projectPartId); projectPartId);
TranslationUnitDoesNotExistCommand translationUnitDoesNotExistCommand(Utf8StringLiteral("dontexists.cpp"), projectPartId); TranslationUnitDoesNotExistMessage translationUnitDoesNotExistMessage(Utf8StringLiteral("dontexists.cpp"), projectPartId);
EXPECT_CALL(mockIpcClient, translationUnitDoesNotExist(translationUnitDoesNotExistCommand)) EXPECT_CALL(mockIpcClient, translationUnitDoesNotExist(translationUnitDoesNotExistMessage))
.Times(1); .Times(1);
clangServer.completeCode(completeCodeCommand); clangServer.completeCode(completeCodeMessage);
} }
TEST_F(ClangIpcServer, GetTranslationUnitDoesNotExistForCompletingUnregisteredFile) TEST_F(ClangIpcServer, GetTranslationUnitDoesNotExistForCompletingUnregisteredFile)
{ {
CompleteCodeCommand completeCodeCommand(parseErrorTestFilePath, CompleteCodeMessage completeCodeMessage(parseErrorTestFilePath,
20, 20,
1, 1,
projectPartId); projectPartId);
TranslationUnitDoesNotExistCommand translationUnitDoesNotExistCommand(parseErrorTestFilePath, projectPartId); TranslationUnitDoesNotExistMessage translationUnitDoesNotExistMessage(parseErrorTestFilePath, projectPartId);
EXPECT_CALL(mockIpcClient, translationUnitDoesNotExist(translationUnitDoesNotExistCommand)) EXPECT_CALL(mockIpcClient, translationUnitDoesNotExist(translationUnitDoesNotExistMessage))
.Times(1); .Times(1);
clangServer.completeCode(completeCodeCommand); clangServer.completeCode(completeCodeMessage);
} }
TEST_F(ClangIpcServer, GetCodeCompletionForUnsavedFile) TEST_F(ClangIpcServer, GetCodeCompletionForUnsavedFile)
{ {
CompleteCodeCommand completeCodeCommand(functionTestFilePath, CompleteCodeMessage completeCodeMessage(functionTestFilePath,
20, 20,
1, 1,
projectPartId); projectPartId);
@@ -213,16 +213,16 @@ TEST_F(ClangIpcServer, GetCodeCompletionForUnsavedFile)
34, 34,
CodeCompletion::FunctionCompletionKind); CodeCompletion::FunctionCompletionKind);
EXPECT_CALL(mockIpcClient, codeCompleted(Property(&CodeCompletedCommand::codeCompletions, Contains(codeCompletion)))) EXPECT_CALL(mockIpcClient, codeCompleted(Property(&CodeCompletedMessage::codeCompletions, Contains(codeCompletion))))
.Times(1); .Times(1);
clangServer.completeCode(completeCodeCommand); clangServer.completeCode(completeCodeMessage);
} }
TEST_F(ClangIpcServer, GetNoCodeCompletionAfterRemovingUnsavedFile) TEST_F(ClangIpcServer, GetNoCodeCompletionAfterRemovingUnsavedFile)
{ {
clangServer.registerTranslationUnitsForCodeCompletion(RegisterTranslationUnitForCodeCompletionCommand({FileContainer(functionTestFilePath, projectPartId)})); clangServer.registerTranslationUnitsForCodeCompletion(RegisterTranslationUnitForCodeCompletionMessage({FileContainer(functionTestFilePath, projectPartId)}));
CompleteCodeCommand completeCodeCommand(functionTestFilePath, CompleteCodeMessage completeCodeMessage(functionTestFilePath,
20, 20,
1, 1,
projectPartId); projectPartId);
@@ -230,19 +230,19 @@ TEST_F(ClangIpcServer, GetNoCodeCompletionAfterRemovingUnsavedFile)
34, 34,
CodeCompletion::FunctionCompletionKind); CodeCompletion::FunctionCompletionKind);
EXPECT_CALL(mockIpcClient, codeCompleted(Property(&CodeCompletedCommand::codeCompletions, Not(Contains(codeCompletion))))) EXPECT_CALL(mockIpcClient, codeCompleted(Property(&CodeCompletedMessage::codeCompletions, Not(Contains(codeCompletion)))))
.Times(1); .Times(1);
clangServer.completeCode(completeCodeCommand); clangServer.completeCode(completeCodeMessage);
} }
TEST_F(ClangIpcServer, GetNewCodeCompletionAfterUpdatingUnsavedFile) TEST_F(ClangIpcServer, GetNewCodeCompletionAfterUpdatingUnsavedFile)
{ {
clangServer.registerTranslationUnitsForCodeCompletion(RegisterTranslationUnitForCodeCompletionCommand({FileContainer(functionTestFilePath, clangServer.registerTranslationUnitsForCodeCompletion(RegisterTranslationUnitForCodeCompletionMessage({FileContainer(functionTestFilePath,
projectPartId, projectPartId,
unsavedContent(updatedUnsavedTestFilePath), unsavedContent(updatedUnsavedTestFilePath),
true)})); true)}));
CompleteCodeCommand completeCodeCommand(functionTestFilePath, CompleteCodeMessage completeCodeMessage(functionTestFilePath,
20, 20,
1, 1,
projectPartId); projectPartId);
@@ -250,109 +250,109 @@ TEST_F(ClangIpcServer, GetNewCodeCompletionAfterUpdatingUnsavedFile)
34, 34,
CodeCompletion::FunctionCompletionKind); CodeCompletion::FunctionCompletionKind);
EXPECT_CALL(mockIpcClient, codeCompleted(Property(&CodeCompletedCommand::codeCompletions, Contains(codeCompletion)))) EXPECT_CALL(mockIpcClient, codeCompleted(Property(&CodeCompletedMessage::codeCompletions, Contains(codeCompletion))))
.Times(1); .Times(1);
clangServer.completeCode(completeCodeCommand); clangServer.completeCode(completeCodeMessage);
} }
TEST_F(ClangIpcServer, GetTranslationUnitDoesNotExistForUnregisterTranslationUnitWithWrongFilePath) TEST_F(ClangIpcServer, GetTranslationUnitDoesNotExistForUnregisterTranslationUnitWithWrongFilePath)
{ {
FileContainer fileContainer(Utf8StringLiteral("foo.cpp"), projectPartId); FileContainer fileContainer(Utf8StringLiteral("foo.cpp"), projectPartId);
UnregisterTranslationUnitsForCodeCompletionCommand command({fileContainer}); UnregisterTranslationUnitsForCodeCompletionMessage message({fileContainer});
TranslationUnitDoesNotExistCommand translationUnitDoesNotExistCommand(fileContainer); TranslationUnitDoesNotExistMessage translationUnitDoesNotExistMessage(fileContainer);
EXPECT_CALL(mockIpcClient, translationUnitDoesNotExist(translationUnitDoesNotExistCommand)) EXPECT_CALL(mockIpcClient, translationUnitDoesNotExist(translationUnitDoesNotExistMessage))
.Times(1); .Times(1);
clangServer.unregisterTranslationUnitsForCodeCompletion(command); clangServer.unregisterTranslationUnitsForCodeCompletion(message);
} }
TEST_F(ClangIpcServer, UnregisterTranslationUnitAndTestFailingCompletion) TEST_F(ClangIpcServer, UnregisterTranslationUnitAndTestFailingCompletion)
{ {
FileContainer fileContainer(functionTestFilePath, projectPartId); FileContainer fileContainer(functionTestFilePath, projectPartId);
UnregisterTranslationUnitsForCodeCompletionCommand command({fileContainer}); UnregisterTranslationUnitsForCodeCompletionMessage message({fileContainer});
clangServer.unregisterTranslationUnitsForCodeCompletion(command); clangServer.unregisterTranslationUnitsForCodeCompletion(message);
CompleteCodeCommand completeCodeCommand(functionTestFilePath, CompleteCodeMessage completeCodeMessage(functionTestFilePath,
20, 20,
1, 1,
projectPartId); projectPartId);
TranslationUnitDoesNotExistCommand translationUnitDoesNotExistCommand(fileContainer); TranslationUnitDoesNotExistMessage translationUnitDoesNotExistMessage(fileContainer);
EXPECT_CALL(mockIpcClient, translationUnitDoesNotExist(translationUnitDoesNotExistCommand)) EXPECT_CALL(mockIpcClient, translationUnitDoesNotExist(translationUnitDoesNotExistMessage))
.Times(1); .Times(1);
clangServer.completeCode(completeCodeCommand); clangServer.completeCode(completeCodeMessage);
} }
TEST_F(ClangIpcServer, GetProjectPartDoesNotExistUnregisterProjectPartInexistingProjectPart) TEST_F(ClangIpcServer, GetProjectPartDoesNotExistUnregisterProjectPartInexistingProjectPart)
{ {
Utf8StringVector inexistingProjectPartFilePath = {Utf8StringLiteral("projectpartsdoesnotexist.pro"), Utf8StringLiteral("project2doesnotexists.pro")}; Utf8StringVector inexistingProjectPartFilePath = {Utf8StringLiteral("projectpartsdoesnotexist.pro"), Utf8StringLiteral("project2doesnotexists.pro")};
UnregisterProjectPartsForCodeCompletionCommand unregisterProjectPartsForCodeCompletionCommand(inexistingProjectPartFilePath); UnregisterProjectPartsForCodeCompletionMessage unregisterProjectPartsForCodeCompletionMessage(inexistingProjectPartFilePath);
ProjectPartsDoNotExistCommand projectPartsDoNotExistCommand(inexistingProjectPartFilePath); ProjectPartsDoNotExistMessage projectPartsDoNotExistMessage(inexistingProjectPartFilePath);
EXPECT_CALL(mockIpcClient, projectPartsDoNotExist(projectPartsDoNotExistCommand)) EXPECT_CALL(mockIpcClient, projectPartsDoNotExist(projectPartsDoNotExistMessage))
.Times(1); .Times(1);
clangServer.unregisterProjectPartsForCodeCompletion(unregisterProjectPartsForCodeCompletionCommand); clangServer.unregisterProjectPartsForCodeCompletion(unregisterProjectPartsForCodeCompletionMessage);
} }
TEST_F(ClangIpcServer, GetProjectPartDoesNotExistRegisterTranslationUnitWithInexistingProjectPart) TEST_F(ClangIpcServer, GetProjectPartDoesNotExistRegisterTranslationUnitWithInexistingProjectPart)
{ {
Utf8String inexistingProjectPartFilePath = Utf8StringLiteral("projectpartsdoesnotexist.pro"); Utf8String inexistingProjectPartFilePath = Utf8StringLiteral("projectpartsdoesnotexist.pro");
RegisterTranslationUnitForCodeCompletionCommand registerFileForCodeCompletionCommand({FileContainer(variableTestFilePath, inexistingProjectPartFilePath)}); RegisterTranslationUnitForCodeCompletionMessage registerFileForCodeCompletionMessage({FileContainer(variableTestFilePath, inexistingProjectPartFilePath)});
ProjectPartsDoNotExistCommand projectPartsDoNotExistCommand({inexistingProjectPartFilePath}); ProjectPartsDoNotExistMessage projectPartsDoNotExistMessage({inexistingProjectPartFilePath});
EXPECT_CALL(mockIpcClient, projectPartsDoNotExist(projectPartsDoNotExistCommand)) EXPECT_CALL(mockIpcClient, projectPartsDoNotExist(projectPartsDoNotExistMessage))
.Times(1); .Times(1);
clangServer.registerTranslationUnitsForCodeCompletion(registerFileForCodeCompletionCommand); clangServer.registerTranslationUnitsForCodeCompletion(registerFileForCodeCompletionMessage);
} }
TEST_F(ClangIpcServer, GetProjectPartDoesNotExistUnregisterTranslationUnitWithInexistingProjectPart) TEST_F(ClangIpcServer, GetProjectPartDoesNotExistUnregisterTranslationUnitWithInexistingProjectPart)
{ {
Utf8String inexistingProjectPartFilePath = Utf8StringLiteral("projectpartsdoesnotexist.pro"); Utf8String inexistingProjectPartFilePath = Utf8StringLiteral("projectpartsdoesnotexist.pro");
UnregisterTranslationUnitsForCodeCompletionCommand unregisterFileForCodeCompletionCommand({FileContainer(variableTestFilePath, inexistingProjectPartFilePath)}); UnregisterTranslationUnitsForCodeCompletionMessage unregisterFileForCodeCompletionMessage({FileContainer(variableTestFilePath, inexistingProjectPartFilePath)});
ProjectPartsDoNotExistCommand projectPartsDoNotExistCommand({inexistingProjectPartFilePath}); ProjectPartsDoNotExistMessage projectPartsDoNotExistMessage({inexistingProjectPartFilePath});
EXPECT_CALL(mockIpcClient, projectPartsDoNotExist(projectPartsDoNotExistCommand)) EXPECT_CALL(mockIpcClient, projectPartsDoNotExist(projectPartsDoNotExistMessage))
.Times(1); .Times(1);
clangServer.unregisterTranslationUnitsForCodeCompletion(unregisterFileForCodeCompletionCommand); clangServer.unregisterTranslationUnitsForCodeCompletion(unregisterFileForCodeCompletionMessage);
} }
TEST_F(ClangIpcServer, GetProjectPartDoesNotExistForCompletingProjectPartFile) TEST_F(ClangIpcServer, GetProjectPartDoesNotExistForCompletingProjectPartFile)
{ {
Utf8String inexistingProjectPartFilePath = Utf8StringLiteral("projectpartsdoesnotexist.pro"); Utf8String inexistingProjectPartFilePath = Utf8StringLiteral("projectpartsdoesnotexist.pro");
CompleteCodeCommand completeCodeCommand(variableTestFilePath, CompleteCodeMessage completeCodeMessage(variableTestFilePath,
20, 20,
1, 1,
inexistingProjectPartFilePath); inexistingProjectPartFilePath);
ProjectPartsDoNotExistCommand projectPartsDoNotExistCommand({inexistingProjectPartFilePath}); ProjectPartsDoNotExistMessage projectPartsDoNotExistMessage({inexistingProjectPartFilePath});
EXPECT_CALL(mockIpcClient, projectPartsDoNotExist(projectPartsDoNotExistCommand)) EXPECT_CALL(mockIpcClient, projectPartsDoNotExist(projectPartsDoNotExistMessage))
.Times(1); .Times(1);
clangServer.completeCode(completeCodeCommand); clangServer.completeCode(completeCodeMessage);
} }
TEST_F(ClangIpcServer, GetProjectPartDoesNotExistForCompletingUnregisteredFile) TEST_F(ClangIpcServer, GetProjectPartDoesNotExistForCompletingUnregisteredFile)
{ {
CompleteCodeCommand completeCodeCommand(parseErrorTestFilePath, CompleteCodeMessage completeCodeMessage(parseErrorTestFilePath,
20, 20,
1, 1,
projectPartId); projectPartId);
TranslationUnitDoesNotExistCommand translationUnitDoesNotExistCommand(parseErrorTestFilePath, projectPartId); TranslationUnitDoesNotExistMessage translationUnitDoesNotExistMessage(parseErrorTestFilePath, projectPartId);
EXPECT_CALL(mockIpcClient, translationUnitDoesNotExist(translationUnitDoesNotExistCommand)) EXPECT_CALL(mockIpcClient, translationUnitDoesNotExist(translationUnitDoesNotExistMessage))
.Times(1); .Times(1);
clangServer.completeCode(completeCodeCommand); clangServer.completeCode(completeCodeMessage);
} }
TEST_F(ClangIpcServer, TicketNumberIsForwarded) TEST_F(ClangIpcServer, TicketNumberIsForwarded)
{ {
CompleteCodeCommand completeCodeCommand(functionTestFilePath, CompleteCodeMessage completeCodeMessage(functionTestFilePath,
20, 20,
1, 1,
projectPartId); projectPartId);
@@ -360,9 +360,9 @@ TEST_F(ClangIpcServer, TicketNumberIsForwarded)
34, 34,
CodeCompletion::FunctionCompletionKind); CodeCompletion::FunctionCompletionKind);
EXPECT_CALL(mockIpcClient, codeCompleted(Property(&CodeCompletedCommand::ticketNumber, Eq(completeCodeCommand.ticketNumber())))) EXPECT_CALL(mockIpcClient, codeCompleted(Property(&CodeCompletedMessage::ticketNumber, Eq(completeCodeMessage.ticketNumber()))))
.Times(1); .Times(1);
clangServer.completeCode(completeCodeCommand); clangServer.completeCode(completeCodeMessage);
} }
} }

View File

@@ -34,21 +34,21 @@
#include <ipcclientproxy.h> #include <ipcclientproxy.h>
#include <ipcserverproxy.h> #include <ipcserverproxy.h>
#include <projectpartsdonotexistcommand.h> #include <projectpartsdonotexistmessage.h>
#include <cmbalivecommand.h> #include <cmbalivemessage.h>
#include <cmbcodecompletedcommand.h> #include <cmbcodecompletedmessage.h>
#include <cmbcommands.h> #include <cmbmessages.h>
#include <cmbcompletecodecommand.h> #include <cmbcompletecodemessage.h>
#include <cmbechocommand.h> #include <cmbechomessage.h>
#include <cmbendcommand.h> #include <cmbendmessage.h>
#include <cmbregisterprojectsforcodecompletioncommand.h> #include <cmbregisterprojectsforcodecompletionmessage.h>
#include <cmbregistertranslationunitsforcodecompletioncommand.h> #include <cmbregistertranslationunitsforcodecompletionmessage.h>
#include <cmbunregisterprojectsforcodecompletioncommand.h> #include <cmbunregisterprojectsforcodecompletionmessage.h>
#include <cmbunregistertranslationunitsforcodecompletioncommand.h> #include <cmbunregistertranslationunitsforcodecompletionmessage.h>
#include <readcommandblock.h> #include <readmessageblock.h>
#include <translationunitdoesnotexistcommand.h> #include <translationunitdoesnotexistmessage.h>
#include <writecommandblock.h> #include <writemessageblock.h>
#include <QBuffer> #include <QBuffer>
#include <QString> #include <QString>
@@ -78,8 +78,8 @@ protected:
void TearDown(); void TearDown();
void scheduleServerCommands(); void scheduleServerMessages();
void scheduleClientCommands(); void scheduleClientMessages();
QBuffer buffer; QBuffer buffer;
MockIpcClient mockIpcClient; MockIpcClient mockIpcClient;
@@ -89,118 +89,118 @@ protected:
ClangBackEnd::IpcClientProxy clientProxy; ClangBackEnd::IpcClientProxy clientProxy;
}; };
TEST_F(ClientServerInProcess, SendEndCommand) TEST_F(ClientServerInProcess, SendEndMessage)
{ {
EXPECT_CALL(mockIpcServer, end()) EXPECT_CALL(mockIpcServer, end())
.Times(1); .Times(1);
serverProxy.end(); serverProxy.end();
scheduleServerCommands(); scheduleServerMessages();
} }
TEST_F(ClientServerInProcess, SendAliveCommand) TEST_F(ClientServerInProcess, SendAliveMessage)
{ {
EXPECT_CALL(mockIpcClient, alive()) EXPECT_CALL(mockIpcClient, alive())
.Times(1); .Times(1);
clientProxy.alive(); clientProxy.alive();
scheduleClientCommands(); scheduleClientMessages();
} }
TEST_F(ClientServerInProcess, SendRegisterTranslationUnitForCodeCompletionCommand) TEST_F(ClientServerInProcess, SendRegisterTranslationUnitForCodeCompletionMessage)
{ {
ClangBackEnd::FileContainer fileContainer(Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_function.cpp"), ClangBackEnd::FileContainer fileContainer(Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_function.cpp"),
Utf8StringLiteral("pathToProjectPart.pro")); Utf8StringLiteral("pathToProjectPart.pro"));
ClangBackEnd::RegisterTranslationUnitForCodeCompletionCommand command({fileContainer}); ClangBackEnd::RegisterTranslationUnitForCodeCompletionMessage message({fileContainer});
EXPECT_CALL(mockIpcServer, registerTranslationUnitsForCodeCompletion(command)) EXPECT_CALL(mockIpcServer, registerTranslationUnitsForCodeCompletion(message))
.Times(1); .Times(1);
serverProxy.registerTranslationUnitsForCodeCompletion(command); serverProxy.registerTranslationUnitsForCodeCompletion(message);
scheduleServerCommands(); scheduleServerMessages();
} }
TEST_F(ClientServerInProcess, SendUnregisterTranslationUnitsForCodeCompletionCommand) TEST_F(ClientServerInProcess, SendUnregisterTranslationUnitsForCodeCompletionMessage)
{ {
ClangBackEnd::FileContainer fileContainer(Utf8StringLiteral("foo.cpp"), Utf8StringLiteral("pathToProjectPart.pro")); ClangBackEnd::FileContainer fileContainer(Utf8StringLiteral("foo.cpp"), Utf8StringLiteral("pathToProjectPart.pro"));
ClangBackEnd::UnregisterTranslationUnitsForCodeCompletionCommand command({fileContainer}); ClangBackEnd::UnregisterTranslationUnitsForCodeCompletionMessage message({fileContainer});
EXPECT_CALL(mockIpcServer, unregisterTranslationUnitsForCodeCompletion(command)) EXPECT_CALL(mockIpcServer, unregisterTranslationUnitsForCodeCompletion(message))
.Times(1); .Times(1);
serverProxy.unregisterTranslationUnitsForCodeCompletion(command); serverProxy.unregisterTranslationUnitsForCodeCompletion(message);
scheduleServerCommands(); scheduleServerMessages();
} }
TEST_F(ClientServerInProcess, SendCompleteCodeCommand) TEST_F(ClientServerInProcess, SendCompleteCodeMessage)
{ {
ClangBackEnd::CompleteCodeCommand command(Utf8StringLiteral("foo.cpp"), 24, 33, Utf8StringLiteral("do what I want")); ClangBackEnd::CompleteCodeMessage message(Utf8StringLiteral("foo.cpp"), 24, 33, Utf8StringLiteral("do what I want"));
EXPECT_CALL(mockIpcServer, completeCode(command)) EXPECT_CALL(mockIpcServer, completeCode(message))
.Times(1); .Times(1);
serverProxy.completeCode(command); serverProxy.completeCode(message);
scheduleServerCommands(); scheduleServerMessages();
} }
TEST_F(ClientServerInProcess, SendCodeCompletedCommand) TEST_F(ClientServerInProcess, SendCodeCompletedMessage)
{ {
ClangBackEnd::CodeCompletions codeCompletions({Utf8StringLiteral("newFunction()")}); ClangBackEnd::CodeCompletions codeCompletions({Utf8StringLiteral("newFunction()")});
ClangBackEnd::CodeCompletedCommand command(codeCompletions, 1); ClangBackEnd::CodeCompletedMessage message(codeCompletions, 1);
EXPECT_CALL(mockIpcClient, codeCompleted(command)) EXPECT_CALL(mockIpcClient, codeCompleted(message))
.Times(1); .Times(1);
clientProxy.codeCompleted(command); clientProxy.codeCompleted(message);
scheduleClientCommands(); scheduleClientMessages();
} }
TEST_F(ClientServerInProcess, SendRegisterProjectPartsForCodeCompletionCommand) TEST_F(ClientServerInProcess, SendRegisterProjectPartsForCodeCompletionMessage)
{ {
ClangBackEnd::ProjectPartContainer projectContainer(Utf8StringLiteral(TESTDATA_DIR"/complete.pro")); ClangBackEnd::ProjectPartContainer projectContainer(Utf8StringLiteral(TESTDATA_DIR"/complete.pro"));
ClangBackEnd::RegisterProjectPartsForCodeCompletionCommand command({projectContainer}); ClangBackEnd::RegisterProjectPartsForCodeCompletionMessage message({projectContainer});
EXPECT_CALL(mockIpcServer, registerProjectPartsForCodeCompletion(command)) EXPECT_CALL(mockIpcServer, registerProjectPartsForCodeCompletion(message))
.Times(1); .Times(1);
serverProxy.registerProjectPartsForCodeCompletion(command); serverProxy.registerProjectPartsForCodeCompletion(message);
scheduleServerCommands(); scheduleServerMessages();
} }
TEST_F(ClientServerInProcess, SendUnregisterProjectPartsForCodeCompletionCommand) TEST_F(ClientServerInProcess, SendUnregisterProjectPartsForCodeCompletionMessage)
{ {
ClangBackEnd::UnregisterProjectPartsForCodeCompletionCommand command({Utf8StringLiteral(TESTDATA_DIR"/complete.pro")}); ClangBackEnd::UnregisterProjectPartsForCodeCompletionMessage message({Utf8StringLiteral(TESTDATA_DIR"/complete.pro")});
EXPECT_CALL(mockIpcServer, unregisterProjectPartsForCodeCompletion(command)) EXPECT_CALL(mockIpcServer, unregisterProjectPartsForCodeCompletion(message))
.Times(1); .Times(1);
serverProxy.unregisterProjectPartsForCodeCompletion(command); serverProxy.unregisterProjectPartsForCodeCompletion(message);
scheduleServerCommands(); scheduleServerMessages();
} }
TEST_F(ClientServerInProcess, SendTranslationUnitDoesNotExistCommand) TEST_F(ClientServerInProcess, SendTranslationUnitDoesNotExistMessage)
{ {
ClangBackEnd::FileContainer fileContainer(Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_function.cpp"), ClangBackEnd::FileContainer fileContainer(Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_function.cpp"),
Utf8StringLiteral("pathToProjectPart.pro")); Utf8StringLiteral("pathToProjectPart.pro"));
ClangBackEnd::TranslationUnitDoesNotExistCommand command(fileContainer); ClangBackEnd::TranslationUnitDoesNotExistMessage message(fileContainer);
EXPECT_CALL(mockIpcClient, translationUnitDoesNotExist(command)) EXPECT_CALL(mockIpcClient, translationUnitDoesNotExist(message))
.Times(1); .Times(1);
clientProxy.translationUnitDoesNotExist(command); clientProxy.translationUnitDoesNotExist(message);
scheduleClientCommands(); scheduleClientMessages();
} }
TEST_F(ClientServerInProcess, SendProjectPartDoesNotExistCommand) TEST_F(ClientServerInProcess, SendProjectPartDoesNotExistMessage)
{ {
ClangBackEnd::ProjectPartsDoNotExistCommand command({Utf8StringLiteral("pathToProjectPart.pro")}); ClangBackEnd::ProjectPartsDoNotExistMessage message({Utf8StringLiteral("pathToProjectPart.pro")});
EXPECT_CALL(mockIpcClient, projectPartsDoNotExist(command)) EXPECT_CALL(mockIpcClient, projectPartsDoNotExist(message))
.Times(1); .Times(1);
clientProxy.projectPartsDoNotExist(command); clientProxy.projectPartsDoNotExist(message);
scheduleClientCommands(); scheduleClientMessages();
} }
ClientServerInProcess::ClientServerInProcess() ClientServerInProcess::ClientServerInProcess()
: serverProxy(&mockIpcClient, &buffer), : serverProxy(&mockIpcClient, &buffer),
@@ -218,17 +218,17 @@ void ClientServerInProcess::TearDown()
buffer.close(); buffer.close();
} }
void ClientServerInProcess::scheduleServerCommands() void ClientServerInProcess::scheduleServerMessages()
{ {
buffer.seek(0); buffer.seek(0);
clientProxy.readCommands(); clientProxy.readMessages();
buffer.buffer().clear(); buffer.buffer().clear();
} }
void ClientServerInProcess::scheduleClientCommands() void ClientServerInProcess::scheduleClientMessages()
{ {
buffer.seek(0); buffer.seek(0);
serverProxy.readCommands(); serverProxy.readMessages();
buffer.buffer().clear(); buffer.buffer().clear();
} }

View File

@@ -30,21 +30,21 @@
#include "mockipclient.h" #include "mockipclient.h"
#include <cmbalivecommand.h> #include <cmbalivemessage.h>
#include <cmbcodecompletedcommand.h> #include <cmbcodecompletedmessage.h>
#include <cmbcommands.h> #include <cmbmessages.h>
#include <cmbcompletecodecommand.h> #include <cmbcompletecodemessage.h>
#include <cmbechocommand.h> #include <cmbechomessage.h>
#include <cmbendcommand.h> #include <cmbendmessage.h>
#include <cmbregisterprojectsforcodecompletioncommand.h> #include <cmbregisterprojectsforcodecompletionmessage.h>
#include <cmbregistertranslationunitsforcodecompletioncommand.h> #include <cmbregistertranslationunitsforcodecompletionmessage.h>
#include <cmbunregisterprojectsforcodecompletioncommand.h> #include <cmbunregisterprojectsforcodecompletionmessage.h>
#include <cmbunregistertranslationunitsforcodecompletioncommand.h> #include <cmbunregistertranslationunitsforcodecompletionmessage.h>
#include <connectionclient.h> #include <connectionclient.h>
#include <projectpartsdonotexistcommand.h> #include <projectpartsdonotexistmessage.h>
#include <readcommandblock.h> #include <readmessageblock.h>
#include <translationunitdoesnotexistcommand.h> #include <translationunitdoesnotexistmessage.h>
#include <writecommandblock.h> #include <writemessageblock.h>
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include <gmock/gmock-matchers.h> #include <gmock/gmock-matchers.h>
@@ -111,66 +111,66 @@ TEST_F(ClientServerOutsideProcess, RestartProcessAfterTermination)
ASSERT_TRUE(clientSpy.wait(100000)); ASSERT_TRUE(clientSpy.wait(100000));
} }
TEST_F(ClientServerOutsideProcess, SendRegisterTranslationUnitForCodeCompletionCommand) TEST_F(ClientServerOutsideProcess, SendRegisterTranslationUnitForCodeCompletionMessage)
{ {
ClangBackEnd::FileContainer fileContainer(Utf8StringLiteral("foo"), Utf8StringLiteral("pathToProjectPart.pro")); ClangBackEnd::FileContainer fileContainer(Utf8StringLiteral("foo"), Utf8StringLiteral("pathToProjectPart.pro"));
ClangBackEnd::RegisterTranslationUnitForCodeCompletionCommand registerTranslationUnitForCodeCompletionCommand({fileContainer}); ClangBackEnd::RegisterTranslationUnitForCodeCompletionMessage registerTranslationUnitForCodeCompletionMessage({fileContainer});
EchoCommand echoCommand(QVariant::fromValue(registerTranslationUnitForCodeCompletionCommand)); EchoMessage echoMessage(QVariant::fromValue(registerTranslationUnitForCodeCompletionMessage));
EXPECT_CALL(mockIpcClient, echo(echoCommand)) EXPECT_CALL(mockIpcClient, echo(echoMessage))
.Times(1); .Times(1);
client.serverProxy().registerTranslationUnitsForCodeCompletion(registerTranslationUnitForCodeCompletionCommand); client.serverProxy().registerTranslationUnitsForCodeCompletion(registerTranslationUnitForCodeCompletionMessage);
ASSERT_TRUE(client.waitForEcho()); ASSERT_TRUE(client.waitForEcho());
} }
TEST_F(ClientServerOutsideProcess, SendUnregisterTranslationUnitsForCodeCompletionCommand) TEST_F(ClientServerOutsideProcess, SendUnregisterTranslationUnitsForCodeCompletionMessage)
{ {
FileContainer fileContainer(Utf8StringLiteral("foo.cpp"), Utf8StringLiteral("bar.pro")); FileContainer fileContainer(Utf8StringLiteral("foo.cpp"), Utf8StringLiteral("bar.pro"));
ClangBackEnd::UnregisterTranslationUnitsForCodeCompletionCommand unregisterTranslationUnitsForCodeCompletionCommand ({fileContainer}); ClangBackEnd::UnregisterTranslationUnitsForCodeCompletionMessage unregisterTranslationUnitsForCodeCompletionMessage ({fileContainer});
EchoCommand echoCommand(QVariant::fromValue(unregisterTranslationUnitsForCodeCompletionCommand)); EchoMessage echoMessage(QVariant::fromValue(unregisterTranslationUnitsForCodeCompletionMessage));
EXPECT_CALL(mockIpcClient, echo(echoCommand)) EXPECT_CALL(mockIpcClient, echo(echoMessage))
.Times(1); .Times(1);
client.serverProxy().unregisterTranslationUnitsForCodeCompletion(unregisterTranslationUnitsForCodeCompletionCommand); client.serverProxy().unregisterTranslationUnitsForCodeCompletion(unregisterTranslationUnitsForCodeCompletionMessage);
ASSERT_TRUE(client.waitForEcho()); ASSERT_TRUE(client.waitForEcho());
} }
TEST_F(ClientServerOutsideProcess, SendCompleteCodeCommand) TEST_F(ClientServerOutsideProcess, SendCompleteCodeMessage)
{ {
CompleteCodeCommand codeCompleteCommand(Utf8StringLiteral("foo.cpp"), 24, 33, Utf8StringLiteral("do what I want")); CompleteCodeMessage codeCompleteMessage(Utf8StringLiteral("foo.cpp"), 24, 33, Utf8StringLiteral("do what I want"));
EchoCommand echoCommand(QVariant::fromValue(codeCompleteCommand)); EchoMessage echoMessage(QVariant::fromValue(codeCompleteMessage));
EXPECT_CALL(mockIpcClient, echo(echoCommand)) EXPECT_CALL(mockIpcClient, echo(echoMessage))
.Times(1); .Times(1);
client.serverProxy().completeCode(codeCompleteCommand); client.serverProxy().completeCode(codeCompleteMessage);
ASSERT_TRUE(client.waitForEcho()); ASSERT_TRUE(client.waitForEcho());
} }
TEST_F(ClientServerOutsideProcess, SendRegisterProjectPartsForCodeCompletionCommand) TEST_F(ClientServerOutsideProcess, SendRegisterProjectPartsForCodeCompletionMessage)
{ {
ClangBackEnd::ProjectPartContainer projectContainer(Utf8StringLiteral(TESTDATA_DIR"/complete.pro")); ClangBackEnd::ProjectPartContainer projectContainer(Utf8StringLiteral(TESTDATA_DIR"/complete.pro"));
ClangBackEnd::RegisterProjectPartsForCodeCompletionCommand registerProjectPartsForCodeCompletionCommand({projectContainer}); ClangBackEnd::RegisterProjectPartsForCodeCompletionMessage registerProjectPartsForCodeCompletionMessage({projectContainer});
EchoCommand echoCommand(QVariant::fromValue(registerProjectPartsForCodeCompletionCommand)); EchoMessage echoMessage(QVariant::fromValue(registerProjectPartsForCodeCompletionMessage));
EXPECT_CALL(mockIpcClient, echo(echoCommand)) EXPECT_CALL(mockIpcClient, echo(echoMessage))
.Times(1); .Times(1);
client.serverProxy().registerProjectPartsForCodeCompletion(registerProjectPartsForCodeCompletionCommand); client.serverProxy().registerProjectPartsForCodeCompletion(registerProjectPartsForCodeCompletionMessage);
ASSERT_TRUE(client.waitForEcho()); ASSERT_TRUE(client.waitForEcho());
} }
TEST_F(ClientServerOutsideProcess, SendUnregisterProjectPartsForCodeCompletionCommand) TEST_F(ClientServerOutsideProcess, SendUnregisterProjectPartsForCodeCompletionMessage)
{ {
ClangBackEnd::UnregisterProjectPartsForCodeCompletionCommand unregisterProjectPartsForCodeCompletionCommand({Utf8StringLiteral(TESTDATA_DIR"/complete.pro")}); ClangBackEnd::UnregisterProjectPartsForCodeCompletionMessage unregisterProjectPartsForCodeCompletionMessage({Utf8StringLiteral(TESTDATA_DIR"/complete.pro")});
EchoCommand echoCommand(QVariant::fromValue(unregisterProjectPartsForCodeCompletionCommand)); EchoMessage echoMessage(QVariant::fromValue(unregisterProjectPartsForCodeCompletionMessage));
EXPECT_CALL(mockIpcClient, echo(echoCommand)) EXPECT_CALL(mockIpcClient, echo(echoMessage))
.Times(1); .Times(1);
client.serverProxy().unregisterProjectPartsForCodeCompletion(unregisterProjectPartsForCodeCompletionCommand); client.serverProxy().unregisterProjectPartsForCodeCompletion(unregisterProjectPartsForCodeCompletionMessage);
ASSERT_TRUE(client.waitForEcho()); ASSERT_TRUE(client.waitForEcho());
} }

View File

@@ -30,7 +30,7 @@
#include <sqliteglobal.h> #include <sqliteglobal.h>
#include <cmbcommands.h> #include <cmbmessages.h>
#include <QCoreApplication> #include <QCoreApplication>
@@ -39,7 +39,7 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
ClangBackEnd::Commands::registerCommands(); ClangBackEnd::Messages::registerMessages();
Sqlite::registerTypes(); Sqlite::registerTypes();
QCoreApplication application(argc, argv); QCoreApplication application(argc, argv);

View File

@@ -43,13 +43,13 @@ class MockIpcClient : public ClangBackEnd::IpcClientInterface {
MOCK_METHOD0(alive, MOCK_METHOD0(alive,
void()); void());
MOCK_METHOD1(echo, MOCK_METHOD1(echo,
void(const ClangBackEnd::EchoCommand &command)); void(const ClangBackEnd::EchoMessage &message));
MOCK_METHOD1(codeCompleted, MOCK_METHOD1(codeCompleted,
void(const ClangBackEnd::CodeCompletedCommand &command)); void(const ClangBackEnd::CodeCompletedMessage &message));
MOCK_METHOD1(translationUnitDoesNotExist, MOCK_METHOD1(translationUnitDoesNotExist,
void(const ClangBackEnd::TranslationUnitDoesNotExistCommand &command)); void(const ClangBackEnd::TranslationUnitDoesNotExistMessage &message));
MOCK_METHOD1(projectPartsDoNotExist, MOCK_METHOD1(projectPartsDoNotExist,
void(const ClangBackEnd::ProjectPartsDoNotExistCommand &command)); void(const ClangBackEnd::ProjectPartsDoNotExistMessage &message));
}; };
#endif // MOCKIPCLIENT_H #endif // MOCKIPCLIENT_H

View File

@@ -43,15 +43,15 @@ class MockIpcServer : public ClangBackEnd::IpcServerInterface {
MOCK_METHOD0(end, MOCK_METHOD0(end,
void()); void());
MOCK_METHOD1(registerTranslationUnitsForCodeCompletion, MOCK_METHOD1(registerTranslationUnitsForCodeCompletion,
void(const ClangBackEnd::RegisterTranslationUnitForCodeCompletionCommand &command)); void(const ClangBackEnd::RegisterTranslationUnitForCodeCompletionMessage &message));
MOCK_METHOD1(unregisterTranslationUnitsForCodeCompletion, MOCK_METHOD1(unregisterTranslationUnitsForCodeCompletion,
void(const ClangBackEnd::UnregisterTranslationUnitsForCodeCompletionCommand &command)); void(const ClangBackEnd::UnregisterTranslationUnitsForCodeCompletionMessage &message));
MOCK_METHOD1(registerProjectPartsForCodeCompletion, MOCK_METHOD1(registerProjectPartsForCodeCompletion,
void(const ClangBackEnd::RegisterProjectPartsForCodeCompletionCommand &command)); void(const ClangBackEnd::RegisterProjectPartsForCodeCompletionMessage &message));
MOCK_METHOD1(unregisterProjectPartsForCodeCompletion, MOCK_METHOD1(unregisterProjectPartsForCodeCompletion,
void(const ClangBackEnd::UnregisterProjectPartsForCodeCompletionCommand &command)); void(const ClangBackEnd::UnregisterProjectPartsForCodeCompletionMessage &message));
MOCK_METHOD1(completeCode, MOCK_METHOD1(completeCode,
void(const ClangBackEnd::CompleteCodeCommand &command)); void(const ClangBackEnd::CompleteCodeMessage &message));
}; };
#endif // MOCKIPCSERVER_H #endif // MOCKIPCSERVER_H

View File

@@ -1,224 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://www.qt.io/licensing. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include <cmbalivecommand.h>
#include <cmbcodecompletedcommand.h>
#include <cmbcommands.h>
#include <cmbcompletecodecommand.h>
#include <cmbendcommand.h>
#include <cmbregistertranslationunitsforcodecompletioncommand.h>
#include <cmbunregistertranslationunitsforcodecompletioncommand.h>
#include <readcommandblock.h>
#include <writecommandblock.h>
#include <QBuffer>
#include <QString>
#include <QVariant>
#include <vector>
#include <gmock/gmock.h>
#include <gmock/gmock-matchers.h>
#include <gtest/gtest.h>
#include "gtest-qt-printing.h"
using namespace testing;
namespace CodeModelBackeEndTest {
class ReadAndWriteCommandBlockTest : public ::testing::Test
{
protected:
ReadAndWriteCommandBlockTest();
virtual void SetUp() override;
virtual void TearDown() override;
template<class Type>
void CompareCommand(const Type &command);
QVariant writeCodeCompletedCommand();
void popLastCharacterFromBuffer();
void pushLastCharacterToBuffer();
void readPartialCommand();
protected:
QBuffer buffer;
ClangBackEnd::WriteCommandBlock writeCommandBlock;
ClangBackEnd::ReadCommandBlock readCommandBlock;
char lastCharacter = 0;
};
ReadAndWriteCommandBlockTest::ReadAndWriteCommandBlockTest()
: writeCommandBlock(&buffer),
readCommandBlock(&buffer)
{
}
void ReadAndWriteCommandBlockTest::SetUp()
{
buffer.open(QIODevice::ReadWrite);
writeCommandBlock = ClangBackEnd::WriteCommandBlock(&buffer);
readCommandBlock = ClangBackEnd::ReadCommandBlock(&buffer);
}
void ReadAndWriteCommandBlockTest::TearDown()
{
buffer.close();
}
TEST_F(ReadAndWriteCommandBlockTest, WriteCommandAndTestSize)
{
writeCommandBlock.write(QVariant::fromValue(ClangBackEnd::EndCommand()));
ASSERT_EQ(46, buffer.size());
}
TEST_F(ReadAndWriteCommandBlockTest, WriteSecondCommandAndTestSize)
{
writeCommandBlock.write(QVariant::fromValue(ClangBackEnd::EndCommand()));
ASSERT_EQ(46, buffer.size());
}
TEST_F(ReadAndWriteCommandBlockTest, WriteTwoCommandsAndTestCount)
{
writeCommandBlock.write(QVariant::fromValue(ClangBackEnd::EndCommand()));
writeCommandBlock.write(QVariant::fromValue(ClangBackEnd::EndCommand()));
ASSERT_EQ(2, writeCommandBlock.counter());
}
TEST_F(ReadAndWriteCommandBlockTest, ReadThreeCommandsAndTestCount)
{
writeCommandBlock.write(QVariant::fromValue(ClangBackEnd::EndCommand()));
writeCommandBlock.write(QVariant::fromValue(ClangBackEnd::EndCommand()));
writeCommandBlock.write(QVariant::fromValue(ClangBackEnd::EndCommand()));
buffer.seek(0);
ASSERT_EQ(3, readCommandBlock.readAll().count());
}
TEST_F(ReadAndWriteCommandBlockTest, CompareEndCommand)
{
CompareCommand(ClangBackEnd::EndCommand());
}
TEST_F(ReadAndWriteCommandBlockTest, CompareAliveCommand)
{
CompareCommand(ClangBackEnd::AliveCommand());
}
TEST_F(ReadAndWriteCommandBlockTest, CompareRegisterTranslationUnitForCodeCompletionCommand)
{
ClangBackEnd::FileContainer fileContainer(Utf8StringLiteral("foo.cpp"), Utf8StringLiteral("pathToProject.pro"));
QVector<ClangBackEnd::FileContainer> fileContainers({fileContainer});
CompareCommand(ClangBackEnd::RegisterTranslationUnitForCodeCompletionCommand(fileContainers));
}
TEST_F(ReadAndWriteCommandBlockTest, CompareUnregisterFileForCodeCompletionCommand)
{
ClangBackEnd::FileContainer fileContainer(Utf8StringLiteral("foo.cpp"), Utf8StringLiteral("pathToProject.pro"));
CompareCommand(ClangBackEnd::UnregisterTranslationUnitsForCodeCompletionCommand({fileContainer}));
}
TEST_F(ReadAndWriteCommandBlockTest, CompareCompleteCodeCommand)
{
CompareCommand(ClangBackEnd::CompleteCodeCommand(Utf8StringLiteral("foo.cpp"), 24, 33, Utf8StringLiteral("do what I want")));
}
TEST_F(ReadAndWriteCommandBlockTest, CompareCodeCompletedCommand)
{
ClangBackEnd::CodeCompletions codeCompletions({Utf8StringLiteral("newFunction()")});
CompareCommand(ClangBackEnd::CodeCompletedCommand(codeCompletions, 1));
}
TEST_F(ReadAndWriteCommandBlockTest, GetInvalidCommandForAPartialBuffer)
{
writeCodeCompletedCommand();
popLastCharacterFromBuffer();
buffer.seek(0);
readPartialCommand();
}
TEST_F(ReadAndWriteCommandBlockTest, ReadCommandAfterInterruption)
{
const QVariant writeCommand = writeCodeCompletedCommand();
popLastCharacterFromBuffer();
buffer.seek(0);
readPartialCommand();
pushLastCharacterToBuffer();
ASSERT_EQ(readCommandBlock.read(), writeCommand);
}
QVariant ReadAndWriteCommandBlockTest::writeCodeCompletedCommand()
{
ClangBackEnd::CodeCompletedCommand command(ClangBackEnd::CodeCompletions({Utf8StringLiteral("newFunction()")}), 1);
const QVariant writeCommand = QVariant::fromValue(command);
writeCommandBlock.write(writeCommand);
return writeCommand;
}
void ReadAndWriteCommandBlockTest::popLastCharacterFromBuffer()
{
auto &internalBuffer = buffer.buffer();
lastCharacter = internalBuffer.at(internalBuffer.size() - 1);
internalBuffer.chop(1);
}
void ReadAndWriteCommandBlockTest::pushLastCharacterToBuffer()
{
buffer.buffer().push_back(lastCharacter);
}
void ReadAndWriteCommandBlockTest::readPartialCommand()
{
QVariant readCommand = readCommandBlock.read();
ASSERT_FALSE(readCommand.isValid());
}
template<class Type>
void ReadAndWriteCommandBlockTest::CompareCommand(const Type &command)
{
const QVariant writeCommand = QVariant::fromValue(command);
writeCommandBlock.write(writeCommand);
buffer.seek(0);
const QVariant readCommand = readCommandBlock.read();
ASSERT_EQ(writeCommand, readCommand);
}
}

View File

@@ -0,0 +1,224 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://www.qt.io/licensing. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include <cmbalivemessage.h>
#include <cmbcodecompletedmessage.h>
#include <cmbmessages.h>
#include <cmbcompletecodemessage.h>
#include <cmbendmessage.h>
#include <cmbregistertranslationunitsforcodecompletionmessage.h>
#include <cmbunregistertranslationunitsforcodecompletionmessage.h>
#include <readmessageblock.h>
#include <writemessageblock.h>
#include <QBuffer>
#include <QString>
#include <QVariant>
#include <vector>
#include <gmock/gmock.h>
#include <gmock/gmock-matchers.h>
#include <gtest/gtest.h>
#include "gtest-qt-printing.h"
using namespace testing;
namespace CodeModelBackeEndTest {
class ReadAndWriteMessageBlockTest : public ::testing::Test
{
protected:
ReadAndWriteMessageBlockTest();
virtual void SetUp() override;
virtual void TearDown() override;
template<class Type>
void CompareMessage(const Type &message);
QVariant writeCodeCompletedMessage();
void popLastCharacterFromBuffer();
void pushLastCharacterToBuffer();
void readPartialMessage();
protected:
QBuffer buffer;
ClangBackEnd::WriteMessageBlock writeMessageBlock;
ClangBackEnd::ReadMessageBlock readMessageBlock;
char lastCharacter = 0;
};
ReadAndWriteMessageBlockTest::ReadAndWriteMessageBlockTest()
: writeMessageBlock(&buffer),
readMessageBlock(&buffer)
{
}
void ReadAndWriteMessageBlockTest::SetUp()
{
buffer.open(QIODevice::ReadWrite);
writeMessageBlock = ClangBackEnd::WriteMessageBlock(&buffer);
readMessageBlock = ClangBackEnd::ReadMessageBlock(&buffer);
}
void ReadAndWriteMessageBlockTest::TearDown()
{
buffer.close();
}
TEST_F(ReadAndWriteMessageBlockTest, WriteMessageAndTestSize)
{
writeMessageBlock.write(QVariant::fromValue(ClangBackEnd::EndMessage()));
ASSERT_EQ(46, buffer.size());
}
TEST_F(ReadAndWriteMessageBlockTest, WriteSecondMessageAndTestSize)
{
writeMessageBlock.write(QVariant::fromValue(ClangBackEnd::EndMessage()));
ASSERT_EQ(46, buffer.size());
}
TEST_F(ReadAndWriteMessageBlockTest, WriteTwoMessagesAndTestCount)
{
writeMessageBlock.write(QVariant::fromValue(ClangBackEnd::EndMessage()));
writeMessageBlock.write(QVariant::fromValue(ClangBackEnd::EndMessage()));
ASSERT_EQ(2, writeMessageBlock.counter());
}
TEST_F(ReadAndWriteMessageBlockTest, ReadThreeMessagesAndTestCount)
{
writeMessageBlock.write(QVariant::fromValue(ClangBackEnd::EndMessage()));
writeMessageBlock.write(QVariant::fromValue(ClangBackEnd::EndMessage()));
writeMessageBlock.write(QVariant::fromValue(ClangBackEnd::EndMessage()));
buffer.seek(0);
ASSERT_EQ(3, readMessageBlock.readAll().count());
}
TEST_F(ReadAndWriteMessageBlockTest, CompareEndMessage)
{
CompareMessage(ClangBackEnd::EndMessage());
}
TEST_F(ReadAndWriteMessageBlockTest, CompareAliveMessage)
{
CompareMessage(ClangBackEnd::AliveMessage());
}
TEST_F(ReadAndWriteMessageBlockTest, CompareRegisterTranslationUnitForCodeCompletionMessage)
{
ClangBackEnd::FileContainer fileContainer(Utf8StringLiteral("foo.cpp"), Utf8StringLiteral("pathToProject.pro"));
QVector<ClangBackEnd::FileContainer> fileContainers({fileContainer});
CompareMessage(ClangBackEnd::RegisterTranslationUnitForCodeCompletionMessage(fileContainers));
}
TEST_F(ReadAndWriteMessageBlockTest, CompareUnregisterFileForCodeCompletionMessage)
{
ClangBackEnd::FileContainer fileContainer(Utf8StringLiteral("foo.cpp"), Utf8StringLiteral("pathToProject.pro"));
CompareMessage(ClangBackEnd::UnregisterTranslationUnitsForCodeCompletionMessage({fileContainer}));
}
TEST_F(ReadAndWriteMessageBlockTest, CompareCompleteCodeMessage)
{
CompareMessage(ClangBackEnd::CompleteCodeMessage(Utf8StringLiteral("foo.cpp"), 24, 33, Utf8StringLiteral("do what I want")));
}
TEST_F(ReadAndWriteMessageBlockTest, CompareCodeCompletedMessage)
{
ClangBackEnd::CodeCompletions codeCompletions({Utf8StringLiteral("newFunction()")});
CompareMessage(ClangBackEnd::CodeCompletedMessage(codeCompletions, 1));
}
TEST_F(ReadAndWriteMessageBlockTest, GetInvalidMessageForAPartialBuffer)
{
writeCodeCompletedMessage();
popLastCharacterFromBuffer();
buffer.seek(0);
readPartialMessage();
}
TEST_F(ReadAndWriteMessageBlockTest, ReadMessageAfterInterruption)
{
const QVariant writeMessage = writeCodeCompletedMessage();
popLastCharacterFromBuffer();
buffer.seek(0);
readPartialMessage();
pushLastCharacterToBuffer();
ASSERT_EQ(readMessageBlock.read(), writeMessage);
}
QVariant ReadAndWriteMessageBlockTest::writeCodeCompletedMessage()
{
ClangBackEnd::CodeCompletedMessage message(ClangBackEnd::CodeCompletions({Utf8StringLiteral("newFunction()")}), 1);
const QVariant writeMessage = QVariant::fromValue(message);
writeMessageBlock.write(writeMessage);
return writeMessage;
}
void ReadAndWriteMessageBlockTest::popLastCharacterFromBuffer()
{
auto &internalBuffer = buffer.buffer();
lastCharacter = internalBuffer.at(internalBuffer.size() - 1);
internalBuffer.chop(1);
}
void ReadAndWriteMessageBlockTest::pushLastCharacterToBuffer()
{
buffer.buffer().push_back(lastCharacter);
}
void ReadAndWriteMessageBlockTest::readPartialMessage()
{
QVariant readMessage = readMessageBlock.read();
ASSERT_FALSE(readMessage.isValid());
}
template<class Type>
void ReadAndWriteMessageBlockTest::CompareMessage(const Type &message)
{
const QVariant writeMessage = QVariant::fromValue(message);
writeMessageBlock.write(writeMessage);
buffer.seek(0);
const QVariant readMessage = readMessageBlock.read();
ASSERT_EQ(writeMessage, readMessage);
}
}

View File

@@ -13,7 +13,7 @@ osx:QMAKE_CXXFLAGS = -stdlib=libc++
DEFINES += \ DEFINES += \
QT_NO_CAST_FROM_ASCII \ QT_NO_CAST_FROM_ASCII \
CLANGBACKEND_TESTS \ CLANGBACKEND_TESTS \
DONT_CHECK_COMMAND_COUNTER \ DONT_CHECK_MESSAGE_COUNTER \
TESTDATA_DIR=\"R\\\"xxx($$PWD/data)xxx\\\"\" TESTDATA_DIR=\"R\\\"xxx($$PWD/data)xxx\\\"\"
win32:DEFINES += ECHOSERVER=\"R\\\"xxx($$OUT_PWD/../echo)xxx\\\"\" win32:DEFINES += ECHOSERVER=\"R\\\"xxx($$OUT_PWD/../echo)xxx\\\"\"
unix: DEFINES += ECHOSERVER=\"R\\\"xxx($$OUT_PWD/../echoserver/echo)xxx\\\"\" unix: DEFINES += ECHOSERVER=\"R\\\"xxx($$OUT_PWD/../echoserver/echo)xxx\\\"\"
@@ -34,7 +34,7 @@ SOURCES += \
lineprefixertest.cpp \ lineprefixertest.cpp \
main.cpp \ main.cpp \
projecttest.cpp \ projecttest.cpp \
readandwritecommandblocktest.cpp \ readandwritemessageblocktest.cpp \
spydummy.cpp \ spydummy.cpp \
sqlitecolumntest.cpp \ sqlitecolumntest.cpp \
sqlitedatabasebackendtest.cpp \ sqlitedatabasebackendtest.cpp \