Clang: Rename CodeModelBackEnd in ClangBackEnd

Change-Id: I13e8a458634110456375956d4d4da7239c86957f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
Marco Bubke
2015-06-16 11:56:00 +02:00
parent 1e92b84633
commit 1402c067b1
167 changed files with 745 additions and 954 deletions

View File

@@ -0,0 +1,73 @@
contains(CONFIG, dll) {
DEFINES += CLANGBACKENDIPC_BUILD_LIB
} else {
DEFINES += CLANGBACKENDIPC_BUILD_STATIC_LIB
}
QT += network
DEFINES += CLANGBACKENDIPC_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/cmbregisterprojectsforcodecompletioncommand.cpp \
$$PWD/cmbunregisterprojectsforcodecompletioncommand.cpp \
$$PWD/translationunitdoesnotexistcommand.cpp \
$$PWD/codecompletionchunk.cpp \
$$PWD/projectpartcontainer.cpp \
$$PWD/projectpartsdonotexistcommand.cpp
HEADERS += \
$$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 \
$$PWD/container_common.h \
$$PWD/clangbackendipc_global.h
contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols

View File

@@ -0,0 +1,2 @@
include(../../qtcreatorlibrary.pri)
include(clangbackendipc-lib.pri)

View File

@@ -0,0 +1,28 @@
import qbs 1.0
QtcLibrary {
name: "ClangBackEndIpc"
Depends { name: "Qt.network" }
Depends { name: "Sqlite" }
cpp.defines: base.concat("CLANGIPC_LIBRARY")
cpp.includePaths: base.concat(".")
Group {
files: [
"*.h",
"*.cpp"
]
}
Export {
Depends { name: "Sqlite" }
Depends { name: "Qt.network" }
cpp.includePaths: [
"."
]
}
}

View File

@@ -0,0 +1,3 @@
QTC_LIB_NAME = Clangbackendipc
QTC_LIB_DEPENDS += sqlite
INCLUDEPATH *= $$IDE_SOURCE_TREE/src/libs/clangbackendipc

View File

@@ -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 CLANGBACKENDIPC_GLOBAL_H
#define CLANGBACKENDIPC_GLOBAL_H
#include <QtCore/qglobal.h>
#if defined(CLANGBACKENDIPC_LIBRARY)
# define CMBIPC_EXPORT Q_DECL_EXPORT
#else
# define CMBIPC_EXPORT Q_DECL_IMPORT
#endif
#ifndef CLANGBACKENDPROCESSPATH
# define CLANGBACKENDPROCESSPATH ""
#endif
namespace ClangBackEnd {
CMBIPC_EXPORT void registerTypes();
}
#endif // CLANGBACKENDIPC_GLOBAL_H

View File

@@ -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 ClangBackEnd {
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()";
}
}

View File

