diff --git a/tests/unit/unittest/builddependencycollector-test.cpp b/tests/unit/unittest/builddependencycollector-test.cpp index 5be0689ef64..8ca1f970e20 100644 --- a/tests/unit/unittest/builddependencycollector-test.cpp +++ b/tests/unit/unittest/builddependencycollector-test.cpp @@ -92,8 +92,6 @@ class BuildDependencyCollector : public ::testing::Test protected: BuildDependencyCollector() { - setFilePathCache(&filePathCache); - collector.addFiles({id(TESTDATA_DIR "/builddependencycollector/project/main.cpp"), id(TESTDATA_DIR "/builddependencycollector/project/main2.cpp")}, {"cc", @@ -114,8 +112,6 @@ protected: emptyCollector.setExcludedFilePaths(Utils::clone(excludePaths)); } - ~BuildDependencyCollector() { setFilePathCache(nullptr); } - FilePathId id(const Utils::SmallStringView &path) const { return filePathCache.filePathId(FilePathView{path}); diff --git a/tests/unit/unittest/gtest-clang-printing.cpp b/tests/unit/unittest/gtest-clang-printing.cpp index bd351371915..13d2d94e5b2 100644 --- a/tests/unit/unittest/gtest-clang-printing.cpp +++ b/tests/unit/unittest/gtest-clang-printing.cpp @@ -27,10 +27,6 @@ #include "gtest-std-printing.h" #ifdef CLANG_UNIT_TESTS -#include -#include -#include - #include #include #include @@ -41,53 +37,6 @@ #include -namespace TestGlobal { - -const clang::SourceManager *globalSourceManager = nullptr; - -void setSourceManager(const clang::SourceManager *sourceManager) -{ - globalSourceManager = sourceManager; -} - -} - -namespace llvm { -std::ostream &operator<<(std::ostream &out, const StringRef stringReference) -{ - out.write(stringReference.data(), std::streamsize(stringReference.size())); - - return out; -} -} - -namespace clang { - -void PrintTo(const FullSourceLoc &sourceLocation, ::std::ostream *os) -{ - auto &&sourceManager = sourceLocation.getManager(); - auto fileName = sourceManager.getFileEntryForID(sourceLocation.getFileID())->getName(); - - *os << "(\"" - << fileName << ", " - << sourceLocation.getSpellingLineNumber() << ", " - << sourceLocation.getSpellingColumnNumber() << ")"; -} - -void PrintTo(const SourceRange &sourceRange, ::std::ostream *os) -{ - if (TestGlobal::globalSourceManager) { - *os << "(" - << sourceRange.getBegin().printToString(*TestGlobal::globalSourceManager) << ", " - << sourceRange.getEnd().printToString(*TestGlobal::globalSourceManager) << ")"; - } else { - *os << "(" - << sourceRange.getBegin().getRawEncoding() << ", " - << sourceRange.getEnd().getRawEncoding() << ")"; - } -} - -} namespace ClangBackEnd { std::ostream &operator<<(std::ostream &os, const TokenInfo &tokenInfo) diff --git a/tests/unit/unittest/gtest-clang-printing.h b/tests/unit/unittest/gtest-clang-printing.h index b0c0a93afba..4dfdbb2685a 100644 --- a/tests/unit/unittest/gtest-clang-printing.h +++ b/tests/unit/unittest/gtest-clang-printing.h @@ -29,27 +29,6 @@ #include -namespace llvm { - -class StringRef; - -std::ostream &operator<<(std::ostream &out, const StringRef stringReference); -} - -namespace clang { -class FullSourceLoc; -class SourceRange; -class SourceManager; - -void PrintTo(const FullSourceLoc &sourceLocation, ::std::ostream *os); -void PrintTo(const SourceRange &sourceLocation, ::std::ostream *os); - -} - -namespace TestGlobal { -void setSourceManager(const clang::SourceManager *sourceManager); -} - namespace ClangBackEnd { class TokenInfo; template diff --git a/tests/unit/unittest/gtest-creator-printing.cpp b/tests/unit/unittest/gtest-creator-printing.cpp index 77bfdcf8a9d..094eb2a6e07 100644 --- a/tests/unit/unittest/gtest-creator-printing.cpp +++ b/tests/unit/unittest/gtest-creator-printing.cpp @@ -31,170 +31,35 @@ #include #include -#include - -#include #include #include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include -#include -#include -#include +#include #include #include -#include -#include -#include -#include #include -#include -#include +#include #include #include #include -namespace { -ClangBackEnd::FilePathCaching *filePathCache = nullptr; -} - void PrintTo(const Utf8String &text, ::std::ostream *os) { *os << text; } -namespace Core { - -std::ostream &operator<<(std::ostream &out, const LocatorFilterEntry &entry) -{ - out << "(" - << entry.displayName << ", "; - - if (entry.internalData.canConvert()) - out << entry.internalData.value(); - - out << ")"; - - return out; -} - -namespace Search { - -using testing::PrintToString; - -class TextPosition; -class TextRange; - -void PrintTo(const TextPosition &position, ::std::ostream *os) -{ - *os << "(" - << position.line << ", " - << position.column << ")"; -} - -void PrintTo(const TextRange &range, ::std::ostream *os) -{ - *os << "(" - << PrintToString(range.begin) << ", " - << PrintToString(range.end) << ")"; -} - -} // namespace Search -} // namespace Core - -namespace ProjectExplorer { - -static const char *typeToString(const MacroType &type) -{ - switch (type) { - case MacroType::Invalid: return "MacroType::Invalid"; - case MacroType::Define: return "MacroType::Define"; - case MacroType::Undefine: return "MacroType::Undefine"; - } - - return ""; -} - -std::ostream &operator<<(std::ostream &out, const MacroType &type) -{ - out << typeToString(type); - - return out; -} - -std::ostream &operator<<(std::ostream &out, const Macro ¯o) -{ - out << "(" - << macro.key.data() << ", " - << macro.value.data() << ", " - << macro.type << ")"; - - return out; -} - -static const char *typeToString(const HeaderPathType &type) -{ - switch (type) { - case HeaderPathType::User: - return "User"; - case HeaderPathType::System: - return "System"; - case HeaderPathType::BuiltIn: - return "BuiltIn"; - case HeaderPathType::Framework: - return "Framework"; - } - - return ""; -} - -std::ostream &operator<<(std::ostream &out, const HeaderPathType &headerPathType) -{ - return out << "HeaderPathType::" << typeToString(headerPathType); -} - -std::ostream &operator<<(std::ostream &out, const HeaderPath &headerPath) -{ - return out << "(" << headerPath.path << ", " << headerPath.type << ")"; -} - -} // namespace ProjectExplorer - namespace Utils { std::ostream &operator<<(std::ostream &out, const LineColumn &lineColumn) { return out << "(" << lineColumn.line << ", " << lineColumn.column << ")"; } - -std::ostream &operator<<(std::ostream &out, const Link &link) -{ - return out << "(" << link.targetFilePath.toString() << ", " << link.targetLine << ", " - << link.targetColumn << ", " << link.linkTextStart << ", " << link.linkTextEnd << ")"; -} - +namespace { const char * toText(Utils::Language language) { using Utils::Language; @@ -210,12 +75,14 @@ const char * toText(Utils::Language language) return ""; } +} // namespace std::ostream &operator<<(std::ostream &out, const Utils::Language &language) { return out << "Utils::" << toText(language); } +namespace { const char * toText(Utils::LanguageVersion languageVersion) { using Utils::LanguageVersion; @@ -247,12 +114,14 @@ const char * toText(Utils::LanguageVersion languageVersion) return ""; } +} // namespace std::ostream &operator<<(std::ostream &out, const Utils::LanguageVersion &languageVersion) { return out << "Utils::" << toText(languageVersion); } +namespace { const std::string toText(Utils::LanguageExtension extension, std::string prefix = {}) { std::stringstream out; @@ -287,6 +156,7 @@ const std::string toText(Utils::LanguageExtension extension, std::string prefix return out.str(); } +} // namespace std::ostream &operator<<(std::ostream &out, const Utils::LanguageExtension &languageExtension) { @@ -308,6 +178,11 @@ void PrintTo(const Utils::PathString &text, ::std::ostream *os) *os << "\"" << text << "\""; } +std::ostream &operator<<(std::ostream &out, const FilePath &filePath) +{ + return out << filePath.toString(); +} + } // namespace Utils namespace Sqlite { @@ -325,6 +200,9 @@ std::ostream &operator<<(std::ostream &out, const Value &value) case Sqlite::ValueType::String: out << "\"" << value.toStringView() << "\""; break; + case Sqlite::ValueType::Blob: + out << "blob"; + break; case Sqlite::ValueType::Null: out << "null"; break; @@ -347,6 +225,9 @@ std::ostream &operator<<(std::ostream &out, const ValueView &value) case Sqlite::ValueType::String: out << "\"" << value.toStringView() << "\""; break; + case Sqlite::ValueType::Blob: + out << "blob"; + break; case Sqlite::ValueType::Null: out << "null"; break; @@ -534,79 +415,6 @@ std::ostream &operator<<(std::ostream &out, const ConstTupleIterator &iterator) namespace ClangBackEnd { -std::ostream &operator<<(std::ostream &out, const FilePathId &id) -{ - if (filePathCache) - return out << "(" << id.filePathId << ", " << filePathCache->filePath(id) << ")"; - - return out << id.filePathId; -} - -std::ostream &operator<<(std::ostream &out, const FilePathView &filePathView) -{ - return out << "(" << filePathView.toStringView() << ", " << filePathView.slashIndex() << ")"; -} - -std::ostream &operator<<(std::ostream &out, const NativeFilePathView &nativeFilePathView) -{ - return out << "(" << nativeFilePathView.toStringView() << ", " << nativeFilePathView.slashIndex() << ")"; -} - -std::ostream &operator<<(std::ostream &out, const IdPaths &idPaths) -{ - out << "(" - << idPaths.id << ", " - << idPaths.filePathIds << ")"; - - return out; -} - -#define RETURN_TEXT_FOR_CASE(enumValue) case SourceLocationKind::enumValue: return #enumValue -static const char *symbolTypeToCStringLiteral(ClangBackEnd::SourceLocationKind kind) -{ - switch (kind) { - RETURN_TEXT_FOR_CASE(None); - RETURN_TEXT_FOR_CASE(Declaration); - RETURN_TEXT_FOR_CASE(DeclarationReference); - RETURN_TEXT_FOR_CASE(Definition); - RETURN_TEXT_FOR_CASE(MacroDefinition); - RETURN_TEXT_FOR_CASE(MacroUsage); - RETURN_TEXT_FOR_CASE(MacroUndefinition); - } - - return ""; -} -#undef RETURN_TEXT_FOR_CASE - -std::ostream &operator<<(std::ostream &out, const SourceLocationEntry &entry) -{ - out << "(" - << entry.symbolId << ", " - << entry.filePathId << ", " - << entry.lineColumn << ", " - << symbolTypeToCStringLiteral(entry.kind) << ")"; - - return out; -} - -std::ostream &operator<<(std::ostream &out, const WatcherEntry &entry) -{ - out << "(" << entry.directoryPathId << ", " << entry.filePathId << ", " << entry.id << ", " - << entry.lastModified << ", " - << ")"; - - return out; -} - -std::ostream &operator<<(std::ostream &os, const SourceLocationsContainer &container) -{ - os << "(" - << container.sourceLocationContainers() - << ")"; - - return os; -} - std::ostream &operator<<(std::ostream &os, const FollowSymbolResult &result) { os << "(" @@ -784,38 +592,6 @@ std::ostream &operator<<(std::ostream &os, const DiagnosticContainer &container) return os; } -std::ostream &operator<<(std::ostream &os, const DynamicASTMatcherDiagnosticContainer &container) -{ - os << "(" - << container.messages << ", " - << container.contexts - << ")"; - - return os; -} - -std::ostream &operator<<(std::ostream &os, const DynamicASTMatcherDiagnosticContextContainer &container) -{ - os << "(" - << container.contextTypeText() << ", " - << container.sourceRange << ", " - << container.arguments - << ")"; - - return os; -} - -std::ostream &operator<<(std::ostream &os, const DynamicASTMatcherDiagnosticMessageContainer &container) -{ - os << "(" - << container.errorTypeText() << ", " - << container.sourceRange << ", " - << container.arguments - << ")"; - - return os; -} - std::ostream &operator<<(std::ostream &os, const FileContainer &container) { os << "(" @@ -948,26 +724,6 @@ std::ostream &operator<<(std::ostream &os, const TokenInfoContainer &container) return os; } -std::ostream &operator<<(std::ostream &out, const NativeFilePath &filePath) -{ - return out << "(" << filePath.path() << ", " << filePath.slashIndex() << ")"; -} - -std::ostream &operator<<(std::ostream &out, const PrecompiledHeadersUpdatedMessage &message) -{ - out << "(" << message.projectPartIds << ")"; - - return out; -} - -std::ostream &operator<<(std::ostream &out, const ProjectPartPch &projectPartPch) -{ - out << "(" << projectPartPch.projectPartId << ", " << projectPartPch.pchPath << ", " - << projectPartPch.lastModified << ")"; - - return out; -} - std::ostream &operator<<(std::ostream &os, const UnsavedFilesUpdatedMessage &message) { os << "(" @@ -986,11 +742,6 @@ std::ostream &operator<<(std::ostream &os, const RequestAnnotationsMessage &mess return os; } -std::ostream &operator<<(std::ostream &out, const RemoveProjectPartsMessage &message) -{ - return out << "(" << message.projectsPartIds << ")"; -} - std::ostream &operator<<(std::ostream &os, const RequestFollowSymbolMessage &message) { os << "(" @@ -1028,10 +779,13 @@ std::ostream &operator<<(std::ostream &out, const RequestToolTipMessage &message return out; } +namespace { + std::ostream &operator<<(std::ostream &os, const ToolTipInfo::QdocCategory category) { return os << qdocCategoryToString(category); } +} // namespace std::ostream &operator<<(std::ostream &out, const ToolTipInfo &info) { @@ -1047,25 +801,6 @@ std::ostream &operator<<(std::ostream &out, const ToolTipInfo &info) return out; } -std::ostream &operator<<(std::ostream &os, const RequestSourceRangesAndDiagnosticsForQueryMessage &message) -{ - os << "(" - << message.query << ", " - << message.source - << ")"; - - return os; -} - -std::ostream &operator<<(std::ostream &os, const RequestSourceRangesForQueryMessage &message) -{ - os << "(" - << message.query - << ")"; - - return os; -} - std::ostream &operator<<(std::ostream &os, const SourceLocationContainer &container) { os << "(" @@ -1087,46 +822,6 @@ std::ostream &operator<<(std::ostream &os, const SourceRangeContainer &container return os; } -std::ostream &operator<<(std::ostream &os, const SourceRangesAndDiagnosticsForQueryMessage &message) -{ - os << "(" - << message.sourceRanges << ", " - << message.diagnostics - << ")"; - - return os; -} - -std::ostream &operator<<(std::ostream &os, const SourceRangesContainer &container) -{ - os << "(" - << container.sourceRangeWithTextContainers - << ")"; - - return os; -} - -std::ostream &operator<<(std::ostream &os, const SourceRangesForQueryMessage &message) -{ - os << "(" - << message.sourceRanges - << ")"; - - return os; -} - -std::ostream &operator<<(std::ostream &os, const SourceRangeWithTextContainer &container) -{ - - os << "(" - << container.start << ", " - << container.end << ", " - << container.text - << ")"; - - return os; -} - std::ostream &operator<<(std::ostream &os, const UnsavedFilesRemovedMessage &message) { os << "(" @@ -1136,13 +831,6 @@ std::ostream &operator<<(std::ostream &os, const UnsavedFilesRemovedMessage &mes return os; } -std::ostream &operator<<(std::ostream &out, const UpdateProjectPartsMessage &message) -{ - return out << "(" - << message.projectsParts - << ")"; -} - std::ostream &operator<<(std::ostream &os, const DocumentsChangedMessage &message) { os << "DocumentsChangedMessage(" @@ -1162,73 +850,7 @@ std::ostream &operator<<(std::ostream &os, const DocumentVisibilityChangedMessag return os; } -std::ostream &operator<<(std::ostream &out, const FilePath &filePath) -{ - return out << "(" << filePath.path() << ", " << filePath.slashIndex() << ")"; -} - -std::ostream &operator<<(std::ostream &out, const ProjectPartEntry &projectPartEntry) -{ - return out << "(" - << projectPartEntry.projectPathName - << ", " - << projectPartEntry.filePathIds - << ")"; -} - -std::ostream &operator<<(std::ostream &out, const UsedMacro &usedMacro) -{ - return out << "(" - << usedMacro.filePathId - << ", " - << usedMacro.macroName - << ")"; -} - -std::ostream &operator<<(std::ostream &out, const FileStatus &fileStatus) -{ - return out << "(" - << fileStatus.filePathId - << ", " - << fileStatus.size - << ", " - << fileStatus.lastModified - << ")"; -} - -std::ostream &operator<<(std::ostream &out, const SourceDependency &sourceDependency) -{ - return out << "(" - << sourceDependency.filePathId - << ", " - << sourceDependency.dependencyFilePathId - << ")"; -} - -std::ostream &operator<<(std::ostream &out, const ProjectPartArtefact &projectPartArtefact) -{ - return out << "(" << projectPartArtefact.projectPartId << ", " - << projectPartArtefact.toolChainArguments << ", " << projectPartArtefact.compilerMacros - << ", " << projectPartArtefact.language << ", " << projectPartArtefact.languageVersion - << ", " << projectPartArtefact.languageExtension << ")"; -} - -std::ostream &operator<<(std::ostream &out, const CompilerMacro &compilerMacro) -{ - return out << "(" << compilerMacro.key << ", " << compilerMacro.value << ", " - << compilerMacro.index << ")"; -} - -std::ostream &operator<<(std::ostream &out, const SymbolEntry &entry) -{ - out << "(" - << entry.symbolName << ", " - << entry.usr << ", " - << entry.symbolKind <<")"; - - return out; -} - +namespace { const char *symbolKindString(SymbolKind symbolKind) { using ClangBackEnd::SymbolKind; @@ -1245,11 +867,6 @@ const char *symbolKindString(SymbolKind symbolKind) return ""; } -std::ostream &operator<<(std::ostream &out, SymbolKind symbolKind) -{ - return out << symbolKindString(symbolKind); -} - const char *symbolTagString(SymbolTag symbolTag) { using ClangBackEnd::SymbolTag; @@ -1264,6 +881,12 @@ const char *symbolTagString(SymbolTag symbolTag) return ""; } +} // namespace + +std::ostream &operator<<(std::ostream &out, SymbolKind symbolKind) +{ + return out << symbolKindString(symbolKind); +} std::ostream &operator<<(std::ostream &out, SymbolTag symbolTag) { @@ -1277,270 +900,8 @@ std::ostream &operator<<(std::ostream &out, SymbolTags symbolTags) return out; } -std::ostream &operator<<(std::ostream &out, const UpdateGeneratedFilesMessage &message) -{ - return out << "(" << message.generatedFiles << ")"; -} - -std::ostream &operator<<(std::ostream &out, const RemoveGeneratedFilesMessage &message) -{ - return out << "(" << message.generatedFiles << ")"; -} - -std::ostream &operator<<(std::ostream &out, const SymbolIndexerTask &task) -{ - return out << "(" << task.filePathId << ", " << task.projectPartId << ")"; -} - -const char* progressTypeToString(ClangBackEnd::ProgressType type) -{ - switch (type) { - case ProgressType::Invalid: - return "Invalid"; - case ProgressType::PrecompiledHeader: - return "PrecompiledHeader"; - case ProgressType::Indexing: - return "Indexing"; - case ProgressType::DependencyCreation: - return "Indexing"; - } - - return nullptr; -} - -std::ostream &operator<<(std::ostream &out, const ProgressMessage &message) -{ - return out << "(" << progressTypeToString(message.progressType) << ", " - << message.progress << ", " - << message.total << ")"; -} - -std::ostream &operator<<(std::ostream &out, const PchTask &task) -{ - return out << "(" << task.projectPartIds << ", " << task.includes << ", " << task.compilerMacros - << toText(task.language) << ", " << task.systemIncludeSearchPaths << ", " - << task.projectIncludeSearchPaths << ", " << task.toolChainArguments << ", " - << toText(task.languageVersion) << ", " << toText(task.languageExtension) << ")"; -} - -std::ostream &operator<<(std::ostream &out, const PchTaskSet &taskSet) -{ - return out << "(" << taskSet.system << ", " << taskSet.project << ")"; -} - -std::ostream &operator<<(std::ostream &out, const BuildDependency &dependency) -{ - return out << "(\n" - << "includes: " << dependency.sources << ",\n" - << "usedMacros: " << dependency.usedMacros << ",\n" - << "fileStatuses: " << dependency.fileStatuses << ",\n" - << "sourceFiles: " << dependency.sourceFiles << ",\n" - << "sourceDependencies: " << dependency.sourceDependencies << ",\n" - << ")"; -} - -std::ostream &operator<<(std::ostream &out, const SlotUsage &slotUsage) -{ - return out << "(" << slotUsage.free << ", " << slotUsage.used << ")"; -} - -const char *typeToString(SourceType sourceType) -{ - using ClangBackEnd::SymbolTag; - - switch (sourceType) { - case SourceType::TopProjectInclude: - return "TopProjectInclude"; - case SourceType::TopSystemInclude: - return "TopSystemInclude"; - case SourceType::SystemInclude: - return "SystemInclude"; - case SourceType::ProjectInclude: - return "ProjectInclude"; - case SourceType::UserInclude: - return "UserInclude"; - case SourceType::Source: - return "Source"; - } - - return ""; -} - -const char *typeToString(HasMissingIncludes hasMissingIncludes) -{ - using ClangBackEnd::SymbolTag; - - switch (hasMissingIncludes) { - case HasMissingIncludes::No: - return "HasMissingIncludes::No"; - case HasMissingIncludes::Yes: - return "HasMissingIncludes::Yes"; - } - - return ""; -} - -std::ostream &operator<<(std::ostream &out, const SourceEntry &entry) -{ - return out << "(" << entry.sourceId << ", " << typeToString(entry.sourceType) << ", " - << typeToString(entry.hasMissingIncludes) << ")"; -} - -std::ostream &operator<<(std::ostream &out, const SourceTimeStamp &sourceTimeStamp) -{ - return out << "(" << sourceTimeStamp.sourceId << ", " << sourceTimeStamp.timeStamp << ")"; -} - -std::ostream &operator<<(std::ostream &out, const TimeStamp &timeStamp) -{ - return out << timeStamp.value; -} - -const char *typeToString(IncludeSearchPathType type) -{ - switch (type) { - case IncludeSearchPathType::Invalid: - return "Invalid"; - case IncludeSearchPathType::User: - return "User"; - case IncludeSearchPathType::System: - return "System"; - case IncludeSearchPathType::BuiltIn: - return "BuiltIn"; - case IncludeSearchPathType::Framework: - return "Framework"; - } - - return nullptr; -} - -std::ostream &operator<<(std::ostream &out, const IncludeSearchPathType &pathType) -{ - return out << "IncludeSearchPathType::" << typeToString(pathType); -} - -std::ostream &operator<<(std::ostream &out, const IncludeSearchPath &path) -{ - return out << "(" << path.path << ", " << path.index << ", " << typeToString(path.type) << ")"; -} - -std::ostream &operator<<(std::ostream &out, const ArgumentsEntry &entry) -{ - return out << "(" << entry.ids << ", " << entry.arguments << ")"; -} - -std::ostream &operator<<(std::ostream &out, const ProjectPartContainer &container) -{ - out << "(" << container.projectPartId << ", " << container.toolChainArguments << ", " - << container.headerPathIds << ", " << container.sourcePathIds << ", " - << container.compilerMacros << ", " << container.systemIncludeSearchPaths << ", " - << container.projectIncludeSearchPaths << ", " << toText(container.language) << ", " - << toText(container.languageVersion) << ", " << toText(container.languageExtension) << ")"; - - return out; -} - -std::ostream &operator<<(std::ostream &out, const ProjectPartId &projectPathId) -{ - return out << projectPathId.projectPathId; -} - -std::ostream &operator<<(std::ostream &out, const PchPaths &pchPaths) -{ - return out << "(" << pchPaths.projectPchPath << ", " << pchPaths.systemPchPath << ")"; -} - -std::ostream &operator<<(std::ostream &out, const ProjectChunkId &chunk) -{ - return out << "(" << chunk.id << ", " << typeToString(chunk.sourceType) << ")"; -} - -std::ostream &operator<<(std::ostream &out, const DirectoryPathId &id) -{ - return out << id.directoryPathId; -} - -void PrintTo(const FilePath &filePath, ::std::ostream *os) -{ - *os << filePath; -} - -void PrintTo(const FilePathView &filePathView, ::std::ostream *os) -{ - *os << filePathView; -} - -void PrintTo(const FilePathId &filePathId, ::std::ostream *os) -{ - *os << filePathId; -} - -namespace V2 { - -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; -} - -std::ostream &operator<<(std::ostream &os, const SourceLocationContainer &container) -{ - os << "(" - << container.filePathId.filePathId << ", " - << container.line << ", " - << container.column << ", " - << container.offset - << ")"; - - return os; -} - -std::ostream &operator<<(std::ostream &os, const SourceRangeContainer &container) -{ - os << "(" - << container.start << ", " - << container.end - << ")"; - - return os; -} - -} // namespace V2 - } // namespace ClangBackEnd -namespace ClangRefactoring { -std::ostream &operator<<(std::ostream &out, const SourceLocation &location) -{ - return out << "(" << location.filePathId << ", " << location.lineColumn << ")"; -} - -std::ostream &operator<<(std::ostream &out, const Symbol &symbol) -{ - return out << "(" << symbol.name << ", " << symbol.symbolId << ", " << symbol.signature << ")"; -} -} // namespace ClangRefactoring - - -namespace CppTools { -class Usage; - -std::ostream &operator<<(std::ostream &out, const Usage &usage) -{ - return out << "(" << usage.path << ", " << usage.line << ", " << usage.column <<")"; -} -} // namespace CppTools - namespace Debugger { std::ostream &operator<<(std::ostream &out, const DiagnosticLocation &loc) { @@ -1759,8 +1120,3 @@ std::ostream &operator<<(std::ostream &out, const ImageCacheStorageIconEntry &en } // namespace Internal } // namespace QmlDesigner - -void setFilePathCache(ClangBackEnd::FilePathCaching *cache) -{ - filePathCache = cache; -} diff --git a/tests/unit/unittest/gtest-creator-printing.h b/tests/unit/unittest/gtest-creator-printing.h index d55471393cb..b35d1f4f1e3 100644 --- a/tests/unit/unittest/gtest-creator-printing.h +++ b/tests/unit/unittest/gtest-creator-printing.h @@ -40,30 +40,6 @@ class Utf8String; void PrintTo(const Utf8String &text, ::std::ostream *os); -namespace clang { -namespace tooling { -struct CompileCommand; - -std::ostream &operator<<(std::ostream &out, const CompileCommand &command); -} // namespace tooling -} // namespace clang - -namespace Core { -struct LocatorFilterEntry; - -std::ostream &operator<<(std::ostream &out, const LocatorFilterEntry &entry); - -namespace Search { - -class TextPosition; -class TextRange; - -void PrintTo(const TextPosition &position, ::std::ostream *os); -void PrintTo(const TextRange &range, ::std::ostream *os); - -} // namespace TextPosition -} // namespace TextPosition - namespace Sqlite { class Value; class ValueView; @@ -95,30 +71,16 @@ std::ostream &operator<<(std::ostream &out, const ValueViews &valueViews); } // namespace SessionChangeSetInternal } // namespace Sqlite -namespace ProjectExplorer { - -enum class MacroType; -class Macro; -enum class HeaderPathType; -class HeaderPath; - -std::ostream &operator<<(std::ostream &out, const MacroType &type); -std::ostream &operator<<(std::ostream &out, const Macro ¯o); -std::ostream &operator<<(std::ostream &out, const HeaderPathType &headerPathType); -std::ostream &operator<<(std::ostream &out, const HeaderPath &headerPath); - -} // namespace ClangRefactoring - namespace Utils { class LineColumn; class SmallStringView; -class Link; +class FilePath; std::ostream &operator<<(std::ostream &out, const LineColumn &lineColumn); std::ostream &operator<<(std::ostream &out, const Utils::Language &language); std::ostream &operator<<(std::ostream &out, const Utils::LanguageVersion &languageVersion); std::ostream &operator<<(std::ostream &out, const Utils::LanguageExtension &languageExtension); -std::ostream &operator<<(std::ostream &out, const Link &link); +std::ostream &operator<<(std::ostream &out, const FilePath &filePath); template std::ostream &operator<<(std::ostream &out, const Utils::optional &optional) @@ -142,12 +104,6 @@ void PrintTo(const Utils::PathString &text, ::std::ostream *os); } // namespace Utils namespace ClangBackEnd { -class SourceLocationEntry; -class IdPaths; -class FilePathId; -class FilePath; -class WatcherEntry; -class SourceLocationsContainer; class CancelMessage; class AliveMessage; class CompletionsMessage; @@ -164,80 +120,29 @@ class DocumentsClosedMessage; class CodeCompletion; class CodeCompletionChunk; class DiagnosticContainer; -class DynamicASTMatcherDiagnosticContainer; -class DynamicASTMatcherDiagnosticContextContainer; -class DynamicASTMatcherDiagnosticMessageContainer; class FileContainer; class FixItContainer; class FullTokenInfo; class HighlightingMarkContainer; -class NativeFilePath; -class PrecompiledHeadersUpdatedMessage; -class ProjectPartPch; class UnsavedFilesUpdatedMessage; -class RemoveProjectPartsMessage; class RequestAnnotationsMessage; class RequestFollowSymbolMessage; class RequestReferencesMessage; class RequestToolTipMessage; -class RequestSourceRangesAndDiagnosticsForQueryMessage; -class RequestSourceRangesForQueryMessage; class SourceLocationContainer; class SourceRangeContainer; -class SourceRangesAndDiagnosticsForQueryMessage; -class SourceRangesContainer; -class SourceRangesForQueryMessage; -class SourceRangeWithTextContainer; class TokenInfo; template class TokenProcessor; -class UnsavedFilesRemovedMessage; -class UpdateProjectPartsMessage; class DocumentsChangedMessage; class DocumentVisibilityChangedMessage; -class FilePath; -template -class AbstractFilePathView; -using FilePathView = AbstractFilePathView<'/'>; -using NativeFilePathView = AbstractFilePathView<'\\'>; class ToolTipInfo; -class ProjectPartEntry; -class UsedMacro; -class FileStatus; -class SourceDependency; -class ProjectPartArtefact; -class CompilerMacro; -class SymbolEntry; -enum class SymbolKind : uchar; -enum class SymbolTag : uchar; -using SymbolTags = Utils::SizedArray; -class UpdateGeneratedFilesMessage; -class RemoveGeneratedFilesMessage; class SuspendResumeJobsEntry; class ReferencesResult; -class SymbolIndexerTask; -class ProgressMessage; -class PchTask; -class PchTaskSet; -class BuildDependency; -class SourceEntry; -class SourceTimeStamp; -class TimeStamp; -class FilePathCaching; -struct SlotUsage; -class IncludeSearchPath; -enum class IncludeSearchPathType : unsigned char; -struct ArgumentsEntry; -class ProjectPartContainer; -class ProjectPartId; -class PchPaths; -class ProjectChunkId; -class DirectoryPathId; +struct ExtraInfo; +class TokenInfoContainer; +class UnsavedFilesRemovedMessage; -std::ostream &operator<<(std::ostream &out, const SourceLocationEntry &entry); -std::ostream &operator<<(std::ostream &out, const IdPaths &idPaths); -std::ostream &operator<<(std::ostream &out, const WatcherEntry &entry); -std::ostream &operator<<(std::ostream &out, const SourceLocationsContainer &container); std::ostream &operator<<(std::ostream &out, const CancelMessage &message); std::ostream &operator<<(std::ostream &out, const AliveMessage &message); std::ostream &operator<<(std::ostream &out, const CompletionsMessage &message); @@ -254,111 +159,39 @@ std::ostream &operator<<(std::ostream &out, const DocumentsClosedMessage &messag std::ostream &operator<<(std::ostream &out, const CodeCompletion &message); std::ostream &operator<<(std::ostream &out, const CodeCompletionChunk &chunk); std::ostream &operator<<(std::ostream &out, const DiagnosticContainer &container); -std::ostream &operator<<(std::ostream &out, const DynamicASTMatcherDiagnosticContainer &container); -std::ostream &operator<<(std::ostream &out, const DynamicASTMatcherDiagnosticContextContainer &container); -std::ostream &operator<<(std::ostream &out, const DynamicASTMatcherDiagnosticMessageContainer &container); std::ostream &operator<<(std::ostream &out, const FileContainer &container); std::ostream &operator<<(std::ostream &out, const FixItContainer &container); std::ostream &operator<<(std::ostream &out, HighlightingType highlightingType); std::ostream &operator<<(std::ostream &out, HighlightingTypes types); std::ostream &operator<<(std::ostream &out, const HighlightingMarkContainer &container); -std::ostream &operator<<(std::ostream &out, const NativeFilePath &filePath); -std::ostream &operator<<(std::ostream &out, const PrecompiledHeadersUpdatedMessage &message); -std::ostream &operator<<(std::ostream &out, const ProjectPartPch &projectPartPch); std::ostream &operator<<(std::ostream &out, const UnsavedFilesUpdatedMessage &message); -std::ostream &operator<<(std::ostream &out, const RemoveProjectPartsMessage &message); std::ostream &operator<<(std::ostream &out, const RequestAnnotationsMessage &message); std::ostream &operator<<(std::ostream &out, const RequestFollowSymbolMessage &message); std::ostream &operator<<(std::ostream &out, const RequestReferencesMessage &message); std::ostream &operator<<(std::ostream &out, const RequestToolTipMessage &message); std::ostream &operator<<(std::ostream &out, const ToolTipInfo &info); -std::ostream &operator<<(std::ostream &out, - const RequestSourceRangesAndDiagnosticsForQueryMessage &message); -std::ostream &operator<<(std::ostream &out, const RequestSourceRangesForQueryMessage &message); std::ostream &operator<<(std::ostream &out, const SourceLocationContainer &container); std::ostream &operator<<(std::ostream &out, const SourceRangeContainer &container); -std::ostream &operator<<(std::ostream &out, const SourceRangesAndDiagnosticsForQueryMessage &message); -std::ostream &operator<<(std::ostream &out, const SourceRangesContainer &container); -std::ostream &operator<<(std::ostream &out, const SourceRangesForQueryMessage &message); -std::ostream &operator<<(std::ostream &out, const SourceRangeWithTextContainer &container); -std::ostream &operator<<(std::ostream &out, const UnsavedFilesRemovedMessage &message); -std::ostream &operator<<(std::ostream &out, const UpdateProjectPartsMessage &message); std::ostream &operator<<(std::ostream &out, const DocumentsChangedMessage &message); std::ostream &operator<<(std::ostream &out, const DocumentVisibilityChangedMessage &message); -std::ostream &operator<<(std::ostream &out, const FilePath &filePath); -std::ostream &operator<<(std::ostream &out, const FilePathId &filePathId); std::ostream &operator<<(std::ostream &out, const TokenInfo& tokenInfo); template std::ostream &operator<<(std::ostream &out, const TokenProcessor &tokenInfos); extern template std::ostream &operator<<(std::ostream &out, const TokenProcessor &tokenInfos); -extern template -std::ostream &operator<<(std::ostream &out, const TokenProcessor &tokenInfos); -std::ostream &operator<<(std::ostream &out, const FilePathView &filePathView); -std::ostream &operator<<(std::ostream &out, const NativeFilePathView &nativeFilePathView); -std::ostream &operator<<(std::ostream &out, const ProjectPartEntry &projectPartEntry); -std::ostream &operator<<(std::ostream &out, const UsedMacro &usedMacro); -std::ostream &operator<<(std::ostream &out, const FileStatus &fileStatus); -std::ostream &operator<<(std::ostream &out, const SourceDependency &sourceDependency); -std::ostream &operator<<(std::ostream &out, const ProjectPartArtefact &projectPartArtefact); -std::ostream &operator<<(std::ostream &out, const CompilerMacro &compilerMacro); -std::ostream &operator<<(std::ostream &out, const SymbolEntry &symbolEntry); +extern template std::ostream &operator<<(std::ostream &out, + const TokenProcessor &tokenInfos); std::ostream &operator<<(std::ostream &out, SymbolKind symbolKind); std::ostream &operator<<(std::ostream &out, SymbolTag symbolTag); std::ostream &operator<<(std::ostream &out, SymbolTags symbolTags); -std::ostream &operator<<(std::ostream &out, const UpdateGeneratedFilesMessage &message); -std::ostream &operator<<(std::ostream &out, const RemoveGeneratedFilesMessage &message); std::ostream &operator<<(std::ostream &os, const SuspendResumeJobsEntry &entry); std::ostream &operator<<(std::ostream &os, const ReferencesResult &value); -std::ostream &operator<<(std::ostream &out, const SymbolIndexerTask &task); -std::ostream &operator<<(std::ostream &out, const ProgressMessage &message); -std::ostream &operator<<(std::ostream &out, const PchTask &task); -std::ostream &operator<<(std::ostream &out, const PchTaskSet &taskSet); -std::ostream &operator<<(std::ostream &out, const BuildDependency &dependency); -std::ostream &operator<<(std::ostream &out, const SourceEntry &entry); -std::ostream &operator<<(std::ostream &out, const SourceTimeStamp &sourceTimeStamp); -std::ostream &operator<<(std::ostream &out, const TimeStamp &timeStamp); -std::ostream &operator<<(std::ostream &out, const SlotUsage &slotUsage); -std::ostream &operator<<(std::ostream &out, const IncludeSearchPathType &pathType); -std::ostream &operator<<(std::ostream &out, const IncludeSearchPath &path); -std::ostream &operator<<(std::ostream &out, const ArgumentsEntry &entry); -std::ostream &operator<<(std::ostream &out, const ProjectPartContainer &container); -std::ostream &operator<<(std::ostream &out, const ProjectPartId &projectPathId); -std::ostream &operator<<(std::ostream &out, const PchPaths &pchPaths); -std::ostream &operator<<(std::ostream &out, const ProjectChunkId &chunk); -std::ostream &operator<<(std::ostream &out, const DirectoryPathId &id); - -void PrintTo(const FilePath &filePath, ::std::ostream *os); -void PrintTo(const FilePathView &filePathView, ::std::ostream *os); -void PrintTo(const FilePathId &filePathId, ::std::ostream *os); - -namespace V2 { -class FileContainer; -class SourceRangeContainer; -class SourceLocationContainer; - -std::ostream &operator<<(std::ostream &out, const FileContainer &container); -std::ostream &operator<<(std::ostream &out, const SourceLocationContainer &container); -std::ostream &operator<<(std::ostream &out, const SourceRangeContainer &container); -} // namespace V2 +std::ostream &operator<<(std::ostream &os, const ExtraInfo &extraInfo); +std::ostream &operator<<(std::ostream &os, const TokenInfoContainer &container); +std::ostream &operator<<(std::ostream &os, const UnsavedFilesRemovedMessage &message); } // namespace ClangBackEnd -namespace ClangRefactoring { -class SourceLocation; -class Symbol; - -std::ostream &operator<<(std::ostream &out, const SourceLocation &location); -std::ostream &operator<<(std::ostream &out, const Symbol &symbol); -} // namespace ClangRefactoring - - -namespace CppTools { -class Usage; - -std::ostream &operator<<(std::ostream &out, const Usage &usage); -} // namespace CppTools - namespace Debugger { class DiagnosticLocation; std::ostream &operator<<(std::ostream &out, const DiagnosticLocation &loc); @@ -436,5 +269,3 @@ std::ostream &operator<<(std::ostream &out, const ImageCacheStorageIconEntry &en } // namespace Internal } // namespace QmlDesigner - -void setFilePathCache(ClangBackEnd::FilePathCaching *filePathCache); diff --git a/tests/unit/unittest/mockpchmanagerclient.h b/tests/unit/unittest/mockpchmanagerclient.h index 0955793de6b..9631f814070 100644 --- a/tests/unit/unittest/mockpchmanagerclient.h +++ b/tests/unit/unittest/mockpchmanagerclient.h @@ -28,6 +28,7 @@ #include "googletest.h" #include +#include class MockPchManagerClient : public ClangBackEnd::PchManagerClientInterface { diff --git a/tests/unit/unittest/sourcerangeextractor-test.cpp b/tests/unit/unittest/sourcerangeextractor-test.cpp index 552cde08acd..e9266542b9e 100644 --- a/tests/unit/unittest/sourcerangeextractor-test.cpp +++ b/tests/unit/unittest/sourcerangeextractor-test.cpp @@ -52,10 +52,6 @@ namespace { class SourceRangeExtractor : public ::testing::Test { -protected: - void SetUp() override; - void TearDown() override; - protected: TestClangTool clangTool{{TESTDATA_DIR "/sourcerangeextractor_location.cpp"}, "", {"cc"}}; ClangBackEnd::SourceRangesContainer sourceRangesContainer; @@ -178,15 +174,5 @@ TEST_F(SourceRangeExtractorSlowTest, EpandText) ASSERT_THAT(expandedText, Eq("second line\nthird line")); } - -void SourceRangeExtractor::SetUp() -{ - TestGlobal::setSourceManager(&sourceManager); -} - -void SourceRangeExtractor::TearDown() -{ - TestGlobal::setSourceManager(nullptr); -} } diff --git a/tests/unit/unittest/symbolscollector-test.cpp b/tests/unit/unittest/symbolscollector-test.cpp index 84fc26ca89b..01f2895d1b7 100644 --- a/tests/unit/unittest/symbolscollector-test.cpp +++ b/tests/unit/unittest/symbolscollector-test.cpp @@ -131,9 +131,6 @@ MATCHER_P(HasSymbolTag, symbolTag, class SymbolsCollector : public testing::Test { protected: - SymbolsCollector() { setFilePathCache(&filePathCache); } - ~SymbolsCollector() { setFilePathCache({}); } - FilePathId filePathId(Utils::SmallStringView filePath) const { return filePathCache.filePathId(ClangBackEnd::FilePathView{filePath});