forked from qt-creator/qt-creator
Clang: Add diagnostics
Diagnostics are now moved to the clang backend process. Fixits are supported too. Change-Id: I20faacf466bbf78dec479220c3d7b336a47bc453 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
@@ -37,7 +37,13 @@ SOURCES += $$PWD/ipcserverinterface.cpp \
|
||||
$$PWD/projectpartcontainer.cpp \
|
||||
$$PWD/projectpartsdonotexistmessage.cpp \
|
||||
$$PWD/lineprefixer.cpp \
|
||||
$$PWD/clangbackendipcdebugutils.cpp
|
||||
$$PWD/clangbackendipcdebugutils.cpp \
|
||||
$$PWD/diagnosticschangedmessage.cpp \
|
||||
$$PWD/diagnosticcontainer.cpp \
|
||||
$$PWD/sourcerangecontainer.cpp \
|
||||
$$PWD/sourcelocationcontainer.cpp \
|
||||
$$PWD/fixitcontainer.cpp \
|
||||
$$PWD/requestdiagnosticsmessage.cpp
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/ipcserverinterface.h \
|
||||
@@ -69,6 +75,12 @@ HEADERS += \
|
||||
$$PWD/container_common.h \
|
||||
$$PWD/clangbackendipc_global.h \
|
||||
$$PWD/lineprefixer.h \
|
||||
$$PWD/clangbackendipcdebugutils.h
|
||||
$$PWD/clangbackendipcdebugutils.h \
|
||||
$$PWD/diagnosticschangedmessage.h \
|
||||
$$PWD/diagnosticcontainer.h \
|
||||
$$PWD/sourcerangecontainer.h \
|
||||
$$PWD/sourcelocationcontainer.h \
|
||||
$$PWD/fixitcontainer.h \
|
||||
$$PWD/requestdiagnosticsmessage.h
|
||||
|
||||
contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols
|
||||
|
||||
@@ -45,6 +45,14 @@
|
||||
|
||||
namespace ClangBackEnd {
|
||||
CMBIPC_EXPORT void registerTypes();
|
||||
}
|
||||
|
||||
enum class DiagnosticSeverity // one to one mapping of the clang enum numbers
|
||||
{
|
||||
Ignored = 0,
|
||||
Note = 1,
|
||||
Warning = 2,
|
||||
Error = 3,
|
||||
Fatal = 4
|
||||
};
|
||||
}
|
||||
#endif // CLANGBACKENDIPC_GLOBAL_H
|
||||
|
||||
@@ -39,7 +39,12 @@
|
||||
#include "cmbunregisterprojectsforcodecompletionmessage.h"
|
||||
#include "cmbcompletecodemessage.h"
|
||||
#include "cmbcodecompletedmessage.h"
|
||||
#include "diagnosticcontainer.h"
|
||||
#include "diagnosticschangedmessage.h"
|
||||
#include "requestdiagnosticsmessage.h"
|
||||
#include "projectpartsdonotexistmessage.h"
|
||||
#include "sourcelocationcontainer.h"
|
||||
#include "sourcerangecontainer.h"
|
||||
#include "translationunitdoesnotexistmessage.h"
|
||||
|
||||
#include <QDataStream>
|
||||
@@ -102,6 +107,26 @@ void Messages::registerMessages()
|
||||
qRegisterMetaType<ProjectPartsDoNotExistMessage>();
|
||||
qRegisterMetaTypeStreamOperators<ProjectPartsDoNotExistMessage>();
|
||||
QMetaType::registerComparators<ProjectPartsDoNotExistMessage>();
|
||||
|
||||
qRegisterMetaType<DiagnosticsChangedMessage>();
|
||||
qRegisterMetaTypeStreamOperators<DiagnosticsChangedMessage>();
|
||||
QMetaType::registerComparators<DiagnosticsChangedMessage>();
|
||||
|
||||
qRegisterMetaType<DiagnosticContainer>();
|
||||
qRegisterMetaTypeStreamOperators<DiagnosticContainer>();
|
||||
QMetaType::registerComparators<DiagnosticContainer>();
|
||||
|
||||
qRegisterMetaType<SourceLocationContainer>();
|
||||
qRegisterMetaTypeStreamOperators<SourceLocationContainer>();
|
||||
QMetaType::registerComparators<SourceLocationContainer>();
|
||||
|
||||
qRegisterMetaType<SourceRangeContainer>();
|
||||
qRegisterMetaTypeStreamOperators<SourceRangeContainer>();
|
||||
QMetaType::registerComparators<SourceRangeContainer>();
|
||||
|
||||
qRegisterMetaType<RequestDiagnosticsMessage>();
|
||||
qRegisterMetaTypeStreamOperators<RequestDiagnosticsMessage>();
|
||||
QMetaType::registerComparators<RequestDiagnosticsMessage>();
|
||||
}
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
202
src/libs/clangbackendipc/diagnosticcontainer.cpp
Normal file
202
src/libs/clangbackendipc/diagnosticcontainer.cpp
Normal file
@@ -0,0 +1,202 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "diagnosticcontainer.h"
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
DiagnosticContainer::DiagnosticContainer(const Utf8String &text,
|
||||
const Utf8String &category,
|
||||
const std::pair<Utf8String,Utf8String> &options,
|
||||
DiagnosticSeverity severity,
|
||||
const SourceLocationContainer &location,
|
||||
const QVector<SourceRangeContainer> &ranges,
|
||||
const QVector<FixItContainer> &fixIts,
|
||||
const QVector<DiagnosticContainer> &children)
|
||||
: location_(location),
|
||||
ranges_(ranges),
|
||||
text_(text),
|
||||
category_(category),
|
||||
enableOption_(options.first),
|
||||
disableOption_(options.second),
|
||||
children_(children),
|
||||
fixIts_(fixIts),
|
||||
severity_(severity)
|
||||
{
|
||||
}
|
||||
|
||||
const Utf8String &DiagnosticContainer::text() const
|
||||
{
|
||||
return text_;
|
||||
}
|
||||
|
||||
const Utf8String &DiagnosticContainer::category() const
|
||||
{
|
||||
return category_;
|
||||
}
|
||||
|
||||
const Utf8String &DiagnosticContainer::enableOption() const
|
||||
{
|
||||
return enableOption_;
|
||||
}
|
||||
|
||||
const Utf8String &DiagnosticContainer::disableOption() const
|
||||
{
|
||||
return disableOption_;
|
||||
}
|
||||
|
||||
const SourceLocationContainer &DiagnosticContainer::location() const
|
||||
{
|
||||
return location_;
|
||||
}
|
||||
|
||||
const QVector<SourceRangeContainer> &DiagnosticContainer::ranges() const
|
||||
{
|
||||
return ranges_;
|
||||
}
|
||||
|
||||
DiagnosticSeverity DiagnosticContainer::severity() const
|
||||
{
|
||||
return severity_;
|
||||
}
|
||||
|
||||
const QVector<FixItContainer> &DiagnosticContainer::fixIts() const
|
||||
{
|
||||
return fixIts_;
|
||||
}
|
||||
|
||||
const QVector<DiagnosticContainer> &DiagnosticContainer::children() const
|
||||
{
|
||||
return children_;
|
||||
}
|
||||
|
||||
quint32 &DiagnosticContainer::severityAsInt()
|
||||
{
|
||||
return reinterpret_cast<quint32&>(severity_);
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const DiagnosticContainer &container)
|
||||
{
|
||||
out << container.text_;
|
||||
out << container.category_;
|
||||
out << container.enableOption_;
|
||||
out << container.disableOption_;
|
||||
out << container.location_;
|
||||
out << quint32(container.severity_);
|
||||
out << container.ranges_;
|
||||
out << container.fixIts_;
|
||||
out << container.children_;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, DiagnosticContainer &container)
|
||||
{
|
||||
in >> container.text_;
|
||||
in >> container.category_;
|
||||
in >> container.enableOption_;
|
||||
in >> container.disableOption_;
|
||||
in >> container.location_;
|
||||
in >> container.severityAsInt();
|
||||
in >> container.ranges_;
|
||||
in >> container.fixIts_;
|
||||
in >> container.children_;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
bool operator==(const DiagnosticContainer &first, const DiagnosticContainer &second)
|
||||
{
|
||||
return first.text_ == second.text_
|
||||
&& first.location_ == second.location_;
|
||||
}
|
||||
|
||||
bool operator<(const DiagnosticContainer &first, const DiagnosticContainer &second)
|
||||
{
|
||||
return first.text_ < second.text_
|
||||
|| (first.text_ == second.text_ && first.location_ < second.location_);
|
||||
}
|
||||
|
||||
static const char *severityToText(DiagnosticSeverity severity)
|
||||
{
|
||||
switch (severity) {
|
||||
case DiagnosticSeverity::Ignored: return "Ignored";
|
||||
case DiagnosticSeverity::Note: return "Note";
|
||||
case DiagnosticSeverity::Warning: return "Warning";
|
||||
case DiagnosticSeverity::Error: return "Error";
|
||||
case DiagnosticSeverity::Fatal: return "Fatal";
|
||||
}
|
||||
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug debug, const DiagnosticContainer &container)
|
||||
{
|
||||
debug.nospace() << "DiagnosticContainer("
|
||||
<< container.text() << ", "
|
||||
<< container.category() << ", "
|
||||
<< container.enableOption() << ", "
|
||||
<< container.disableOption() << ", "
|
||||
<< container.location() << ", "
|
||||
<< container.ranges() << ", "
|
||||
<< container.fixIts() << ", "
|
||||
<< container.children()
|
||||
<< ")";
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
||||
void PrintTo(const DiagnosticContainer &container, ::std::ostream* os)
|
||||
{
|
||||
*os << severityToText(container.severity()) << ": "
|
||||
<< container.text().constData() << ", "
|
||||
<< container.category().constData() << ", "
|
||||
<< container.enableOption().constData() << ", ";
|
||||
PrintTo(container.location(), os);
|
||||
*os << "[";
|
||||
for (const auto &range : container.ranges())
|
||||
PrintTo(range, os);
|
||||
*os << "], ";
|
||||
*os << "[";
|
||||
for (const auto &fixIt : container.fixIts())
|
||||
PrintTo(fixIt, os);
|
||||
*os << "], ";
|
||||
*os << "[";
|
||||
for (const auto &child : container.children())
|
||||
PrintTo(child, os);
|
||||
*os << "], ";
|
||||
*os << ")";
|
||||
}
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
98
src/libs/clangbackendipc/diagnosticcontainer.h
Normal file
98
src/libs/clangbackendipc/diagnosticcontainer.h
Normal file
@@ -0,0 +1,98 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and 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 CLANGBACKEND_DIAGNOSTICCONTAINER_H
|
||||
#define CLANGBACKEND_DIAGNOSTICCONTAINER_H
|
||||
|
||||
#include "sourcerangecontainer.h"
|
||||
#include "fixitcontainer.h"
|
||||
|
||||
#include <QVector>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
class CMBIPC_EXPORT DiagnosticContainer
|
||||
{
|
||||
friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const DiagnosticContainer &container);
|
||||
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, DiagnosticContainer &container);
|
||||
friend CMBIPC_EXPORT bool operator==(const DiagnosticContainer &first, const DiagnosticContainer &second);
|
||||
friend CMBIPC_EXPORT bool operator<(const DiagnosticContainer &first, const DiagnosticContainer &second);
|
||||
|
||||
public:
|
||||
DiagnosticContainer() = default;
|
||||
DiagnosticContainer(const Utf8String &text,
|
||||
const Utf8String &category,
|
||||
const std::pair<Utf8String,Utf8String> &options,
|
||||
DiagnosticSeverity severity,
|
||||
const SourceLocationContainer &location,
|
||||
const QVector<SourceRangeContainer> &ranges,
|
||||
const QVector<FixItContainer> &fixIts,
|
||||
const QVector<DiagnosticContainer> &children);
|
||||
|
||||
const Utf8String &text() const;
|
||||
const Utf8String &category() const;
|
||||
const Utf8String &enableOption() const;
|
||||
const Utf8String &disableOption() const;
|
||||
const SourceLocationContainer &location() const;
|
||||
const QVector<SourceRangeContainer> &ranges() const;
|
||||
DiagnosticSeverity severity() const;
|
||||
const QVector<FixItContainer> &fixIts() const;
|
||||
const QVector<DiagnosticContainer> &children() const;
|
||||
|
||||
private:
|
||||
quint32 &severityAsInt();
|
||||
|
||||
private:
|
||||
SourceLocationContainer location_;
|
||||
QVector<SourceRangeContainer> ranges_;
|
||||
Utf8String text_;
|
||||
Utf8String category_;
|
||||
Utf8String enableOption_;
|
||||
Utf8String disableOption_;
|
||||
QVector<DiagnosticContainer> children_;
|
||||
QVector<FixItContainer> fixIts_;
|
||||
DiagnosticSeverity severity_;
|
||||
};
|
||||
|
||||
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const DiagnosticContainer &container);
|
||||
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, DiagnosticContainer &container);
|
||||
CMBIPC_EXPORT bool operator==(const DiagnosticContainer &first, const DiagnosticContainer &second);
|
||||
CMBIPC_EXPORT bool operator<(const DiagnosticContainer &first, const DiagnosticContainer &second);
|
||||
|
||||
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const DiagnosticContainer &container);
|
||||
void PrintTo(const DiagnosticContainer &container, ::std::ostream* os);
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
Q_DECLARE_METATYPE(ClangBackEnd::DiagnosticContainer)
|
||||
|
||||
#endif // CLANGBACKEND_DIAGNOSTICCONTAINER_H
|
||||
112
src/libs/clangbackendipc/diagnosticschangedmessage.cpp
Normal file
112
src/libs/clangbackendipc/diagnosticschangedmessage.cpp
Normal 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 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.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "diagnosticschangedmessage.h"
|
||||
|
||||
#include "container_common.h"
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
DiagnosticsChangedMessage::DiagnosticsChangedMessage(const FileContainer &file,
|
||||
const QVector<DiagnosticContainer> &diagnostics,
|
||||
quint32 documentRevision)
|
||||
: file_(file),
|
||||
diagnostics_(diagnostics),
|
||||
documentRevision_(documentRevision)
|
||||
{
|
||||
}
|
||||
|
||||
const FileContainer &DiagnosticsChangedMessage::file() const
|
||||
{
|
||||
return file_;
|
||||
}
|
||||
|
||||
const QVector<DiagnosticContainer> &DiagnosticsChangedMessage::diagnostics() const
|
||||
{
|
||||
return diagnostics_;
|
||||
}
|
||||
|
||||
quint32 DiagnosticsChangedMessage::documentRevision() const
|
||||
{
|
||||
return documentRevision_;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const DiagnosticsChangedMessage &message)
|
||||
{
|
||||
out << message.file_;
|
||||
out << message.diagnostics_;
|
||||
out << message.documentRevision_;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, DiagnosticsChangedMessage &message)
|
||||
{
|
||||
in >> message.file_;
|
||||
in >> message.diagnostics_;
|
||||
in >> message.documentRevision_;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
bool operator==(const DiagnosticsChangedMessage &first, const DiagnosticsChangedMessage &second)
|
||||
{
|
||||
return first.file_ == second.file_
|
||||
&& first.diagnostics_ == second.diagnostics_;
|
||||
}
|
||||
|
||||
bool operator<(const DiagnosticsChangedMessage &first, const DiagnosticsChangedMessage &second)
|
||||
{
|
||||
return first.file_ < second.file_
|
||||
&& compareContainer(first.diagnostics_, second.diagnostics_);
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug debug, const DiagnosticsChangedMessage &message)
|
||||
{
|
||||
debug.nospace() << "DiagnosticsChangedMessage("
|
||||
<< message.file_ << QStringLiteral(", ")
|
||||
<< message.documentRevision_
|
||||
<< ")";
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
||||
void PrintTo(const DiagnosticsChangedMessage &message, ::std::ostream* os)
|
||||
{
|
||||
*os << "DiagnosticsChangedMessage(";
|
||||
PrintTo(message.file(), os);
|
||||
*os << ")";
|
||||
}
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
79
src/libs/clangbackendipc/diagnosticschangedmessage.h
Normal file
79
src/libs/clangbackendipc/diagnosticschangedmessage.h
Normal 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 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 CLANGBACKEND_DIAGNOSTICSCHANGEDMESSAGE_H
|
||||
#define CLANGBACKEND_DIAGNOSTICSCHANGEDMESSAGE_H
|
||||
|
||||
#include "clangbackendipc_global.h"
|
||||
#include "diagnosticcontainer.h"
|
||||
#include "filecontainer.h"
|
||||
|
||||
#include <QVector>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
class CMBIPC_EXPORT DiagnosticsChangedMessage
|
||||
{
|
||||
friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const DiagnosticsChangedMessage &message);
|
||||
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, DiagnosticsChangedMessage &message);
|
||||
friend CMBIPC_EXPORT bool operator==(const DiagnosticsChangedMessage &first, const DiagnosticsChangedMessage &second);
|
||||
friend CMBIPC_EXPORT bool operator<(const DiagnosticsChangedMessage &first, const DiagnosticsChangedMessage &second);
|
||||
friend CMBIPC_EXPORT QDebug operator<<(QDebug debug, const DiagnosticsChangedMessage &message);
|
||||
friend void PrintTo(const DiagnosticsChangedMessage &message, ::std::ostream* os);
|
||||
|
||||
public:
|
||||
DiagnosticsChangedMessage() = default;
|
||||
DiagnosticsChangedMessage(const FileContainer &file,
|
||||
const QVector<DiagnosticContainer> &diagnostics,
|
||||
quint32 documentRevision);
|
||||
|
||||
const FileContainer &file() const;
|
||||
const QVector<DiagnosticContainer> &diagnostics() const;
|
||||
quint32 documentRevision() const;
|
||||
|
||||
private:
|
||||
FileContainer file_;
|
||||
QVector<DiagnosticContainer> diagnostics_;
|
||||
quint32 documentRevision_;
|
||||
};
|
||||
|
||||
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const DiagnosticsChangedMessage &message);
|
||||
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, DiagnosticsChangedMessage &message);
|
||||
CMBIPC_EXPORT bool operator==(const DiagnosticsChangedMessage &first, const DiagnosticsChangedMessage &second);
|
||||
CMBIPC_EXPORT bool operator<(const DiagnosticsChangedMessage &first, const DiagnosticsChangedMessage &second);
|
||||
|
||||
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const DiagnosticsChangedMessage &message);
|
||||
void PrintTo(const DiagnosticsChangedMessage &message, ::std::ostream* os);
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
Q_DECLARE_METATYPE(ClangBackEnd::DiagnosticsChangedMessage)
|
||||
|
||||
#endif // CLANGBACKEND_DIAGNOSTICSCHANGEDMESSAGE_H
|
||||
98
src/libs/clangbackendipc/fixitcontainer.cpp
Normal file
98
src/libs/clangbackendipc/fixitcontainer.cpp
Normal file
@@ -0,0 +1,98 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and 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.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "fixitcontainer.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
FixItContainer::FixItContainer(const Utf8String &text,
|
||||
const SourceRangeContainer &range)
|
||||
: range_(range),
|
||||
text_(text)
|
||||
{
|
||||
}
|
||||
|
||||
const Utf8String &FixItContainer::text() const
|
||||
{
|
||||
return text_;
|
||||
}
|
||||
|
||||
const SourceRangeContainer &FixItContainer::range() const
|
||||
{
|
||||
return range_;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const FixItContainer &container)
|
||||
{
|
||||
out << container.text_;
|
||||
out << container.range_;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, FixItContainer &container)
|
||||
{
|
||||
in >> container.text_;
|
||||
in >> container.range_;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
bool operator==(const FixItContainer &first, const FixItContainer &second)
|
||||
{
|
||||
return first.text_ == second.text_ && first.range_ == second.range_;
|
||||
}
|
||||
|
||||
bool operator<(const FixItContainer &first, const FixItContainer &second)
|
||||
{
|
||||
return first.range_ < second.range_;
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug debug, const FixItContainer &container)
|
||||
{
|
||||
debug.nospace() << "FixItContainer("
|
||||
<< container.text() << ", "
|
||||
<< container.range()
|
||||
<< ")";
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
||||
void PrintTo(const FixItContainer &container, ::std::ostream* os)
|
||||
{
|
||||
*os << "FixIt(" << container.text().constData() << ", ";
|
||||
*os<< ")";
|
||||
PrintTo(container.range(), os);
|
||||
}
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
70
src/libs/clangbackendipc/fixitcontainer.h
Normal file
70
src/libs/clangbackendipc/fixitcontainer.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 CLANGBACKEND_FIXITCONTAINER_H
|
||||
#define CLANGBACKEND_FIXITCONTAINER_H
|
||||
|
||||
#include "sourcerangecontainer.h"
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
class CMBIPC_EXPORT FixItContainer
|
||||
{
|
||||
friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const FixItContainer &container);
|
||||
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, FixItContainer &container);
|
||||
friend CMBIPC_EXPORT bool operator==(const FixItContainer &first, const FixItContainer &second);
|
||||
friend CMBIPC_EXPORT bool operator<(const FixItContainer &first, const FixItContainer &second);
|
||||
|
||||
public:
|
||||
FixItContainer() = default;
|
||||
FixItContainer(const Utf8String &text,
|
||||
const SourceRangeContainer &range);
|
||||
|
||||
const Utf8String &text() const;
|
||||
const SourceRangeContainer &range() const;
|
||||
|
||||
private:
|
||||
SourceRangeContainer range_;
|
||||
Utf8String text_;
|
||||
};
|
||||
|
||||
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const FixItContainer &container);
|
||||
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, FixItContainer &container);
|
||||
CMBIPC_EXPORT bool operator==(const FixItContainer &first, const FixItContainer &second);
|
||||
CMBIPC_EXPORT bool operator<(const FixItContainer &first, const FixItContainer &second);
|
||||
|
||||
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const FixItContainer &container);
|
||||
void PrintTo(const FixItContainer &container, ::std::ostream* os);
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
Q_DECLARE_METATYPE(ClangBackEnd::FixItContainer)
|
||||
|
||||
#endif // CLANGBACKEND_FIXITCONTAINER_H
|
||||
@@ -74,5 +74,11 @@ void IpcClientDispatcher::projectPartsDoNotExist(const ProjectPartsDoNotExistMes
|
||||
client->projectPartsDoNotExist(message);
|
||||
}
|
||||
|
||||
void IpcClientDispatcher::diagnosticsChanged(const DiagnosticsChangedMessage &message)
|
||||
{
|
||||
for (auto *client : clients)
|
||||
client->diagnosticsChanged(message);
|
||||
}
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ public:
|
||||
void codeCompleted(const CodeCompletedMessage &message) override;
|
||||
void translationUnitDoesNotExist(const TranslationUnitDoesNotExistMessage &message) override;
|
||||
void projectPartsDoNotExist(const ProjectPartsDoNotExistMessage &message) override;
|
||||
void diagnosticsChanged(const DiagnosticsChangedMessage &message) override;
|
||||
|
||||
private:
|
||||
QVector<IpcClientInterface*> clients;
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "cmbechomessage.h"
|
||||
#include "projectpartsdonotexistmessage.h"
|
||||
#include "translationunitdoesnotexistmessage.h"
|
||||
#include "diagnosticschangedmessage.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QVariant>
|
||||
@@ -48,6 +49,7 @@ void IpcClientInterface::dispatch(const QVariant &message)
|
||||
static const int codeCompletedMessageType = QMetaType::type("ClangBackEnd::CodeCompletedMessage");
|
||||
static const int translationUnitDoesNotExistMessage = QMetaType::type("ClangBackEnd::TranslationUnitDoesNotExistMessage");
|
||||
static const int projectPartsDoNotExistMessage = QMetaType::type("ClangBackEnd::ProjectPartsDoNotExistMessage");
|
||||
static const int diagnosticsChangedMessage = QMetaType::type("ClangBackEnd::DiagnosticsChangedMessage");
|
||||
|
||||
int type = message.userType();
|
||||
|
||||
@@ -61,6 +63,8 @@ void IpcClientInterface::dispatch(const QVariant &message)
|
||||
translationUnitDoesNotExist(message.value<TranslationUnitDoesNotExistMessage>());
|
||||
else if (type == projectPartsDoNotExistMessage)
|
||||
projectPartsDoNotExist(message.value<ProjectPartsDoNotExistMessage>());
|
||||
else if (type == diagnosticsChangedMessage)
|
||||
diagnosticsChanged(message.value<DiagnosticsChangedMessage>());
|
||||
else
|
||||
qWarning() << "Unknown IpcClientMessage";
|
||||
}
|
||||
|
||||
@@ -45,6 +45,8 @@ class CompleteCodeMessage;
|
||||
class CodeCompletedMessage;
|
||||
class TranslationUnitDoesNotExistMessage;
|
||||
class ProjectPartsDoNotExistMessage;
|
||||
class DiagnosticsChangedMessage;
|
||||
class RequestDiagnosticsMessage;
|
||||
|
||||
class CMBIPC_EXPORT IpcClientInterface : public IpcInterface
|
||||
{
|
||||
@@ -56,6 +58,7 @@ public:
|
||||
virtual void codeCompleted(const CodeCompletedMessage &message) = 0;
|
||||
virtual void translationUnitDoesNotExist(const TranslationUnitDoesNotExistMessage &message) = 0;
|
||||
virtual void projectPartsDoNotExist(const ProjectPartsDoNotExistMessage &message) = 0;
|
||||
virtual void diagnosticsChanged(const DiagnosticsChangedMessage &message) = 0;
|
||||
};
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "cmbcodecompletedmessage.h"
|
||||
#include "cmbechomessage.h"
|
||||
#include "cmbregistertranslationunitsforcodecompletionmessage.h"
|
||||
#include "diagnosticschangedmessage.h"
|
||||
#include "ipcserverinterface.h"
|
||||
#include "projectpartsdonotexistmessage.h"
|
||||
#include "translationunitdoesnotexistmessage.h"
|
||||
@@ -98,6 +99,11 @@ void IpcClientProxy::projectPartsDoNotExist(const ProjectPartsDoNotExistMessage
|
||||
writeMessageBlock.write(QVariant::fromValue(message));
|
||||
}
|
||||
|
||||
void IpcClientProxy::diagnosticsChanged(const DiagnosticsChangedMessage &message)
|
||||
{
|
||||
writeMessageBlock.write(QVariant::fromValue(message));
|
||||
}
|
||||
|
||||
void IpcClientProxy::readMessages()
|
||||
{
|
||||
for (const QVariant &message : readMessageBlock.readAll())
|
||||
|
||||
@@ -62,6 +62,7 @@ public:
|
||||
void codeCompleted(const CodeCompletedMessage &message) override;
|
||||
void translationUnitDoesNotExist(const TranslationUnitDoesNotExistMessage &message) override;
|
||||
void projectPartsDoNotExist(const ProjectPartsDoNotExistMessage &message) override;
|
||||
void diagnosticsChanged(const DiagnosticsChangedMessage &message) override;
|
||||
|
||||
void readMessages();
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "cmbregistertranslationunitsforcodecompletionmessage.h"
|
||||
#include "cmbunregisterprojectsforcodecompletionmessage.h"
|
||||
#include "cmbunregistertranslationunitsforcodecompletionmessage.h"
|
||||
#include "requestdiagnosticsmessage.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QVariant>
|
||||
@@ -49,6 +50,7 @@ void IpcServerInterface::dispatch(const QVariant &message)
|
||||
static const int registerProjectPartsForCodeCompletionMessageType = QMetaType::type("ClangBackEnd::RegisterProjectPartsForCodeCompletionMessage");
|
||||
static const int unregisterProjectPartsForCodeCompletionMessageType = QMetaType::type("ClangBackEnd::UnregisterProjectPartsForCodeCompletionMessage");
|
||||
static const int completeCodeMessageType = QMetaType::type("ClangBackEnd::CompleteCodeMessage");
|
||||
static const int requestDiagnosticsMessageType = QMetaType::type("ClangBackEnd::RequestDiagnosticsMessage");
|
||||
|
||||
int type = message.userType();
|
||||
|
||||
@@ -64,6 +66,8 @@ void IpcServerInterface::dispatch(const QVariant &message)
|
||||
unregisterProjectPartsForCodeCompletion(message.value<UnregisterProjectPartsForCodeCompletionMessage>());
|
||||
else if (type == completeCodeMessageType)
|
||||
completeCode(message.value<CompleteCodeMessage>());
|
||||
else if (type == requestDiagnosticsMessageType)
|
||||
requestDiagnostics(message.value<RequestDiagnosticsMessage>());
|
||||
else
|
||||
qWarning() << "Unknown IpcServerMessage";
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ public:
|
||||
virtual void registerProjectPartsForCodeCompletion(const RegisterProjectPartsForCodeCompletionMessage &message) = 0;
|
||||
virtual void unregisterProjectPartsForCodeCompletion(const UnregisterProjectPartsForCodeCompletionMessage &message) = 0;
|
||||
virtual void completeCode(const CompleteCodeMessage &message) = 0;
|
||||
virtual void requestDiagnostics(const RequestDiagnosticsMessage &message) = 0;
|
||||
|
||||
void addClient(IpcClientInterface *client);
|
||||
void removeClient(IpcClientInterface *client);
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <cmbregistertranslationunitsforcodecompletionmessage.h>
|
||||
#include <cmbunregisterprojectsforcodecompletionmessage.h>
|
||||
#include <cmbunregistertranslationunitsforcodecompletionmessage.h>
|
||||
#include <requestdiagnosticsmessage.h>
|
||||
#include <ipcclientinterface.h>
|
||||
|
||||
#include <QLocalServer>
|
||||
@@ -95,5 +96,10 @@ void IpcServerProxy::completeCode(const CompleteCodeMessage &message)
|
||||
writeMessageBlock.write(QVariant::fromValue(message));
|
||||
}
|
||||
|
||||
void IpcServerProxy::requestDiagnostics(const ClangBackEnd::RequestDiagnosticsMessage &message)
|
||||
{
|
||||
writeMessageBlock.write(QVariant::fromValue(message));
|
||||
}
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ public:
|
||||
void registerProjectPartsForCodeCompletion(const RegisterProjectPartsForCodeCompletionMessage &message) override;
|
||||
void unregisterProjectPartsForCodeCompletion(const UnregisterProjectPartsForCodeCompletionMessage &message) override;
|
||||
void completeCode(const CompleteCodeMessage &message) override;
|
||||
void requestDiagnostics(const RequestDiagnosticsMessage &message) override;
|
||||
|
||||
void readMessages();
|
||||
|
||||
|
||||
97
src/libs/clangbackendipc/requestdiagnosticsmessage.cpp
Normal file
97
src/libs/clangbackendipc/requestdiagnosticsmessage.cpp
Normal file
@@ -0,0 +1,97 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "requestdiagnosticsmessage.h"
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
RequestDiagnosticsMessage::RequestDiagnosticsMessage(const FileContainer &file,
|
||||
quint32 documentRevision)
|
||||
: file_(file),
|
||||
documentRevision_(documentRevision)
|
||||
{
|
||||
}
|
||||
|
||||
const FileContainer RequestDiagnosticsMessage::file() const
|
||||
{
|
||||
return file_;
|
||||
}
|
||||
|
||||
quint32 RequestDiagnosticsMessage::documentRevision() const
|
||||
{
|
||||
return documentRevision_;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const RequestDiagnosticsMessage &message)
|
||||
{
|
||||
out << message.file_;
|
||||
out << message.documentRevision_;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, RequestDiagnosticsMessage &message)
|
||||
{
|
||||
in >> message.file_;
|
||||
in >> message.documentRevision_;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
bool operator==(const RequestDiagnosticsMessage &first, const RequestDiagnosticsMessage &second)
|
||||
{
|
||||
return first.file_ == second.file_ && first.documentRevision_ == second.documentRevision_;
|
||||
}
|
||||
|
||||
bool operator<(const RequestDiagnosticsMessage &first, const RequestDiagnosticsMessage &second)
|
||||
{
|
||||
return first.file_ < second.file_;
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug debug, const RequestDiagnosticsMessage &message)
|
||||
{
|
||||
debug.nospace() << "RequestDiagnosticsMessage("
|
||||
<< message.file() << ", "
|
||||
<< message.documentRevision()
|
||||
<< ")";
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
||||
void PrintTo(const RequestDiagnosticsMessage &message, ::std::ostream* os)
|
||||
{
|
||||
*os << message.file().filePath().constData()
|
||||
<< "(" << message.file().projectPartId().constData() << ")";
|
||||
}
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
71
src/libs/clangbackendipc/requestdiagnosticsmessage.h
Normal file
71
src/libs/clangbackendipc/requestdiagnosticsmessage.h
Normal 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 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 CLANGBACKEND_REQUESTDIAGNOSTICSMESSAGE_H
|
||||
#define CLANGBACKEND_REQUESTDIAGNOSTICSMESSAGE_H
|
||||
|
||||
#include "filecontainer.h"
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
class CMBIPC_EXPORT RequestDiagnosticsMessage
|
||||
{
|
||||
friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RequestDiagnosticsMessage &message);
|
||||
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RequestDiagnosticsMessage &message);
|
||||
friend CMBIPC_EXPORT bool operator==(const RequestDiagnosticsMessage &first, const RequestDiagnosticsMessage &second);
|
||||
friend CMBIPC_EXPORT bool operator<(const RequestDiagnosticsMessage &first, const RequestDiagnosticsMessage &second);
|
||||
friend CMBIPC_EXPORT QDebug operator<<(QDebug debug, const RequestDiagnosticsMessage &message);
|
||||
friend void PrintTo(const RequestDiagnosticsMessage &message, ::std::ostream* os);
|
||||
|
||||
public:
|
||||
RequestDiagnosticsMessage() = default;
|
||||
RequestDiagnosticsMessage(const FileContainer &file, quint32 documentRevision);
|
||||
|
||||
const FileContainer file() const;
|
||||
quint32 documentRevision() const;
|
||||
|
||||
private:
|
||||
FileContainer file_;
|
||||
quint32 documentRevision_;
|
||||
};
|
||||
|
||||
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RequestDiagnosticsMessage &message);
|
||||
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RequestDiagnosticsMessage &message);
|
||||
CMBIPC_EXPORT bool operator==(const RequestDiagnosticsMessage &first, const RequestDiagnosticsMessage &second);
|
||||
CMBIPC_EXPORT bool operator<(const RequestDiagnosticsMessage &first, const RequestDiagnosticsMessage &second);
|
||||
|
||||
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const RequestDiagnosticsMessage &message);
|
||||
void PrintTo(const RequestDiagnosticsMessage &message, ::std::ostream* os);
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
Q_DECLARE_METATYPE(ClangBackEnd::RequestDiagnosticsMessage)
|
||||
|
||||
#endif // CLANGBACKEND_REQUESTDIAGNOSTICSMESSAGE_H
|
||||
111
src/libs/clangbackendipc/sourcelocationcontainer.cpp
Normal file
111
src/libs/clangbackendipc/sourcelocationcontainer.cpp
Normal file
@@ -0,0 +1,111 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "sourcelocationcontainer.h"
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
SourceLocationContainer::SourceLocationContainer(const Utf8String &filePath,
|
||||
uint line,
|
||||
uint offset)
|
||||
: filePath_(filePath),
|
||||
line_(line),
|
||||
offset_(offset)
|
||||
{
|
||||
}
|
||||
|
||||
const Utf8String &SourceLocationContainer::filePath() const
|
||||
{
|
||||
return filePath_;
|
||||
}
|
||||
|
||||
uint SourceLocationContainer::line() const
|
||||
{
|
||||
return line_;
|
||||
}
|
||||
|
||||
|
||||
uint SourceLocationContainer::offset() const
|
||||
{
|
||||
return offset_;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const SourceLocationContainer &container)
|
||||
{
|
||||
out << container.filePath_;
|
||||
out << container.line_;
|
||||
out << container.offset_;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, SourceLocationContainer &container)
|
||||
{
|
||||
in >> container.filePath_;
|
||||
in >> container.line_;
|
||||
in >> container.offset_;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
bool operator==(const SourceLocationContainer &first, const SourceLocationContainer &second)
|
||||
{
|
||||
return first.offset_ == second.offset_ && first.filePath_ == second.filePath_;
|
||||
}
|
||||
|
||||
bool operator<(const SourceLocationContainer &first, const SourceLocationContainer &second)
|
||||
{
|
||||
return first.filePath_ < second.filePath_
|
||||
|| (first.filePath_ == second.filePath_ && first.offset_ < second.offset_);
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug debug, const SourceLocationContainer &container)
|
||||
{
|
||||
debug.nospace() << "SourceLocationContainer("
|
||||
<< container.filePath() << ", "
|
||||
<< container.line() << ", "
|
||||
<< container.offset()
|
||||
<< ")";
|
||||
return debug;
|
||||
}
|
||||
|
||||
void PrintTo(const SourceLocationContainer &container, ::std::ostream* os)
|
||||
{
|
||||
*os << "["
|
||||
<< container.filePath().constData() << ", "
|
||||
<< container.line() << ", "
|
||||
<< container.offset()
|
||||
<< "]";
|
||||
}
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
77
src/libs/clangbackendipc/sourcelocationcontainer.h
Normal file
77
src/libs/clangbackendipc/sourcelocationcontainer.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 CLANGBACKEND_SOURCELOCATIONCONTAINER_H
|
||||
#define CLANGBACKEND_SOURCELOCATIONCONTAINER_H
|
||||
|
||||
#include <clangbackendipc_global.h>
|
||||
|
||||
#include <utf8string.h>
|
||||
|
||||
#include <QMetaType>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
class CMBIPC_EXPORT SourceLocationContainer
|
||||
{
|
||||
friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const SourceLocationContainer &container);
|
||||
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, SourceLocationContainer &container);
|
||||
friend CMBIPC_EXPORT bool operator==(const SourceLocationContainer &first, const SourceLocationContainer &second);
|
||||
friend CMBIPC_EXPORT bool operator<(const SourceLocationContainer &first, const SourceLocationContainer &second);
|
||||
|
||||
public:
|
||||
SourceLocationContainer() = default;
|
||||
SourceLocationContainer(const Utf8String &filePath,
|
||||
uint line,
|
||||
uint offset);
|
||||
|
||||
const Utf8String &filePath() const;
|
||||
uint line() const;
|
||||
uint offset() const;
|
||||
|
||||
private:
|
||||
Utf8String filePath_;
|
||||
uint line_;
|
||||
uint offset_;
|
||||
};
|
||||
|
||||
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const SourceLocationContainer &container);
|
||||
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, SourceLocationContainer &container);
|
||||
CMBIPC_EXPORT bool operator==(const SourceLocationContainer &first, const SourceLocationContainer &second);
|
||||
CMBIPC_EXPORT bool operator<(const SourceLocationContainer &first, const SourceLocationContainer &second);
|
||||
|
||||
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const SourceLocationContainer &container);
|
||||
void PrintTo(const SourceLocationContainer &container, ::std::ostream* os);
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
Q_DECLARE_METATYPE(ClangBackEnd::SourceLocationContainer)
|
||||
|
||||
#endif // CLANGBACKEND_SOURCELOCATIONCONTAINER_H
|
||||
100
src/libs/clangbackendipc/sourcerangecontainer.cpp
Normal file
100
src/libs/clangbackendipc/sourcerangecontainer.cpp
Normal 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 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.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "sourcerangecontainer.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
SourceRangeContainer::SourceRangeContainer(SourceLocationContainer start,
|
||||
SourceLocationContainer end)
|
||||
: start_(start),
|
||||
end_(end)
|
||||
{
|
||||
}
|
||||
|
||||
SourceLocationContainer SourceRangeContainer::start() const
|
||||
{
|
||||
return start_;
|
||||
}
|
||||
|
||||
SourceLocationContainer SourceRangeContainer::end() const
|
||||
{
|
||||
return end_;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const SourceRangeContainer &container)
|
||||
{
|
||||
out << container.start_;
|
||||
out << container.end_;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, SourceRangeContainer &container)
|
||||
{
|
||||
in >> container.start_;
|
||||
in >> container.end_;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
bool operator==(const SourceRangeContainer &first, const SourceRangeContainer &second)
|
||||
{
|
||||
return first.start_ == second.start_ && first.end_ == second.end_;
|
||||
}
|
||||
|
||||
bool operator<(const SourceRangeContainer &first, const SourceRangeContainer &second)
|
||||
{
|
||||
return first.start_ < second.start_
|
||||
|| (first.start_ == second.start_ && first.end_ < second.end_);
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug debug, const SourceRangeContainer &container)
|
||||
{
|
||||
debug.nospace() << "SourceRangeContainer("
|
||||
<< container.start() << ", "
|
||||
<< container.end()
|
||||
<< ")";
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
||||
void PrintTo(const SourceRangeContainer &container, ::std::ostream* os)
|
||||
{
|
||||
*os << "[";
|
||||
PrintTo(container.start(), os);
|
||||
*os << ", ";
|
||||
PrintTo(container.end(), os);
|
||||
*os<< "]";
|
||||
}
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
71
src/libs/clangbackendipc/sourcerangecontainer.h
Normal file
71
src/libs/clangbackendipc/sourcerangecontainer.h
Normal 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 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 CLANGBACKEND_SOURCERANGECONTAINER_H
|
||||
#define CLANGBACKEND_SOURCERANGECONTAINER_H
|
||||
|
||||
#include "sourcelocationcontainer.h"
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
class CMBIPC_EXPORT SourceRangeContainer
|
||||
{
|
||||
friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const SourceRangeContainer &container);
|
||||
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, SourceRangeContainer &container);
|
||||
friend CMBIPC_EXPORT bool operator==(const SourceRangeContainer &first, const SourceRangeContainer &second);
|
||||
friend CMBIPC_EXPORT bool operator<(const SourceRangeContainer &first, const SourceRangeContainer &second);
|
||||
|
||||
public:
|
||||
SourceRangeContainer() = default;
|
||||
SourceRangeContainer(SourceLocationContainer start,
|
||||
SourceLocationContainer end);
|
||||
|
||||
SourceLocationContainer start() const;
|
||||
SourceLocationContainer end() const;
|
||||
|
||||
private:
|
||||
SourceLocationContainer start_;
|
||||
SourceLocationContainer end_;
|
||||
|
||||
};
|
||||
|
||||
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const SourceRangeContainer &container);
|
||||
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, SourceRangeContainer &container);
|
||||
CMBIPC_EXPORT bool operator==(const SourceRangeContainer &first, const SourceRangeContainer &second);
|
||||
CMBIPC_EXPORT bool operator<(const SourceRangeContainer &first, const SourceRangeContainer &second);
|
||||
|
||||
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const SourceRangeContainer &container);
|
||||
void PrintTo(const SourceRangeContainer &container, ::std::ostream* os);
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
Q_DECLARE_METATYPE(ClangBackEnd::SourceRangeContainer)
|
||||
|
||||
#endif // CLANGBACKEND_SOURCERANGECONTAINER_H
|
||||
Reference in New Issue
Block a user