Commit 1f18848e authored by Marco Bubke's avatar Marco Bubke

Clang: Cleanup more PrintTo functions

Change-Id: If1389462479ae10b067904f05cf785c3d8fb9638
Reviewed-by: David Schulz's avatarDavid Schulz <david.schulz@qt.io>
Reviewed-by: Nikolai Kosjar's avatarNikolai Kosjar <nikolai.kosjar@qt.io>
parent 50790f61
......@@ -208,6 +208,6 @@ private:
CMBIPC_EXPORT QDebug operator<<(QDebug debug, CodeCompletion::Kind kind);
std::ostream &operator<<(std::ostream &os, const CodeCompletion::Kind kind);
std::ostream &operator<<(std::ostream &os, const CodeCompletion::Availability availability);
CMBIPC_EXPORT std::ostream &operator<<(std::ostream &os, const CodeCompletion::Kind kind);
CMBIPC_EXPORT std::ostream &operator<<(std::ostream &os, const CodeCompletion::Availability availability);
} // namespace ClangBackEnd
......@@ -423,12 +423,15 @@ bool operator==(const Document &first, const Document &second)
&& first.projectPart().id() == second.projectPart().id();
}
void PrintTo(const Document &document, ::std::ostream *os)
std::ostream &operator<<(std::ostream &os, const Document &document)
{
*os << "Document("
<< document.filePath().constData() << ", "
<< document.projectPart().id().constData() << ", "
<< document.documentRevision() << ")";
os << "("
<< document.filePath() << ", "
<< document.projectPart().id() << ", "
<< document.documentRevision()
<< ")";
return os;
}
} // namespace ClangBackEnd
......@@ -133,5 +133,5 @@ private:
};
bool operator==(const Document &first, const Document &second);
void PrintTo(const Document &document, ::std::ostream *os);
std::ostream &operator<<(std::ostream &os, const Document &document);
} // namespace ClangBackEnd
......@@ -107,7 +107,6 @@ public:
{
return second == first;
}
template<typename Type,
typename = typename std::enable_if<std::is_pointer<Type>::value>::type
>
......@@ -124,11 +123,9 @@ public:
return second == first;
}
friend std::ostream &operator<<(std::ostream &out, const ClangString &string)
friend std::ostream &operator<<(std::ostream &os, const ClangString &string)
{
out << string.cString();
return out;
return os << string.cString();
}
private:
......
......@@ -144,17 +144,20 @@ bool operator==(Type first, Type second)
return clang_equalTypes(first.cxType, second.cxType);
}
void PrintTo(CXTypeKind typeKind, ::std::ostream* os)
std::ostream &operator<<(std::ostream &os, CXTypeKind typeKind)
{
ClangString typeKindSpelling(clang_getTypeKindSpelling(typeKind));
*os << typeKindSpelling.cString();
return os << typeKindSpelling.cString();
}
void PrintTo(const Type &type, ::std::ostream* os)
std::ostream &operator<<(std::ostream &os, const Type &type)
{
ClangString typeKindSpelling(clang_getTypeKindSpelling(type.kind()));
*os << typeKindSpelling.cString()
<< ": \"" << type.spelling().cString() << "\"";
os << typeKindSpelling
<< ": \"" << type.spelling() << "\"";
return os;
}
......
......@@ -77,6 +77,6 @@ private:
bool operator==(Type first, Type second);
void PrintTo(CXTypeKind typeKind, ::std::ostream* os);
void PrintTo(const Type &type, ::std::ostream* os);
std::ostream &operator<<(std::ostream &os, CXTypeKind typeKind);
std::ostream &operator<<(std::ostream &os, const Type &type);
} // namespace ClangBackEnd
......@@ -28,10 +28,6 @@
#include "clangstring.h"
#include "codecompletionchunkconverter.h"
#ifdef CLANGBACKEND_TESTS
#include <gtest/gtest.h>
#endif
#include <QDebug>
namespace ClangBackEnd {
......@@ -344,15 +340,15 @@ const CodeCompletion &CodeCompletionsExtractor::currentCodeCompletion() const
return currentCodeCompletion_;
}
#ifdef CLANGBACKEND_TESTS
void PrintTo(const CodeCompletionsExtractor &extractor, std::ostream *os)
std::ostream &operator<<(std::ostream &os, const CodeCompletionsExtractor &extractor)
{
*os << "name: " << ::testing::PrintToString(extractor.currentCodeCompletion().text())
<< ", kind: " << ::testing::PrintToString(extractor.currentCodeCompletion().completionKind())
<< ", priority: " << extractor.currentCodeCompletion().priority()
<< ", kind: " << ::testing::PrintToString(extractor.currentCodeCompletion().availability());
os << "name: " << extractor.currentCodeCompletion().text()
<< ", kind: " << extractor.currentCodeCompletion().completionKind()
<< ", priority: " << extractor.currentCodeCompletion().priority()
<< ", kind: " << extractor.currentCodeCompletion().availability();
return os;
}
#endif
} // namespace ClangBackEnd
......@@ -31,6 +31,8 @@
#include <QVector>
#include <iosfwd>
namespace ClangBackEnd {
class CodeCompletionsExtractor
......@@ -78,7 +80,5 @@ private:
uint cxCodeCompleteResultIndex = -1;
};
#ifdef CLANGBACKEND_TESTS
void PrintTo(const CodeCompletionsExtractor &extractor, ::std::ostream* os);
#endif
std::ostream &operator<<(std::ostream &os, const CodeCompletionsExtractor &extractor);
} // namespace ClangBackEnd
......@@ -403,29 +403,31 @@ bool operator!=(const Cursor &first, const Cursor &second)
return !(first == second);
}
void PrintTo(CXCursorKind cursorKind, ::std::ostream *os)
std::ostream &operator<<(std::ostream &os, CXCursorKind cursorKind)
{
ClangString cursorKindSpelling(clang_getCursorKindSpelling(cursorKind));
*os << cursorKindSpelling.cString();
return os << cursorKindSpelling.cString();
}
void PrintTo(const Cursor &cursor, ::std::ostream*os)
std::ostream &operator<<(std::ostream &os, const Cursor &cursor)
{
if (cursor.isValid()) {
ClangString cursorKindSpelling(clang_getCursorKindSpelling(cursor.kind()));
*os << cursorKindSpelling.cString() << " ";
os << cursorKindSpelling << " ";
auto identifier = cursor.displayName();
if (identifier.hasContent()) {
*os << "\""
<< identifier
<< "\": ";
os << "\""
<< identifier
<< "\": ";
}
PrintTo(cursor.sourceLocation(), os);
os << cursor.sourceLocation();
} else {
*os << "Invalid cursor!";
os << "Invalid cursor!";
}
return os;
}
} // namespace ClangBackEnd
......
......@@ -130,6 +130,7 @@ void Cursor::visit(VisitorCallback visitorCallback) const
bool operator==(const Cursor &first, const Cursor &second);
bool operator!=(const Cursor &first, const Cursor &second);
void PrintTo(CXCursorKind cursorKind, ::std::ostream *os);
void PrintTo(const Cursor &cursor, ::std::ostream* os);
std::ostream &operator<<(std::ostream &os, CXCursorKind cursorKind);
std::ostream &operator<<(std::ostream &os, const Cursor &cursor);
} // namespace ClangBackEnd
......@@ -114,15 +114,17 @@ SourceLocation::operator CXSourceLocation() const
return cxSourceLocation;
}
void PrintTo(const SourceLocation &sourceLocation, std::ostream *os)
std::ostream &operator<<(std::ostream &os, const SourceLocation &sourceLocation)
{
auto filePath = sourceLocation.filePath();
if (filePath.hasContent())
*os << filePath.constData() << ", ";
os << filePath << ", ";
*os << "line: " << sourceLocation.line()
<< ", column: "<< sourceLocation.column()
<< ", offset: "<< sourceLocation.offset();
os << "line: " << sourceLocation.line()
<< ", column: "<< sourceLocation.column()
<< ", offset: "<< sourceLocation.offset();
return os;
}
} // namespace ClangBackEnd
......
......@@ -72,6 +72,6 @@ private:
bool operator==(const SourceLocation &first, const SourceLocation &second);
void PrintTo(const SourceLocation &sourceLocation, ::std::ostream* os);
std::ostream &operator<<(std::ostream &os, const SourceLocation &sourceLocation);
} // namespace ClangBackEnd
......@@ -100,13 +100,14 @@ bool operator==(const SourceRange &first, const SourceRange &second)
return clang_equalRanges(first.cxSourceRange, second.cxSourceRange);
}
void PrintTo(const SourceRange &sourceRange, ::std::ostream* os)
std::ostream &operator<<(std::ostream &os, const SourceRange &sourceRange)
{
*os << "[";
PrintTo(sourceRange.start(), os);
*os << ", ";
PrintTo(sourceRange.end(), os);
*os << "]";
os << "["
<< sourceRange.start() << ", "
<< sourceRange.end()
<< "]";
return os;
}
} // namespace ClangBackEnd
......@@ -61,5 +61,5 @@ private:
};
bool operator==(const SourceRange &first, const SourceRange &second);
void PrintTo(const SourceRange &sourceRange, ::std::ostream* os);
std::ostream &operator<<(std::ostream &os, const SourceRange &sourceRange);
} // namespace ClangBackEnd
......@@ -97,12 +97,14 @@ bool UnsavedFile::replaceAt(uint position, uint length, const Utf8String &replac
return false;
}
void PrintTo(const UnsavedFile &unsavedFile, std::ostream *os)
std::ostream &operator<<(std::ostream &os, const UnsavedFile &unsavedFile)
{
*os << "UnsavedFile("
<< unsavedFile.m_filePath.constData() << ", "
<< unsavedFile.m_fileContent.constData() << ", "
<< unsavedFile.m_fileContent.byteSize() << ")";
os << "UnsavedFile("
<< unsavedFile.m_filePath << ", "
<< unsavedFile.m_fileContent << ", "
<< unsavedFile.m_fileContent << ")";
return os;
}
} // namespace ClangBackEnd
......@@ -34,7 +34,7 @@ using uint = unsigned int;
class UnsavedFile
{
public:
friend void PrintTo(const UnsavedFile &unsavedFile, std::ostream *os);
friend std::ostream &operator<<(std::ostream &os, const UnsavedFile &unsavedFile);
UnsavedFile();
UnsavedFile(const Utf8String &filePath, const Utf8String &fileContent);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment