Clang: Fix build

This amends commit cf4dbb4bb6.

Change-Id: Ib74fba38348a02f6bb9d254b7a5e9013a2013942
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Orgad Shaneh
2018-04-08 01:20:42 +03:00
committed by Orgad Shaneh
parent 1c82a53e74
commit 5e483d04bc
14 changed files with 163 additions and 166 deletions

View File

@@ -146,7 +146,7 @@ Utils::PathStringVector generatedFilePaths(const V2::FileContainers &generaredFi
generaredFilePaths.reserve(generaredFiles.size()); generaredFilePaths.reserve(generaredFiles.size());
for (const V2::FileContainer &generatedFile : generaredFiles) for (const V2::FileContainer &generatedFile : generaredFiles)
generaredFilePaths.push_back(generatedFile.filePath().path()); generaredFilePaths.push_back(generatedFile.filePath.path());
return generaredFilePaths; return generaredFilePaths;
} }
@@ -156,7 +156,7 @@ Utils::PathStringVector generatedFilePaths(const V2::FileContainers &generaredFi
Utils::PathStringVector PchCreator::generateGlobalHeaderPaths() const Utils::PathStringVector PchCreator::generateGlobalHeaderPaths() const
{ {
auto includeFunction = [&] (const V2::ProjectPartContainer &projectPart) { auto includeFunction = [&] (const V2::ProjectPartContainer &projectPart) {
return m_filePathCache.filePaths(projectPart.headerPathIds()); return m_filePathCache.filePaths(projectPart.headerPathIds);
}; };
Utils::PathStringVector headerPaths = generateGlobal<Utils::PathStringVector>(m_projectParts, Utils::PathStringVector headerPaths = generateGlobal<Utils::PathStringVector>(m_projectParts,
@@ -175,7 +175,7 @@ Utils::PathStringVector PchCreator::generateGlobalHeaderPaths() const
Utils::PathStringVector PchCreator::generateGlobalSourcePaths() const Utils::PathStringVector PchCreator::generateGlobalSourcePaths() const
{ {
auto sourceFunction = [&] (const V2::ProjectPartContainer &projectPart) { auto sourceFunction = [&] (const V2::ProjectPartContainer &projectPart) {
return m_filePathCache.filePaths(projectPart.sourcePathIds()); return m_filePathCache.filePaths(projectPart.sourcePathIds);
}; };
return generateGlobal<Utils::PathStringVector>(m_projectParts, sourceFunction); return generateGlobal<Utils::PathStringVector>(m_projectParts, sourceFunction);
@@ -197,7 +197,7 @@ Utils::SmallStringVector PchCreator::generateGlobalArguments() const
auto argumentFunction = [] (const V2::ProjectPartContainer &projectPart) auto argumentFunction = [] (const V2::ProjectPartContainer &projectPart)
-> const Utils::SmallStringVector & { -> const Utils::SmallStringVector & {
return projectPart.arguments(); return projectPart.arguments;
}; };
generateGlobal(arguments, m_projectParts, argumentFunction); generateGlobal(arguments, m_projectParts, argumentFunction);
@@ -212,7 +212,7 @@ Utils::SmallStringVector PchCreator::generateGlobalCommandLine() const
auto argumentFunction = [] (const V2::ProjectPartContainer &projectPart) auto argumentFunction = [] (const V2::ProjectPartContainer &projectPart)
-> const Utils::SmallStringVector & { -> const Utils::SmallStringVector & {
return projectPart.arguments(); return projectPart.arguments;
}; };
generateGlobal(commandLine, m_projectParts, argumentFunction); generateGlobal(commandLine, m_projectParts, argumentFunction);
@@ -324,10 +324,10 @@ namespace {
void hashProjectPart(QCryptographicHash &hash, const V2::ProjectPartContainer &projectPart) void hashProjectPart(QCryptographicHash &hash, const V2::ProjectPartContainer &projectPart)
{ {
const auto &projectPartId = projectPart.projectPartId(); const auto &projectPartId = projectPart.projectPartId;
hash.addData(projectPartId.data(), projectPartId.size()); hash.addData(projectPartId.data(), projectPartId.size());
for (const auto &argument : projectPart.arguments()) for (const auto &argument : projectPart.arguments)
hash.addData(argument.data(), argument.size()); hash.addData(argument.data(), argument.size());
} }
} }
@@ -374,7 +374,7 @@ Utils::SmallString PchCreator::generateGlobalPchFilePath() const
Utils::SmallStringVector PchCreator::generateProjectPartCommandLine( Utils::SmallStringVector PchCreator::generateProjectPartCommandLine(
const V2::ProjectPartContainer &projectPart) const const V2::ProjectPartContainer &projectPart) const
{ {
const Utils::SmallStringVector &arguments = projectPart.arguments(); const Utils::SmallStringVector &arguments = projectPart.arguments;
Utils::SmallStringVector commandLine; Utils::SmallStringVector commandLine;
commandLine.reserve(arguments.size() + 1); commandLine.reserve(arguments.size() + 1);
@@ -400,10 +400,10 @@ Utils::PathStringVector PchCreator::generateProjectPartHeaders(
const V2::ProjectPartContainer &projectPart) const const V2::ProjectPartContainer &projectPart) const
{ {
Utils::PathStringVector headerPaths; Utils::PathStringVector headerPaths;
headerPaths.reserve(projectPart.headerPathIds().size() + m_generatedFiles.size()); headerPaths.reserve(projectPart.headerPathIds.size() + m_generatedFiles.size());
std::transform(projectPart.headerPathIds().begin(), std::transform(projectPart.headerPathIds.begin(),
projectPart.headerPathIds().end(), projectPart.headerPathIds.end(),
std::back_inserter(headerPaths), std::back_inserter(headerPaths),
[&] (FilePathId filePathId) { [&] (FilePathId filePathId) {
return m_filePathCache.filePath(filePathId); return m_filePathCache.filePath(filePathId);
@@ -459,10 +459,10 @@ Utils::PathStringVector PchCreator::generateProjectPartHeaderAndSourcePaths(
const V2::ProjectPartContainer &projectPart) const const V2::ProjectPartContainer &projectPart) const
{ {
Utils::PathStringVector includeAndSources; Utils::PathStringVector includeAndSources;
includeAndSources.reserve(projectPart.headerPathIds().size() + projectPart.sourcePathIds().size()); includeAndSources.reserve(projectPart.headerPathIds.size() + projectPart.sourcePathIds.size());
appendFilePathId(includeAndSources, projectPart.headerPathIds(), m_filePathCache); appendFilePathId(includeAndSources, projectPart.headerPathIds, m_filePathCache);
appendFilePathId(includeAndSources, projectPart.sourcePathIds(), m_filePathCache); appendFilePathId(includeAndSources, projectPart.sourcePathIds, m_filePathCache);
return includeAndSources; return includeAndSources;
} }
@@ -536,7 +536,7 @@ Utils::SmallStringVector PchCreator::generateProjectPartPchCompilerArguments(
Utils::SmallStringVector PchCreator::generateProjectPartClangCompilerArguments( Utils::SmallStringVector PchCreator::generateProjectPartClangCompilerArguments(
const V2::ProjectPartContainer &projectPart) const const V2::ProjectPartContainer &projectPart) const
{ {
Utils::SmallStringVector compilerArguments = projectPart.arguments().clone(); Utils::SmallStringVector compilerArguments = projectPart.arguments.clone();
const auto pchArguments = generateProjectPartPchCompilerArguments(projectPart); const auto pchArguments = generateProjectPartPchCompilerArguments(projectPart);
append(compilerArguments, pchArguments); append(compilerArguments, pchArguments);
@@ -556,9 +556,9 @@ IdPaths PchCreator::generateProjectPartPch(const V2::ProjectPartContainer &proje
generateFileWithContent(pchIncludeFilePath, content); generateFileWithContent(pchIncludeFilePath, content);
generatePch(generateProjectPartClangCompilerArguments(projectPart), generatePch(generateProjectPartClangCompilerArguments(projectPart),
{projectPart.projectPartId().clone(), std::move(pchFilePath), lastModified}); {projectPart.projectPartId.clone(), std::move(pchFilePath), lastModified});
return {projectPart.projectPartId().clone(), std::move(allExternalIncludes)}; return {projectPart.projectPartId.clone(), std::move(allExternalIncludes)};
} }
void PchCreator::generatePchs() void PchCreator::generatePchs()

View File

@@ -50,10 +50,10 @@ ClangQueryGatherer::createSourceRangesForSource(
{ {
ClangQuery clangQuery(*filePathCache, std::move(query)); ClangQuery clangQuery(*filePathCache, std::move(query));
clangQuery.addFile(std::string(source.filePath().directory()), clangQuery.addFile(std::string(source.filePath.directory()),
std::string(source.filePath().name()), std::string(source.filePath.name()),
std::string(source.takeUnsavedFileContent()), std::string(source.unsavedFileContent),
std::vector<std::string>(source.takeCommandLineArguments())); std::vector<std::string>(source.commandLineArguments));
clangQuery.addUnsavedFiles(unsaved); clangQuery.addUnsavedFiles(unsaved);

View File

@@ -102,8 +102,8 @@ void ClangTool::addUnsavedFiles(const V2::FileContainers &unsavedFiles)
m_unsavedFileContents.reserve(m_unsavedFileContents.size() + unsavedFiles.size()); m_unsavedFileContents.reserve(m_unsavedFileContents.size() + unsavedFiles.size());
auto convertToUnsavedFileContent = [] (const V2::FileContainer &unsavedFile) { auto convertToUnsavedFileContent = [] (const V2::FileContainer &unsavedFile) {
return UnsavedFileContent{toNativePath(unsavedFile.filePath().path().clone()), return UnsavedFileContent{toNativePath(unsavedFile.filePath.path().clone()),
unsavedFile.unsavedFileContent().clone()}; unsavedFile.unsavedFileContent.clone()};
}; };
std::transform(unsavedFiles.begin(), std::transform(unsavedFiles.begin(),

View File

@@ -58,18 +58,18 @@ void RefactoringServer::end()
void RefactoringServer::requestSourceLocationsForRenamingMessage(RequestSourceLocationsForRenamingMessage &&message) void RefactoringServer::requestSourceLocationsForRenamingMessage(RequestSourceLocationsForRenamingMessage &&message)
{ {
SymbolFinder symbolFinder(message.line(), message.column(), m_filePathCache); SymbolFinder symbolFinder(message.line, message.column, m_filePathCache);
symbolFinder.addFile(std::string(message.filePath().directory()), symbolFinder.addFile(std::string(message.filePath.directory()),
std::string(message.filePath().name()), std::string(message.filePath.name()),
std::string(message.unsavedContent()), std::string(message.unsavedContent),
std::vector<std::string>(message.commandLine())); std::vector<std::string>(message.commandLine));
symbolFinder.findSymbol(); symbolFinder.findSymbol();
client()->sourceLocationsForRenamingMessage({symbolFinder.takeSymbolName(), client()->sourceLocationsForRenamingMessage({symbolFinder.takeSymbolName(),
symbolFinder.takeSourceLocations(), symbolFinder.takeSourceLocations(),
message.textDocumentRevision()}); message.textDocumentRevision});
} }
void RefactoringServer::requestSourceRangesAndDiagnosticsForQueryMessage( void RefactoringServer::requestSourceRangesAndDiagnosticsForQueryMessage(
@@ -77,10 +77,10 @@ void RefactoringServer::requestSourceRangesAndDiagnosticsForQueryMessage(
{ {
ClangQuery clangQuery(m_filePathCache, message.takeQuery()); ClangQuery clangQuery(m_filePathCache, message.takeQuery());
clangQuery.addFile(std::string(message.source().filePath().directory()), clangQuery.addFile(std::string(message.source.filePath.directory()),
std::string(message.source().filePath().name()), std::string(message.source.filePath.name()),
std::string(message.source().unsavedFileContent()), std::string(message.source.unsavedFileContent),
std::vector<std::string>(message.source().commandLineArguments())); std::vector<std::string>(message.source.commandLineArguments));
clangQuery.findLocations(); clangQuery.findLocations();

View File

@@ -179,7 +179,7 @@ void SourceRangeExtractor::addSourceRanges(const std::vector<clang::SourceRange>
const std::vector<SourceRangeWithTextContainer> &SourceRangeExtractor::sourceRangeWithTextContainers() const const std::vector<SourceRangeWithTextContainer> &SourceRangeExtractor::sourceRangeWithTextContainers() const
{ {
return sourceRangesContainer.sourceRangeWithTextContainers(); return sourceRangesContainer.sourceRangeWithTextContainers;
} }
} // namespace ClangBackEnd } // namespace ClangBackEnd

View File

@@ -69,7 +69,7 @@ TEST_F(ClangQuery, NoSourceRangesForDefaultConstruction)
{ {
auto sourceRanges = simpleFunctionQuery.takeSourceRanges(); auto sourceRanges = simpleFunctionQuery.takeSourceRanges();
ASSERT_THAT(sourceRanges.sourceRangeWithTextContainers(), IsEmpty()); ASSERT_THAT(sourceRanges.sourceRangeWithTextContainers, IsEmpty());
} }
TEST_F(ClangQuerySlowTest, SourceRangesForSimpleFunctionDeclarationAreNotEmpty) TEST_F(ClangQuerySlowTest, SourceRangesForSimpleFunctionDeclarationAreNotEmpty)
@@ -78,7 +78,7 @@ TEST_F(ClangQuerySlowTest, SourceRangesForSimpleFunctionDeclarationAreNotEmpty)
simpleFunctionQuery.findLocations(); simpleFunctionQuery.findLocations();
ASSERT_THAT(simpleFunctionQuery.takeSourceRanges().sourceRangeWithTextContainers(), Not(IsEmpty())); ASSERT_THAT(simpleFunctionQuery.takeSourceRanges().sourceRangeWithTextContainers, Not(IsEmpty()));
} }
TEST_F(ClangQuerySlowTest, RootSourceRangeForSimpleFunctionDeclarationRange) TEST_F(ClangQuerySlowTest, RootSourceRangeForSimpleFunctionDeclarationRange)
@@ -87,7 +87,7 @@ TEST_F(ClangQuerySlowTest, RootSourceRangeForSimpleFunctionDeclarationRange)
simpleFunctionQuery.findLocations(); simpleFunctionQuery.findLocations();
ASSERT_THAT(simpleFunctionQuery.takeSourceRanges().sourceRangeWithTextContainers(), ASSERT_THAT(simpleFunctionQuery.takeSourceRanges().sourceRangeWithTextContainers,
Contains(IsSourceRangeWithText(1, 1, 8, 2, "int function(int* pointer, int value)\n{\n if (pointer == nullptr) {\n return value + 1;\n } else {\n return value - 1;\n }\n}"))); Contains(IsSourceRangeWithText(1, 1, 8, 2, "int function(int* pointer, int value)\n{\n if (pointer == nullptr) {\n return value + 1;\n } else {\n return value - 1;\n }\n}")));
} }
@@ -101,7 +101,7 @@ TEST_F(ClangQuerySlowTest, SourceRangeInUnsavedFileDeclarationRange)
query.findLocations(); query.findLocations();
ASSERT_THAT(query.takeSourceRanges().sourceRangeWithTextContainers(), ASSERT_THAT(query.takeSourceRanges().sourceRangeWithTextContainers,
Contains(IsSourceRangeWithText(1, 1, 1, 15, "void unsaved();"))); Contains(IsSourceRangeWithText(1, 1, 1, 15, "void unsaved();")));
} }
@@ -113,7 +113,7 @@ TEST_F(ClangQuerySlowTest, FileIsNotExistingButTheUnsavedDataIsParsed)
query.findLocations(); query.findLocations();
ASSERT_THAT(query.takeSourceRanges().sourceRangeWithTextContainers(), ASSERT_THAT(query.takeSourceRanges().sourceRangeWithTextContainers,
Contains(IsSourceRangeWithText(1, 1, 1, 12, "void f() {}"))); Contains(IsSourceRangeWithText(1, 1, 1, 12, "void f() {}")));
} }
@@ -127,7 +127,7 @@ TEST_F(ClangQuerySlowTest, DISABLED_SourceRangeInUnsavedFileDeclarationRangeOver
query.findLocations(); query.findLocations();
ASSERT_THAT(query.takeSourceRanges().sourceRangeWithTextContainers(), ASSERT_THAT(query.takeSourceRanges().sourceRangeWithTextContainers,
Contains(IsSourceRangeWithText(1, 1, 1, 15, "void unsaved();"))); Contains(IsSourceRangeWithText(1, 1, 1, 15, "void unsaved();")));
} }
@@ -137,7 +137,7 @@ TEST_F(ClangQuerySlowTest, RootSourceRangeForSimpleFieldDeclarationRange)
simpleClassQuery.findLocations(); simpleClassQuery.findLocations();
ASSERT_THAT(simpleClassQuery.takeSourceRanges().sourceRangeWithTextContainers().at(0), ASSERT_THAT(simpleClassQuery.takeSourceRanges().sourceRangeWithTextContainers.at(0),
IsSourceRangeWithText(4, 5, 4, 10, " int x;")); IsSourceRangeWithText(4, 5, 4, 10, " int x;"));
} }
@@ -145,7 +145,7 @@ TEST_F(ClangQuerySlowTest, NoSourceRangesForEmptyQuery)
{ {
simpleClassQuery.findLocations(); simpleClassQuery.findLocations();
ASSERT_THAT(simpleClassQuery.takeSourceRanges().sourceRangeWithTextContainers(), IsEmpty()); ASSERT_THAT(simpleClassQuery.takeSourceRanges().sourceRangeWithTextContainers, IsEmpty());
} }
TEST_F(ClangQuerySlowTest, NoSourceRangesForWrongQuery) TEST_F(ClangQuerySlowTest, NoSourceRangesForWrongQuery)
@@ -154,7 +154,7 @@ TEST_F(ClangQuerySlowTest, NoSourceRangesForWrongQuery)
simpleClassQuery.findLocations(); simpleClassQuery.findLocations();
ASSERT_THAT(simpleClassQuery.takeSourceRanges().sourceRangeWithTextContainers(), IsEmpty()); ASSERT_THAT(simpleClassQuery.takeSourceRanges().sourceRangeWithTextContainers, IsEmpty());
} }
TEST_F(ClangQuerySlowTest, NoDiagnosticsForDefaultConstruction) TEST_F(ClangQuerySlowTest, NoDiagnosticsForDefaultConstruction)

View File

@@ -48,13 +48,13 @@ using testing::Contains;
using testing::Each; using testing::Each;
using testing::ElementsAre; using testing::ElementsAre;
using testing::Eq; using testing::Eq;
using testing::Field;
using testing::Ge; using testing::Ge;
using testing::IsEmpty; using testing::IsEmpty;
using testing::Le; using testing::Le;
using testing::NiceMock; using testing::NiceMock;
using testing::Pair; using testing::Pair;
using testing::PrintToString; using testing::PrintToString;
using testing::Property;
using testing::SizeIs; using testing::SizeIs;
using testing::UnorderedElementsAre; using testing::UnorderedElementsAre;
using testing::_; using testing::_;
@@ -71,8 +71,8 @@ MATCHER_P2(Contains, line, column,
+ ")" + ")"
) )
{ {
return arg.line() == uint(line) return arg.line == uint(line)
&& arg.column() == uint(column); && arg.column == uint(column);
} }
class ClangQueryGatherer : public ::testing::Test class ClangQueryGatherer : public ::testing::Test
@@ -111,8 +111,8 @@ TEST_F(ClangQueryGatherer, CreateSourceRanges)
auto sourceRangesAndDiagnostics = gatherer.createSourceRangesForSource(&filePathCache, source.clone(), {unsaved}, query.clone()); auto sourceRangesAndDiagnostics = gatherer.createSourceRangesForSource(&filePathCache, source.clone(), {unsaved}, query.clone());
ASSERT_THAT(sourceRangesAndDiagnostics, ASSERT_THAT(sourceRangesAndDiagnostics,
Property(&SourceRangesForQueryMessage::sourceRanges, Field(&SourceRangesForQueryMessage::sourceRanges,
Property(&SourceRangesContainer::sourceRangeWithTextContainers, Field(&SourceRangesContainer::sourceRangeWithTextContainers,
Contains(IsSourceRangeWithText(2, 1, 2, 12, "void f() {}"))))); Contains(IsSourceRangeWithText(2, 1, 2, 12, "void f() {}")))));
} }
@@ -121,8 +121,8 @@ TEST_F(ClangQueryGatherer, CreateSourceRangessWithUnsavedContent)
auto sourceRangesAndDiagnostics = gatherer.createSourceRangesForSource(&filePathCache, source.clone(), {unsaved}, query.clone()); auto sourceRangesAndDiagnostics = gatherer.createSourceRangesForSource(&filePathCache, source.clone(), {unsaved}, query.clone());
ASSERT_THAT(sourceRangesAndDiagnostics, ASSERT_THAT(sourceRangesAndDiagnostics,
Property(&SourceRangesForQueryMessage::sourceRanges, Field(&SourceRangesForQueryMessage::sourceRanges,
Property(&SourceRangesContainer::sourceRangeWithTextContainers, Field(&SourceRangesContainer::sourceRangeWithTextContainers,
Contains(IsSourceRangeWithText(1, 1, 1, 9, "void f();"))))); Contains(IsSourceRangeWithText(1, 1, 1, 9, "void f();")))));
} }
@@ -143,8 +143,8 @@ TEST_F(ClangQueryGatherer, CreateSourceRangesForNextSource)
auto sourceRangesAndDiagnostics = gatherer.createNextSourceRanges(); auto sourceRangesAndDiagnostics = gatherer.createNextSourceRanges();
ASSERT_THAT(sourceRangesAndDiagnostics, ASSERT_THAT(sourceRangesAndDiagnostics,
Property(&SourceRangesForQueryMessage::sourceRanges, Field(&SourceRangesForQueryMessage::sourceRanges,
Property(&SourceRangesContainer::sourceRangeWithTextContainers, Field(&SourceRangesContainer::sourceRangeWithTextContainers,
Contains(IsSourceRangeWithText(1, 1, 1, 9, "void f();"))))); Contains(IsSourceRangeWithText(1, 1, 1, 9, "void f();")))));
} }
@@ -161,8 +161,8 @@ TEST_F(ClangQueryGatherer, StartCreateSourceRangesForNextSource)
future.wait(); future.wait();
ASSERT_THAT(future.get(), ASSERT_THAT(future.get(),
Property(&SourceRangesForQueryMessage::sourceRanges, Field(&SourceRangesForQueryMessage::sourceRanges,
Property(&SourceRangesContainer::sourceRangeWithTextContainers, Field(&SourceRangesContainer::sourceRangeWithTextContainers,
Contains(IsSourceRangeWithText(1, 1, 1, 9, "void f();"))))); Contains(IsSourceRangeWithText(1, 1, 1, 9, "void f();")))));
} }
@@ -195,12 +195,12 @@ TEST_F(ClangQueryGatherer, AfterStartCreateSourceRangesMessagesGetCollected)
ASSERT_THAT(manyGatherer.allCurrentProcessedMessages(), ASSERT_THAT(manyGatherer.allCurrentProcessedMessages(),
UnorderedElementsAre( UnorderedElementsAre(
Property(&SourceRangesForQueryMessage::sourceRanges, Field(&SourceRangesForQueryMessage::sourceRanges,
Property(&SourceRangesContainer::sourceRangeWithTextContainers, Field(&SourceRangesContainer::sourceRangeWithTextContainers,
UnorderedElementsAre(IsSourceRangeWithText(1, 1, 1, 9, "void f();"), UnorderedElementsAre(IsSourceRangeWithText(1, 1, 1, 9, "void f();"),
IsSourceRangeWithText(2, 1, 2, 12, "void f() {}")))), IsSourceRangeWithText(2, 1, 2, 12, "void f() {}")))),
Property(&SourceRangesForQueryMessage::sourceRanges, Field(&SourceRangesForQueryMessage::sourceRanges,
Property(&SourceRangesContainer::sourceRangeWithTextContainers, Field(&SourceRangesContainer::sourceRangeWithTextContainers,
UnorderedElementsAre( UnorderedElementsAre(
IsSourceRangeWithText(1, 1, 1, 13, "int header();"), IsSourceRangeWithText(1, 1, 1, 13, "int header();"),
IsSourceRangeWithText(3, 1, 3, 15, "int function();")))))); IsSourceRangeWithText(3, 1, 3, 15, "int function();"))))));
@@ -216,13 +216,13 @@ TEST_F(ClangQueryGatherer, GetFinishedMessages)
ASSERT_THAT(messages, ASSERT_THAT(messages,
AllOf(SizeIs(2), AllOf(SizeIs(2),
UnorderedElementsAre( UnorderedElementsAre(
Property(&SourceRangesForQueryMessage::sourceRanges, Field(&SourceRangesForQueryMessage::sourceRanges,
Property(&SourceRangesContainer::sourceRangeWithTextContainers, Field(&SourceRangesContainer::sourceRangeWithTextContainers,
UnorderedElementsAre( UnorderedElementsAre(
IsSourceRangeWithText(1, 1, 1, 9, "void f();"), IsSourceRangeWithText(1, 1, 1, 9, "void f();"),
IsSourceRangeWithText(2, 1, 2, 12, "void f() {}")))), IsSourceRangeWithText(2, 1, 2, 12, "void f() {}")))),
Property(&SourceRangesForQueryMessage::sourceRanges, Field(&SourceRangesForQueryMessage::sourceRanges,
Property(&SourceRangesContainer::sourceRangeWithTextContainers, Field(&SourceRangesContainer::sourceRangeWithTextContainers,
UnorderedElementsAre( UnorderedElementsAre(
IsSourceRangeWithText(1, 1, 1, 13, "int header();"), IsSourceRangeWithText(1, 1, 1, 13, "int header();"),
IsSourceRangeWithText(3, 1, 3, 15, "int function();"))))))); IsSourceRangeWithText(3, 1, 3, 15, "int function();")))))));
@@ -241,8 +241,8 @@ TEST_F(ClangQueryGatherer, GetFinishedMessagesAfterSecondPass)
ASSERT_THAT(messages, ASSERT_THAT(messages,
AllOf(SizeIs(1), AllOf(SizeIs(1),
ElementsAre( ElementsAre(
Property(&SourceRangesForQueryMessage::sourceRanges, Field(&SourceRangesForQueryMessage::sourceRanges,
Property(&SourceRangesContainer::sourceRangeWithTextContainers, Field(&SourceRangesContainer::sourceRangeWithTextContainers,
UnorderedElementsAre( UnorderedElementsAre(
IsSourceRangeWithText(3, 1, 3, 15, "int function();"))))))); IsSourceRangeWithText(3, 1, 3, 15, "int function();")))))));
} }
@@ -258,18 +258,18 @@ TEST_F(ClangQueryGatherer, FilterDuplicates)
ASSERT_THAT(messages, ASSERT_THAT(messages,
AllOf(SizeIs(3), AllOf(SizeIs(3),
UnorderedElementsAre( UnorderedElementsAre(
Property(&SourceRangesForQueryMessage::sourceRanges, Field(&SourceRangesForQueryMessage::sourceRanges,
Property(&SourceRangesContainer::sourceRangeWithTextContainers, Field(&SourceRangesContainer::sourceRangeWithTextContainers,
UnorderedElementsAre( UnorderedElementsAre(
IsSourceRangeWithText(1, 1, 1, 9, "void f();"), IsSourceRangeWithText(1, 1, 1, 9, "void f();"),
IsSourceRangeWithText(2, 1, 2, 12, "void f() {}")))), IsSourceRangeWithText(2, 1, 2, 12, "void f() {}")))),
Property(&SourceRangesForQueryMessage::sourceRanges, Field(&SourceRangesForQueryMessage::sourceRanges,
Property(&SourceRangesContainer::sourceRangeWithTextContainers, Field(&SourceRangesContainer::sourceRangeWithTextContainers,
UnorderedElementsAre( UnorderedElementsAre(
IsSourceRangeWithText(1, 1, 1, 13, "int header();"), IsSourceRangeWithText(1, 1, 1, 13, "int header();"),
IsSourceRangeWithText(3, 1, 3, 15, "int function();")))), IsSourceRangeWithText(3, 1, 3, 15, "int function();")))),
Property(&SourceRangesForQueryMessage::sourceRanges, Field(&SourceRangesForQueryMessage::sourceRanges,
Property(&SourceRangesContainer::sourceRangeWithTextContainers, Field(&SourceRangesContainer::sourceRangeWithTextContainers,
UnorderedElementsAre( UnorderedElementsAre(
IsSourceRangeWithText(3, 1, 3, 15, "int function();"))))))); IsSourceRangeWithText(3, 1, 3, 15, "int function();")))))));
} }

View File

@@ -41,9 +41,9 @@ namespace {
using testing::_; using testing::_;
using testing::AllOf; using testing::AllOf;
using testing::Field;
using testing::NiceMock; using testing::NiceMock;
using testing::NotNull; using testing::NotNull;
using testing::Property;
using testing::Return; using testing::Return;
using testing::ReturnNew; using testing::ReturnNew;
using testing::DefaultValue; using testing::DefaultValue;
@@ -166,9 +166,9 @@ TEST_F(ClangQueryProjectFindFilter, CallingRequestSourceRangesAndDiagnostics)
EXPECT_CALL(mockRefactoringServer, EXPECT_CALL(mockRefactoringServer,
requestSourceRangesAndDiagnosticsForQueryMessage( requestSourceRangesAndDiagnosticsForQueryMessage(
AllOf( AllOf(
Property(&Message::source, Field(&Message::source,
Property(&FileContainer::unsavedFileContent, exampleContent)), Field(&FileContainer::unsavedFileContent, exampleContent)),
Property(&Message::query, queryText)))); Field(&Message::query, queryText))));
findFilter.requestSourceRangesAndDiagnostics(QString(queryText), QString(exampleContent)); findFilter.requestSourceRangesAndDiagnostics(QString(queryText), QString(exampleContent));
} }

View File

@@ -41,19 +41,19 @@ MATCHER_P5(HasDiagnosticMessage, errorTypeText, startLine, startColumn, endLine,
+ ")}" + ")}"
) )
{ {
if (!arg.empty() && arg.front().messages().empty()) { if (!arg.empty() && arg.front().messages.empty()) {
*result_listener << "no messages"; *result_listener << "no messages";
return false; return false;
} }
auto message = arg.front().messages().front(); auto message = arg.front().messages.front();
auto sourceRange = message.sourceRange(); auto sourceRange = message.sourceRange;
return message.errorTypeText() == errorTypeText return message.errorTypeText() == errorTypeText
&& sourceRange.start().line() == uint(startLine) && sourceRange.start.line == uint(startLine)
&& sourceRange.start().column() == uint(startColumn) && sourceRange.start.column == uint(startColumn)
&& sourceRange.end().line() == uint(endLine) && sourceRange.end.line == uint(endLine)
&& sourceRange.end().column() == uint(endColumn); && sourceRange.end.column == uint(endColumn);
} }
MATCHER_P5(HasDiagnosticContext, contextTypeText, startLine, startColumn, endLine, endColumn, MATCHER_P5(HasDiagnosticContext, contextTypeText, startLine, startColumn, endLine, endColumn,
@@ -66,19 +66,19 @@ MATCHER_P5(HasDiagnosticContext, contextTypeText, startLine, startColumn, endLin
+ ")}" + ")}"
) )
{ {
if (!arg.empty() && arg.front().messages().empty()) { if (!arg.empty() && arg.front().messages.empty()) {
*result_listener << "no context"; *result_listener << "no context";
return false; return false;
} }
auto context = arg.front().contexts().front(); auto context = arg.front().contexts.front();
auto sourceRange = context.sourceRange(); auto sourceRange = context.sourceRange;
return context.contextTypeText() == contextTypeText return context.contextTypeText() == contextTypeText
&& sourceRange.start().line() == uint(startLine) && sourceRange.start.line == uint(startLine)
&& sourceRange.start().column() == uint(startColumn) && sourceRange.start.column == uint(startColumn)
&& sourceRange.end().line() == uint(endLine) && sourceRange.end.line == uint(endLine)
&& sourceRange.end().column() == uint(endColumn); && sourceRange.end.column == uint(endColumn);
} }
} }

