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 @@ ...@@ -27,8 +27,6 @@
#include <QDebug> #include <QDebug>
#include <ostream>
namespace ClangBackEnd { namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const CancelMessage &) QDebug operator<<(QDebug debug, const CancelMessage &)
...@@ -38,9 +36,4 @@ QDebug operator<<(QDebug debug, const CancelMessage &) ...@@ -38,9 +36,4 @@ QDebug operator<<(QDebug debug, const CancelMessage &)
return debug; return debug;
} }
std::ostream &operator<<(std::ostream &os, const CancelMessage &/*message*/)
{
return os << "()";
}
} // namespace ClangBackEnd } // namespace ClangBackEnd
...@@ -49,7 +49,6 @@ public: ...@@ -49,7 +49,6 @@ public:
}; };
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const CancelMessage &message); CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const CancelMessage &message);
std::ostream &operator<<(std::ostream &os, const CancelMessage &message);
DECLARE_MESSAGE(CancelMessage) DECLARE_MESSAGE(CancelMessage)
} // namespace ClangBackEnd } // namespace ClangBackEnd
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#include <QDebug> #include <QDebug>
#include <ostream>
namespace ClangBackEnd { namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const AliveMessage &/*message*/) QDebug operator<<(QDebug debug, const AliveMessage &/*message*/)
...@@ -36,9 +34,4 @@ QDebug operator<<(QDebug debug, const AliveMessage &/*message*/) ...@@ -36,9 +34,4 @@ QDebug operator<<(QDebug debug, const AliveMessage &/*message*/)
return debug.nospace() << "AliveMessage()"; return debug.nospace() << "AliveMessage()";
} }
std::ostream &operator<<(std::ostream &os, const AliveMessage &/*message*/)
{
return os << "()";
}
} }
...@@ -29,8 +29,6 @@ ...@@ -29,8 +29,6 @@
#include <QDataStream> #include <QDataStream>
#include <iosfwd>
namespace ClangBackEnd { namespace ClangBackEnd {
class AliveMessage class AliveMessage
...@@ -53,7 +51,6 @@ public: ...@@ -53,7 +51,6 @@ public:
}; };
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const AliveMessage &message); CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const AliveMessage &message);
std::ostream &operator<<(std::ostream &os, const AliveMessage &message);
DECLARE_MESSAGE(AliveMessage) DECLARE_MESSAGE(AliveMessage)
} }
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#include <QDebug> #include <QDebug>
#include <ostream>
namespace ClangBackEnd { namespace ClangBackEnd {
#define RETURN_TEXT_FOR_CASE(enumValue) case CompletionCorrection::enumValue: return #enumValue #define RETURN_TEXT_FOR_CASE(enumValue) case CompletionCorrection::enumValue: return #enumValue
...@@ -55,17 +53,5 @@ QDebug operator<<(QDebug debug, const CodeCompletedMessage &message) ...@@ -55,17 +53,5 @@ QDebug operator<<(QDebug debug, const CodeCompletedMessage &message)
return debug; 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 } // namespace ClangBackEnd
...@@ -91,7 +91,6 @@ public: ...@@ -91,7 +91,6 @@ public:
} }
friend CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const CodeCompletedMessage &message); friend CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const CodeCompletedMessage &message);
friend std::ostream &operator<<(std::ostream &os, const CodeCompletedMessage &message);
private: private:
CodeCompletions m_codeCompletions; CodeCompletions m_codeCompletions;
......
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#include <QDebug> #include <QDebug>
#include <ostream>
namespace ClangBackEnd { namespace ClangBackEnd {
quint64 CompleteCodeMessage::ticketCounter = 0; quint64 CompleteCodeMessage::ticketCounter = 0;
...@@ -50,21 +48,5 @@ QDebug operator<<(QDebug debug, const CompleteCodeMessage &message) ...@@ -50,21 +48,5 @@ QDebug operator<<(QDebug debug, const CompleteCodeMessage &message)
return debug; 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 } // namespace ClangBackEnd
...@@ -127,7 +127,6 @@ public: ...@@ -127,7 +127,6 @@ public:
} }
friend CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const CompleteCodeMessage &message); friend CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const CompleteCodeMessage &message);
friend std::ostream &operator<<(std::ostream &os, const CompleteCodeMessage &message);
private: private:
Utf8String m_filePath; Utf8String m_filePath;
......
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#include <QDebug> #include <QDebug>
#include <ostream>
namespace ClangBackEnd { namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const EchoMessage &) QDebug operator<<(QDebug debug, const EchoMessage &)
...@@ -36,10 +34,5 @@ QDebug operator<<(QDebug debug, const EchoMessage &) ...@@ -36,10 +34,5 @@ QDebug operator<<(QDebug debug, const EchoMessage &)
return debug.nospace() << "EchoMessage()"; return debug.nospace() << "EchoMessage()";
} }
std::ostream &operator<<(std::ostream &os, const EchoMessage &/*message*/)
{
return os << "()";
}
} // namespace ClangBackEnd } // namespace ClangBackEnd
...@@ -29,8 +29,6 @@ ...@@ -29,8 +29,6 @@
#include "messageenvelop.h" #include "messageenvelop.h"
#include <iosfwd>
namespace ClangBackEnd { namespace ClangBackEnd {
class EchoMessage class EchoMessage
...@@ -71,7 +69,6 @@ private: ...@@ -71,7 +69,6 @@ private:
}; };
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const EchoMessage &message); CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const EchoMessage &message);
std::ostream &operator<<(std::ostream &os, const EchoMessage &message);
DECLARE_MESSAGE(EchoMessage) DECLARE_MESSAGE(EchoMessage)
} // namespace ClangBackEnd } // namespace ClangBackEnd
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#include <QDebug> #include <QDebug>
#include <ostream>
namespace ClangBackEnd { namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const EndMessage &/*message*/) QDebug operator<<(QDebug debug, const EndMessage &/*message*/)
...@@ -36,9 +34,4 @@ QDebug operator<<(QDebug debug, const EndMessage &/*message*/) ...@@ -36,9 +34,4 @@ QDebug operator<<(QDebug debug, const EndMessage &/*message*/)
return debug.nospace() << "EndMessage()"; return debug.nospace() << "EndMessage()";
} }
std::ostream &operator<<(std::ostream &os, const EndMessage &/*message*/)
{
return os << "()";
}
} }
...@@ -29,8 +29,6 @@ ...@@ -29,8 +29,6 @@
#include <QDataStream> #include <QDataStream>
#include <iosfwd>
namespace ClangBackEnd { namespace ClangBackEnd {
class EndMessage class EndMessage
...@@ -53,7 +51,6 @@ public: ...@@ -53,7 +51,6 @@ public:
}; };
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const EndMessage &message); CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const EndMessage &message);
std::ostream &operator<<(std::ostream &os, const EndMessage &message);
DECLARE_MESSAGE(EndMessage) DECLARE_MESSAGE(EndMessage)
} }
...@@ -27,9 +27,6 @@ ...@@ -27,9 +27,6 @@
#include <QDebug> #include <QDebug>
#include <algorithm>
#include <ostream>
namespace ClangBackEnd { namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const RegisterProjectPartsForEditorMessage &message) QDebug operator<<(QDebug debug, const RegisterProjectPartsForEditorMessage &message)
...@@ -44,14 +41,5 @@ QDebug operator<<(QDebug debug, const RegisterProjectPartsForEditorMessage &mess ...@@ -44,14 +41,5 @@ QDebug operator<<(QDebug debug, const RegisterProjectPartsForEditorMessage &mess
return debug; return debug;
} }
std::ostream &operator<<(std::ostream &os, const RegisterProjectPartsForEditorMessage &message)
{
os << "("
<< message.projectContainers()
<< ")";
return os;
}
} // namespace ClangBackEnd } // namespace ClangBackEnd
...@@ -70,7 +70,6 @@ private: ...@@ -70,7 +70,6 @@ private:
}; };
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const RegisterProjectPartsForEditorMessage &message); CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const RegisterProjectPartsForEditorMessage &message);
std::ostream &operator<<(std::ostream &os, const RegisterProjectPartsForEditorMessage &message);
DECLARE_MESSAGE(RegisterProjectPartsForEditorMessage); DECLARE_MESSAGE(RegisterProjectPartsForEditorMessage);
} // namespace ClangBackEnd } // namespace ClangBackEnd
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#include <QDebug> #include <QDebug>
#include <ostream>
namespace ClangBackEnd { namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const RegisterTranslationUnitForEditorMessage &message) QDebug operator<<(QDebug debug, const RegisterTranslationUnitForEditorMessage &message)
...@@ -48,15 +46,5 @@ QDebug operator<<(QDebug debug, const RegisterTranslationUnitForEditorMessage &m ...@@ -48,15 +46,5 @@ QDebug operator<<(QDebug debug, const RegisterTranslationUnitForEditorMessage &m
return debug; return debug;
} }
std::ostream &operator<<(std::ostream &os, const RegisterTranslationUnitForEditorMessage &message)
{
os << "RegisterTranslationUnitForEditorMessage("
<< message.fileContainers() << ", "
<< message.currentEditorFilePath() << ", "
<< message.visibleEditorFilePaths() << ")";
return os;
}
} // namespace ClangBackEnd } // namespace ClangBackEnd
...@@ -84,7 +84,6 @@ public: ...@@ -84,7 +84,6 @@ public:
&& first.visibleEditorFilePaths_ == second.visibleEditorFilePaths_; && first.visibleEditorFilePaths_ == second.visibleEditorFilePaths_;
} }
friend std::ostream &operator<<(std::ostream &os, const RegisterTranslationUnitForEditorMessage &message);
private: private:
QVector<FileContainer> fileContainers_; QVector<FileContainer> fileContainers_;
Utf8String currentEditorFilePath_; Utf8String currentEditorFilePath_;
......
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#include <QDebug> #include <QDebug>
#include <ostream>
namespace ClangBackEnd { namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const UnregisterProjectPartsForEditorMessage &message) QDebug operator<<(QDebug debug, const UnregisterProjectPartsForEditorMessage &message)
...@@ -43,14 +41,5 @@ QDebug operator<<(QDebug debug, const UnregisterProjectPartsForEditorMessage &me ...@@ -43,14 +41,5 @@ QDebug operator<<(QDebug debug, const UnregisterProjectPartsForEditorMessage &me
return debug; return debug;
} }
std::ostream &operator<<(std::ostream &os, const UnregisterProjectPartsForEditorMessage &message)
{
os << "("
<< message.projectPartIds()
<< ")";
return os;
}
} // namespace ClangBackEnd } // namespace ClangBackEnd
...@@ -71,7 +71,6 @@ private: ...@@ -71,7 +71,6 @@ private:
}; };
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const UnregisterProjectPartsForEditorMessage &message); CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const UnregisterProjectPartsForEditorMessage &message);
std::ostream &operator<<(std::ostream &os, const UnregisterProjectPartsForEditorMessage &message);
DECLARE_MESSAGE(UnregisterProjectPartsForEditorMessage); DECLARE_MESSAGE(UnregisterProjectPartsForEditorMessage);
} // namespace ClangBackEnd } // namespace ClangBackEnd
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#include <QDebug> #include <QDebug>
#include <ostream>
namespace ClangBackEnd { namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const UnregisterTranslationUnitsForEditorMessage &message) QDebug operator<<(QDebug debug, const UnregisterTranslationUnitsForEditorMessage &message)
...@@ -43,14 +41,5 @@ QDebug operator<<(QDebug debug, const UnregisterTranslationUnitsForEditorMessage ...@@ -43,14 +41,5 @@ QDebug operator<<(QDebug debug, const UnregisterTranslationUnitsForEditorMessage
return debug; return debug;
} }
std::ostream &operator<<(std::ostream &os, const UnregisterTranslationUnitsForEditorMessage &message)
{
os << "("
<< message.fileContainers()
<< ")";
return os;
}
} // namespace ClangBackEnd } // namespace ClangBackEnd
...@@ -66,8 +66,6 @@ public: ...@@ -66,8 +66,6 @@ public:
return first.m_fileContainers == second.m_fileContainers; return first.m_fileContainers == second.m_fileContainers;
} }
friend std::ostream &operator<<(std::ostream &os, const UnregisterTranslationUnitsForEditorMessage &message);
private: private:
QVector<FileContainer> m_fileContainers; QVector<FileContainer> m_fileContainers;
}; };
......
...@@ -84,19 +84,6 @@ QDebug operator<<(QDebug debug, const CodeCompletion &message) ...@@ -84,19 +84,6 @@ QDebug operator<<(QDebug debug, const CodeCompletion &message)
return debug; 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) std::ostream &operator<<(std::ostream &os, const CodeCompletion::Kind kind)
{ {
return os << completionKindToString(kind); return os << completionKindToString(kind);
......
...@@ -194,7 +194,6 @@ public: ...@@ -194,7 +194,6 @@ public:
} }
friend CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const CodeCompletion &message); friend CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const CodeCompletion &message);
friend std::ostream &operator<<(std::ostream &os, const CodeCompletion &message);
private: private:
Utf8String m_text; Utf8String m_text;
......
...@@ -75,20 +75,6 @@ QDebug operator<<(QDebug debug, const CodeCompletionChunk &chunk) ...@@ -75,20 +75,6 @@ QDebug operator<<(QDebug debug, const CodeCompletionChunk &chunk)
return debug; 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) std::ostream &operator<<(std::ostream &os, const CodeCompletionChunk::Kind &kind)
{ {
return os << completionChunkKindToString(kind); return os << completionChunkKindToString(kind);
......
...@@ -127,7 +127,6 @@ private: ...@@ -127,7 +127,6 @@ private:
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const CodeCompletionChunk &chunk); 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); std::ostream &operator<<(std::ostream &os, const CodeCompletionChunk::Kind &kind);
} // namespace ClangBackEnd } // namespace ClangBackEnd
...@@ -29,23 +29,8 @@ ...@@ -29,23 +29,8 @@
#include <QDebug> #include <QDebug>
#include <ostream>
namespace ClangBackEnd { 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) QDebug operator<<(QDebug debug, const DiagnosticContainer &container)
{ {
debug.nospace() << "DiagnosticContainer(" debug.nospace() << "DiagnosticContainer("
...@@ -62,20 +47,5 @@ QDebug operator<<(QDebug debug, const DiagnosticContainer &container) ...@@ -62,20 +47,5 @@ QDebug operator<<(QDebug debug, const DiagnosticContainer &container)
return debug; 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 } // namespace ClangBackEnd
...@@ -162,6 +162,5 @@ private: ...@@ -162,6 +162,5 @@ private:
}; };
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const DiagnosticContainer &container); CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const DiagnosticContainer &container);
std::ostream &operator<<(std::ostream &os, const DiagnosticContainer &container);
} // namespace ClangBackEnd } // namespace ClangBackEnd
...@@ -25,11 +25,8 @@ ...@@ -25,11 +25,8 @@
#include "documentannotationschangedmessage.h" #include "documentannotationschangedmessage.h"
#include <QDataStream>
#include <QDebug> #include <QDebug>
#include <ostream>
namespace ClangBackEnd { namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const DocumentAnnotationsChangedMessage &message) QDebug operator<<(QDebug debug, const DocumentAnnotationsChangedMessage &message)
...@@ -45,18 +42,5 @@ QDebug operator<<(QDebug debug, const DocumentAnnotationsChangedMessage &message ...@@ -45,18 +42,5 @@ QDebug operator<<(QDebug debug, const DocumentAnnotationsChangedMessage &message
return debug; 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()
<< ")";