diff options
Diffstat (limited to 'src/libs/codemodelbackendipc')
60 files changed, 5219 insertions, 0 deletions
diff --git a/src/libs/codemodelbackendipc/cmbalivecommand.cpp b/src/libs/codemodelbackendipc/cmbalivecommand.cpp new file mode 100644 index 0000000000..44126948bb --- /dev/null +++ b/src/libs/codemodelbackendipc/cmbalivecommand.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** 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 <QtDebug> + +#include <QDataStream> + +namespace CodeModelBackEnd { + +QDataStream &operator<<(QDataStream &out, const AliveCommand &/*command*/) +{ + return out; +} + +QDataStream &operator>>(QDataStream &in, AliveCommand &/*command*/) +{ + return in; +} + +bool operator == (const AliveCommand &/*first*/, const AliveCommand &/*second*/) +{ + return true; +} + +bool operator < (const AliveCommand &/*first*/, const AliveCommand &/*second*/) +{ + return true; +} + +QDebug operator <<(QDebug debug, const AliveCommand &/*command*/) +{ + return debug.nospace() << "AliveCommand()"; +} + +} diff --git a/src/libs/codemodelbackendipc/cmbalivecommand.h b/src/libs/codemodelbackendipc/cmbalivecommand.h new file mode 100644 index 0000000000..47c896d24d --- /dev/null +++ b/src/libs/codemodelbackendipc/cmbalivecommand.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifndef CMBALIVECOMMAND_H +#define CMBALIVECOMMAND_H + +#include "codemodelbackendipc_global.h" + +#include <QMetaType> + +namespace CodeModelBackEnd { + +class CMBIPC_EXPORT AliveCommand +{ +}; + +CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const AliveCommand &command); +CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, AliveCommand &command); +CMBIPC_EXPORT bool operator == (const AliveCommand &first, const AliveCommand &second); +CMBIPC_EXPORT bool operator < (const AliveCommand &first, const AliveCommand &second); + +CMBIPC_EXPORT QDebug operator <<(QDebug debug, const AliveCommand &command); + +} + +Q_DECLARE_METATYPE(CodeModelBackEnd::AliveCommand) + +#endif // CMBALIVECOMMAND_H diff --git a/src/libs/codemodelbackendipc/cmbcodecompletedcommand.cpp b/src/libs/codemodelbackendipc/cmbcodecompletedcommand.cpp new file mode 100644 index 0000000000..3e59aaf497 --- /dev/null +++ b/src/libs/codemodelbackendipc/cmbcodecompletedcommand.cpp @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** 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 "cmbcodecompletedcommand.h" + +#include <QDebug> + +#include <QDataStream> + +#include <ostream> + +namespace CodeModelBackEnd { + +CodeCompletedCommand::CodeCompletedCommand(const QVector<CodeCompletion> &codeCompletions, quint64 ticketNumber) + : codeCompletions_(codeCompletions), + ticketNumber_(ticketNumber) +{ +} + +const QVector<CodeCompletion> &CodeCompletedCommand::codeCompletions() const +{ + return codeCompletions_; +} + +quint64 CodeCompletedCommand::ticketNumber() const +{ + return ticketNumber_; +} + +QDataStream &operator<<(QDataStream &out, const CodeCompletedCommand &command) +{ + out << command.codeCompletions_; + out << command.ticketNumber_; + + return out; +} + +QDataStream &operator>>(QDataStream &in, CodeCompletedCommand &command) +{ + in >> command.codeCompletions_; + in >> command.ticketNumber_; + + return in; +} + +bool operator == (const CodeCompletedCommand &first, const CodeCompletedCommand &second) +{ + return first.ticketNumber_ == second.ticketNumber_ + && first.codeCompletions_ == second.codeCompletions_; +} + +bool operator < (const CodeCompletedCommand &first, const CodeCompletedCommand &second) +{ + return first.ticketNumber_ < second.ticketNumber_; +} + +QDebug operator <<(QDebug debug, const CodeCompletedCommand &command) +{ + debug.nospace() << "CodeCompletedCommand("; + + debug.nospace() << command.codeCompletions_ << ", " << command.ticketNumber_; + + debug.nospace() << ")"; + + return debug; +} + +void PrintTo(const CodeCompletedCommand &command, ::std::ostream* os) +{ + QString output; + QDebug debug(&output); + + debug << command; + + *os << output.toUtf8().constData(); +} + +} // namespace CodeModelBackEnd + diff --git a/src/libs/codemodelbackendipc/cmbcodecompletedcommand.h b/src/libs/codemodelbackendipc/cmbcodecompletedcommand.h new file mode 100644 index 0000000000..1cb52b1e4f --- /dev/null +++ b/src/libs/codemodelbackendipc/cmbcodecompletedcommand.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifndef CODEMODELBACKEND_CODECOMPLETEDCOMMAND_H +#define CODEMODELBACKEND_CODECOMPLETEDCOMMAND_H + +#include <QMetaType> +#include <QVector> + +#include "codecompletion.h" + +namespace CodeModelBackEnd { + +class CMBIPC_EXPORT CodeCompletedCommand +{ + friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CodeCompletedCommand &command); + friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CodeCompletedCommand &command); + friend CMBIPC_EXPORT bool operator == (const CodeCompletedCommand &first, const CodeCompletedCommand &second); + friend CMBIPC_EXPORT bool operator < (const CodeCompletedCommand &first, const CodeCompletedCommand &second); + friend CMBIPC_EXPORT QDebug operator <<(QDebug debug, const CodeCompletedCommand &command); + friend void PrintTo(const CodeCompletedCommand &command, ::std::ostream* os); +public: + CodeCompletedCommand() = default; + CodeCompletedCommand(const QVector<CodeCompletion> &codeCompletions, quint64 ticketNumber); + + const QVector<CodeCompletion> &codeCompletions() const; + + quint64 ticketNumber() const; + +private: + QVector<CodeCompletion> codeCompletions_; + quint64 ticketNumber_ = 0; +}; + +CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CodeCompletedCommand &command); +CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CodeCompletedCommand &command); +CMBIPC_EXPORT bool operator == (const CodeCompletedCommand &first, const CodeCompletedCommand &second); +CMBIPC_EXPORT bool operator < (const CodeCompletedCommand &first, const CodeCompletedCommand &second); + +CMBIPC_EXPORT QDebug operator <<(QDebug debug, const CodeCompletedCommand &command); +void PrintTo(const CodeCompletedCommand &command, ::std::ostream* os); + +} // namespace CodeModelBackEnd + +Q_DECLARE_METATYPE(CodeModelBackEnd::CodeCompletedCommand) + +#endif // CODEMODELBACKEND_CODECOMPLETEDCOMMAND_H diff --git a/src/libs/codemodelbackendipc/cmbcommands.cpp b/src/libs/codemodelbackendipc/cmbcommands.cpp new file mode 100644 index 0000000000..7a817f09df --- /dev/null +++ b/src/libs/codemodelbackendipc/cmbcommands.cpp @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** 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 "cmbcommands.h" + +#include "cmbalivecommand.h" +#include "cmbendcommand.h" +#include "cmbechocommand.h" +#include "cmbregistertranslationunitsforcodecompletioncommand.h" +#include "cmbunregistertranslationunitsforcodecompletioncommand.h" +#include "cmbregisterprojectsforcodecompletioncommand.h" +#include "cmbunregisterprojectsforcodecompletioncommand.h" +#include "cmbcompletecodecommand.h" +#include "cmbcodecompletedcommand.h" +#include "projectpartsdonotexistcommand.h" +#include "translationunitdoesnotexistcommand.h" + +#include <QDataStream> + +namespace CodeModelBackEnd { + +void Commands::registerCommands() +{ + qRegisterMetaType<EndCommand>(); + qRegisterMetaTypeStreamOperators<EndCommand>(); + QMetaType::registerComparators<EndCommand>(); + + qRegisterMetaType<AliveCommand>(); + qRegisterMetaTypeStreamOperators<AliveCommand>(); + QMetaType::registerComparators<AliveCommand>(); + + qRegisterMetaType<EchoCommand>(); + qRegisterMetaTypeStreamOperators<EchoCommand>(); + + qRegisterMetaType<RegisterTranslationUnitForCodeCompletionCommand>(); + qRegisterMetaTypeStreamOperators<RegisterTranslationUnitForCodeCompletionCommand>(); + QMetaType::registerComparators<RegisterTranslationUnitForCodeCompletionCommand>(); + + qRegisterMetaType<FileContainer>(); + qRegisterMetaTypeStreamOperators<FileContainer>(); + QMetaType::registerComparators<FileContainer>(); + + qRegisterMetaType<UnregisterTranslationUnitsForCodeCompletionCommand>(); + qRegisterMetaTypeStreamOperators<UnregisterTranslationUnitsForCodeCompletionCommand>(); + QMetaType::registerComparators<UnregisterTranslationUnitsForCodeCompletionCommand>(); + + qRegisterMetaType<CompleteCodeCommand>(); + qRegisterMetaTypeStreamOperators<CompleteCodeCommand>(); + QMetaType::registerComparators<CompleteCodeCommand>(); + + qRegisterMetaType<CodeCompletion>(); + qRegisterMetaTypeStreamOperators<CodeCompletion>(); + QMetaType::registerComparators<CodeCompletion>(); + + qRegisterMetaType<CodeCompletedCommand>(); + qRegisterMetaTypeStreamOperators<CodeCompletedCommand>(); + QMetaType::registerComparators<CodeCompletedCommand>(); + + qRegisterMetaType<RegisterProjectPartsForCodeCompletionCommand>(); + qRegisterMetaTypeStreamOperators<RegisterProjectPartsForCodeCompletionCommand>(); + QMetaType::registerComparators<RegisterProjectPartsForCodeCompletionCommand>(); + + qRegisterMetaType<ProjectPartContainer>(); + qRegisterMetaTypeStreamOperators<ProjectPartContainer>(); + QMetaType::registerComparators<ProjectPartContainer>(); + + qRegisterMetaType<UnregisterProjectPartsForCodeCompletionCommand>(); + qRegisterMetaTypeStreamOperators<UnregisterProjectPartsForCodeCompletionCommand>(); + QMetaType::registerComparators<UnregisterProjectPartsForCodeCompletionCommand>(); + + qRegisterMetaType<TranslationUnitDoesNotExistCommand>(); + qRegisterMetaTypeStreamOperators<TranslationUnitDoesNotExistCommand>(); + QMetaType::registerComparators<TranslationUnitDoesNotExistCommand>(); + + qRegisterMetaType<ProjectPartsDoNotExistCommand>(); + qRegisterMetaTypeStreamOperators<ProjectPartsDoNotExistCommand>(); + QMetaType::registerComparators<ProjectPartsDoNotExistCommand>(); +} + +} // namespace CodeModelBackEnd + diff --git a/src/libs/codemodelbackendipc/cmbcommands.h b/src/libs/codemodelbackendipc/cmbcommands.h new file mode 100644 index 0000000000..08119d9fdf --- /dev/null +++ b/src/libs/codemodelbackendipc/cmbcommands.h @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifndef CODEMODELBACKEND_COMMANDS_H +#define CODEMODELBACKEND_COMMANDS_H + +#include <codemodelbackendipc_global.h> + +namespace CodeModelBackEnd { + +namespace Commands +{ +CMBIPC_EXPORT void registerCommands(); +} + +} // namespace CodeModelBackEnd + +#endif // CODEMODELBACKEND_COMMANDS_H diff --git a/src/libs/codemodelbackendipc/cmbcompletecodecommand.cpp b/src/libs/codemodelbackendipc/cmbcompletecodecommand.cpp new file mode 100644 index 0000000000..8540bd2038 --- /dev/null +++ b/src/libs/codemodelbackendipc/cmbcompletecodecommand.cpp @@ -0,0 +1,146 @@ +/**************************************************************************** +** +** 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 "cmbcompletecodecommand.h" + +#include <QDebug> + +#include <QDataStream> + +#include <ostream> + +namespace CodeModelBackEnd { + +quint64 CompleteCodeCommand::ticketCounter = 0; + +CompleteCodeCommand::CompleteCodeCommand(const Utf8String &filePath, quint32 line, quint32 column, const Utf8String &projectPartId) + : filePath_(filePath), + projectPartId_(projectPartId), + ticketNumber_(++ticketCounter), + line_(line), + column_(column) +{ +} + +const Utf8String &CompleteCodeCommand::filePath() const +{ + return filePath_; +} + +const Utf8String &CompleteCodeCommand::projectPartId() const +{ + return projectPartId_; +} + +quint32 CompleteCodeCommand::line() const +{ + return line_; +} + +quint32 CompleteCodeCommand::column() const +{ + return column_; +} + +quint64 CompleteCodeCommand::ticketNumber() const +{ + return ticketNumber_; +} + +QDataStream &operator<<(QDataStream &out, const CompleteCodeCommand &command) +{ + out << command.filePath_; + out << command.projectPartId_; + out << command.ticketNumber_; + out << command.line_; + out << command.column_; + + return out; +} + +QDataStream &operator>>(QDataStream &in, CompleteCodeCommand &command) +{ + in >> command.filePath_; + in >> command.projectPartId_; + in >> command.ticketNumber_; + in >> command.line_; + in >> command.column_; + + return in; +} + +bool operator == (const CompleteCodeCommand &first, const CompleteCodeCommand &second) +{ + return first.ticketNumber_ == second.ticketNumber_ + && first.filePath_ == second.filePath_ + && first.projectPartId_ == second.projectPartId_ + && first.line_ == second.line_ + && first.column_ == second.column_; +} + +bool operator < (const CompleteCodeCommand &first, const CompleteCodeCommand &second) +{ + return first.ticketNumber_ < second.ticketNumber_ + && first.filePath_ < second.filePath_ + && first.projectPartId_ < second.projectPartId_ + && first.line_ < second.line_ + && first.column_ < second.column_; +} + +QDebug operator <<(QDebug debug, const CompleteCodeCommand &command) +{ + debug.nospace() << "CompleteCodeCommand("; + + debug.nospace() << command.filePath_ << ", "; + debug.nospace() << command.line_<< ", "; + debug.nospace() << command.column_<< ", "; + debug.nospace() << command.projectPartId_ << ", "; + debug.nospace() << command.ticketNumber_; + + debug.nospace() << ")"; + + return debug; +} + +void PrintTo(const CompleteCodeCommand &command, ::std::ostream* os) +{ + *os << "CompleteCodeCommand("; + + *os << command.filePath_.constData() << ", "; + *os << command.line_ << ", "; + *os << command.column_ << ", "; + *os << command.projectPartId_.constData() << ", "; + *os << command.ticketNumber_; + + *os << ")"; +} + +} // namespace CodeModelBackEnd + diff --git a/src/libs/codemodelbackendipc/cmbcompletecodecommand.h b/src/libs/codemodelbackendipc/cmbcompletecodecommand.h new file mode 100644 index 0000000000..61ccfe5348 --- /dev/null +++ b/src/libs/codemodelbackendipc/cmbcompletecodecommand.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifndef CODEMODELBACKEND_COMPLETECODECOMMAND_H +#define CODEMODELBACKEND_COMPLETECODECOMMAND_H + +#include "codemodelbackendipc_global.h" + +#include <QMetaType> +#include <utf8string.h> + +namespace CodeModelBackEnd { + +class CMBIPC_EXPORT CompleteCodeCommand +{ + friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CompleteCodeCommand &command); + friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CompleteCodeCommand &command); + friend CMBIPC_EXPORT bool operator == (const CompleteCodeCommand &first, const CompleteCodeCommand &second); + friend CMBIPC_EXPORT bool operator < (const CompleteCodeCommand &first, const CompleteCodeCommand &second); + friend CMBIPC_EXPORT QDebug operator <<(QDebug debug, const CompleteCodeCommand &command); + friend void PrintTo(const CompleteCodeCommand &command, ::std::ostream* os); + +public: + CompleteCodeCommand() = default; + CompleteCodeCommand(const Utf8String &filePath, + quint32 line, + quint32 column, + const Utf8String &projectPartId); + + const Utf8String &filePath() const; + const Utf8String &projectPartId() const; + + quint32 line() const; + quint32 column() const; + + quint64 ticketNumber() const; + +private: + Utf8String filePath_; + Utf8String projectPartId_; + static quint64 ticketCounter; + quint64 ticketNumber_; + quint32 line_ = 0; + quint32 column_ = 0; +}; + +CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CompleteCodeCommand &command); +CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CompleteCodeCommand &command); +CMBIPC_EXPORT bool operator == (const CompleteCodeCommand &first, const CompleteCodeCommand &second); +CMBIPC_EXPORT bool operator < (const CompleteCodeCommand &first, const CompleteCodeCommand &second); + +CMBIPC_EXPORT QDebug operator <<(QDebug debug, const CompleteCodeCommand &command); +void PrintTo(const CompleteCodeCommand &command, ::std::ostream* os); + +} // namespace CodeModelBackEnd + +Q_DECLARE_METATYPE(CodeModelBackEnd::CompleteCodeCommand) + +#endif // CODEMODELBACKEND_COMPLETECODECOMMAND_H diff --git a/src/libs/codemodelbackendipc/cmbechocommand.cpp b/src/libs/codemodelbackendipc/cmbechocommand.cpp new file mode 100644 index 0000000000..2fd8ee4eaa --- /dev/null +++ b/src/libs/codemodelbackendipc/cmbechocommand.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** 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 "cmbechocommand.h" + +#include <QtDebug> + +#include <QDataStream> + +#include <ostream> + +namespace CodeModelBackEnd { + +EchoCommand::EchoCommand(const QVariant &command) + : command_(command) +{ + +} + +const QVariant &EchoCommand::command() const +{ + return command_; +} + +QDataStream &operator<<(QDataStream &out, const EchoCommand &command) +{ + out << command.command(); + + return out; +} + +QDataStream &operator>>(QDataStream &in, EchoCommand &command) +{ + in >> command.command_; + + return in; +} + +bool operator == (const EchoCommand &first, const EchoCommand &second) +{ + return first.command_ == second.command_; +} + +bool operator < (const EchoCommand &first, const EchoCommand &second) +{ + return first.command_ < second.command_; +} + +QDebug operator <<(QDebug debug, const EchoCommand &command) +{ + return debug.nospace() << "EchoCommand(" << command.command() << ")"; +} + +void PrintTo(const EchoCommand &command, ::std::ostream* os) +{ + QString output; + QDebug debug(&output); + + debug << command; + + *os << output.toUtf8().constData(); +} + +} // namespace CodeModelBackEnd + diff --git a/src/libs/codemodelbackendipc/cmbechocommand.h b/src/libs/codemodelbackendipc/cmbechocommand.h new file mode 100644 index 0000000000..c5f0572ad4 --- /dev/null +++ b/src/libs/codemodelbackendipc/cmbechocommand.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifndef CODEMODELBACKEND_ECHOCOMMAND_H +#define CODEMODELBACKEND_ECHOCOMMAND_H + +#include "codemodelbackendipc_global.h" + +#include <QMetaType> +#include <QVariant> + +namespace CodeModelBackEnd { + +class CMBIPC_EXPORT EchoCommand +{ + friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, EchoCommand &command); + friend CMBIPC_EXPORT bool operator == (const EchoCommand &first, const EchoCommand &second); + friend CMBIPC_EXPORT bool operator < (const EchoCommand &first, const EchoCommand &second); +public: + EchoCommand() = default; + explicit EchoCommand(const QVariant &command); + + const QVariant &command() const; + +private: + QVariant command_; +}; + +CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const EchoCommand &command); +CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, EchoCommand &command); +CMBIPC_EXPORT bool operator == (const EchoCommand &first, const EchoCommand &second); +CMBIPC_EXPORT bool operator < (const EchoCommand &first, const EchoCommand &second); + +CMBIPC_EXPORT QDebug operator <<(QDebug debug, const EchoCommand &command); +void PrintTo(const EchoCommand &command, ::std::ostream* os); + +} // namespace CodeModelBackEnd + +Q_DECLARE_METATYPE(CodeModelBackEnd::EchoCommand) + +#endif // CODEMODELBACKEND_ECHOCOMMAND_H diff --git a/src/libs/codemodelbackendipc/cmbendcommand.cpp b/src/libs/codemodelbackendipc/cmbendcommand.cpp new file mode 100644 index 0000000000..9c95b4a846 --- /dev/null +++ b/src/libs/codemodelbackendipc/cmbendcommand.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** 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 "cmbendcommand.h" + +#include <QtDebug> + +#include <QDataStream> + +#include <ostream> + +namespace CodeModelBackEnd { + +QDataStream &operator<<(QDataStream &out, const EndCommand &/*command*/) +{ + return out; +} + +QDataStream &operator>>(QDataStream &in, EndCommand &/*command*/) +{ + return in; +} + +bool operator == (const EndCommand &/*first*/, const EndCommand &/*second*/) +{ + return true; +} + +bool operator < (const EndCommand &/*first*/, const EndCommand &/*second*/) +{ + return true; +} + +QDebug operator <<(QDebug debug, const EndCommand &/*command*/) +{ + return debug.nospace() << "EndCommand()"; +} + +void PrintTo(const EndCommand &/*command*/, ::std::ostream* os) +{ + *os << "EndCommand()"; +} +} + diff --git a/src/libs/codemodelbackendipc/cmbendcommand.h b/src/libs/codemodelbackendipc/cmbendcommand.h new file mode 100644 index 0000000000..0c0c7bf43d --- /dev/null +++ b/src/libs/codemodelbackendipc/cmbendcommand.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifndef CMBENDCOMMAND_H +#define CMBENDCOMMAND_H + +#include "codemodelbackendipc_global.h" + +#include <QMetaType> + +namespace CodeModelBackEnd { + +class CMBIPC_EXPORT EndCommand +{ +}; + +CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const EndCommand &command); +CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, EndCommand &command); +CMBIPC_EXPORT bool operator == (const EndCommand &first, const EndCommand &second); +CMBIPC_EXPORT bool operator < (const EndCommand &first, const EndCommand &second); + +CMBIPC_EXPORT QDebug operator <<(QDebug debug, const EndCommand &command); +void PrintTo(const EndCommand &command, ::std::ostream* os); +} + +Q_DECLARE_METATYPE(CodeModelBackEnd::EndCommand) + +#endif // CMBENDCOMMAND_H diff --git a/src/libs/codemodelbackendipc/cmbregisterprojectsforcodecompletioncommand.cpp b/src/libs/codemodelbackendipc/cmbregisterprojectsforcodecompletioncommand.cpp new file mode 100644 index 0000000000..a2bd64cb0c --- /dev/null +++ b/src/libs/codemodelbackendipc/cmbregisterprojectsforcodecompletioncommand.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** 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 "cmbregisterprojectsforcodecompletioncommand.h" + +#include <QtDebug> + +#include <QDataStream> + +#include <ostream> + +namespace CodeModelBackEnd { + +RegisterProjectPartsForCodeCompletionCommand::RegisterProjectPartsForCodeCompletionCommand(const QVector<ProjectPartContainer> &projectContainers) + :projectContainers_(projectContainers) +{ +} + +const QVector<ProjectPartContainer> &RegisterProjectPartsForCodeCompletionCommand::projectContainers() const +{ + return projectContainers_; +} + +QDataStream &operator<<(QDataStream &out, const RegisterProjectPartsForCodeCompletionCommand &command) +{ + out << command.projectContainers_; + + return out; +} + +QDataStream &operator>>(QDataStream &in, RegisterProjectPartsForCodeCompletionCommand &command) +{ + in >> command.projectContainers_; + + return in; +} + +bool operator == (const RegisterProjectPartsForCodeCompletionCommand &first, const RegisterProjectPartsForCodeCompletionCommand &second) +{ + return first.projectContainers_ == second.projectContainers_; +} + +bool operator < (const RegisterProjectPartsForCodeCompletionCommand &first, const RegisterProjectPartsForCodeCompletionCommand &second) +{ + return first.projectContainers_ < second.projectContainers_; +} + +QDebug operator <<(QDebug debug, const RegisterProjectPartsForCodeCompletionCommand &command) +{ + debug.nospace() << "RegisterProjectPartsForCodeCompletion("; + + for (const ProjectPartContainer &projectContainer : command.projectContainers()) + debug.nospace() << projectContainer<< ", "; + + debug.nospace() << ")"; + + return debug; +} + +void PrintTo(const RegisterProjectPartsForCodeCompletionCommand &command, ::std::ostream* os) +{ + *os << "RegisterProjectPartsForCodeCompletion("; + + for (const ProjectPartContainer &projectContainer : command.projectContainers()) + PrintTo(projectContainer, os); + + *os << ")"; +} + +} // namespace CodeModelBackEnd + diff --git a/src/libs/codemodelbackendipc/cmbregisterprojectsforcodecompletioncommand.h b/src/libs/codemodelbackendipc/cmbregisterprojectsforcodecompletioncommand.h new file mode 100644 index 0000000000..95990f9cf9 --- /dev/null +++ b/src/libs/codemodelbackendipc/cmbregisterprojectsforcodecompletioncommand.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifndef CODEMODELBACKEND_REGISTERPROJECTSFORCODECOMPLETIONCOMAND_H +#define CODEMODELBACKEND_REGISTERPROJECTSFORCODECOMPLETIONCOMAND_H + +#include <QMetaType> +#include <QVector> + +#include "projectpartcontainer.h" + +namespace CodeModelBackEnd { + +class CMBIPC_EXPORT RegisterProjectPartsForCodeCompletionCommand +{ + friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RegisterProjectPartsForCodeCompletionCommand &command); + friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RegisterProjectPartsForCodeCompletionCommand &command); + friend CMBIPC_EXPORT bool operator == (const RegisterProjectPartsForCodeCompletionCommand &first, const RegisterProjectPartsForCodeCompletionCommand &second); + friend CMBIPC_EXPORT bool operator < (const RegisterProjectPartsForCodeCompletionCommand &first, const RegisterProjectPartsForCodeCompletionCommand &second); + friend void PrintTo(const RegisterProjectPartsForCodeCompletionCommand &command, ::std::ostream* os); +public: + RegisterProjectPartsForCodeCompletionCommand() = default; + RegisterProjectPartsForCodeCompletionCommand(const QVector<ProjectPartContainer> &projectContainers); + + const QVector<ProjectPartContainer> &projectContainers() const; + +private: + QVector<ProjectPartContainer> projectContainers_; +}; + +CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RegisterProjectPartsForCodeCompletionCommand &command); +CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RegisterProjectPartsForCodeCompletionCommand &command); +CMBIPC_EXPORT bool operator == (const RegisterProjectPartsForCodeCompletionCommand &first, const RegisterProjectPartsForCodeCompletionCommand &second); +CMBIPC_EXPORT bool operator < (const RegisterProjectPartsForCodeCompletionCommand &first, const RegisterProjectPartsForCodeCompletionCommand &second); + +CMBIPC_EXPORT QDebug operator <<(QDebug debug, const RegisterProjectPartsForCodeCompletionCommand &command); +void PrintTo(const RegisterProjectPartsForCodeCompletionCommand &command, ::std::ostream* os); +} // namespace CodeModelBackEnd + +Q_DECLARE_METATYPE(CodeModelBackEnd::RegisterProjectPartsForCodeCompletionCommand) + +#endif // CODEMODELBACKEND_REGISTERPROJECTSFORCODECOMPLETIONCOMAND_H diff --git a/src/libs/codemodelbackendipc/cmbregistertranslationunitsforcodecompletioncommand.cpp b/src/libs/codemodelbackendipc/cmbregistertranslationunitsforcodecompletioncommand.cpp new file mode 100644 index 0000000000..495b6ccf2b --- /dev/null +++ b/src/libs/codemodelbackendipc/cmbregistertranslationunitsforcodecompletioncommand.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** 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 "cmbregistertranslationunitsforcodecompletioncommand.h" + +#include <QtDebug> + +#include <QDataStream> + +#include <ostream> + +namespace CodeModelBackEnd { + +RegisterTranslationUnitForCodeCompletionCommand::RegisterTranslationUnitForCodeCompletionCommand(const QVector<FileContainer> &fileContainers) + : fileContainers_(fileContainers) +{ +} + +const QVector<FileContainer> &RegisterTranslationUnitForCodeCompletionCommand::fileContainers() const +{ + return fileContainers_; +} + +QDataStream &operator<<(QDataStream &out, const RegisterTranslationUnitForCodeCompletionCommand &command) +{ + out << command.fileContainers_; + + return out; +} + +QDataStream &operator>>(QDataStream &in, RegisterTranslationUnitForCodeCompletionCommand &command) +{ + in >> command.fileContainers_; + + return in; +} + +bool operator == (const RegisterTranslationUnitForCodeCompletionCommand &first, const RegisterTranslationUnitForCodeCompletionCommand &second) +{ + return first.fileContainers_ == second.fileContainers_; +} + +bool operator < (const RegisterTranslationUnitForCodeCompletionCommand &first, const RegisterTranslationUnitForCodeCompletionCommand &second) +{ + return first.fileContainers_ < second.fileContainers_; +} + +QDebug operator <<(QDebug debug, const RegisterTranslationUnitForCodeCompletionCommand &command) +{ + debug.nospace() << "RegisterTranslationUnitForCodeCompletionCommand("; + + for (const FileContainer &fileContainer : command.fileContainers()) + debug.nospace() << fileContainer<< ", "; + + debug.nospace() << ")"; + + return debug; +} + +void PrintTo(const RegisterTranslationUnitForCodeCompletionCommand &command, ::std::ostream* os) +{ + *os << "RegisterTranslationUnitForCodeCompletionCommand("; + + for (const FileContainer &fileContainer : command.fileContainers()) + PrintTo(fileContainer, os); + + *os << ")"; +} + +} // namespace CodeModelBackEnd + diff --git a/src/libs/codemodelbackendipc/cmbregistertranslationunitsforcodecompletioncommand.h b/src/libs/codemodelbackendipc/cmbregistertranslationunitsforcodecompletioncommand.h new file mode 100644 index 0000000000..59c62e18fd --- /dev/null +++ b/src/libs/codemodelbackendipc/cmbregistertranslationunitsforcodecompletioncommand.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifndef CODEMODELBACKEND_REGISTERFILEFORCODECOMPLETION_H +#define CODEMODELBACKEND_REGISTERFILEFORCODECOMPLETION_H + +#include <qmetatype.h> + +#include <QVector> +#include "filecontainer.h" + +namespace CodeModelBackEnd { + +class CMBIPC_EXPORT RegisterTranslationUnitForCodeCompletionCommand +{ + friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RegisterTranslationUnitForCodeCompletionCommand &command); + friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RegisterTranslationUnitForCodeCompletionCommand &command); + friend CMBIPC_EXPORT bool operator == (const RegisterTranslationUnitForCodeCompletionCommand &first, const RegisterTranslationUnitForCodeCompletionCommand &second); + friend CMBIPC_EXPORT bool operator < (const RegisterTranslationUnitForCodeCompletionCommand &first, const RegisterTranslationUnitForCodeCompletionCommand &second); + friend void PrintTo(const RegisterTranslationUnitForCodeCompletionCommand &command, ::std::ostream* os); +public: + RegisterTranslationUnitForCodeCompletionCommand() = default; + RegisterTranslationUnitForCodeCompletionCommand(const QVector<FileContainer> &fileContainers); + + const QVector<FileContainer> &fileContainers() const; + +private: + QVector<FileContainer> fileContainers_; +}; + +CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RegisterTranslationUnitForCodeCompletionCommand &command); +CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RegisterTranslationUnitForCodeCompletionCommand &command); +CMBIPC_EXPORT bool operator == (const RegisterTranslationUnitForCodeCompletionCommand &first, const RegisterTranslationUnitForCodeCompletionCommand &second); +CMBIPC_EXPORT bool operator < (const RegisterTranslationUnitForCodeCompletionCommand &first, const RegisterTranslationUnitForCodeCompletionCommand &second); + +CMBIPC_EXPORT QDebug operator <<(QDebug debug, const RegisterTranslationUnitForCodeCompletionCommand &command); +void PrintTo(const RegisterTranslationUnitForCodeCompletionCommand &command, ::std::ostream* os); +} // namespace CodeModelBackEnd + +Q_DECLARE_METATYPE(CodeModelBackEnd::RegisterTranslationUnitForCodeCompletionCommand) + +#endif // CODEMODELBACKEND_REGISTERFILEFORCODECOMPLITION_H diff --git a/src/libs/codemodelbackendipc/cmbunregisterprojectsforcodecompletioncommand.cpp b/src/libs/codemodelbackendipc/cmbunregisterprojectsforcodecompletioncommand.cpp new file mode 100644 index 0000000000..8145b1808d --- /dev/null +++ b/src/libs/codemodelbackendipc/cmbunregisterprojectsforcodecompletioncommand.cpp @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** 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 "cmbunregisterprojectsforcodecompletioncommand.h" + +#include <QtDebug> + +#include <QDataStream> + +#include <ostream> + +namespace CodeModelBackEnd { + + +UnregisterProjectPartsForCodeCompletionCommand::UnregisterProjectPartsForCodeCompletionCommand(const Utf8StringVector &filePaths) + : filePaths_(filePaths) +{ +} + +const Utf8StringVector &UnregisterProjectPartsForCodeCompletionCommand::filePaths() const +{ + return filePaths_; +} + +QDataStream &operator<<(QDataStream &out, const UnregisterProjectPartsForCodeCompletionCommand &command) +{ + out << command.filePaths_; + + return out; +} + +QDataStream &operator>>(QDataStream &in, UnregisterProjectPartsForCodeCompletionCommand &command) +{ + in >> command.filePaths_; + + return in; +} + +bool operator == (const UnregisterProjectPartsForCodeCompletionCommand &first, const UnregisterProjectPartsForCodeCompletionCommand &second) +{ + return first.filePaths_ == second.filePaths_; +} + +bool operator < (const UnregisterProjectPartsForCodeCompletionCommand &first, const UnregisterProjectPartsForCodeCompletionCommand &second) +{ + return first.filePaths_ < second.filePaths_; +} + +QDebug operator <<(QDebug debug, const UnregisterProjectPartsForCodeCompletionCommand &command) +{ + debug.nospace() << "UnregisterProjectPartsForCodeCompletionCommand("; + + for (const Utf8String &fileNames_ : command.filePaths()) + debug.nospace() << fileNames_ << ", "; + + debug.nospace() << ")"; + + return debug; +} + +void PrintTo(const UnregisterProjectPartsForCodeCompletionCommand &command, ::std::ostream* os) +{ + *os << "UnregisterProjectPartsForCodeCompletionCommand("; + + for (const Utf8String &fileNames_ : command.filePaths()) + *os << fileNames_.constData() << ", "; + + *os << ")"; +} + +} // namespace CodeModelBackEnd + diff --git a/src/libs/codemodelbackendipc/cmbunregisterprojectsforcodecompletioncommand.h b/src/libs/codemodelbackendipc/cmbunregisterprojectsforcodecompletioncommand.h new file mode 100644 index 0000000000..61fa3c3c13 --- /dev/null +++ b/src/libs/codemodelbackendipc/cmbunregisterprojectsforcodecompletioncommand.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifndef CODEMODELBACKEND_UNREGISTERPROJECTSFORCODECOMPLETION_H +#define CODEMODELBACKEND_UNREGISTERPROJECTSFORCODECOMPLETION_H + +#include "codemodelbackendipc_global.h" + +#include <utf8stringvector.h> + +#include <QMetaType> + +namespace CodeModelBackEnd { + +class CMBIPC_EXPORT UnregisterProjectPartsForCodeCompletionCommand +{ + friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UnregisterProjectPartsForCodeCompletionCommand &command); + friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UnregisterProjectPartsForCodeCompletionCommand &command); + friend CMBIPC_EXPORT bool operator == (const UnregisterProjectPartsForCodeCompletionCommand &first, const UnregisterProjectPartsForCodeCompletionCommand &second); + friend CMBIPC_EXPORT bool operator < (const UnregisterProjectPartsForCodeCompletionCommand &first, const UnregisterProjectPartsForCodeCompletionCommand &second); + friend void PrintTo(const UnregisterProjectPartsForCodeCompletionCommand &command, ::std::ostream* os); + +public: + UnregisterProjectPartsForCodeCompletionCommand() = default; + UnregisterProjectPartsForCodeCompletionCommand(const Utf8StringVector &filePaths); + + const Utf8StringVector &filePaths() const; + +private: + Utf8StringVector filePaths_; +}; + +CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UnregisterProjectPartsForCodeCompletionCommand &command); +CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UnregisterProjectPartsForCodeCompletionCommand &command); +CMBIPC_EXPORT bool operator == (const UnregisterProjectPartsForCodeCompletionCommand &first, const UnregisterProjectPartsForCodeCompletionCommand &second); +CMBIPC_EXPORT bool operator < (const UnregisterProjectPartsForCodeCompletionCommand &first, const UnregisterProjectPartsForCodeCompletionCommand &second); + +CMBIPC_EXPORT QDebug operator <<(QDebug debug, const UnregisterProjectPartsForCodeCompletionCommand &command); +void PrintTo(const UnregisterProjectPartsForCodeCompletionCommand &command, ::std::ostream* os); +} // namespace CodeModelBackEnd + +Q_DECLARE_METATYPE(CodeModelBackEnd::UnregisterProjectPartsForCodeCompletionCommand) + +#endif // CODEMODELBACKEND_UNREGISTERPROJECTSFORCODECOMPLETION_H diff --git a/src/libs/codemodelbackendipc/cmbunregistertranslationunitsforcodecompletioncommand.cpp b/src/libs/codemodelbackendipc/cmbunregistertranslationunitsforcodecompletioncommand.cpp new file mode 100644 index 0000000000..ed9f9697b2 --- /dev/null +++ b/src/libs/codemodelbackendipc/cmbunregistertranslationunitsforcodecompletioncommand.cpp @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** 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 "cmbunregistertranslationunitsforcodecompletioncommand.h" + +#include <QtDebug> + +#ifdef CODEMODELBACKEND_TESTS +#include <gtest/gtest-printers.h> +#endif + +#include <QDataStream> + +namespace CodeModelBackEnd { + + +UnregisterTranslationUnitsForCodeCompletionCommand::UnregisterTranslationUnitsForCodeCompletionCommand(const QVector<FileContainer> &fileContainers) + : fileContainers_(fileContainers) +{ +} + +const QVector<FileContainer> &UnregisterTranslationUnitsForCodeCompletionCommand::fileContainers() const +{ + return fileContainers_; +} + +QDataStream &operator<<(QDataStream &out, const UnregisterTranslationUnitsForCodeCompletionCommand &command) +{ + out << command.fileContainers_; + + return out; +} + +QDataStream &operator>>(QDataStream &in, UnregisterTranslationUnitsForCodeCompletionCommand &command) +{ + in >> command.fileContainers_; + + return in; +} + +bool operator == (const UnregisterTranslationUnitsForCodeCompletionCommand &first, const UnregisterTranslationUnitsForCodeCompletionCommand &second) +{ + return first.fileContainers_ == second.fileContainers_; +} + +bool operator < (const UnregisterTranslationUnitsForCodeCompletionCommand &first, const UnregisterTranslationUnitsForCodeCompletionCommand &second) +{ + return first.fileContainers_ < second.fileContainers_; +} + +QDebug operator <<(QDebug debug, const UnregisterTranslationUnitsForCodeCompletionCommand &command) +{ + debug.nospace() << "UnregisterTranslationUnitsForCodeCompletionCommand("; + + for (const FileContainer &fileContainer : command.fileContainers()) + debug.nospace() << fileContainer << ", "; + + debug.nospace() << ")"; + + return debug; +} + +#ifdef CODEMODELBACKEND_TESTS +void PrintTo(const UnregisterTranslationUnitsForCodeCompletionCommand &command, ::std::ostream* os) +{ + *os << "UnregisterTranslationUnitsForCodeCompletionCommand("; + + for (const FileContainer &fileContainer : command.fileContainers()) + *os << ::testing::PrintToString(fileContainer) << ", "; + + *os << ")"; +} +#endif + + +} // namespace CodeModelBackEnd + diff --git a/src/libs/codemodelbackendipc/cmbunregistertranslationunitsforcodecompletioncommand.h b/src/libs/codemodelbackendipc/cmbunregistertranslationunitsforcodecompletioncommand.h new file mode 100644 index 0000000000..d9b0f056bf --- /dev/null +++ b/src/libs/codemodelbackendipc/cmbunregistertranslationunitsforcodecompletioncommand.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifndef CODEMODELBACKEND_UNRegisterTranslationUnitForCodeCompletionCommand_H +#define CODEMODELBACKEND_UNRegisterTranslationUnitForCodeCompletionCommand_H + +#include "codemodelbackendipc_global.h" + +#include "filecontainer.h" + +#include <QVector> +#include <QMetaType> + +namespace CodeModelBackEnd { + +class CMBIPC_EXPORT UnregisterTranslationUnitsForCodeCompletionCommand +{ + friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UnregisterTranslationUnitsForCodeCompletionCommand &command); + friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UnregisterTranslationUnitsForCodeCompletionCommand &command); + friend CMBIPC_EXPORT bool operator == (const UnregisterTranslationUnitsForCodeCompletionCommand &first, const UnregisterTranslationUnitsForCodeCompletionCommand &second); + friend CMBIPC_EXPORT bool operator < (const UnregisterTranslationUnitsForCodeCompletionCommand &first, const UnregisterTranslationUnitsForCodeCompletionCommand &second); + friend void PrintTo(const UnregisterTranslationUnitsForCodeCompletionCommand &command, ::std::ostream* os); + +public: + UnregisterTranslationUnitsForCodeCompletionCommand() = default; + UnregisterTranslationUnitsForCodeCompletionCommand(const QVector<FileContainer> &fileContainers); + + const QVector<FileContainer> &fileContainers() const; + +private: + QVector<FileContainer> fileContainers_; +}; + +CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UnregisterTranslationUnitsForCodeCompletionCommand &command); +CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UnregisterTranslationUnitsForCodeCompletionCommand &command); +CMBIPC_EXPORT bool operator == (const UnregisterTranslationUnitsForCodeCompletionCommand &first, const UnregisterTranslationUnitsForCodeCompletionCommand &second); +CMBIPC_EXPORT bool operator < (const UnregisterTranslationUnitsForCodeCompletionCommand &first, const UnregisterTranslationUnitsForCodeCompletionCommand &second); + +CMBIPC_EXPORT QDebug operator <<(QDebug debug, const UnregisterTranslationUnitsForCodeCompletionCommand &command); +#ifdef CODEMODELBACKEND_TESTS +void PrintTo(const UnregisterTranslationUnitsForCodeCompletionCommand &command, ::std::ostream* os); +#endif +} // namespace CodeModelBackEnd + +Q_DECLARE_METATYPE(CodeModelBackEnd::UnregisterTranslationUnitsForCodeCompletionCommand) + +#endif // CODEMODELBACKEND_UNRegisterTranslationUnitForCodeCompletionCommand_H diff --git a/src/libs/codemodelbackendipc/codecompletion.cpp b/src/libs/codemodelbackendipc/codecompletion.cpp new file mode 100644 index 0000000000..ff5fc65a28 --- /dev/null +++ b/src/libs/codemodelbackendipc/codecompletion.cpp @@ -0,0 +1,255 @@ +/**************************************************************************** +** +** 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 "codecompletion.h" + +#include <QDebug> + +#include <QDataStream> + +#include <ostream> + +namespace CodeModelBackEnd { + +CodeCompletion::CodeCompletion(const Utf8String &text, + const Utf8String &hint, + const Utf8String &snippet, + quint32 priority, + Kind completionKind, + Availability availability, + bool hasParameters) + : text_(text), + hint_(hint), + snippet_(snippet), + priority_(priority), + completionKind_(completionKind), + availability_(availability), + hasParameters_(hasParameters) +{ +} + +void CodeCompletion::setText(const Utf8String &text) +{ + text_ = text; +} + +const Utf8String &CodeCompletion::text() const +{ + return text_; +} +const Utf8String &CodeCompletion::hint() const +{ + return hint_; +} + +const Utf8String &CodeCompletion::snippet() const +{ + return snippet_; +} + +void CodeCompletion::setCompletionKind(CodeCompletion::Kind completionKind) +{ + completionKind_ = completionKind; +} + +CodeCompletion::Kind CodeCompletion::completionKind() const +{ + return completionKind_; +} + +void CodeCompletion::setChunks(const QVector<CodeCompletionChunk> &chunks) +{ + chunks_ = chunks; +} + +const QVector<CodeCompletionChunk> &CodeCompletion::chunks() const +{ + return chunks_; +} + +void CodeCompletion::setAvailability(CodeCompletion::Availability availability) +{ + availability_ = availability; +} + +CodeCompletion::Availability CodeCompletion::availability() const +{ + return availability_; +} + +void CodeCompletion::setHasParameters(bool hasParameters) +{ + hasParameters_ = hasParameters; +} + +bool CodeCompletion::hasParameters() const +{ + return hasParameters_; +} + +void CodeCompletion::setPriority(quint32 priority) +{ + priority_ = priority; +} + +quint32 CodeCompletion::priority() const +{ + return priority_; +} + +quint32 &CodeCompletion::completionKindAsInt() +{ + return reinterpret_cast<quint32&>(completionKind_); +} + +quint32 &CodeCompletion::availabilityAsInt() +{ + return reinterpret_cast<quint32&>(availability_); +} + +QDataStream &operator<<(QDataStream &out, const CodeCompletion &command) +{ + out << command.text_; + out << command.hint_; + out << command.snippet_; + out << command.chunks_; + out << command.priority_; + out << command.completionKind_; + out << command.availability_; + out << command.hasParameters_; + + return out; +} + +QDataStream &operator>>(QDataStream &in, CodeCompletion &command) +{ + in >> command.text_; + in >> command.hint_; + in >> command.snippet_; + in >> command.chunks_; + in >> command.priority_; + in >> command.completionKindAsInt(); + in >> command.availabilityAsInt(); + in >> command.hasParameters_; + + return in; +} + +bool operator == (const CodeCompletion &first, const CodeCompletion &second) +{ + return first.text_ == second.text_ + && first.completionKind_ == second.completionKind_; +} + +bool operator < (const CodeCompletion &first, const CodeCompletion &second) +{ + return first.text_ < second.text_; +} + +static const char *completionKindToString(CodeCompletion::Kind kind) +{ + switch (kind) { + case CodeCompletion::Other: return "Other"; + case CodeCompletion::FunctionCompletionKind: return "Function"; + case CodeCompletion::TemplateFunctionCompletionKind: return "TemplateFunction"; + case CodeCompletion::ConstructorCompletionKind: return "Constructor"; + case CodeCompletion::DestructorCompletionKind: return "Destructor"; + case CodeCompletion::VariableCompletionKind: return "Variable"; + case CodeCompletion::ClassCompletionKind: return "Class"; + case CodeCompletion::TemplateClassCompletionKind: return "TemplateClass"; + case CodeCompletion::EnumerationCompletionKind: return "Enumeration"; + case CodeCompletion::EnumeratorCompletionKind: return "Enumerator"; + case CodeCompletion::NamespaceCompletionKind: return "Namespace"; + case CodeCompletion::PreProcessorCompletionKind: return "PreProcessor"; + case CodeCompletion::SignalCompletionKind: return "Signal"; + case CodeCompletion::SlotCompletionKind: return "Slot"; + case CodeCompletion::ObjCMessageCompletionKind: return "ObjCMessage"; + case CodeCompletion::KeywordCompletionKind: return "Keyword"; + case CodeCompletion::ClangSnippetKind: return "ClangSnippet"; + } + + return nullptr; +} + +static const char *availabilityToString(CodeCompletion::Availability availability) +{ + switch (availability) { + case CodeCompletion::Available: return "Available"; + case CodeCompletion::Deprecated: return "Deprecated"; + case CodeCompletion::NotAvailable: return "NotAvailable"; + case CodeCompletion::NotAccessible: return "NotAccessible"; + } + return nullptr; +} + +QDebug operator <<(QDebug debug, const CodeCompletion &command) +{ + debug.nospace() << "CodeCompletion("; + + debug.nospace() << command.text_ << ", "; + debug.nospace() << command.hint_ << ", "; + debug.nospace() << command.snippet_ << ", "; + debug.nospace() << command.priority_ << ", "; + debug.nospace() << completionKindToString(command.completionKind_) << ", "; + debug.nospace() << availabilityToString(command.availability_) << ", "; + debug.nospace() << command.hasParameters_; + + debug.nospace() << ")"; + + return debug; +} + +void PrintTo(const CodeCompletion &command, ::std::ostream* os) +{ + *os << "CodeCompletion("; + + *os << command.text_.constData() << ", "; + *os << command.hint_.constData() << ", "; + *os << command.snippet_.constData() << ", "; + *os << command.priority_ << ", "; + *os << completionKindToString(command.completionKind_) << ", "; + *os << availabilityToString(command.availability_) << ", "; + *os << command.hasParameters_; + + *os << ")"; +} + +void PrintTo(CodeCompletion::Kind kind, ::std::ostream *os) +{ + *os << completionKindToString(kind); +} + +void PrintTo(CodeCompletion::Availability availability, std::ostream *os) +{ + *os << availabilityToString(availability); +} + +} // namespace CodeModelBackEnd + diff --git a/src/libs/codemodelbackendipc/codecompletion.h b/src/libs/codemodelbackendipc/codecompletion.h new file mode 100644 index 0000000000..e847c7e2dd --- /dev/null +++ b/src/libs/codemodelbackendipc/codecompletion.h @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifndef CODEMODELBACKEND_CODECOMPLETION_H +#define CODEMODELBACKEND_CODECOMPLETION_H + +#include <QMetaType> +#include <utf8string.h> + +#include "codecompletionchunk.h" + +#include "codemodelbackendipc_global.h" + +namespace CodeModelBackEnd { + +class CMBIPC_EXPORT CodeCompletion +{ + friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CodeCompletion &command); + friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CodeCompletion &command); + 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 void PrintTo(const CodeCompletion &command, ::std::ostream* os); + +public: + enum Kind : quint32 { + Other = 0, + FunctionCompletionKind, + TemplateFunctionCompletionKind, + ConstructorCompletionKind, + DestructorCompletionKind, + VariableCompletionKind, + ClassCompletionKind, + TemplateClassCompletionKind, + EnumerationCompletionKind, + EnumeratorCompletionKind, + NamespaceCompletionKind, + PreProcessorCompletionKind, + SignalCompletionKind, + SlotCompletionKind, + ObjCMessageCompletionKind, + KeywordCompletionKind, + ClangSnippetKind + }; + + enum Availability : quint32 { + Available, + Deprecated, + NotAvailable, + NotAccessible + }; + +public: + CodeCompletion() = default; + CodeCompletion(const Utf8String &text, + const Utf8String &hint = Utf8String(), + const Utf8String &snippet = Utf8String(), + quint32 priority = 0, + Kind completionKind = Other, + Availability availability = Available, + bool hasParameters = false); + + void setText(const Utf8String &text); + const Utf8String &text() const; + + const Utf8String &hint() const; + const Utf8String &snippet() const; + + void setCompletionKind(Kind completionKind); + Kind completionKind() const; + + void setChunks(const QVector<CodeCompletionChunk> &chunks); + const QVector<CodeCompletionChunk> &chunks() const; + + void setAvailability(Availability availability); + Availability availability() const; + + void setHasParameters(bool hasParameters); + bool hasParameters() const; + + void setPriority(quint32 priority); + quint32 priority() const; + +private: + quint32 &completionKindAsInt(); + quint32 &availabilityAsInt(); + +private: + Utf8String text_; + Utf8String hint_; + Utf8String snippet_; + QVector<CodeCompletionChunk> chunks_; + quint32 priority_ = 0; + Kind completionKind_ = Other; + Availability availability_ = NotAvailable; + bool hasParameters_ = false; +}; + +CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CodeCompletion &command); +CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CodeCompletion &command); +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, CodeCompletion::Kind kind); + +void PrintTo(const CodeCompletion &command, ::std::ostream* os); +void PrintTo(CodeCompletion::Kind kind, ::std::ostream *os); +void PrintTo(CodeCompletion::Availability availability, ::std::ostream *os); +} // namespace CodeModelBackEnd + +Q_DECLARE_METATYPE(CodeModelBackEnd::CodeCompletion) + +#endif // CODEMODELBACKEND_CODECOMPLETION_H diff --git a/src/libs/codemodelbackendipc/codecompletionchunk.cpp b/src/libs/codemodelbackendipc/codecompletionchunk.cpp new file mode 100644 index 0000000000..fbe5ca1d6e --- /dev/null +++ b/src/libs/codemodelbackendipc/codecompletionchunk.cpp @@ -0,0 +1,178 @@ +/**************************************************************************** +** +** 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 "codecompletionchunk.h" + +#include <QDataStream> + +#include <QDebug> + +#include <ostream> + +namespace CodeModelBackEnd { + +CodeCompletionChunk::CodeCompletionChunk() + : kind_(Invalid) +{ +} + +CodeCompletionChunk::CodeCompletionChunk(CodeCompletionChunk::Kind kind, + const Utf8String &text, + const QVector<CodeCompletionChunk> &optionalChunks) + : text_(text), + optionalChunks_(optionalChunks), + kind_(kind) +{ +} + +CodeCompletionChunk::Kind CodeCompletionChunk::kind() const +{ + return kind_; +} + +const Utf8String &CodeCompletionChunk::text() const +{ + return text_; +} + +const QVector<CodeCompletionChunk> &CodeCompletionChunk::optionalChunks() const +{ + return optionalChunks_; +} + +quint32 &CodeCompletionChunk::kindAsInt() +{ + return reinterpret_cast<quint32&>(kind_); +} + +QDataStream &operator <<(QDataStream &out, const CodeCompletionChunk &chunk) +{ + out << chunk.kind_; + out << chunk.text_; + + if (chunk.kind() == CodeCompletionChunk::Optional) + out << chunk.optionalChunks_; + + return out; +} + +QDataStream &operator >>(QDataStream &in, CodeCompletionChunk &chunk) +{ + in >> chunk.kindAsInt(); + in >> chunk.text_; + + if (chunk.kind_ == CodeCompletionChunk::Optional) + in >> chunk.optionalChunks_; + + return in; +} + +bool operator ==(const CodeCompletionChunk &first, const CodeCompletionChunk &second) +{ + return first.kind() == second.kind() + && first.text() == second.text() + && first.optionalChunks() == second.optionalChunks(); +} + +static const char *completionChunkKindToString(CodeCompletionChunk::Kind kind) +{ + switch (kind) { + case CodeCompletionChunk::Optional: return "Optional"; + case CodeCompletionChunk::TypedText: return "TypedText"; + case CodeCompletionChunk::Text: return "Text"; + case CodeCompletionChunk::Placeholder: return "Placeholder"; + case CodeCompletionChunk::Informative: return "Informative"; + case CodeCompletionChunk::CurrentParameter: return "CurrentParameter"; + case CodeCompletionChunk::LeftParen: return "LeftParen"; + case CodeCompletionChunk::RightParen: return "RightParen"; + case CodeCompletionChunk::LeftBracket: return "LeftBracket"; + case CodeCompletionChunk::RightBracket: return "RightBracket"; + case CodeCompletionChunk::LeftBrace: return "LeftBrace"; + case CodeCompletionChunk::RightBrace: return "RightBrace"; + case CodeCompletionChunk::LeftAngle: return "LeftAngle"; + case CodeCompletionChunk::RightAngle: return "RightAngle"; + case CodeCompletionChunk::Comma: return "Comma"; + case CodeCompletionChunk::ResultType: return "ResultType"; + case CodeCompletionChunk::Colon: return "Colon"; + case CodeCompletionChunk::SemiColon: return "SemiColon"; + case CodeCompletionChunk::Equal: return "Equal"; + case CodeCompletionChunk::HorizontalSpace: return "HorizontalSpace"; + case CodeCompletionChunk::VerticalSpace: return "VerticalSpace"; + case CodeCompletionChunk::Invalid: return "Invalid"; + } + + return nullptr; +} + +QDebug operator <<(QDebug debug, const CodeCompletionChunk &chunk) +{ + debug.nospace() << "CodeCompletionChunk("; + debug.nospace() << completionChunkKindToString(chunk.kind()) << ", "; + debug.nospace() << chunk.text(); + + if (chunk.kind() == CodeCompletionChunk::Optional) + debug.nospace() << ", " << chunk.optionalChunks(); + + debug.nospace() << ")"; + + return debug; +} + +void PrintTo(const CodeCompletionChunk &chunk, ::std::ostream* os) +{ + *os << "{"; + *os << completionChunkKindToString(chunk.kind()) << ", "; + *os << chunk.text().constData(); + + if (chunk.kind() == CodeCompletionChunk::Optional) { + const auto optionalChunks = chunk.optionalChunks(); + *os << ", {"; + + for (auto optionalChunkPosition = optionalChunks.cbegin(); + optionalChunkPosition != optionalChunks.cend(); + ++optionalChunkPosition) { + PrintTo(*optionalChunkPosition, os); + if (std::next(optionalChunkPosition) != optionalChunks.cend()) + *os << ", "; + } + + *os << "}"; + } + + *os << "}"; +} + +void PrintTo(const CodeCompletionChunk::Kind &kind, ::std::ostream* os) +{ + *os << completionChunkKindToString(kind); +} + +} // namespace CodeModelBackEnd + diff --git a/src/libs/codemodelbackendipc/codecompletionchunk.h b/src/libs/codemodelbackendipc/codecompletionchunk.h new file mode 100644 index 0000000000..e2f100faf2 --- /dev/null +++ b/src/libs/codemodelbackendipc/codecompletionchunk.h @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifndef CODEMODELBACKEND_CODECOMPLETIONCHUNK_H +#define CODEMODELBACKEND_CODECOMPLETIONCHUNK_H + +#include <utf8string.h> + +#include <QVector> + +#include "codemodelbackendipc_global.h" + +namespace CodeModelBackEnd { + +class CMBIPC_EXPORT CodeCompletionChunk +{ + friend CMBIPC_EXPORT QDataStream &operator <<(QDataStream &out, const CodeCompletionChunk &chunk); + friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CodeCompletionChunk &chunk); + friend CMBIPC_EXPORT bool operator == (const CodeCompletionChunk &first, const CodeCompletionChunk &second); + +public: + enum Kind : quint32 { + Optional, + TypedText, + Text, + Placeholder, + Informative, + CurrentParameter, + LeftParen, + RightParen, + LeftBracket, + RightBracket, + LeftBrace, + RightBrace, + LeftAngle, + RightAngle, + Comma, + ResultType, + Colon, + SemiColon, + Equal, + HorizontalSpace, + VerticalSpace, + Invalid = 255}; + + CodeCompletionChunk(); + CodeCompletionChunk(Kind kind, + const Utf8String &text, + const QVector<CodeCompletionChunk> &optionalChunks = QVector<CodeCompletionChunk>()); + + Kind kind() const; + const Utf8String &text() const; + const QVector<CodeCompletionChunk> &optionalChunks() const; + +private: + quint32 &kindAsInt(); + +private: + Utf8String text_; + QVector<CodeCompletionChunk> optionalChunks_; + Kind kind_ = Invalid; + +}; + +CMBIPC_EXPORT QDataStream &operator <<(QDataStream &out, const CodeCompletionChunk &chunk); +CMBIPC_EXPORT QDataStream &operator >>(QDataStream &in, CodeCompletionChunk &chunk); +CMBIPC_EXPORT bool operator ==(const CodeCompletionChunk &first, const CodeCompletionChunk &second); + +CMBIPC_EXPORT QDebug operator <<(QDebug debug, const CodeCompletionChunk &chunk); + +void PrintTo(const CodeCompletionChunk &chunk, ::std::ostream* os); +void PrintTo(const CodeCompletionChunk::Kind &kind, ::std::ostream* os); + +} // namespace CodeModelBackEnd + +Q_DECLARE_METATYPE(CodeModelBackEnd::CodeCompletionChunk) + +#endif // CODEMODELBACKEND_CODECOMPLETIONCHUNK_H diff --git a/src/libs/codemodelbackendipc/codemodelbackendipc-lib.pri b/src/libs/codemodelbackendipc/codemodelbackendipc-lib.pri new file mode 100644 index 0000000000..54068e45c1 --- /dev/null +++ b/src/libs/codemodelbackendipc/codemodelbackendipc-lib.pri @@ -0,0 +1,72 @@ +contains(CONFIG, dll) { + DEFINES += CODEMODELBACKENDIPC_BUILD_LIB +} else { + DEFINES += CODEMODELBACKENDIPC_BUILD_STATIC_LIB +} + +QT += network + +DEFINES += CODEMODELBACKENDIPC_LIBRARY + +INCLUDEPATH += $$PWD + +SOURCES += $$PWD/ipcserverinterface.cpp \ + $$PWD/ipcserverproxy.cpp \ + $$PWD/ipcserver.cpp \ + $$PWD/ipcclientinterface.cpp \ + $$PWD/cmbendcommand.cpp \ + $$PWD/cmbalivecommand.cpp \ + $$PWD/ipcclientproxy.cpp \ + $$PWD/cmbcommands.cpp \ + $$PWD/writecommandblock.cpp \ + $$PWD/readcommandblock.cpp \ + $$PWD/ipcinterface.cpp \ + $$PWD/connectionserver.cpp \ + $$PWD/connectionclient.cpp \ + $$PWD/cmbechocommand.cpp \ + $$PWD/ipcclientdispatcher.cpp \ + $$PWD/cmbregistertranslationunitsforcodecompletioncommand.cpp \ + $$PWD/filecontainer.cpp \ + $$PWD/cmbunregistertranslationunitsforcodecompletioncommand.cpp \ + $$PWD/cmbcompletecodecommand.cpp \ + $$PWD/cmbcodecompletedcommand.cpp \ + $$PWD/codecompletion.cpp \ + $$PWD/codemodelbackendipc_global.cpp \ + $$PWD/cmbregisterprojectsforcodecompletioncommand.cpp \ + $$PWD/cmbunregisterprojectsforcodecompletioncommand.cpp \ + $$PWD/translationunitdoesnotexistcommand.cpp \ + $$PWD/codecompletionchunk.cpp \ + $$PWD/projectpartcontainer.cpp \ + $$PWD/projectpartsdonotexistcommand.cpp + + +HEADERS += $$PWD/codemodelbackendipc_global.h \ + $$PWD/ipcserverinterface.h \ + $$PWD/ipcserverproxy.h \ + $$PWD/ipcserver.h \ + $$PWD/ipcclientinterface.h \ + $$PWD/cmbendcommand.h \ + $$PWD/cmbalivecommand.h \ + $$PWD/ipcclientproxy.h \ + $$PWD/cmbcommands.h \ + $$PWD/writecommandblock.h \ + $$PWD/readcommandblock.h \ + $$PWD/ipcinterface.h \ + $$PWD/connectionserver.h \ + $$PWD/connectionclient.h \ + $$PWD/cmbechocommand.h \ + $$PWD/ipcclientdispatcher.h \ + $$PWD/cmbregistertranslationunitsforcodecompletioncommand.h \ + $$PWD/filecontainer.h \ + $$PWD/cmbunregistertranslationunitsforcodecompletioncommand.h \ + $$PWD/cmbcompletecodecommand.h \ + $$PWD/cmbcodecompletedcommand.h \ + $$PWD/codecompletion.h \ + $$PWD/cmbregisterprojectsforcodecompletioncommand.h \ + $$PWD/cmbunregisterprojectsforcodecompletioncommand.h \ + $$PWD/translationunitdoesnotexistcommand.h \ + $$PWD/codecompletionchunk.h \ + $$PWD/projectpartcontainer.h \ + $$PWD/projectpartsdonotexistcommand.h + +contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols diff --git a/src/libs/codemodelbackendipc/codemodelbackendipc.pro b/src/libs/codemodelbackendipc/codemodelbackendipc.pro new file mode 100644 index 0000000000..bc048b4f9d --- /dev/null +++ b/src/libs/codemodelbackendipc/codemodelbackendipc.pro @@ -0,0 +1,2 @@ +include(../../qtcreatorlibrary.pri) +include(codemodelbackendipc-lib.pri) diff --git a/src/libs/codemodelbackendipc/codemodelbackendipc.qbs b/src/libs/codemodelbackendipc/codemodelbackendipc.qbs new file mode 100644 index 0000000000..7d08615586 --- /dev/null +++ b/src/libs/codemodelbackendipc/codemodelbackendipc.qbs @@ -0,0 +1,28 @@ +import qbs 1.0 + +QtcLibrary { + name: "CodeModelBackEndIpc" + + Depends { name: "Qt.network" } + Depends { name: "Sqlite" } + + cpp.defines: base.concat("CODEMODELBACKENDIPC_LIBRARY") + cpp.includePaths: base.concat(".") + + Group { + files: [ + "*.h", + "*.cpp" + ] + } + + Export { + Depends { name: "Sqlite" } + Depends { name: "Qt.network" } + cpp.includePaths: [ + "." + ] + } +} + + diff --git a/src/libs/codemodelbackendipc/codemodelbackendipc_dependencies.pri b/src/libs/codemodelbackendipc/codemodelbackendipc_dependencies.pri new file mode 100644 index 0000000000..98a3a2a5d9 --- /dev/null +++ b/src/libs/codemodelbackendipc/codemodelbackendipc_dependencies.pri @@ -0,0 +1,3 @@ +QTC_LIB_NAME = Codemodelbackendipc +QTC_LIB_DEPENDS += sqlite +INCLUDEPATH *= $$IDE_SOURCE_TREE/src/libs/codemodelbackendipc diff --git a/src/libs/codemodelbackendipc/codemodelbackendipc_global.cpp b/src/libs/codemodelbackendipc/codemodelbackendipc_global.cpp new file mode 100644 index 0000000000..2ad16d31d7 --- /dev/null +++ b/src/libs/codemodelbackendipc/codemodelbackendipc_global.cpp @@ -0,0 +1,37 @@ +/**************************************************************************** +** +** 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 "codecompletion.h" + +namespace CodeModelBackEnd { +void registerTypes() +{ +} +} diff --git a/src/libs/codemodelbackendipc/codemodelbackendipc_global.h b/src/libs/codemodelbackendipc/codemodelbackendipc_global.h new file mode 100644 index 0000000000..5a7d6cc382 --- /dev/null +++ b/src/libs/codemodelbackendipc/codemodelbackendipc_global.h @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifndef CODEMODELBACKENDIPC_GLOBAL_H +#define CODEMODELBACKENDIPC_GLOBAL_H + +#include <QtCore/qglobal.h> + +#if defined(CODEMODELBACKENDIPC_LIBRARY) +# define CMBIPC_EXPORT Q_DECL_EXPORT +#else +# define CMBIPC_EXPORT Q_DECL_IMPORT +#endif + +#ifndef CODEMODELBACKENDPROCESSPATH +# define CODEMODELBACKENDPROCESSPATH "" +#endif + +namespace CodeModelBackEnd { +CMBIPC_EXPORT void registerTypes(); +} + +#endif // CODEMODELBACKENDIPC_GLOBAL_H diff --git a/src/libs/codemodelbackendipc/connectionclient.cpp b/src/libs/codemodelbackendipc/connectionclient.cpp new file mode 100644 index 0000000000..6eb0ab9719 --- /dev/null +++ b/src/libs/codemodelbackendipc/connectionclient.cpp @@ -0,0 +1,300 @@ +/**************************************************************************** +** +** 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 "connectionclient.h" + +#include <QProcess> +#include <QThread> +#include <QCoreApplication> + +#include "cmbregistertranslationunitsforcodecompletioncommand.h" +#include "cmbunregistertranslationunitsforcodecompletioncommand.h" +#include "cmbcompletecodecommand.h" + +namespace CodeModelBackEnd { + +namespace { +QString currentProcessId() +{ + return QString::number(QCoreApplication::applicationPid()); +} + +QString connectionName() +{ + return QStringLiteral("CodeModelBackEnd-") + currentProcessId(); +} +} + +ConnectionClient::ConnectionClient(IpcClientInterface *client) + : serverProxy_(client, &localSocket), + isAliveTimerResetted(false) +{ + processAliveTimer.setInterval(10000); + + connect(&processAliveTimer, &QTimer::timeout, + this, &ConnectionClient::restartProcessIfTimerIsNotResettedAndSocketIsEmpty); + + connect(&localSocket, + static_cast<void (QLocalSocket::*)(QLocalSocket::LocalSocketError)>(&QLocalSocket::error), + this, + &ConnectionClient::printLocalSocketError); +} + +ConnectionClient::~ConnectionClient() +{ + finishProcess(); +} + +bool ConnectionClient::connectToServer() +{ + startProcess(); + resetProcessAliveTimer(); + const bool isConnected = connectToLocalSocket(); + + return isConnected; +} + +bool ConnectionClient::disconnectFromServer() +{ + localSocket.disconnectFromServer(); + if (localSocket.state() != QLocalSocket::UnconnectedState) + return localSocket.waitForDisconnected(); + + return true; +} + +bool ConnectionClient::isConnected() const +{ + return localSocket.state() == QLocalSocket::ConnectedState; +} + +void ConnectionClient::waitUntilSocketIsFlushed() const +{ + // Avoid to call QAbstractSocket::waitForBytesWritten(), which is known to + // be unreliable on Windows. Instead, call processEvents() to actually send + // the data. + while (localSocket.bytesToWrite() > 0) { + QCoreApplication::processEvents(); + QThread::msleep(20); + } +} + +void ConnectionClient::sendEndCommand() +{ + serverProxy_.end(); + localSocket.flush(); + waitUntilSocketIsFlushed(); +} + +void ConnectionClient::resetProcessAliveTimer() +{ + isAliveTimerResetted = true; + processAliveTimer.start(); +} + +void ConnectionClient::setProcessAliveTimerInterval(int processTimerInterval) +{ + processAliveTimer.setInterval(processTimerInterval); +} + +void ConnectionClient::startProcess() +{ + if (!isProcessIsRunning()) { + connectProcessFinished(); + connectStandardOutputAndError(); + process()->start(processPath(), {connectionName()}); + process()->waitForStarted(); + resetProcessAliveTimer(); + } +} + +void ConnectionClient::restartProcess() +{ + finishProcess(); + startProcess(); + + connectToServer(); + + emit processRestarted(); +} + +void ConnectionClient::restartProcessIfTimerIsNotResettedAndSocketIsEmpty() +{ + if (isAliveTimerResetted) { + isAliveTimerResetted = false; + return; // Already reset, but we were scheduled after. + } + + if (localSocket.bytesAvailable() > 0) + return; // We come first, the incoming data was not yet processed. + + restartProcess(); +} + +bool ConnectionClient::connectToLocalSocket() +{ + QThread::msleep(30); + + for (int counter = 0; counter < 1000; counter++) { + localSocket.connectToServer(connectionName()); + bool isConnected = localSocket.waitForConnected(20); + + if (isConnected) + return isConnected; + else + QThread::msleep(30); + } + + qDebug() << "Cannot connect:" <<localSocket.errorString(); + + return false; +} + +void ConnectionClient::endProcess() +{ + if (isProcessIsRunning()) { + sendEndCommand(); + process()->waitForFinished(); + } +} + +void ConnectionClient::terminateProcess() +{ +#ifndef Q_OS_WIN32 + if (isProcessIsRunning()) { + process()->terminate(); + process()->waitForFinished(); + } +#endif +} + +void ConnectionClient::killProcess() +{ + if (isProcessIsRunning()) { + process()->kill(); + process()->waitForFinished(); + } +} + +void ConnectionClient::printLocalSocketError(QLocalSocket::LocalSocketError /*socketError*/) +{ + qWarning() << "ClangCodeModel ConnectionClient LocalSocket Error:" << localSocket.errorString(); +} + +void ConnectionClient::printStandardOutput() +{ + qWarning() << "CodeModelBackEnd:" << process_->readAllStandardOutput(); +} + +void ConnectionClient::printStandardError() +{ + qWarning() << "CodeModelBackEnd Error:" << process_->readAllStandardError(); +} + +void ConnectionClient::finishProcess() +{ + processAliveTimer.stop(); + + disconnectProcessFinished(); + endProcess(); + disconnectFromServer(); + terminateProcess(); + killProcess(); + + process_.reset(); + + serverProxy_.resetCounter(); +} + +bool ConnectionClient::waitForEcho() +{ + return localSocket.waitForReadyRead(); +} + +IpcServerProxy &ConnectionClient::serverProxy() +{ + return serverProxy_; +} + +QProcess *ConnectionClient::processForTestOnly() const +{ + return process_.get(); +} + +bool ConnectionClient::isProcessIsRunning() const +{ + return process_ && process_->state() == QProcess::Running; +} + +QProcess *ConnectionClient::process() const +{ + if (!process_) + process_.reset(new QProcess); + + return process_.get(); +} + +void ConnectionClient::connectProcessFinished() const +{ + connect(process(), + static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), + this, + &ConnectionClient::restartProcess); + +} + +void ConnectionClient::disconnectProcessFinished() const +{ + if (process_) { + disconnect(process_.get(), + static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), + this, + &ConnectionClient::restartProcess); + } +} + +void ConnectionClient::connectStandardOutputAndError() const +{ + connect(process(), &QProcess::readyReadStandardOutput, this, &ConnectionClient::printStandardOutput); + connect(process(), &QProcess::readyReadStandardError, this, &ConnectionClient::printStandardError); +} + +const QString &ConnectionClient::processPath() const +{ + return processPath_; +} + +void ConnectionClient::setProcessPath(const QString &processPath) +{ + processPath_ = processPath; +} + +} // namespace CodeModelBackEnd + diff --git a/src/libs/codemodelbackendipc/connectionclient.h b/src/libs/codemodelbackendipc/connectionclient.h new file mode 100644 index 0000000000..ea36bfd08b --- /dev/null +++ b/src/libs/codemodelbackendipc/connectionclient.h @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifndef CODEMODELBACKEND_CONNECTIONCLIENT_H +#define CODEMODELBACKEND_CONNECTIONCLIENT_H + +#include <QLocalSocket> + +#include <memory> + +#include "ipcserverproxy.h" + +QT_BEGIN_NAMESPACE +class QProcess; +QT_END_NAMESPACE + +class Utf8String; +class Utf8StringVector; + +namespace CodeModelBackEnd { + +class FileContainer; + +class CMBIPC_EXPORT ConnectionClient : public QObject +{ + Q_OBJECT + +public: + ConnectionClient(IpcClientInterface *client); + ~ConnectionClient(); + + bool connectToServer(); + bool disconnectFromServer(); + bool isConnected() const; + + void sendEndCommand(); + + void resetProcessAliveTimer(); + void setProcessAliveTimerInterval(int processTimerInterval); + + const QString &processPath() const; + void setProcessPath(const QString &processPath); + + void startProcess(); + void restartProcess(); + void restartProcessIfTimerIsNotResettedAndSocketIsEmpty(); + void finishProcess(); + bool isProcessIsRunning() const; + + bool waitForEcho(); + + IpcServerProxy &serverProxy(); + + QProcess *processForTestOnly() const; + +signals: + void processRestarted(); + +private: + bool connectToLocalSocket(); + void endProcess(); + void terminateProcess(); + void killProcess(); + void printLocalSocketError(QLocalSocket::LocalSocketError socketError); + void printStandardOutput(); + void printStandardError(); + + QProcess *process() const; + void connectProcessFinished() const; + void disconnectProcessFinished() const; + void connectStandardOutputAndError() const; + + void waitUntilSocketIsFlushed() const; + +private: + mutable std::unique_ptr<QProcess> process_; + QLocalSocket localSocket; + IpcServerProxy serverProxy_; + QTimer processAliveTimer; + QString processPath_; + bool isAliveTimerResetted; +}; + +} // namespace CodeModelBackEnd + +#endif // CODEMODELBACKEND_CONNECTIONCLIENT_H diff --git a/src/libs/codemodelbackendipc/connectionserver.cpp b/src/libs/codemodelbackendipc/connectionserver.cpp new file mode 100644 index 0000000000..fc59286439 --- /dev/null +++ b/src/libs/codemodelbackendipc/connectionserver.cpp @@ -0,0 +1,150 @@ +/**************************************************************************** +** +** 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 "connectionserver.h" + +#include <QLocalSocket> +#include <QCoreApplication> +#include <QTimer> + +#include <ipcserverinterface.h> + +#include <cstdlib> + +namespace CodeModelBackEnd { + +QString ConnectionServer::connectionName; + +ConnectionServer::ConnectionServer(const QString &connectionName) + : aliveTimerId(startTimer(5000)) +{ + this->connectionName = connectionName; + + connect(&localServer, &QLocalServer::newConnection, this, &ConnectionServer::handleNewConnection); + std::atexit(&ConnectionServer::removeServer); +#if defined(Q_OS_LINUX) + std::at_quick_exit(&ConnectionServer::removeServer); +#endif + std::set_terminate(&ConnectionServer::removeServer); +} + +ConnectionServer::~ConnectionServer() +{ + removeServer(); +} + +void ConnectionServer::start() +{ + QLocalServer::removeServer(connectionName); + localServer.listen(connectionName); +} + +void ConnectionServer::setIpcServer(IpcServerInterface *ipcServer) +{ + this->ipcServer = ipcServer; + +} + +int ConnectionServer::clientProxyCount() const +{ + return ipcClientProxies.size(); +} + +void ConnectionServer::timerEvent(QTimerEvent *timerEvent) +{ + if (aliveTimerId == timerEvent->timerId()) + sendAliveCommand(); +} + +void ConnectionServer::handleNewConnection() +{ + QLocalSocket *localSocket(nextPendingConnection()); + + ipcClientProxies.emplace_back(ipcServer, localSocket); + + ipcServer->addClient(&ipcClientProxies.back()); + + localSockets.push_back(localSocket); + + emit newConnection(); +} + +void ConnectionServer::sendAliveCommand() +{ + ipcServer->client()->alive(); +} + +void ConnectionServer::handleSocketDisconnect() +{ + QLocalSocket *senderLocalSocket = static_cast<QLocalSocket*>(sender()); + + removeClientProxyWithLocalSocket(senderLocalSocket); + localSockets.erase(std::remove_if(localSockets.begin(), + localSockets.end(), + [senderLocalSocket](QLocalSocket *localSocketInList) { return localSocketInList == senderLocalSocket;})); + + delayedExitApplicationIfNoSockedIsConnected(); +} + +void ConnectionServer::removeClientProxyWithLocalSocket(QLocalSocket *localSocket) +{ + ipcClientProxies.erase(std::remove_if(ipcClientProxies.begin(), + ipcClientProxies.end(), + [localSocket](const IpcClientProxy &client) { return client.isUsingThatIoDevice(localSocket);})); +} + +QLocalSocket *ConnectionServer::nextPendingConnection() +{ + QLocalSocket *localSocket = localServer.nextPendingConnection(); + + connect(localSocket, &QLocalSocket::disconnected, this, &ConnectionServer::handleSocketDisconnect); + + return localSocket; +} + +void ConnectionServer::removeServer() +{ + QLocalServer::removeServer(connectionName); +} + +void ConnectionServer::delayedExitApplicationIfNoSockedIsConnected() +{ + if (localSockets.size() == 0) + QTimer::singleShot(60000, this, &ConnectionServer::exitApplicationIfNoSockedIsConnected); +} + +void ConnectionServer::exitApplicationIfNoSockedIsConnected() +{ + if (localSockets.size() == 0) + QCoreApplication::exit(); +} + +} // namespace CodeModelBackEnd + diff --git a/src/libs/codemodelbackendipc/connectionserver.h b/src/libs/codemodelbackendipc/connectionserver.h new file mode 100644 index 0000000000..1e863ba463 --- /dev/null +++ b/src/libs/codemodelbackendipc/connectionserver.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifndef CODEMODELBACKEND_CONNECTIONSERVER_H +#define CODEMODELBACKEND_CONNECTIONSERVER_H + +#include <QLocalServer> +#include <ipcclientproxy.h> +#include <vector> + +namespace CodeModelBackEnd { + +class IpcServerInterface; +class IpcClientProxy; + +class CMBIPC_EXPORT ConnectionServer : public QObject +{ + Q_OBJECT +public: + ConnectionServer(const QString &connectionName); + ~ConnectionServer(); + + void start(); + void setIpcServer(IpcServerInterface *ipcServer); + + int clientProxyCount() const; + + static void removeServer(); + +signals: + void newConnection(); + +protected: + void timerEvent(QTimerEvent *timerEvent); + +private: + void handleNewConnection(); + void sendAliveCommand(); + void handleSocketDisconnect(); + void removeClientProxyWithLocalSocket(QLocalSocket *localSocket); + QLocalSocket *nextPendingConnection(); + void delayedExitApplicationIfNoSockedIsConnected(); + void exitApplicationIfNoSockedIsConnected(); + +private: + std::vector<IpcClientProxy> ipcClientProxies; + std::vector<QLocalSocket*> localSockets; + IpcServerInterface *ipcServer; + QLocalServer localServer; + static QString connectionName; + int aliveTimerId; +}; + +} // namespace CodeModelBackEnd + +#endif // CODEMODELBACKEND_CONNECTIONSERVER_H diff --git a/src/libs/codemodelbackendipc/filecontainer.cpp b/src/libs/codemodelbackendipc/filecontainer.cpp new file mode 100644 index 0000000000..2542eddd65 --- /dev/null +++ b/src/libs/codemodelbackendipc/filecontainer.cpp @@ -0,0 +1,136 @@ +/**************************************************************************** +** +** 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 "filecontainer.h" + +#include <QtDebug> + +#include <QDataStream> + +#include <ostream> + +namespace CodeModelBackEnd { + +FileContainer::FileContainer(const Utf8String &fileName, + const Utf8String &projectPartId, + const Utf8String &unsavedFileContent, + bool hasUnsavedFileContent) + : filePath_(fileName), + projectPartId_(projectPartId), + unsavedFileContent_(unsavedFileContent), + hasUnsavedFileContent_(hasUnsavedFileContent) +{ +} + +const Utf8String &FileContainer::filePath() const +{ + return filePath_; +} + +const Utf8String &FileContainer::projectPartId() const +{ + return projectPartId_; +} + +const Utf8String &FileContainer::unsavedFileContent() const +{ + return unsavedFileContent_; +} + +bool FileContainer::hasUnsavedFileContent() const +{ + return hasUnsavedFileContent_; +} + +QDataStream &operator<<(QDataStream &out, const FileContainer &container) +{ + out << container.filePath_; + out << container.projectPartId_; + out << container.unsavedFileContent_; + out << container.hasUnsavedFileContent_; + + return out; +} + +QDataStream &operator>>(QDataStream &in, FileContainer &container) +{ + in >> container.filePath_; + in >> container.projectPartId_; + in >> container.unsavedFileContent_; + in >> container.hasUnsavedFileContent_; + + return in; +} + +bool operator == (const FileContainer &first, const FileContainer &second) +{ + return first.filePath_ == second.filePath_ && first.projectPartId_ == second.projectPartId_; +} + +bool operator < (const FileContainer &first, const FileContainer &second) +{ + if (first.filePath_ == second.filePath_) + return first.projectPartId_ < second.projectPartId_; + + return first.filePath_ < second.filePath_; +} + +QDebug operator <<(QDebug debug, const FileContainer &container) +{ + debug.nospace() << "FileContainer(" + << container.filePath() + << ", " + << container.projectPartId(); + + if (container.hasUnsavedFileContent()) + debug.nospace() << ", " + << container.unsavedFileContent(); + + debug.nospace() << ")"; + + return debug; +} + +void PrintTo(const FileContainer &container, ::std::ostream* os) +{ + *os << "FileContainer(" + << container.filePath().constData() + << ", " + << container.projectPartId().constData(); + + if (container.hasUnsavedFileContent()) + *os << ", " + << container.unsavedFileContent().constData(); + + *os << ")"; +} + +} // namespace CodeModelBackEnd + diff --git a/src/libs/codemodelbackendipc/filecontainer.h b/src/libs/codemodelbackendipc/filecontainer.h new file mode 100644 index 0000000000..bd3a9d9b4b --- /dev/null +++ b/src/libs/codemodelbackendipc/filecontainer.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifndef CODEMODELBACKEND_FILECONTAINER_H +#define CODEMODELBACKEND_FILECONTAINER_H + +#include <qmetatype.h> + +#include <utf8string.h> + +#include <codemodelbackendipc_global.h> + +namespace CodeModelBackEnd { + +class CMBIPC_EXPORT FileContainer +{ + friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const FileContainer &container); + friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, FileContainer &container); + friend CMBIPC_EXPORT bool operator == (const FileContainer &first, const FileContainer &second); + friend CMBIPC_EXPORT bool operator < (const FileContainer &first, const FileContainer &second); +public: + FileContainer() = default; + FileContainer(const Utf8String &filePath, + const Utf8String &projectPartId, + const Utf8String &unsavedFileContent = Utf8String(), + bool hasUnsavedFileContent = false); + + const Utf8String &filePath() const; + const Utf8String &projectPartId() const; + const Utf8String &unsavedFileContent() const; + bool hasUnsavedFileContent() const; + +private: + Utf8String filePath_; + Utf8String projectPartId_; + Utf8String unsavedFileContent_; + bool hasUnsavedFileContent_ = false; +}; + +CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const FileContainer &container); +CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, FileContainer &container); +CMBIPC_EXPORT bool operator == (const FileContainer &first, const FileContainer &second); +CMBIPC_EXPORT bool operator < (const FileContainer &first, const FileContainer &second); + +CMBIPC_EXPORT QDebug operator <<(QDebug debug, const FileContainer &container); +void PrintTo(const FileContainer &container, ::std::ostream* os); + +} // namespace CodeModelBackEnd + +Q_DECLARE_METATYPE(CodeModelBackEnd::FileContainer) + +#endif // CODEMODELBACKEND_FILECONTAINER_H diff --git a/src/libs/codemodelbackendipc/ipcclientdispatcher.cpp b/src/libs/codemodelbackendipc/ipcclientdispatcher.cpp new file mode 100644 index 0000000000..8dbf4658bb --- /dev/null +++ b/src/libs/codemodelbackendipc/ipcclientdispatcher.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** 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 "ipcclientdispatcher.h" + +#include <QtDebug> + +namespace CodeModelBackEnd { + +void IpcClientDispatcher::addClient(IpcClientInterface *client) +{ + clients.append(client); +} + +void IpcClientDispatcher::removeClient(IpcClientInterface *client) +{ + clients.removeOne(client); +} + +void IpcClientDispatcher::alive() +{ + for (auto *client : clients) + client->alive(); +} + +void IpcClientDispatcher::echo(const EchoCommand &command) +{ + for (auto *client : clients) + client->echo(command); +} + +void IpcClientDispatcher::codeCompleted(const CodeCompletedCommand &command) +{ + for (auto *client : clients) + client->codeCompleted(command); +} + +void IpcClientDispatcher::translationUnitDoesNotExist(const TranslationUnitDoesNotExistCommand &command) +{ + for (auto *client : clients) + client->translationUnitDoesNotExist(command); +} + +void IpcClientDispatcher::projectPartsDoNotExist(const ProjectPartsDoNotExistCommand &command) +{ + for (auto *client : clients) + client->projectPartsDoNotExist(command); +} + +} // namespace CodeModelBackEnd + diff --git a/src/libs/codemodelbackendipc/ipcclientdispatcher.h b/src/libs/codemodelbackendipc/ipcclientdispatcher.h new file mode 100644 index 0000000000..8409c00524 --- /dev/null +++ b/src/libs/codemodelbackendipc/ipcclientdispatcher.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifndef CODEMODELBACKEND_IPCCLIENTDISPATCHER_H +#define CODEMODELBACKEND_IPCCLIENTDISPATCHER_H + +#include "ipcclientinterface.h" + +#include <QVector> + +namespace CodeModelBackEnd { + +class CMBIPC_EXPORT IpcClientDispatcher : public CodeModelBackEnd::IpcClientInterface +{ +public: + void addClient(IpcClientInterface *client); + void removeClient(IpcClientInterface *client); + + void alive() override; + void echo(const EchoCommand &command) override; + void codeCompleted(const CodeCompletedCommand &command) override; + void translationUnitDoesNotExist(const TranslationUnitDoesNotExistCommand &command) override; + void projectPartsDoNotExist(const ProjectPartsDoNotExistCommand &command) override; + +private: + QVector<IpcClientInterface*> clients; +}; + +} // namespace CodeModelBackEnd + +#endif // CODEMODELBACKEND_IPCCLIENTDISPATCHER_H diff --git a/src/libs/codemodelbackendipc/ipcclientinterface.cpp b/src/libs/codemodelbackendipc/ipcclientinterface.cpp new file mode 100644 index 0000000000..87fa32547b --- /dev/null +++ b/src/libs/codemodelbackendipc/ipcclientinterface.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** 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 "ipcclientinterface.h" + +#include <QVariant> +#include <QtDebug> + +#include "cmbechocommand.h" +#include "cmbcodecompletedcommand.h" +#include "translationunitdoesnotexistcommand.h" +#include "projectpartsdonotexistcommand.h" + +namespace CodeModelBackEnd { + + +void IpcClientInterface::dispatch(const QVariant &command) +{ + static const int aliveCommandType = QMetaType::type("CodeModelBackEnd::AliveCommand"); + static const int echoCommandType = QMetaType::type("CodeModelBackEnd::EchoCommand"); + static const int codeCompletedCommandType = QMetaType::type("CodeModelBackEnd::CodeCompletedCommand"); + static const int translationUnitDoesNotExistCommand = QMetaType::type("CodeModelBackEnd::TranslationUnitDoesNotExistCommand"); + static const int projectPartsDoNotExistCommand = QMetaType::type("CodeModelBackEnd::ProjectPartsDoNotExistCommand"); + + int type = command.userType(); + + if (type == aliveCommandType) + alive(); + else if (type == echoCommandType) + echo(command.value<EchoCommand>()); + else if (type == codeCompletedCommandType) + codeCompleted(command.value<CodeCompletedCommand>()); + else if (type == translationUnitDoesNotExistCommand) + translationUnitDoesNotExist(command.value<TranslationUnitDoesNotExistCommand>()); + else if (type == projectPartsDoNotExistCommand) + projectPartsDoNotExist(command.value<ProjectPartsDoNotExistCommand>()); + else + qWarning() << "Unknown IpcClientCommand"; +} + +} // namespace CodeModelBackEnd + diff --git a/src/libs/codemodelbackendipc/ipcclientinterface.h b/src/libs/codemodelbackendipc/ipcclientinterface.h new file mode 100644 index 0000000000..9bf5fe1507 --- /dev/null +++ b/src/libs/codemodelbackendipc/ipcclientinterface.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifndef CODEMODELBACKEND_IPCCLIENTINTERFACE_H +#define CODEMODELBACKEND_IPCCLIENTINTERFACE_H + +#include "ipcinterface.h" + +namespace CodeModelBackEnd { + +class IpcServerInterface; +class RegisterTranslationUnitForCodeCompletionCommand; +class RegisterProjectPartsForCodeCompletionCommand; +class UnregisterTranslationUnitsForCodeCompletionCommand; +class UnregisterProjectPartsForCodeCompletionCommand; +class EchoCommand; +class CompleteCodeCommand; +class CodeCompletedCommand; +class TranslationUnitDoesNotExistCommand; +class ProjectPartsDoNotExistCommand; + +class CMBIPC_EXPORT IpcClientInterface : public IpcInterface +{ +public: + void dispatch(const QVariant &command) override; + + virtual void alive() = 0; + virtual void echo(const EchoCommand &command) = 0; + virtual void codeCompleted(const CodeCompletedCommand &command) = 0; + virtual void translationUnitDoesNotExist(const TranslationUnitDoesNotExistCommand &command) = 0; + virtual void projectPartsDoNotExist(const ProjectPartsDoNotExistCommand &command) = 0; +}; + +} // namespace CodeModelBackEnd + +#endif // CODEMODELBACKEND_IPCCLIENTINTERFACE_H diff --git a/src/libs/codemodelbackendipc/ipcclientproxy.cpp b/src/libs/codemodelbackendipc/ipcclientproxy.cpp new file mode 100644 index 0000000000..d10fa38d00 --- /dev/null +++ b/src/libs/codemodelbackendipc/ipcclientproxy.cpp @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** 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 "ipcclientproxy.h" + +#include <cmbalivecommand.h> + +#include <QVariant> +#include <QVector> +#include <QIODevice> +#include <QtDebug> + +#include "ipcserverinterface.h" +#include "cmbechocommand.h" +#include "cmbregistertranslationunitsforcodecompletioncommand.h" +#include "cmbcodecompletedcommand.h" +#include "translationunitdoesnotexistcommand.h" +#include "projectpartsdonotexistcommand.h" + +namespace CodeModelBackEnd { + +IpcClientProxy::IpcClientProxy(IpcServerInterface *server, QIODevice *ioDevice) + : writeCommandBlock(ioDevice), + readCommandBlock(ioDevice), + server(server), + ioDevice(ioDevice) +{ + QObject::connect(ioDevice, &QIODevice::readyRead, [this] () {IpcClientProxy::readCommands();}); +} + +IpcClientProxy::IpcClientProxy(IpcClientProxy &&other) + : writeCommandBlock(std::move(other.writeCommandBlock)), + readCommandBlock(std::move(other.readCommandBlock)), + server(std::move(other.server)), + ioDevice(std::move(other.ioDevice)) +{ + +} + +IpcClientProxy &IpcClientProxy::operator =(IpcClientProxy &&other) +{ + writeCommandBlock = std::move(other.writeCommandBlock); + readCommandBlock = std::move(other.readCommandBlock); + server = std::move(other.server); + ioDevice = std::move(other.ioDevice); + + return *this; +} + +void IpcClientProxy::alive() +{ + writeCommandBlock.write(QVariant::fromValue(AliveCommand())); +} + +void IpcClientProxy::echo(const EchoCommand &command) +{ + writeCommandBlock.write(QVariant::fromValue(command)); +} + +void IpcClientProxy::codeCompleted(const CodeCompletedCommand &command) +{ + writeCommandBlock.write(QVariant::fromValue(command)); +} + +void IpcClientProxy::translationUnitDoesNotExist(const TranslationUnitDoesNotExistCommand &command) +{ + writeCommandBlock.write(QVariant::fromValue(command)); +} + +void IpcClientProxy::projectPartsDoNotExist(const ProjectPartsDoNotExistCommand &command) +{ + writeCommandBlock.write(QVariant::fromValue(command)); +} + +void IpcClientProxy::readCommands() +{ + for (const QVariant &command : readCommandBlock.readAll()) + server->dispatch(command); +} + +bool IpcClientProxy::isUsingThatIoDevice(QIODevice *ioDevice) const +{ + return this->ioDevice == ioDevice; +} + +} // namespace CodeModelBackEnd + diff --git a/src/libs/codemodelbackendipc/ipcclientproxy.h b/src/libs/codemodelbackendipc/ipcclientproxy.h new file mode 100644 index 0000000000..9d532dd890 --- /dev/null +++ b/src/libs/codemodelbackendipc/ipcclientproxy.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifndef CODELMODELBACKEND_IPCCLIENTPROXY_H +#define CODELMODELBACKEND_IPCCLIENTPROXY_H + +#include <QtGlobal> + +#include <memory> + +#include "codemodelbackendipc_global.h" +#include "ipcclientinterface.h" + +#include "writecommandblock.h" +#include "readcommandblock.h" + +QT_BEGIN_NAMESPACE +class QLocalServer; +class QIODevice; +QT_END_NAMESPACE + +namespace CodeModelBackEnd { + +class CMBIPC_EXPORT IpcClientProxy : public IpcClientInterface +{ +public: + explicit IpcClientProxy(IpcServerInterface *server, QIODevice *ioDevice); + IpcClientProxy(const IpcClientProxy&) = delete; + const IpcClientProxy &operator =(const IpcClientProxy&) = delete; + + IpcClientProxy(IpcClientProxy&&other); + IpcClientProxy &operator =(IpcClientProxy&&other); + + void alive() override; + void echo(const EchoCommand &command) override; + void codeCompleted(const CodeCompletedCommand &command) override; + void translationUnitDoesNotExist(const TranslationUnitDoesNotExistCommand &command) override; + void projectPartsDoNotExist(const ProjectPartsDoNotExistCommand &command) override; + + void readCommands(); + + bool isUsingThatIoDevice(QIODevice *ioDevice) const; + +private: + CodeModelBackEnd::WriteCommandBlock writeCommandBlock; + CodeModelBackEnd::ReadCommandBlock readCommandBlock; + IpcServerInterface *server = nullptr; + QIODevice *ioDevice = nullptr; +}; + +} // namespace CodeModelBackEnd + +#endif // CODELMODELBACKEND_IPCCLIENTPROXY_H diff --git a/src/libs/codemodelbackendipc/ipcinterface.cpp b/src/libs/codemodelbackendipc/ipcinterface.cpp new file mode 100644 index 0000000000..5576e80476 --- /dev/null +++ b/src/libs/codemodelbackendipc/ipcinterface.cpp @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** 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 "ipcinterface.h" + +namespace CodeModelBackEnd { + +IpcInterface::~IpcInterface() +{ +} + +} // namespace CodeModelBackEnd + diff --git a/src/libs/codemodelbackendipc/ipcinterface.h b/src/libs/codemodelbackendipc/ipcinterface.h new file mode 100644 index 0000000000..f53677f2c4 --- /dev/null +++ b/src/libs/codemodelbackendipc/ipcinterface.h @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifndef CODEMODELBACKEND_IPCINTERFACE_H +#define CODEMODELBACKEND_IPCINTERFACE_H + +#include <QtGlobal> + +QT_BEGIN_NAMESPACE +class QVariant; +QT_END_NAMESPACE + +#include <codemodelbackendipc_global.h> + +namespace CodeModelBackEnd { + +class CMBIPC_EXPORT IpcInterface +{ +public: + virtual ~IpcInterface(); + virtual void dispatch(const QVariant &command) = 0; +}; + +} // namespace CodeModelBackEnd + +#endif // CODEMODELBACKEND_IPCINTERFACE_H diff --git a/src/libs/codemodelbackendipc/ipcserver.cpp b/src/libs/codemodelbackendipc/ipcserver.cpp new file mode 100644 index 0000000000..dccaa5db4f --- /dev/null +++ b/src/libs/codemodelbackendipc/ipcserver.cpp @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** 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 "ipcserver.h" + +namespace CodeModelBackEnd { + +IpcServer::IpcServer() +{ + +} + +IpcServer::~IpcServer() +{ + +} + +} // namespace CodeModelBackEnd + diff --git a/src/libs/codemodelbackendipc/ipcserver.h b/src/libs/codemodelbackendipc/ipcserver.h new file mode 100644 index 0000000000..23d5c4769f --- /dev/null +++ b/src/libs/codemodelbackendipc/ipcserver.h @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifndef CODEMODELBACKEND_IPCSERVER_H +#define CODEMODELBACKEND_IPCSERVER_H + +#include "ipcserverinterface.h" + +namespace CodeModelBackEnd { + +class IpcServer : public IpcServerInterface +{ +public: + IpcServer(); + ~IpcServer(); +}; + +} // namespace CodeModelBackEnd + +#endif // CODEMODELBACKEND_IPCSERVER_H diff --git a/src/libs/codemodelbackendipc/ipcserverinterface.cpp b/src/libs/codemodelbackendipc/ipcserverinterface.cpp new file mode 100644 index 0000000000..1ea47c0503 --- /dev/null +++ b/src/libs/codemodelbackendipc/ipcserverinterface.cpp @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** 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 "ipcserverinterface.h" + +#include <QVariant> +#include <QtDebug> + +#include "cmbregistertranslationunitsforcodecompletioncommand.h" +#include "cmbunregistertranslationunitsforcodecompletioncommand.h" +#include "cmbregisterprojectsforcodecompletioncommand.h" +#include "cmbunregisterprojectsforcodecompletioncommand.h" +#include "cmbcompletecodecommand.h" + +namespace CodeModelBackEnd { + +void IpcServerInterface::dispatch(const QVariant &command) +{ + static const int endCommandType = QMetaType::type("CodeModelBackEnd::EndCommand"); + static const int registerTranslationUnitsForCodeCompletionCommandType = QMetaType::type("CodeModelBackEnd::RegisterTranslationUnitForCodeCompletionCommand"); + static const int unregisterTranslationUnitsForCodeCompletionCommandType = QMetaType::type("CodeModelBackEnd::UnregisterTranslationUnitsForCodeCompletionCommand"); + static const int registerProjectPartsForCodeCompletionCommandType = QMetaType::type("CodeModelBackEnd::RegisterProjectPartsForCodeCompletionCommand"); + static const int unregisterProjectPartsForCodeCompletionCommandType = QMetaType::type("CodeModelBackEnd::UnregisterProjectPartsForCodeCompletionCommand"); + static const int completeCodeCommandType = QMetaType::type("CodeModelBackEnd::CompleteCodeCommand"); + + int type = command.userType(); + + if (type == endCommandType) + end(); + else if (type == registerTranslationUnitsForCodeCompletionCommandType) + registerTranslationUnitsForCodeCompletion(command.value<RegisterTranslationUnitForCodeCompletionCommand>()); + else if (type == unregisterTranslationUnitsForCodeCompletionCommandType) + unregisterTranslationUnitsForCodeCompletion(command.value<UnregisterTranslationUnitsForCodeCompletionCommand>()); + else if (type == registerProjectPartsForCodeCompletionCommandType) + registerProjectPartsForCodeCompletion(command.value<RegisterProjectPartsForCodeCompletionCommand>()); + else if (type == unregisterProjectPartsForCodeCompletionCommandType) + unregisterProjectPartsForCodeCompletion(command.value<UnregisterProjectPartsForCodeCompletionCommand>()); + else if (type == completeCodeCommandType) + completeCode(command.value<CompleteCodeCommand>()); + else + qWarning() << "Unknown IpcServerCommand"; +} + +void IpcServerInterface::addClient(IpcClientInterface *client) +{ + clientDispatcher.addClient(client); +} + +void IpcServerInterface::removeClient(IpcClientInterface *client) +{ + clientDispatcher.removeClient(client); +} + +IpcClientInterface *IpcServerInterface::client() +{ + return &clientDispatcher; +} + +} // namespace CodeModelBackEnd + diff --git a/src/libs/codemodelbackendipc/ipcserverinterface.h b/src/libs/codemodelbackendipc/ipcserverinterface.h new file mode 100644 index 0000000000..1fcffcde6f --- /dev/null +++ b/src/libs/codemodelbackendipc/ipcserverinterface.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifndef CODEMODELBACKEND_IPCSERVERINTERFACE_H +#define CODEMODELBACKEND_IPCSERVERINTERFACE_H + +#include "ipcinterface.h" + +#include "ipcclientdispatcher.h" + +namespace CodeModelBackEnd { + +class IpcClientInterface; + +class CMBIPC_EXPORT IpcServerInterface : public IpcInterface +{ +public: + void dispatch(const QVariant &command) override; + + virtual void end() = 0; + virtual void registerTranslationUnitsForCodeCompletion(const RegisterTranslationUnitForCodeCompletionCommand &command) = 0; + virtual void unregisterTranslationUnitsForCodeCompletion(const UnregisterTranslationUnitsForCodeCompletionCommand &command) = 0; + virtual void registerProjectPartsForCodeCompletion(const RegisterProjectPartsForCodeCompletionCommand &command) = 0; + virtual void unregisterProjectPartsForCodeCompletion(const UnregisterProjectPartsForCodeCompletionCommand &command) = 0; + virtual void completeCode(const CompleteCodeCommand &command) = 0; + + void addClient(IpcClientInterface *client); + void removeClient(IpcClientInterface *client); + + IpcClientInterface *client(); + +private: + IpcClientDispatcher clientDispatcher; +}; + +} // namespace CodeModelBackEnd + +#endif // CODEMODELBACKEND_IPCSERVERINTERFACE_H diff --git a/src/libs/codemodelbackendipc/ipcserverproxy.cpp b/src/libs/codemodelbackendipc/ipcserverproxy.cpp new file mode 100644 index 0000000000..17d95292df --- /dev/null +++ b/src/libs/codemodelbackendipc/ipcserverproxy.cpp @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** 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 "ipcserverproxy.h" + +#include <QProcess> +#include <QLocalSocket> +#include <QLocalServer> + +#include <cmbendcommand.h> +#include <cmbalivecommand.h> +#include <cmbregistertranslationunitsforcodecompletioncommand.h> +#include <cmbunregistertranslationunitsforcodecompletioncommand.h> +#include <cmbregisterprojectsforcodecompletioncommand.h> +#include <cmbunregisterprojectsforcodecompletioncommand.h> +#include <cmbcompletecodecommand.h> + +#include <ipcclientinterface.h> + +namespace CodeModelBackEnd { + +IpcServerProxy::IpcServerProxy(IpcClientInterface *client, QIODevice *ioDevice) + : writeCommandBlock(ioDevice), + readCommandBlock(ioDevice), + client(client) +{ + QObject::connect(ioDevice, &QIODevice::readyRead, [this] () {IpcServerProxy::readCommands();}); +} + +void IpcServerProxy::readCommands() +{ + for (const QVariant &command : readCommandBlock.readAll()) + client->dispatch(command); +} + +void IpcServerProxy::resetCounter() +{ + writeCommandBlock.resetCounter(); + readCommandBlock.resetCounter(); +} + +void IpcServerProxy::end() +{ + writeCommandBlock.write(QVariant::fromValue(EndCommand())); +} + +void IpcServerProxy::registerTranslationUnitsForCodeCompletion(const RegisterTranslationUnitForCodeCompletionCommand &command) +{ + writeCommandBlock.write(QVariant::fromValue(command)); +} + +void IpcServerProxy::unregisterTranslationUnitsForCodeCompletion(const UnregisterTranslationUnitsForCodeCompletionCommand &command) +{ + writeCommandBlock.write(QVariant::fromValue(command)); +} + +void IpcServerProxy::registerProjectPartsForCodeCompletion(const RegisterProjectPartsForCodeCompletionCommand &command) +{ + writeCommandBlock.write(QVariant::fromValue(command)); +} + +void IpcServerProxy::unregisterProjectPartsForCodeCompletion(const UnregisterProjectPartsForCodeCompletionCommand &command) +{ + writeCommandBlock.write(QVariant::fromValue(command)); +} + +void IpcServerProxy::completeCode(const CompleteCodeCommand &command) +{ + writeCommandBlock.write(QVariant::fromValue(command)); +} + +} // namespace CodeModelBackEnd + diff --git a/src/libs/codemodelbackendipc/ipcserverproxy.h b/src/libs/codemodelbackendipc/ipcserverproxy.h new file mode 100644 index 0000000000..33e2ef58ab --- /dev/null +++ b/src/libs/codemodelbackendipc/ipcserverproxy.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifndef CODEMODELBACKEND_IPCSERVERPROXY_H +#define CODEMODELBACKEND_IPCSERVERPROXY_H + +#include <qglobal.h> +#include <QTimer> + +#include <memory> + +#include "ipcserverinterface.h" +#include "writecommandblock.h" +#include "readcommandblock.h" + +QT_BEGIN_NAMESPACE +class QVariant; +class QProcess; +class QLocalServer; +class QLocalSocket; +QT_END_NAMESPACE + +namespace CodeModelBackEnd { + +class CMBIPC_EXPORT IpcServerProxy : public IpcServerInterface +{ +public: + IpcServerProxy(IpcClientInterface *client, QIODevice *ioDevice); + IpcServerProxy(const IpcServerProxy&) = delete; + IpcServerProxy &operator =(const IpcServerProxy&) = delete; + + void end() override; + void registerTranslationUnitsForCodeCompletion(const RegisterTranslationUnitForCodeCompletionCommand &command) override; + void unregisterTranslationUnitsForCodeCompletion(const UnregisterTranslationUnitsForCodeCompletionCommand &command) override; + void registerProjectPartsForCodeCompletion(const RegisterProjectPartsForCodeCompletionCommand &command) override; + void unregisterProjectPartsForCodeCompletion(const UnregisterProjectPartsForCodeCompletionCommand &command) override; + void completeCode(const CompleteCodeCommand &command) override; + + void readCommands(); + + void resetCounter(); + +private: + CodeModelBackEnd::WriteCommandBlock writeCommandBlock; + CodeModelBackEnd::ReadCommandBlock readCommandBlock; + IpcClientInterface *client; +}; + +} // namespace CodeModelBackEnd + +#endif // CODEMODELBACKEND_IPCSERVERPROXY_H diff --git a/src/libs/codemodelbackendipc/projectpartcontainer.cpp b/src/libs/codemodelbackendipc/projectpartcontainer.cpp new file mode 100644 index 0000000000..067fdf0b79 --- /dev/null +++ b/src/libs/codemodelbackendipc/projectpartcontainer.cpp @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** 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 "projectpartcontainer.h" + +#include <QtDebug> + +#include <QDataStream> + +#include <ostream> + +namespace CodeModelBackEnd { + +ProjectPartContainer::ProjectPartContainer(const Utf8String &projectPathId, + const Utf8StringVector &arguments) + : projectPartId_(projectPathId), + arguments_(arguments) +{ +} + +const Utf8String &ProjectPartContainer::projectPartId() const +{ + return projectPartId_; +} + +const Utf8StringVector &ProjectPartContainer::arguments() const +{ + return arguments_; +} + + +QDataStream &operator<<(QDataStream &out, const ProjectPartContainer &container) +{ + out << container.projectPartId_; + out << container.arguments_; + + return out; +} + +QDataStream &operator>>(QDataStream &in, ProjectPartContainer &container) +{ + in >> container.projectPartId_; + in >> container.arguments_; + + return in; +} + +bool operator == (const ProjectPartContainer &first, const ProjectPartContainer &second) +{ + return first.projectPartId_ == second.projectPartId_; +} + +bool operator < (const ProjectPartContainer &first, const ProjectPartContainer &second) +{ + return first.projectPartId_ < second.projectPartId_; +} + +QDebug operator <<(QDebug debug, const ProjectPartContainer &container) +{ + debug.nospace() << "ProjectPartContainer(" + << container.projectPartId() + << "," + << container.arguments() + << ")"; + + return debug; +} + +void PrintTo(const ProjectPartContainer &container, ::std::ostream* os) +{ + *os << "ProjectPartContainer(" + << container.projectPartId().constData() + << "," + << container.arguments().constData() + << ")"; +} + + +} // namespace CodeModelBackEnd + diff --git a/src/libs/codemodelbackendipc/projectpartcontainer.h b/src/libs/codemodelbackendipc/projectpartcontainer.h new file mode 100644 index 0000000000..e8ee7b6e93 --- /dev/null +++ b/src/libs/codemodelbackendipc/projectpartcontainer.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifndef CODEMODELBACKEND_PROJECTCONTAINER_H +#define CODEMODELBACKEND_PROJECTCONTAINER_H + +#include <QMetaType> + +#include <utf8stringvector.h> + +#include <codemodelbackendipc_global.h> + +namespace CodeModelBackEnd { + +class CMBIPC_EXPORT ProjectPartContainer +{ + friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const ProjectPartContainer &container); + friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, ProjectPartContainer &container); + friend CMBIPC_EXPORT bool operator == (const ProjectPartContainer &first, const ProjectPartContainer &second); + friend CMBIPC_EXPORT bool operator < (const ProjectPartContainer &first, const ProjectPartContainer &second); +public: + ProjectPartContainer() = default; + ProjectPartContainer(const Utf8String &projectPartId, + const Utf8StringVector &arguments = Utf8StringVector()); + + const Utf8String &projectPartId() const; + const Utf8StringVector &arguments() const; + +private: + Utf8String projectPartId_; + Utf8StringVector arguments_; +}; + +CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const ProjectPartContainer &container); +CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, ProjectPartContainer &container); +CMBIPC_EXPORT bool operator == (const ProjectPartContainer &first, const ProjectPartContainer &second); +CMBIPC_EXPORT bool operator < (const ProjectPartContainer &first, const ProjectPartContainer &second); + +QDebug operator <<(QDebug debug, const ProjectPartContainer &container); +void PrintTo(const ProjectPartContainer &container, ::std::ostream* os); + +} // namespace CodeModelBackEnd + +Q_DECLARE_METATYPE(CodeModelBackEnd::ProjectPartContainer) + +#endif // CODEMODELBACKEND_PROJECTCONTAINER_H diff --git a/src/libs/codemodelbackendipc/projectpartsdonotexistcommand.cpp b/src/libs/codemodelbackendipc/projectpartsdonotexistcommand.cpp new file mode 100644 index 0000000000..532a6ce8d8 --- /dev/null +++ b/src/libs/codemodelbackendipc/projectpartsdonotexistcommand.cpp @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** 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 "projectpartsdonotexistcommand.h" + +#include <QDebug> + +#include <QDataStream> + +#include <ostream> + +namespace CodeModelBackEnd { + +ProjectPartsDoNotExistCommand::ProjectPartsDoNotExistCommand(const Utf8StringVector &projectPartIds) + : projectPartIds_(projectPartIds) +{ +} + + +const Utf8StringVector &ProjectPartsDoNotExistCommand::projectPartIds() const +{ + return projectPartIds_; +} + +QDataStream &operator<<(QDataStream &out, const ProjectPartsDoNotExistCommand &command) +{ + out << command.projectPartIds_; + + return out; +} + +QDataStream &operator>>(QDataStream &in, ProjectPartsDoNotExistCommand &command) +{ + in >> command.projectPartIds_; + + return in; +} + +bool operator == (const ProjectPartsDoNotExistCommand &first, const ProjectPartsDoNotExistCommand &second) +{ + return first.projectPartIds_ == second.projectPartIds_; +} + +bool operator < (const ProjectPartsDoNotExistCommand &first, const ProjectPartsDoNotExistCommand &second) +{ + return first.projectPartIds_ < second.projectPartIds_; +} + +QDebug operator <<(QDebug debug, const ProjectPartsDoNotExistCommand &command) +{ + debug.nospace() << "ProjectPartDoesNotExistCommand("; + + debug.nospace() << command.projectPartIds_; + + debug.nospace() << ")"; + + return debug; +} + +void PrintTo(const ProjectPartsDoNotExistCommand &command, ::std::ostream* os) +{ + QString output; + QDebug debug(&output); + + debug << command; + + *os << output.toUtf8().constData(); +} + + +} // namespace CodeModelBackEnd + diff --git a/src/libs/codemodelbackendipc/projectpartsdonotexistcommand.h b/src/libs/codemodelbackendipc/projectpartsdonotexistcommand.h new file mode 100644 index 0000000000..9754c92e44 --- /dev/null +++ b/src/libs/codemodelbackendipc/projectpartsdonotexistcommand.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifndef CODEMODELBACKEND_PROJECTPARTSDONOTEXISTCOMMAND_H +#define CODEMODELBACKEND_PROJECTPARTSDONOTEXISTCOMMAND_H + +#include <QMetaType> + +#include <utf8stringvector.h> + +#include "codemodelbackendipc_global.h" + +namespace CodeModelBackEnd { + +class CMBIPC_EXPORT ProjectPartsDoNotExistCommand +{ + friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const ProjectPartsDoNotExistCommand &command); + friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, ProjectPartsDoNotExistCommand &command); + friend CMBIPC_EXPORT bool operator == (const ProjectPartsDoNotExistCommand &first, const ProjectPartsDoNotExistCommand &second); + friend CMBIPC_EXPORT bool operator < (const ProjectPartsDoNotExistCommand &first, const ProjectPartsDoNotExistCommand &second); + friend CMBIPC_EXPORT QDebug operator <<(QDebug debug, const ProjectPartsDoNotExistCommand &command); + friend void PrintTo(const ProjectPartsDoNotExistCommand &command, ::std::ostream* os); +public: + ProjectPartsDoNotExistCommand() = default; + ProjectPartsDoNotExistCommand(const Utf8StringVector &projectPartIds); + + const Utf8StringVector &projectPartIds() const; + +private: + Utf8StringVector projectPartIds_; +}; + +CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const ProjectPartsDoNotExistCommand &command); +CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, ProjectPartsDoNotExistCommand &command); +CMBIPC_EXPORT bool operator == (const ProjectPartsDoNotExistCommand &first, const ProjectPartsDoNotExistCommand &second); +CMBIPC_EXPORT bool operator < (const ProjectPartsDoNotExistCommand &first, const ProjectPartsDoNotExistCommand &second); + +CMBIPC_EXPORT QDebug operator <<(QDebug debug, const ProjectPartsDoNotExistCommand &command); +void PrintTo(const ProjectPartsDoNotExistCommand &command, ::std::ostream* os); + +} // namespace CodeModelBackEnd + +Q_DECLARE_METATYPE(CodeModelBackEnd::ProjectPartsDoNotExistCommand) + +#endif // CODEMODELBACKEND_PROJECTPARTSDONOTEXISTCOMMAND_H diff --git a/src/libs/codemodelbackendipc/readcommandblock.cpp b/src/libs/codemodelbackendipc/readcommandblock.cpp new file mode 100644 index 0000000000..1b5a2b7e9e --- /dev/null +++ b/src/libs/codemodelbackendipc/readcommandblock.cpp @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** 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 "readcommandblock.h" + +#include <QDataStream> +#include <QIODevice> +#include <QVariant> +#include <QtDebug> + +namespace CodeModelBackEnd { + +ReadCommandBlock::ReadCommandBlock(QIODevice *ioDevice) + : ioDevice(ioDevice), + commandCounter(0), + blockSize(0) +{ +} + +void ReadCommandBlock::checkIfCommandIsLost(QDataStream &in) +{ + qint64 currentCommandCounter; + + in >> currentCommandCounter; + +#ifndef DONT_CHECK_COMMAND_COUNTER + bool commandLost = !((currentCommandCounter == 0 && commandCounter == 0) || (commandCounter + 1 == currentCommandCounter)); + if (commandLost) + qWarning() << "client command lost: " << commandCounter << currentCommandCounter; +#endif + + commandCounter = currentCommandCounter; +} + +QVariant ReadCommandBlock::read() +{ + QDataStream in(ioDevice); + + QVariant command; + + if (isTheWholeCommandReadable(in)) { + checkIfCommandIsLost(in); + in >> command; + } + + return command; +} + +QVector<QVariant> ReadCommandBlock::readAll() +{ + QVector<QVariant> commands; + + while (true) { + const QVariant command = read(); + if (command.isValid()) + commands.append(command); + else + return commands; + } + + Q_UNREACHABLE(); +} + +void ReadCommandBlock::resetCounter() +{ + commandCounter = 0; +} + +bool ReadCommandBlock::isTheWholeCommandReadable(QDataStream &in) +{ + const qint64 bytesAvailable = ioDevice->bytesAvailable(); + + if (bytesAvailable == 0) + return false; + + if (blockSize == 0) + in >> blockSize; + + if (bytesAvailable < blockSize) + return false; + + blockSize = 0; + + return true; +} + +} // namespace CodeModelBackEnd + diff --git a/src/libs/codemodelbackendipc/readcommandblock.h b/src/libs/codemodelbackendipc/readcommandblock.h new file mode 100644 index 0000000000..1d4d93246f --- /dev/null +++ b/src/libs/codemodelbackendipc/readcommandblock.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifndef CODEMODELBACKEND_READCOMMANDBLOCK_H +#define CODEMODELBACKEND_READCOMMANDBLOCK_H + +#include <QtGlobal> + +QT_BEGIN_NAMESPACE +class QVariant; +class QDataStream; +class QIODevice; +QT_END_NAMESPACE + +namespace CodeModelBackEnd { + +class ReadCommandBlock +{ +public: + ReadCommandBlock(QIODevice *ioDevice = nullptr); + + QVariant read(); + QVector<QVariant> readAll(); + + void resetCounter(); + +private: + bool isTheWholeCommandReadable(QDataStream &in); + void checkIfCommandIsLost(QDataStream &in); + +private: + QIODevice *ioDevice; + qint64 commandCounter; + qint32 blockSize; +}; + +} // namespace CodeModelBackEnd + +#endif // CODEMODELBACKEND_READCOMMANDBLOCK_H diff --git a/src/libs/codemodelbackendipc/translationunitdoesnotexistcommand.cpp b/src/libs/codemodelbackendipc/translationunitdoesnotexistcommand.cpp new file mode 100644 index 0000000000..a63c225af3 --- /dev/null +++ b/src/libs/codemodelbackendipc/translationunitdoesnotexistcommand.cpp @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** 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 "translationunitdoesnotexistcommand.h" + +#include <QDebug> + +#include <QDataStream> + +#include <ostream> + +namespace CodeModelBackEnd { + +TranslationUnitDoesNotExistCommand::TranslationUnitDoesNotExistCommand(const FileContainer &fileContainer) + : fileContainer_(fileContainer) +{ +} + +TranslationUnitDoesNotExistCommand::TranslationUnitDoesNotExistCommand(const Utf8String &filePath, const Utf8String &projectPartId) + : fileContainer_(filePath, projectPartId) +{ +} + +const FileContainer &TranslationUnitDoesNotExistCommand::fileContainer() const +{ + return fileContainer_; +} + +const Utf8String &TranslationUnitDoesNotExistCommand::filePath() const +{ + return fileContainer_.filePath(); +} + +const Utf8String &TranslationUnitDoesNotExistCommand::projectPartId() const +{ + return fileContainer_.projectPartId(); +} + +QDataStream &operator<<(QDataStream &out, const TranslationUnitDoesNotExistCommand &command) +{ + out << command.fileContainer_; + + return out; +} + +QDataStream &operator>>(QDataStream &in, TranslationUnitDoesNotExistCommand &command) +{ + in >> command.fileContainer_; + + return in; +} + +bool operator == (const TranslationUnitDoesNotExistCommand &first, const TranslationUnitDoesNotExistCommand &second) +{ + return first.fileContainer_ == second.fileContainer_; +} + +bool operator < (const TranslationUnitDoesNotExistCommand &first, const TranslationUnitDoesNotExistCommand &second) +{ + return first.fileContainer_ < second.fileContainer_; +} + +QDebug operator <<(QDebug debug, const TranslationUnitDoesNotExistCommand &command) +{ + debug.nospace() << "TranslationUnitDoesNotExistCommand("; + + debug.nospace() << command.fileContainer_; + + debug.nospace() << ")"; + + return debug; +} + +void PrintTo(const TranslationUnitDoesNotExistCommand &command, ::std::ostream* os) +{ + QString output; + QDebug debug(&output); + + debug << command; + + *os << output.toUtf8().constData(); +} + +} // namespace CodeModelBackEnd + diff --git a/src/libs/codemodelbackendipc/translationunitdoesnotexistcommand.h b/src/libs/codemodelbackendipc/translationunitdoesnotexistcommand.h new file mode 100644 index 0000000000..535c212fac --- /dev/null +++ b/src/libs/codemodelbackendipc/translationunitdoesnotexistcommand.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifndef CODEMODELBACKEND_TRANSLATIONUNITDOESNOTEXISTSCOMMAND_H +#define CODEMODELBACKEND_TRANSLATIONUNITDOESNOTEXISTSCOMMAND_H + +#include <QMetaType> + +#include "filecontainer.h" + +namespace CodeModelBackEnd { + +class CMBIPC_EXPORT TranslationUnitDoesNotExistCommand +{ + friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const TranslationUnitDoesNotExistCommand &command); + friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, TranslationUnitDoesNotExistCommand &command); + friend CMBIPC_EXPORT bool operator == (const TranslationUnitDoesNotExistCommand &first, const TranslationUnitDoesNotExistCommand &second); + friend CMBIPC_EXPORT bool operator < (const TranslationUnitDoesNotExistCommand &first, const TranslationUnitDoesNotExistCommand &second); + friend CMBIPC_EXPORT QDebug operator <<(QDebug debug, const TranslationUnitDoesNotExistCommand &command); + friend void PrintTo(const TranslationUnitDoesNotExistCommand &command, ::std::ostream* os); +public: + TranslationUnitDoesNotExistCommand() = default; + TranslationUnitDoesNotExistCommand(const FileContainer &fileContainer); + TranslationUnitDoesNotExistCommand(const Utf8String &filePath, const Utf8String &projectPartId); + + const FileContainer &fileContainer() const; + const Utf8String &filePath() const; + const Utf8String &projectPartId() const; + +private: + FileContainer fileContainer_; +}; + +CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const TranslationUnitDoesNotExistCommand &command); +CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, TranslationUnitDoesNotExistCommand &command); +CMBIPC_EXPORT bool operator == (const TranslationUnitDoesNotExistCommand &first, const TranslationUnitDoesNotExistCommand &second); +CMBIPC_EXPORT bool operator < (const TranslationUnitDoesNotExistCommand &first, const TranslationUnitDoesNotExistCommand &second); + +CMBIPC_EXPORT QDebug operator <<(QDebug debug, const TranslationUnitDoesNotExistCommand &command); +void PrintTo(const TranslationUnitDoesNotExistCommand &command, ::std::ostream* os); + +} // namespace CodeModelBackEnd + +Q_DECLARE_METATYPE(CodeModelBackEnd::TranslationUnitDoesNotExistCommand) + +#endif // CODEMODELBACKEND_TRANSLATIONUNITDOESNOTEXISTSCOMMAND_H diff --git a/src/libs/codemodelbackendipc/writecommandblock.cpp b/src/libs/codemodelbackendipc/writecommandblock.cpp new file mode 100644 index 0000000000..e6bdc0792a --- /dev/null +++ b/src/libs/codemodelbackendipc/writecommandblock.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** 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 "writecommandblock.h" + +#include <QDataStream> +#include <QIODevice> +#include <QVariant> +#include <QtDebug> + +namespace CodeModelBackEnd { + +WriteCommandBlock::WriteCommandBlock(QIODevice *ioDevice) + : commandCounter(0), + ioDevice(ioDevice) +{ +} + +void WriteCommandBlock::write(const QVariant &command) +{ + QByteArray block; + QDataStream out(&block, QIODevice::WriteOnly); + + const qint32 dummyBockSize = 0; + out << dummyBockSize; + + out << commandCounter; + + out << command; + + out.device()->seek(0); + out << qint32(block.size()); + + ++commandCounter; + + ioDevice->write(block); +} + +qint64 WriteCommandBlock::counter() const +{ + return commandCounter; +} + +void WriteCommandBlock::resetCounter() +{ + commandCounter = 0; +} + + +} // namespace CodeModelBackEnd + diff --git a/src/libs/codemodelbackendipc/writecommandblock.h b/src/libs/codemodelbackendipc/writecommandblock.h new file mode 100644 index 0000000000..18ee35b7c1 --- /dev/null +++ b/src/libs/codemodelbackendipc/writecommandblock.h @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and 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. +** +****************************************************************************/ + +#ifndef CODEMODELBACKEND_WRITECOMMANDBLOCK_H +#define CODEMODELBACKEND_WRITECOMMANDBLOCK_H + +#include <QtGlobal> + +QT_BEGIN_NAMESPACE +class QVariant; +class QDataStream; +class QIODevice; +QT_END_NAMESPACE + +namespace CodeModelBackEnd { + +class WriteCommandBlock +{ +public: + WriteCommandBlock(QIODevice *ioDevice = nullptr); + + void write(const QVariant &command); + + qint64 counter() const; + + void resetCounter(); + +private: + qint64 commandCounter; + QIODevice *ioDevice; +}; + +} // namespace CodeModelBackEnd + +#endif // CODEMODELBACKEND_WRITECOMMANDBLOCK_H |