View File

@@ -302,7 +302,7 @@ TEST_F(PchCreatorVerySlowTest, DISABLED_CreatePartPchs)
auto includePaths = creator.generateProjectPartPch(projectPart1); auto includePaths = creator.generateProjectPartPch(projectPart1);
ASSERT_THAT(includePaths.id, projectPart1.projectPartId()); ASSERT_THAT(includePaths.id, projectPart1.projectPartId);
ASSERT_THAT(includePaths.filePathIds, ASSERT_THAT(includePaths.filePathIds,
AllOf(Contains(FilePathId{1, 1}), AllOf(Contains(FilePathId{1, 1}),
Contains(FilePathId{1, 2}), Contains(FilePathId{1, 2}),

View File

@@ -96,9 +96,9 @@ TEST_F(RefactoringClient, SourceLocationsForRenaming)
{ {
client.setLocalRenamingCallback(mockLocalRenaming.AsStdFunction()); client.setLocalRenamingCallback(mockLocalRenaming.AsStdFunction());
EXPECT_CALL(mockLocalRenaming, Call(renameMessage.symbolName().toQString(), EXPECT_CALL(mockLocalRenaming, Call(renameMessage.symbolName.toQString(),
renameMessage.sourceLocations(), renameMessage.sourceLocations,
renameMessage.textDocumentRevision())); renameMessage.textDocumentRevision));
client.sourceLocationsForRenamingMessage(std::move(renameMessage)); client.sourceLocationsForRenamingMessage(std::move(renameMessage));
} }

View File

@@ -43,6 +43,7 @@ namespace {
using testing::AllOf; using testing::AllOf;
using testing::Contains; using testing::Contains;
using testing::Field;
using testing::IsEmpty; using testing::IsEmpty;
using testing::NiceMock; using testing::NiceMock;
using testing::Not; using testing::Not;
@@ -72,8 +73,8 @@ MATCHER_P2(IsSourceLocation, line, column,
+ ")" + ")"
) )
{ {
return arg.line() == uint(line) return arg.line == uint(line)
&& arg.column() == uint(column); && arg.column == uint(column);
} }
class RefactoringServer : public ::testing::Test class RefactoringServer : public ::testing::Test
@@ -116,9 +117,9 @@ TEST_F(RefactoringServerSlowTest, RequestSourceLocationsForRenamingMessage)
EXPECT_CALL(mockRefactoringClient, EXPECT_CALL(mockRefactoringClient,
sourceLocationsForRenamingMessage( sourceLocationsForRenamingMessage(
AllOf(Property(&SourceLocationsForRenamingMessage::textDocumentRevision, 1), AllOf(Field(&SourceLocationsForRenamingMessage::textDocumentRevision, 1),
Property(&SourceLocationsForRenamingMessage::symbolName, "v"), Field(&SourceLocationsForRenamingMessage::symbolName, "v"),
Property(&SourceLocationsForRenamingMessage::sourceLocations, Field(&SourceLocationsForRenamingMessage::sourceLocations,
Property(&SourceLocationsContainer::sourceLocationContainers, Property(&SourceLocationsContainer::sourceLocationContainers,
AllOf(Contains(IsSourceLocation(1, 5)), AllOf(Contains(IsSourceLocation(1, 5)),
Contains(IsSourceLocation(3, 9)))))))); Contains(IsSourceLocation(3, 9))))))));
@@ -134,8 +135,8 @@ TEST_F(RefactoringServerSlowTest, RequestSingleSourceRangesForQueryMessage)
EXPECT_CALL(mockRefactoringClient, EXPECT_CALL(mockRefactoringClient,
sourceRangesForQueryMessage( sourceRangesForQueryMessage(
Property(&SourceRangesForQueryMessage::sourceRanges, Field(&SourceRangesForQueryMessage::sourceRanges,
Property(&SourceRangesContainer::sourceRangeWithTextContainers, Field(&SourceRangesContainer::sourceRangeWithTextContainers,
Contains(IsSourceRangeWithText(1, 1, 2, 4, sourceContent)))))); Contains(IsSourceRangeWithText(1, 1, 2, 4, sourceContent))))));
refactoringServer.requestSourceRangesForQueryMessage(std::move(message)); refactoringServer.requestSourceRangesForQueryMessage(std::move(message));
@@ -156,8 +157,8 @@ TEST_F(RefactoringServerSlowTest, RequestSingleSourceRangesAndDiagnosticsWithUns
EXPECT_CALL(mockRefactoringClient, EXPECT_CALL(mockRefactoringClient,
sourceRangesForQueryMessage( sourceRangesForQueryMessage(
Property(&SourceRangesForQueryMessage::sourceRanges, Field(&SourceRangesForQueryMessage::sourceRanges,
Property(&SourceRangesContainer::sourceRangeWithTextContainers, Field(&SourceRangesContainer::sourceRangeWithTextContainers,
Contains(IsSourceRangeWithText(1, 1, 1, 9, unsavedContent)))))); Contains(IsSourceRangeWithText(1, 1, 1, 9, unsavedContent))))));
refactoringServer.requestSourceRangesForQueryMessage(std::move(message)); refactoringServer.requestSourceRangesForQueryMessage(std::move(message));
@@ -171,13 +172,13 @@ TEST_F(RefactoringServerSlowTest, RequestTwoSourceRangesForQueryMessage)
EXPECT_CALL(mockRefactoringClient, EXPECT_CALL(mockRefactoringClient,
sourceRangesForQueryMessage( sourceRangesForQueryMessage(
Property(&SourceRangesForQueryMessage::sourceRanges, Field(&SourceRangesForQueryMessage::sourceRanges,
Property(&SourceRangesContainer::sourceRangeWithTextContainers, Field(&SourceRangesContainer::sourceRangeWithTextContainers,
Contains(IsSourceRangeWithText(1, 1, 2, 4, sourceContent)))))); Contains(IsSourceRangeWithText(1, 1, 2, 4, sourceContent))))));
EXPECT_CALL(mockRefactoringClient, EXPECT_CALL(mockRefactoringClient,
sourceRangesForQueryMessage( sourceRangesForQueryMessage(
Property(&SourceRangesForQueryMessage::sourceRanges, Field(&SourceRangesForQueryMessage::sourceRanges,
Property(&SourceRangesContainer::sourceRangeWithTextContainers, Field(&SourceRangesContainer::sourceRangeWithTextContainers,
Not(Contains(IsSourceRangeWithText(1, 1, 2, 4, sourceContent))))))); Not(Contains(IsSourceRangeWithText(1, 1, 2, 4, sourceContent)))))));
refactoringServer.requestSourceRangesForQueryMessage(std::move(message)); refactoringServer.requestSourceRangesForQueryMessage(std::move(message));
@@ -195,13 +196,13 @@ TEST_F(RefactoringServerVerySlowTest, RequestManySourceRangesForQueryMessage)
EXPECT_CALL(mockRefactoringClient, EXPECT_CALL(mockRefactoringClient,
sourceRangesForQueryMessage( sourceRangesForQueryMessage(
Property(&SourceRangesForQueryMessage::sourceRanges, Field(&SourceRangesForQueryMessage::sourceRanges,
Property(&SourceRangesContainer::sourceRangeWithTextContainers, Field(&SourceRangesContainer::sourceRangeWithTextContainers,
Contains(IsSourceRangeWithText(1, 1, 2, 4, sourceContent)))))); Contains(IsSourceRangeWithText(1, 1, 2, 4, sourceContent))))));
EXPECT_CALL(mockRefactoringClient, EXPECT_CALL(mockRefactoringClient,
sourceRangesForQueryMessage( sourceRangesForQueryMessage(
Property(&SourceRangesForQueryMessage::sourceRanges, Field(&SourceRangesForQueryMessage::sourceRanges,
Property(&SourceRangesContainer::sourceRangeWithTextContainers, Field(&SourceRangesContainer::sourceRangeWithTextContainers,
Not(Contains(IsSourceRangeWithText(1, 1, 2, 4, sourceContent))))))) Not(Contains(IsSourceRangeWithText(1, 1, 2, 4, sourceContent)))))))
.Times(processingSlotCount + 2); .Times(processingSlotCount + 2);
@@ -269,10 +270,10 @@ TEST_F(RefactoringServerSlowTest, ForValidRequestSourceRangesAndDiagnosticsGetSo
EXPECT_CALL(mockRefactoringClient, EXPECT_CALL(mockRefactoringClient,
sourceRangesAndDiagnosticsForQueryMessage( sourceRangesAndDiagnosticsForQueryMessage(
AllOf( AllOf(
Property(&SourceRangesAndDiagnosticsForQueryMessage::sourceRanges, Field(&SourceRangesAndDiagnosticsForQueryMessage::sourceRanges,
Property(&SourceRangesContainer::sourceRangeWithTextContainers, Field(&SourceRangesContainer::sourceRangeWithTextContainers,
Contains(IsSourceRangeWithText(1, 1, 1, 12, "void f() {}")))), Contains(IsSourceRangeWithText(1, 1, 1, 12, "void f() {}")))),
Property(&SourceRangesAndDiagnosticsForQueryMessage::diagnostics, Field(&SourceRangesAndDiagnosticsForQueryMessage::diagnostics,
IsEmpty())))); IsEmpty()))));
refactoringServer.requestSourceRangesAndDiagnosticsForQueryMessage(std::move(message)); refactoringServer.requestSourceRangesAndDiagnosticsForQueryMessage(std::move(message));
@@ -288,10 +289,10 @@ TEST_F(RefactoringServerSlowTest, ForInvalidRequestSourceRangesAndDiagnosticsGet
EXPECT_CALL(mockRefactoringClient, EXPECT_CALL(mockRefactoringClient,
sourceRangesAndDiagnosticsForQueryMessage( sourceRangesAndDiagnosticsForQueryMessage(
AllOf( AllOf(
Property(&SourceRangesAndDiagnosticsForQueryMessage::sourceRanges, Field(&SourceRangesAndDiagnosticsForQueryMessage::sourceRanges,
Property(&SourceRangesContainer::sourceRangeWithTextContainers, Field(&SourceRangesContainer::sourceRangeWithTextContainers,
IsEmpty())), IsEmpty())),
Property(&SourceRangesAndDiagnosticsForQueryMessage::diagnostics, Field(&SourceRangesAndDiagnosticsForQueryMessage::diagnostics,
Not(IsEmpty()))))); Not(IsEmpty())))));
refactoringServer.requestSourceRangesAndDiagnosticsForQueryMessage(std::move(message)); refactoringServer.requestSourceRangesAndDiagnosticsForQueryMessage(std::move(message));

View File

@@ -40,10 +40,10 @@ MATCHER_P4(IsSourceRange, startLine, startColumn, endLine, endColumn,
+ ")]" + ")]"
) )
{ {
return arg.start().line() == uint(startLine) return arg.start.line == uint(startLine)
&& arg.start().column() == uint(startColumn) && arg.start.column == uint(startColumn)
&& arg.end().line() == uint(endLine) && arg.end.line == uint(endLine)
&& arg.end().column() == uint(endColumn); && arg.end.column == uint(endColumn);
} }
MATCHER_P5(IsSourceRangeWithText, startLine, startColumn, endLine, endColumn, text, MATCHER_P5(IsSourceRangeWithText, startLine, startColumn, endLine, endColumn, text,
@@ -56,11 +56,11 @@ MATCHER_P5(IsSourceRangeWithText, startLine, startColumn, endLine, endColumn, te
+ ")" + ")"
) )
{ {
return arg.start().line() == uint(startLine) return arg.start.line == uint(startLine)
&& arg.start().column() == uint(startColumn) && arg.start.column == uint(startColumn)
&& arg.end().line() == uint(endLine) && arg.end.line == uint(endLine)
&& arg.end().column() == uint(endColumn) && arg.end.column == uint(endColumn)
&& arg.text().toCarriageReturnsStripped() == text; && arg.text.toCarriageReturnsStripped() == text;
} }

View File

@@ -42,11 +42,7 @@ MATCHER_P2(IsSourceLocation, line, column,
+ ", column " + PrintToString(column) + ", column " + PrintToString(column)
) )
{ {
if (arg.line() != uint(line) return arg.line == uint(line) && arg.column == uint(column);
|| arg.column() != uint(column))
return false;
return true;
} }
MATCHER_P(StrEq, text, MATCHER_P(StrEq, text,