Commit bb62fd3e authored by Marco Bubke's avatar Marco Bubke

Clang: Move printing functions in clang support to unit tests

The printing functions are only used by the unit tests and they use an
external API. So we can easily move them to the printing functions in
the unit test project. We have to move the TokenInfo print functions too
because the depend on other print functions. The rest of the print
functions will be moved in other patches.

Change-Id: I87c452f8ca40687ec47de675ba6bee13efa5655b
Reviewed-by: Nikolai Kosjar's avatarNikolai Kosjar <nikolai.kosjar@qt.io>
parent 8cce4daa
......@@ -27,8 +27,6 @@
#include <QDebug>
#include <ostream>
namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const CancelMessage &)
......@@ -38,9 +36,4 @@ QDebug operator<<(QDebug debug, const CancelMessage &)
return debug;
}
std::ostream &operator<<(std::ostream &os, const CancelMessage &/*message*/)
{
return os << "()";
}
} // namespace ClangBackEnd
......@@ -49,7 +49,6 @@ public:
};
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const CancelMessage &message);
std::ostream &operator<<(std::ostream &os, const CancelMessage &message);
DECLARE_MESSAGE(CancelMessage)
} // namespace ClangBackEnd
......@@ -27,8 +27,6 @@
#include <QDebug>
#include <ostream>
namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const AliveMessage &/*message*/)
......@@ -36,9 +34,4 @@ QDebug operator<<(QDebug debug, const AliveMessage &/*message*/)
return debug.nospace() << "AliveMessage()";
}
std::ostream &operator<<(std::ostream &os, const AliveMessage &/*message*/)
{
return os << "()";
}
}
......@@ -29,8 +29,6 @@
#include <QDataStream>
#include <iosfwd>
namespace ClangBackEnd {
class AliveMessage
......@@ -53,7 +51,6 @@ public:
};
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const AliveMessage &message);
std::ostream &operator<<(std::ostream &os, const AliveMessage &message);
DECLARE_MESSAGE(AliveMessage)
}
......@@ -27,8 +27,6 @@
#include <QDebug>
#include <ostream>
namespace ClangBackEnd {
#define RETURN_TEXT_FOR_CASE(enumValue) case CompletionCorrection::enumValue: return #enumValue
......@@ -55,17 +53,5 @@ QDebug operator<<(QDebug debug, const CodeCompletedMessage &message)
return debug;
}
std::ostream &operator<<(std::ostream &os, const CodeCompletedMessage &message)
{
os << "("
<< message.m_codeCompletions << ", "
<< completionCorrectionToText(message.neededCorrection()) << ", "
<< message.m_ticketNumber
<< ")";
return os;
}
} // namespace ClangBackEnd
......@@ -91,7 +91,6 @@ public:
}
friend CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const CodeCompletedMessage &message);
friend std::ostream &operator<<(std::ostream &os, const CodeCompletedMessage &message);
private:
CodeCompletions m_codeCompletions;
......
......@@ -27,8 +27,6 @@
#include <QDebug>
#include <ostream>
namespace ClangBackEnd {
quint64 CompleteCodeMessage::ticketCounter = 0;
......@@ -50,21 +48,5 @@ QDebug operator<<(QDebug debug, const CompleteCodeMessage &message)
return debug;
}
std::ostream &operator<<(std::ostream &os, const CompleteCodeMessage &message)
{
os << "("
<< message.m_filePath.constData() << ", "
<< message.m_line << ", "
<< message.m_column << ", "
<< message.m_projectPartId.constData() << ", "
<< message.m_ticketNumber << ", "
<< message.m_funcNameStartLine << ", "
<< message.m_funcNameStartColumn
<< ")";
return os;
}
} // namespace ClangBackEnd
......@@ -127,7 +127,6 @@ public:
}
friend CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const CompleteCodeMessage &message);
friend std::ostream &operator<<(std::ostream &os, const CompleteCodeMessage &message);
private:
Utf8String m_filePath;
......
......@@ -27,8 +27,6 @@
#include <QDebug>
#include <ostream>
namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const EchoMessage &)
......@@ -36,10 +34,5 @@ QDebug operator<<(QDebug debug, const EchoMessage &)
return debug.nospace() << "EchoMessage()";
}
std::ostream &operator<<(std::ostream &os, const EchoMessage &/*message*/)
{
return os << "()";
}
} // namespace ClangBackEnd
......@@ -29,8 +29,6 @@
#include "messageenvelop.h"
#include <iosfwd>
namespace ClangBackEnd {
class EchoMessage
......@@ -71,7 +69,6 @@ private:
};
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const EchoMessage &message);
std::ostream &operator<<(std::ostream &os, const EchoMessage &message);
DECLARE_MESSAGE(EchoMessage)
} // namespace ClangBackEnd
......@@ -27,8 +27,6 @@
#include <QDebug>
#include <ostream>
namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const EndMessage &/*message*/)
......@@ -36,9 +34,4 @@ QDebug operator<<(QDebug debug, const EndMessage &/*message*/)
return debug.nospace() << "EndMessage()";
}
std::ostream &operator<<(std::ostream &os, const EndMessage &/*message*/)
{
return os << "()";
}
}
......@@ -29,8 +29,6 @@
#include <QDataStream>
#include <iosfwd>
namespace ClangBackEnd {
class EndMessage
......@@ -53,7 +51,6 @@ public:
};
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const EndMessage &message);
std::ostream &operator<<(std::ostream &os, const EndMessage &message);
DECLARE_MESSAGE(EndMessage)
}
......@@ -27,9 +27,6 @@
#include <QDebug>
#include <algorithm>
#include <ostream>
namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const RegisterProjectPartsForEditorMessage &message)
......@@ -44,14 +41,5 @@ QDebug operator<<(QDebug debug, const RegisterProjectPartsForEditorMessage &mess
return debug;
}
std::ostream &operator<<(std::ostream &os, const RegisterProjectPartsForEditorMessage &message)
{
os << "("
<< message.projectContainers()
<< ")";
return os;
}
} // namespace ClangBackEnd
......@@ -70,7 +70,6 @@ private:
};
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const RegisterProjectPartsForEditorMessage &message);
std::ostream &operator<<(std::ostream &os, const RegisterProjectPartsForEditorMessage &message);
DECLARE_MESSAGE(RegisterProjectPartsForEditorMessage);
} // namespace ClangBackEnd
......@@ -27,8 +27,6 @@
#include <QDebug>
#include <ostream>
namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const RegisterTranslationUnitForEditorMessage &message)
......@@ -48,15 +46,5 @@ QDebug operator<<(QDebug debug, const RegisterTranslationUnitForEditorMessage &m
return debug;
}
std::ostream &operator<<(std::ostream &os, const RegisterTranslationUnitForEditorMessage &message)
{
os << "RegisterTranslationUnitForEditorMessage("
<< message.fileContainers() << ", "
<< message.currentEditorFilePath() << ", "
<< message.visibleEditorFilePaths() << ")";
return os;
}
} // namespace ClangBackEnd
......@@ -84,7 +84,6 @@ public:
&& first.visibleEditorFilePaths_ == second.visibleEditorFilePaths_;
}
friend std::ostream &operator<<(std::ostream &os, const RegisterTranslationUnitForEditorMessage &message);
private:
QVector<FileContainer> fileContainers_;
Utf8String currentEditorFilePath_;
......
......@@ -27,8 +27,6 @@
#include <QDebug>
#include <ostream>
namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const UnregisterProjectPartsForEditorMessage &message)
......@@ -43,14 +41,5 @@ QDebug operator<<(QDebug debug, const UnregisterProjectPartsForEditorMessage &me
return debug;
}
std::ostream &operator<<(std::ostream &os, const UnregisterProjectPartsForEditorMessage &message)
{
os << "("
<< message.projectPartIds()
<< ")";
return os;
}
} // namespace ClangBackEnd
......@@ -71,7 +71,6 @@ private:
};
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const UnregisterProjectPartsForEditorMessage &message);
std::ostream &operator<<(std::ostream &os, const UnregisterProjectPartsForEditorMessage &message);
DECLARE_MESSAGE(UnregisterProjectPartsForEditorMessage);
} // namespace ClangBackEnd
......@@ -27,8 +27,6 @@
#include <QDebug>
#include <ostream>
namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const UnregisterTranslationUnitsForEditorMessage &message)
......@@ -43,14 +41,5 @@ QDebug operator<<(QDebug debug, const UnregisterTranslationUnitsForEditorMessage
return debug;
}
std::ostream &operator<<(std::ostream &os, const UnregisterTranslationUnitsForEditorMessage &message)
{
os << "("
<< message.fileContainers()
<< ")";
return os;
}
} // namespace ClangBackEnd
......@@ -66,8 +66,6 @@ public:
return first.m_fileContainers == second.m_fileContainers;
}
friend std::ostream &operator<<(std::ostream &os, const UnregisterTranslationUnitsForEditorMessage &message);
private:
QVector<FileContainer> m_fileContainers;
};
......
......@@ -84,19 +84,6 @@ QDebug operator<<(QDebug debug, const CodeCompletion &message)
return debug;
}
std::ostream &operator<<(std::ostream &os, const CodeCompletion &message)
{
os << "("
<< message.m_text << ", "
<< message.m_priority << ", "
<< message.m_completionKind << ", "
<< message.m_availability << ", "
<< message.m_hasParameters
<< ")";
return os;
}
std::ostream &operator<<(std::ostream &os, const CodeCompletion::Kind kind)
{
return os << completionKindToString(kind);
......
......@@ -194,7 +194,6 @@ public:
}
friend CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const CodeCompletion &message);
friend std::ostream &operator<<(std::ostream &os, const CodeCompletion &message);
private:
Utf8String m_text;
......
......@@ -75,20 +75,6 @@ QDebug operator<<(QDebug debug, const CodeCompletionChunk &chunk)
return debug;
}
std::ostream &operator<<(std::ostream &os, const CodeCompletionChunk &chunk)
{
os << "("
<< chunk.kind() << ", "
<< chunk.text();
if (chunk.isOptional())
os << ", optional";
os << ")";
return os;
}
std::ostream &operator<<(std::ostream &os, const CodeCompletionChunk::Kind &kind)
{
return os << completionChunkKindToString(kind);
......
......@@ -127,7 +127,6 @@ private:
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const CodeCompletionChunk &chunk);
std::ostream &operator<<(std::ostream &os, const CodeCompletionChunk &chunk);
std::ostream &operator<<(std::ostream &os, const CodeCompletionChunk::Kind &kind);
} // namespace ClangBackEnd
......@@ -29,23 +29,8 @@
#include <QDebug>
#include <ostream>
namespace ClangBackEnd {
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("
......@@ -62,20 +47,5 @@ QDebug operator<<(QDebug debug, const DiagnosticContainer &container)
return debug;
}
std::ostream &operator<<(std::ostream &os, const DiagnosticContainer &container)
{
os << "("
<< severityToText(container.severity()) << ": "
<< container.text() << ", "
<< container.category() << ", "
<< container.enableOption() << ", "
<< container.location() << ", "
<< container.ranges() << ", "
<< container.fixIts() << ", "
<< container.children() << ")";
return os;
}
} // namespace ClangBackEnd
......@@ -162,6 +162,5 @@ private:
};
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const DiagnosticContainer &container);
std::ostream &operator<<(std::ostream &os, const DiagnosticContainer &container);
} // namespace ClangBackEnd
......@@ -25,11 +25,8 @@
#include "documentannotationschangedmessage.h"
#include <QDataStream>
#include <QDebug>
#include <ostream>
namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const DocumentAnnotationsChangedMessage &message)
......@@ -45,18 +42,5 @@ QDebug operator<<(QDebug debug, const DocumentAnnotationsChangedMessage &message
return debug;
}
std::ostream &operator<<(std::ostream &os, const DocumentAnnotationsChangedMessage &message)
{
os << "DocumentAnnotationsChangedMessage("
<< message.fileContainer()
<< "," << message.diagnostics().size()
<< "," << !message.firstHeaderErrorDiagnostic().text().isEmpty()
<< "," << message.tokenInfos().size()
<< "," << message.skippedPreprocessorRanges().size()
<< ")";
return os;
}
} // namespace ClangBackEnd
......@@ -118,7 +118,6 @@ private:
};
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const DocumentAnnotationsChangedMessage &message);
std::ostream &operator<<(std::ostream &os, const DocumentAnnotationsChangedMessage &message);
DECLARE_MESSAGE(DocumentAnnotationsChangedMessage)
} // namespace ClangBackEnd
......@@ -37,14 +37,4 @@ QDebug operator<<(QDebug debug, const DynamicASTMatcherDiagnosticContainer &cont
return debug;
}
std::ostream &operator<<(std::ostream &os, const DynamicASTMatcherDiagnosticContainer &container)
{
os << "("
<< container.messages() << ", "
<< container.contexts()
<< ")";
return os;
}
} // namespace ClangBackEnd
......@@ -99,6 +99,5 @@ private:
using DynamicASTMatcherDiagnosticContainers = std::vector<DynamicASTMatcherDiagnosticContainer>;
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const DynamicASTMatcherDiagnosticContainer &container);
std::ostream &operator<<(std::ostream &os, const DynamicASTMatcherDiagnosticContainer &container);
} // namespace ClangBackEnd
......@@ -25,8 +25,6 @@
#include "dynamicastmatcherdiagnosticcontextcontainer.h"
namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const DynamicASTMatcherDiagnosticContextContainer &container)
......@@ -40,17 +38,6 @@ QDebug operator<<(QDebug debug, const DynamicASTMatcherDiagnosticContextContaine
return debug;
}
std::ostream &operator<<(std::ostream &os, const DynamicASTMatcherDiagnosticContextContainer &container)
{
os << "("
<< container.contextTypeText() << ", "
<< container.sourceRange() << ", "
<< container.arguments()
<< ")";
return os;
}
#define RETURN_CASE(name) \
case ClangQueryDiagnosticContextType::name: return #name;
......
......@@ -108,6 +108,5 @@ private:
using DynamicASTMatcherDiagnosticContextContainers = std::vector<DynamicASTMatcherDiagnosticContextContainer>;
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const DynamicASTMatcherDiagnosticContextContainer &container);
std::ostream &operator<<(std::ostream &os, const DynamicASTMatcherDiagnosticContextContainer &container);
} // namespace ClangBackEnd
......@@ -41,17 +41,6 @@ QDebug operator<<(QDebug debug, const DynamicASTMatcherDiagnosticMessageContaine
return debug;
}
std::ostream &operator<<(std::ostream &os, const DynamicASTMatcherDiagnosticMessageContainer &container)
{
os << "("
<< container.errorTypeText() << ", "
<< container.sourceRange() << ", "
<< container.arguments()
<< ")";
return os;
}
Utils::SmallString DynamicASTMatcherDiagnosticMessageContainer::errorTypeText() const
{
switch (m_errorType) {
......
......@@ -106,6 +106,5 @@ private:
using DynamicASTMatcherDiagnosticMessageContainers = std::vector<DynamicASTMatcherDiagnosticMessageContainer>;
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const DynamicASTMatcherDiagnosticMessageContainer &container);
std::ostream &operator<<(std::ostream &os, const DynamicASTMatcherDiagnosticMessageContainer &container);
} // namespace ClangBackEnd
......@@ -29,8 +29,6 @@
#include <QDebug>
#include <ostream>
namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const FileContainer &container)
......@@ -54,22 +52,5 @@ QDebug operator<<(QDebug debug, const FileContainer &container)
return debug;
}
std::ostream &operator<<(std::ostream &os, const FileContainer &container)
{
os << "("
<< container.filePath() << ", "
<< container.projectPartId() << ", "
<< container.fileArguments() << ", "
<< container.documentRevision();
if (container.hasUnsavedFileContent())
os << ", "
<< container.unsavedFileContent();
os << ")";
return os;
}
} // namespace ClangBackEnd
......@@ -147,6 +147,5 @@ private:
};
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const FileContainer &container);
std::ostream &operator<<(std::ostream &os, const FileContainer &container);
} // namespace ClangBackEnd
......@@ -40,21 +40,5 @@ QDebug operator<<(QDebug debug, const FileContainer &container)
return debug;
}
std::ostream &operator<<(std::ostream &os, const FileContainer &container)
{
os << "("
<< container.filePath() << ", "
<< container.commandLineArguments() << ", "
<< container.documentRevision();
if (container.unsavedFileContent().hasContent())
os << ", \""
<< container.unsavedFileContent();
os << "\")";
return os;
}
} // namespace V2
} // namespace ClangBackEnd
......@@ -130,7 +130,6 @@ private:
using FileContainers = std::vector<FileContainer>;
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const FileContainer &container);
std::ostream &operator<<(std::ostream &os, const FileContainer &container);
} // namespace V2
} // namespace ClangBackEnd
......@@ -136,11 +136,6 @@ public:
return in;
}
friend std::ostream &operator<<(std::ostream &out, const FilePath &filePath)
{
return out << "(" << filePath.path() << ", " << filePath.slashIndex() << ")";
}
friend bool operator==(const FilePath &first, const FilePath &second)
{
return first.m_path == second.m_path;
......
......@@ -27,8 +27,6 @@
#include <QDebug>
#include <ostream>