@@ -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 "clangbackendipc_global.h"
#include <QMetaType>
namespace ClangBackEnd {
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(ClangBackEnd::AliveCommand)
#endif // CMBALIVECOMMAND_H

View File

@@ -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 ClangBackEnd {
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 ClangBackEnd

View File

@@ -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 CLANGBACKEND_CODECOMPLETEDCOMMAND_H
#define CLANGBACKEND_CODECOMPLETEDCOMMAND_H
#include <QMetaType>
#include <QVector>
#include "codecompletion.h"
namespace ClangBackEnd {
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 ClangBackEnd
Q_DECLARE_METATYPE(ClangBackEnd::CodeCompletedCommand)
#endif // CLANGBACKEND_CODECOMPLETEDCOMMAND_H

View File

@@ -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 ClangBackEnd {
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 ClangBackEnd

View File

@@ -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 CLANGBACKEND_COMMANDS_H
#define CLANGBACKEND_COMMANDS_H
#include <clangbackendipc_global.h>
namespace ClangBackEnd {
namespace Commands
{
CMBIPC_EXPORT void registerCommands();
}
} // namespace ClangBackEnd
#endif // CLANGBACKEND_COMMANDS_H

View File

@@ -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 ClangBackEnd {
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 ClangBackEnd

View File

@@ -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 CLANGBACKEND_COMPLETECODECOMMAND_H
#define CLANGBACKEND_COMPLETECODECOMMAND_H
#include "clangbackendipc_global.h"
#include <QMetaType>
#include <utf8string.h>
namespace ClangBackEnd {
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 ClangBackEnd
Q_DECLARE_METATYPE(ClangBackEnd::CompleteCodeCommand)
#endif // CLANGBACKEND_COMPLETECODECOMMAND_H

View File

@@ -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 ClangBackEnd {
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 ClangBackEnd

View File

@@ -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 CLANGBACKEND_ECHOCOMMAND_H
#define CLANGBACKEND_ECHOCOMMAND_H
#include "clangbackendipc_global.h"
#include <QMetaType>
#include <QVariant>
namespace ClangBackEnd {
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 ClangBackEnd
Q_DECLARE_METATYPE(ClangBackEnd::EchoCommand)
#endif // CLANGBACKEND_ECHOCOMMAND_H

View File

@@ -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 ClangBackEnd {
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()";
}
}

View File

@@ -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 "clangbackendipc_global.h"
#include <QMetaType>
namespace ClangBackEnd {
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(ClangBackEnd::EndCommand)
#endif // CMBENDCOMMAND_H

View File

@@ -0,0 +1,102 @@
/****************************************************************************
**
** 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>
#include <algorithm>
#include "container_common.h"
namespace ClangBackEnd {
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 compareContainer(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 ClangBackEnd

View File

@@ -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 CLANGBACKEND_REGISTERPROJECTSFORCODECOMPLETIONCOMAND_H
#define CLANGBACKEND_REGISTERPROJECTSFORCODECOMPLETIONCOMAND_H
#include <QMetaType>
#include <QVector>
#include "projectpartcontainer.h"
namespace ClangBackEnd {
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 ClangBackEnd
Q_DECLARE_METATYPE(ClangBackEnd::RegisterProjectPartsForCodeCompletionCommand)
#endif // CLANGBACKEND_REGISTERPROJECTSFORCODECOMPLETIONCOMAND_H

View File

@@ -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 "cmbregistertranslationunitsforcodecompletioncommand.h"
#include <QtDebug>
#include <QDataStream>
#include <ostream>
#include "container_common.h"
namespace ClangBackEnd {
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 compareContainer(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 ClangBackEnd

View File

@@ -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 CLANGBACKEND_REGISTERFILEFORCODECOMPLETION_H
#define CLANGBACKEND_REGISTERFILEFORCODECOMPLETION_H
#include <qmetatype.h>
#include <QVector>
#include "filecontainer.h"
namespace ClangBackEnd {
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 ClangBackEnd
Q_DECLARE_METATYPE(ClangBackEnd::RegisterTranslationUnitForCodeCompletionCommand)
#endif // CLANGBACKEND_REGISTERFILEFORCODECOMPLITION_H

View File

@@ -0,0 +1,101 @@
/****************************************************************************
**
** 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>
#include "container_common.h"
namespace ClangBackEnd {
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 compareContainer(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 ClangBackEnd

View File

@@ -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 CLANGBACKEND_UNREGISTERPROJECTSFORCODECOMPLETION_H
#define CLANGBACKEND_UNREGISTERPROJECTSFORCODECOMPLETION_H
#include "clangbackendipc_global.h"
#include <utf8stringvector.h>
#include <QMetaType>
namespace ClangBackEnd {
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 ClangBackEnd
Q_DECLARE_METATYPE(ClangBackEnd::UnregisterProjectPartsForCodeCompletionCommand)
#endif // CLANGBACKEND_UNREGISTERPROJECTSFORCODECOMPLETION_H

View File

@@ -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 "cmbunregistertranslationunitsforcodecompletioncommand.h"
#include <QtDebug>
#ifdef CLANGBACKEND_TESTS
#include <gtest/gtest-printers.h>
#endif
#include <QDataStream>
#include "container_common.h"
namespace ClangBackEnd {
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 compareContainer(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 CLANGBACKEND_TESTS
void PrintTo(const UnregisterTranslationUnitsForCodeCompletionCommand &command, ::std::ostream* os)
{
*os << "UnregisterTranslationUnitsForCodeCompletionCommand(";
for (const FileContainer &fileContainer : command.fileContainers())
*os << ::testing::PrintToString(fileContainer) << ", ";
*os << ")";
}
#endif
} // namespace ClangBackEnd

View File

@@ -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 CLANGBACKEND_UNRegisterTranslationUnitForCodeCompletionCommand_H
#define CLANGBACKEND_UNRegisterTranslationUnitForCodeCompletionCommand_H
#include "clangbackendipc_global.h"
#include "filecontainer.h"
#include <QVector>
#include <QMetaType>
namespace ClangBackEnd {
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 CLANGBACKEND_TESTS
void PrintTo(const UnregisterTranslationUnitsForCodeCompletionCommand &command, ::std::ostream* os);
#endif
} // namespace ClangBackEnd
Q_DECLARE_METATYPE(ClangBackEnd::UnregisterTranslationUnitsForCodeCompletionCommand)
#endif // CLANGBACKEND_UNRegisterTranslationUnitForCodeCompletionCommand_H

View File

@@ -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 ClangBackEnd {
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 ClangBackEnd

View File

@@ -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 CLANGBACKEND_CODECOMPLETION_H
#define CLANGBACKEND_CODECOMPLETION_H
#include <QMetaType>
#include <utf8string.h>
#include "codecompletionchunk.h"
#include "clangbackendipc_global.h"
namespace ClangBackEnd {
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 ClangBackEnd
Q_DECLARE_METATYPE(ClangBackEnd::CodeCompletion)
#endif // CLANGBACKEND_CODECOMPLETION_H

View File

@@ -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 ClangBackEnd {
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 ClangBackEnd

View File

@@ -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 CLANGBACKEND_CODECOMPLETIONCHUNK_H
#define CLANGBACKEND_CODECOMPLETIONCHUNK_H
#include <utf8string.h>
#include <QVector>
#include "clangbackendipc_global.h"
namespace ClangBackEnd {
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 ClangBackEnd
Q_DECLARE_METATYPE(ClangBackEnd::CodeCompletionChunk)
#endif // CLANGBACKEND_CODECOMPLETIONCHUNK_H

View File

@@ -0,0 +1,288 @@
/****************************************************************************
**
** 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 ClangBackEnd {
namespace {
QString currentProcessId()
{
return QString::number(QCoreApplication::applicationPid());
}
QString connectionName()
{
return QStringLiteral("ClangBackEnd-") + 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::sendEndCommand()
{
serverProxy_.end();
localSocket.flush();
}
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() << "ClangBackEnd:" << process_->readAllStandardOutput();
}
void ConnectionClient::printStandardError()
{
qWarning() << "ClangBackEnd 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 ClangBackEnd

View File

@@ -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 CLANGBACKEND_CONNECTIONCLIENT_H
#define CLANGBACKEND_CONNECTIONCLIENT_H
#include <QLocalSocket>
#include <memory>
#include "ipcserverproxy.h"
QT_BEGIN_NAMESPACE
class QProcess;
QT_END_NAMESPACE
class Utf8String;
class Utf8StringVector;
namespace ClangBackEnd {
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 ClangBackEnd
#endif // CLANGBACKEND_CONNECTIONCLIENT_H

View File

@@ -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 ClangBackEnd {
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(_GLIBCXX_HAVE_AT_QUICK_EXIT)
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 ClangBackEnd

View File

@@ -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 CLANGBACKEND_CONNECTIONSERVER_H
#define CLANGBACKEND_CONNECTIONSERVER_H
#include <QLocalServer>
#include <ipcclientproxy.h>
#include <vector>
namespace ClangBackEnd {
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 ClangBackEnd
#endif // CLANGBACKEND_CONNECTIONSERVER_H

View File

@@ -0,0 +1,62 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef CONTAINER_COMMON_H
#define CONTAINER_COMMON_H
namespace ClangBackEnd {
template <typename Container>
bool compareContainer(const Container &first, const Container &second)
{
if (first.size() != second.size())
return first.size() < second.size();
Container firstCopy = first;
Container secondCopy = second;
std::sort(firstCopy.begin(), firstCopy.end());
std::sort(secondCopy.begin(), secondCopy.end());
auto isProjectPartContainerSmaller = [] (decltype(*first.cbegin()) &firstElement,
decltype(*second.cbegin()) &secondElement) {
return firstElement < secondElement;
};
return std::equal(firstCopy.cbegin(),
firstCopy.cend(),
secondCopy.cbegin(),
isProjectPartContainerSmaller);
}
}
#endif // CONTAINER_COMMON_H

View File

@@ -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 ClangBackEnd {
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 ClangBackEnd

View File

@@ -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 CLANGBACKEND_FILECONTAINER_H
#define CLANGBACKEND_FILECONTAINER_H
#include <qmetatype.h>
#include <utf8string.h>
#include <clangbackendipc_global.h>
namespace ClangBackEnd {
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 ClangBackEnd
Q_DECLARE_METATYPE(ClangBackEnd::FileContainer)
#endif // CLANGBACKEND_FILECONTAINER_H

View File

@@ -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 ClangBackEnd {
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 ClangBackEnd

View File

@@ -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 CLANGBACKEND_IPCCLIENTDISPATCHER_H
#define CLANGBACKEND_IPCCLIENTDISPATCHER_H
#include "ipcclientinterface.h"
#include <QVector>
namespace ClangBackEnd {
class CMBIPC_EXPORT IpcClientDispatcher : public ClangBackEnd::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 ClangBackEnd
#endif // CLANGBACKEND_IPCCLIENTDISPATCHER_H

View File

@@ -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 ClangBackEnd {
void IpcClientInterface::dispatch(const QVariant &command)
{
static const int aliveCommandType = QMetaType::type("ClangBackEnd::AliveCommand");
static const int echoCommandType = QMetaType::type("ClangBackEnd::EchoCommand");
static const int codeCompletedCommandType = QMetaType::type("ClangBackEnd::CodeCompletedCommand");
static const int translationUnitDoesNotExistCommand = QMetaType::type("ClangBackEnd::TranslationUnitDoesNotExistCommand");
static const int projectPartsDoNotExistCommand = QMetaType::type("ClangBackEnd::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 ClangBackEnd

View File

@@ -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 CLANGBACKEND_IPCCLIENTINTERFACE_H
#define CLANGBACKEND_IPCCLIENTINTERFACE_H
#include "ipcinterface.h"
namespace ClangBackEnd {
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 ClangBackEnd
#endif // CLANGBACKEND_IPCCLIENTINTERFACE_H

View File

@@ -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 ClangBackEnd {
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 ClangBackEnd

View File

@@ -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 "clangbackendipc_global.h"
#include "ipcclientinterface.h"
#include "writecommandblock.h"
#include "readcommandblock.h"
QT_BEGIN_NAMESPACE
class QLocalServer;
class QIODevice;
QT_END_NAMESPACE
namespace ClangBackEnd {
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:
ClangBackEnd::WriteCommandBlock writeCommandBlock;
ClangBackEnd::ReadCommandBlock readCommandBlock;
IpcServerInterface *server = nullptr;
QIODevice *ioDevice = nullptr;
};
} // namespace ClangBackEnd
#endif // CODELMODELBACKEND_IPCCLIENTPROXY_H

View File

@@ -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 ClangBackEnd {
IpcInterface::~IpcInterface()
{
}
} // namespace ClangBackEnd

View File

@@ -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 CLANGBACKEND_IPCINTERFACE_H
#define CLANGBACKEND_IPCINTERFACE_H
#include <QtGlobal>
QT_BEGIN_NAMESPACE
class QVariant;
QT_END_NAMESPACE
#include "clangbackendipc_global.h"
namespace ClangBackEnd {
class CMBIPC_EXPORT IpcInterface
{
public:
virtual ~IpcInterface();
virtual void dispatch(const QVariant &command) = 0;
};
} // namespace ClangBackEnd
#endif // CLANGBACKEND_IPCINTERFACE_H

View File

@@ -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 ClangBackEnd {
IpcServer::IpcServer()
{
}
IpcServer::~IpcServer()
{
}
} // namespace ClangBackEnd

View File

@@ -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 CLANGBACKEND_IPCSERVER_H
#define CLANGBACKEND_IPCSERVER_H
#include "ipcserverinterface.h"
namespace ClangBackEnd {
class IpcServer : public IpcServerInterface
{
public:
IpcServer();
~IpcServer();
};
} // namespace ClangBackEnd
#endif // CLANGBACKEND_IPCSERVER_H

View File

@@ -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 ClangBackEnd {
void IpcServerInterface::dispatch(const QVariant &command)
{
static const int endCommandType = QMetaType::type("ClangBackEnd::EndCommand");
static const int registerTranslationUnitsForCodeCompletionCommandType = QMetaType::type("ClangBackEnd::RegisterTranslationUnitForCodeCompletionCommand");
static const int unregisterTranslationUnitsForCodeCompletionCommandType = QMetaType::type("ClangBackEnd::UnregisterTranslationUnitsForCodeCompletionCommand");
static const int registerProjectPartsForCodeCompletionCommandType = QMetaType::type("ClangBackEnd::RegisterProjectPartsForCodeCompletionCommand");
static const int unregisterProjectPartsForCodeCompletionCommandType = QMetaType::type("ClangBackEnd::UnregisterProjectPartsForCodeCompletionCommand");
static const int completeCodeCommandType = QMetaType::type("ClangBackEnd::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 ClangBackEnd

View File

@@ -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 CLANGBACKEND_IPCSERVERINTERFACE_H
#define CLANGBACKEND_IPCSERVERINTERFACE_H
#include "ipcinterface.h"
#include "ipcclientdispatcher.h"
namespace ClangBackEnd {
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 ClangBackEnd
#endif // CLANGBACKEND_IPCSERVERINTERFACE_H

View File

@@ -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 ClangBackEnd {
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 ClangBackEnd

View File

@@ -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 CLANGBACKEND_IPCSERVERPROXY_H
#define CLANGBACKEND_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 ClangBackEnd {
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:
ClangBackEnd::WriteCommandBlock writeCommandBlock;
ClangBackEnd::ReadCommandBlock readCommandBlock;
IpcClientInterface *client;
};
} // namespace ClangBackEnd
#endif // CLANGBACKEND_IPCSERVERPROXY_H

View File

@@ -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 ClangBackEnd {
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 ClangBackEnd

View File

@@ -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 CLANGBACKEND_PROJECTCONTAINER_H
#define CLANGBACKEND_PROJECTCONTAINER_H
#include <QMetaType>
#include <utf8stringvector.h>
#include <clangbackendipc_global.h>
namespace ClangBackEnd {
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 ClangBackEnd
Q_DECLARE_METATYPE(ClangBackEnd::ProjectPartContainer)
#endif // CLANGBACKEND_PROJECTCONTAINER_H

View File

@@ -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 ClangBackEnd {
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 ClangBackEnd

View File

@@ -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 CLANGBACKEND_PROJECTPARTSDONOTEXISTCOMMAND_H
#define CLANGBACKEND_PROJECTPARTSDONOTEXISTCOMMAND_H
#include <QMetaType>
#include <utf8stringvector.h>
#include "clangbackendipc_global.h"
namespace ClangBackEnd {
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 ClangBackEnd
Q_DECLARE_METATYPE(ClangBackEnd::ProjectPartsDoNotExistCommand)
#endif // CLANGBACKEND_PROJECTPARTSDONOTEXISTCOMMAND_H

View File

@@ -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.
**
****************************************************************************/
#include "readcommandblock.h"
#include <QDataStream>
#include <QIODevice>
#include <QVariant>
#include <QtDebug>
namespace ClangBackEnd {
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)
{
if (ioDevice->bytesAvailable() == 0)
return false;
if (blockSize == 0)
in >> blockSize;
if (ioDevice->bytesAvailable() < blockSize)
return false;
blockSize = 0;
return true;
}
} // namespace ClangBackEnd

View File

@@ -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 CLANGBACKEND_READCOMMANDBLOCK_H
#define CLANGBACKEND_READCOMMANDBLOCK_H
#include <QtGlobal>
QT_BEGIN_NAMESPACE
class QVariant;
class QDataStream;
class QIODevice;
QT_END_NAMESPACE
namespace ClangBackEnd {
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 ClangBackEnd
#endif // CLANGBACKEND_READCOMMANDBLOCK_H

View File

@@ -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 ClangBackEnd {
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 ClangBackEnd

View File

@@ -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 CLANGBACKEND_TRANSLATIONUNITDOESNOTEXISTSCOMMAND_H
#define CLANGBACKEND_TRANSLATIONUNITDOESNOTEXISTSCOMMAND_H
#include <QMetaType>
#include "filecontainer.h"
namespace ClangBackEnd {
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 ClangBackEnd
Q_DECLARE_METATYPE(ClangBackEnd::TranslationUnitDoesNotExistCommand)
#endif // CLANGBACKEND_TRANSLATIONUNITDOESNOTEXISTSCOMMAND_H

View File

@@ -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 ClangBackEnd {
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() - sizeof(qint32));
++commandCounter;
ioDevice->write(block);
}
qint64 WriteCommandBlock::counter() const
{
return commandCounter;
}
void WriteCommandBlock::resetCounter()
{
commandCounter = 0;
}
} // namespace ClangBackEnd

View File

@@ -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 CLANGBACKEND_WRITECOMMANDBLOCK_H
#define CLANGBACKEND_WRITECOMMANDBLOCK_H
#include <QtGlobal>
QT_BEGIN_NAMESPACE
class QVariant;
class QDataStream;
class QIODevice;
QT_END_NAMESPACE
namespace ClangBackEnd {
class WriteCommandBlock
{
public:
WriteCommandBlock(QIODevice *ioDevice = nullptr);
void write(const QVariant &command);
qint64 counter() const;
void resetCounter();
private:
qint64 commandCounter;
QIODevice *ioDevice;
};
} // namespace ClangBackEnd
#endif // CLANGBACKEND_WRITECOMMANDBLOCK_H