summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@qt.io>2018-09-03 14:38:01 +0200
committerMarco Bubke <marco.bubke@qt.io>2018-09-06 11:26:00 +0000
commit2a30f0e5d6f8d57f65ce21f2344049d050dc8d9e (patch)
treec74c252907a921696bdda24c5776877094274d73
parent461d5b5d152168f87f36a4d5d2aacce46bfa8500 (diff)
downloadqt-creator-2a30f0e5d6f8d57f65ce21f2344049d050dc8d9e.tar.gz
Clang: Improve generated files handling
Generated files are referenced by the system collector directly to set the unsaved files. Change-Id: I24be3ee544b7824b8b0e518eafd409f32bd002ab Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
-rw-r--r--src/libs/clangsupport/generatedfiles.cpp2
-rw-r--r--src/libs/utils/smallstringio.h4
-rw-r--r--src/tools/clangrefactoringbackend/clangrefactoringbackendmain.cpp7
-rw-r--r--src/tools/clangrefactoringbackend/source/clangrefactoringbackend-source.pri3
-rw-r--r--src/tools/clangrefactoringbackend/source/refactoringserver.cpp9
-rw-r--r--src/tools/clangrefactoringbackend/source/refactoringserver.h5
-rw-r--r--src/tools/clangrefactoringbackend/source/symbolindexer.cpp47
-rw-r--r--src/tools/clangrefactoringbackend/source/symbolindexer.h8
-rw-r--r--src/tools/clangrefactoringbackend/source/symbolindexing.cpp5
-rw-r--r--src/tools/clangrefactoringbackend/source/symbolindexing.h8
-rw-r--r--src/tools/clangrefactoringbackend/source/symbolindexinginterface.h3
-rw-r--r--src/tools/clangrefactoringbackend/source/symbolscollector.cpp4
-rw-r--r--src/tools/clangrefactoringbackend/source/symbolscollector.h4
-rw-r--r--src/tools/clangrefactoringbackend/source/symbolscollectorinterface.h4
-rw-r--r--src/tools/clangrefactoringbackend/source/symbolscollectormanager.cpp35
-rw-r--r--src/tools/clangrefactoringbackend/source/symbolscollectormanager.h16
-rw-r--r--src/tools/clangrefactoringbackend/source/symbolscollectormanagerinterface.h2
-rw-r--r--tests/unit/unittest/gtest-creator-printing.cpp6
-rw-r--r--tests/unit/unittest/mocksymbolindexertaskqueue.h2
-rw-r--r--tests/unit/unittest/mocksymbolindexing.h10
-rw-r--r--tests/unit/unittest/mocksymbolscollector.h11
-rw-r--r--tests/unit/unittest/refactoringserver-test.cpp20
-rw-r--r--tests/unit/unittest/symbolindexer-test.cpp80
-rw-r--r--tests/unit/unittest/symbolindexing-test.cpp9
-rw-r--r--tests/unit/unittest/symbolscollector-test.cpp106
-rw-r--r--tests/unit/unittest/symbolscollectormanager-test.cpp20
-rw-r--r--tests/unit/unittest/unittest.pro3
27 files changed, 232 insertions, 201 deletions
diff --git a/src/libs/clangsupport/generatedfiles.cpp b/src/libs/clangsupport/generatedfiles.cpp
index d5e36987b2..dfbcb145dd 100644
--- a/src/libs/clangsupport/generatedfiles.cpp
+++ b/src/libs/clangsupport/generatedfiles.cpp
@@ -81,7 +81,7 @@ public:
}
bool operator()(const FilePath &first, const V2::FileContainer &second)
{
- return second.filePath < first;
+ return first < second.filePath;
}
};
diff --git a/src/libs/utils/smallstringio.h b/src/libs/utils/smallstringio.h
index 5ef27b188d..10efd06627 100644
--- a/src/libs/utils/smallstringio.h
+++ b/src/libs/utils/smallstringio.h
@@ -82,12 +82,8 @@ std::ostream &operator<<(std::ostream &out, const BasicSmallString<Size> &string
formatedString.replace("\n", "\\n");
formatedString.replace("\t", "\\t");
- out << "\"";
-
out.write(formatedString.data(), std::streamsize(formatedString.size()));
- out << "\"";
-
return out;
}
diff --git a/src/tools/clangrefactoringbackend/clangrefactoringbackendmain.cpp b/src/tools/clangrefactoringbackend/clangrefactoringbackendmain.cpp
index 0bc703abf5..1fac050883 100644
--- a/src/tools/clangrefactoringbackend/clangrefactoringbackendmain.cpp
+++ b/src/tools/clangrefactoringbackend/clangrefactoringbackendmain.cpp
@@ -31,6 +31,7 @@
#include <connectionserver.h>
#include <filepathcaching.h>
+#include <generatedfiles.h>
#include <refactoringserver.h>
#include <refactoringclientproxy.h>
#include <symbolindexing.h>
@@ -42,6 +43,7 @@
using namespace std::chrono_literals;
using ClangBackEnd::FilePathCaching;
+using ClangBackEnd::GeneratedFiles;
using ClangBackEnd::RefactoringClientProxy;
using ClangBackEnd::RefactoringServer;
using ClangBackEnd::RefactoringDatabaseInitializer;
@@ -100,8 +102,9 @@ int main(int argc, char *argv[])
Sqlite::Database database{Utils::PathString{databasePath}, 100000ms};
RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database};
FilePathCaching filePathCache{database};
- SymbolIndexing symbolIndexing{database, filePathCache};
- RefactoringServer clangCodeModelServer{symbolIndexing, filePathCache};
+ GeneratedFiles generatedFiles;
+ SymbolIndexing symbolIndexing{database, filePathCache, generatedFiles};
+ RefactoringServer clangCodeModelServer{symbolIndexing, filePathCache, generatedFiles};
ConnectionServer<RefactoringServer, RefactoringClientProxy> connectionServer;
connectionServer.setServer(&clangCodeModelServer);
connectionServer.start(connectionName);
diff --git a/src/tools/clangrefactoringbackend/source/clangrefactoringbackend-source.pri b/src/tools/clangrefactoringbackend/source/clangrefactoringbackend-source.pri
index bea4690467..d15e0f625d 100644
--- a/src/tools/clangrefactoringbackend/source/clangrefactoringbackend-source.pri
+++ b/src/tools/clangrefactoringbackend/source/clangrefactoringbackend-source.pri
@@ -76,5 +76,4 @@ SOURCES += \
$$PWD/projectpartartefact.cpp \
$$PWD/filestatuscache.cpp \
$$PWD/symbolindexertaskqueue.cpp \
- $$PWD/symbolindexertaskscheduler.cpp \
- $$PWD/symbolscollectormanager.cpp
+ $$PWD/symbolindexertaskscheduler.cpp
diff --git a/src/tools/clangrefactoringbackend/source/refactoringserver.cpp b/src/tools/clangrefactoringbackend/source/refactoringserver.cpp
index 799901a520..2348b8800d 100644
--- a/src/tools/clangrefactoringbackend/source/refactoringserver.cpp
+++ b/src/tools/clangrefactoringbackend/source/refactoringserver.cpp
@@ -40,9 +40,11 @@
namespace ClangBackEnd {
RefactoringServer::RefactoringServer(SymbolIndexingInterface &symbolIndexing,
- FilePathCachingInterface &filePathCache)
+ FilePathCachingInterface &filePathCache,
+ GeneratedFiles &generatedFiles)
: m_symbolIndexing(symbolIndexing),
- m_filePathCache(filePathCache)
+ m_filePathCache(filePathCache),
+ m_generatedFiles(generatedFiles)
{
m_pollTimer.setInterval(100);
@@ -97,8 +99,7 @@ void RefactoringServer::requestSourceRangesForQueryMessage(RequestSourceRangesFo
void RefactoringServer::updateProjectParts(UpdateProjectPartsMessage &&message)
{
- m_symbolIndexing.updateProjectParts(message.takeProjectsParts(),
- m_generatedFiles.fileContainers());
+ m_symbolIndexing.updateProjectParts(message.takeProjectsParts());
}
void RefactoringServer::updateGeneratedFiles(UpdateGeneratedFilesMessage &&message)
diff --git a/src/tools/clangrefactoringbackend/source/refactoringserver.h b/src/tools/clangrefactoringbackend/source/refactoringserver.h
index ce18aaf548..d36e0ce388 100644
--- a/src/tools/clangrefactoringbackend/source/refactoringserver.h
+++ b/src/tools/clangrefactoringbackend/source/refactoringserver.h
@@ -56,7 +56,8 @@ class RefactoringServer : public RefactoringServerInterface,
using Future = std::future<SourceRangesForQueryMessage>;
public:
RefactoringServer(SymbolIndexingInterface &symbolIndexing,
- FilePathCachingInterface &filePathCache);
+ FilePathCachingInterface &filePathCache,
+ GeneratedFiles &generatedFiles);
void end() override;
void requestSourceLocationsForRenamingMessage(RequestSourceLocationsForRenamingMessage &&message) override;
@@ -85,10 +86,10 @@ private:
private:
ClangQueryGatherer m_gatherer;
- GeneratedFiles m_generatedFiles;
QTimer m_pollTimer;
SymbolIndexingInterface &m_symbolIndexing;
FilePathCachingInterface &m_filePathCache;
+ GeneratedFiles &m_generatedFiles;
};
} // namespace ClangBackEnd
diff --git a/src/tools/clangrefactoringbackend/source/symbolindexer.cpp b/src/tools/clangrefactoringbackend/source/symbolindexer.cpp
index cb47f87406..3235284d96 100644
--- a/src/tools/clangrefactoringbackend/source/symbolindexer.cpp
+++ b/src/tools/clangrefactoringbackend/source/symbolindexer.cpp
@@ -25,11 +25,37 @@
#include "symbolindexer.h"
-#include <symbolscollector.h>
+#include <symbolscollectorinterface.h>
#include <symbolindexertaskqueue.h>
+#include <chrono>
+#include <iostream>
+
namespace ClangBackEnd {
+using namespace std::chrono;
+
+class Timer
+{
+public:
+ Timer(Utils::SmallStringView name)
+ : name(name)
+ {}
+
+ void commit()
+ {
+ auto end = steady_clock::now();
+ auto time_difference = duration_cast<milliseconds>(end - begin);
+ begin = end;
+ std::cerr << name << " " << timePoint++ << ": " << time_difference.count() << "\n";
+ }
+
+private:
+ Utils::SmallString name;
+ time_point<steady_clock> begin{steady_clock::now()};
+ int timePoint = 1;
+};
+
SymbolIndexer::SymbolIndexer(SymbolIndexerTaskQueueInterface &symbolIndexerTaskQueue,
SymbolStorageInterface &symbolStorage,
ClangPathWatcherInterface &pathWatcher,
@@ -46,14 +72,13 @@ SymbolIndexer::SymbolIndexer(SymbolIndexerTaskQueueInterface &symbolIndexerTaskQ
pathWatcher.setNotifier(this);
}
-void SymbolIndexer::updateProjectParts(V2::ProjectPartContainers &&projectParts, const V2::FileContainers &generatedFiles)
+void SymbolIndexer::updateProjectParts(V2::ProjectPartContainers &&projectParts)
{
for (V2::ProjectPartContainer &projectPart : projectParts)
- updateProjectPart(std::move(projectPart), generatedFiles);
+ updateProjectPart(std::move(projectPart));
}
-void SymbolIndexer::updateProjectPart(V2::ProjectPartContainer &&projectPart,
- const V2::FileContainers &generatedFiles)
+void SymbolIndexer::updateProjectPart(V2::ProjectPartContainer &&projectPart)
{
Sqlite::ImmediateTransaction transaction{m_transactionInterface};
const auto optionalArtefact = m_symbolStorage.fetchProjectPartArtefact(projectPart.projectPartId);
@@ -67,7 +92,6 @@ void SymbolIndexer::updateProjectPart(V2::ProjectPartContainer &&projectPart,
projectPartId = optionalArtefact->projectPartId;
FilePathIds sourcePathIds = updatableFilePathIds(projectPart, optionalArtefact);
-
if (sourcePathIds.empty())
return;
@@ -75,15 +99,14 @@ void SymbolIndexer::updateProjectPart(V2::ProjectPartContainer &&projectPart,
std::vector<SymbolIndexerTask> symbolIndexerTask;
symbolIndexerTask.reserve(projectPart.sourcePathIds.size());
-
for (FilePathId sourcePathId : projectPart.sourcePathIds) {
- auto indexing = [projectPart, arguments, generatedFiles, sourcePathId]
+ auto indexing = [projectPartId = projectPart.projectPartId, arguments, sourcePathId]
(SymbolsCollectorInterface &symbolsCollector,
SymbolStorageInterface &symbolStorage,
Sqlite::TransactionInterface &transactionInterface) {
- symbolsCollector.addFile(sourcePathId, arguments);
+ auto id = Utils::SmallString::number(sourcePathId.filePathId);
- symbolsCollector.addUnsavedFiles(generatedFiles);
+ symbolsCollector.setFile(sourcePathId, arguments);
symbolsCollector.collectSymbols();
@@ -92,7 +115,7 @@ void SymbolIndexer::updateProjectPart(V2::ProjectPartContainer &&projectPart,
symbolStorage.addSymbolsAndSourceLocations(symbolsCollector.symbols(),
symbolsCollector.sourceLocations());
- symbolStorage.updateProjectPartSources(projectPart.projectPartId,
+ symbolStorage.updateProjectPartSources(projectPartId,
symbolsCollector.sourceFiles());
symbolStorage.insertOrUpdateUsedMacros(symbolsCollector.usedMacros());
@@ -147,7 +170,7 @@ void SymbolIndexer::updateChangedPath(FilePathId filePathId,
(SymbolsCollectorInterface &symbolsCollector,
SymbolStorageInterface &symbolStorage,
Sqlite::TransactionInterface &transactionInterface) {
- symbolsCollector.addFile(filePathId, arguments);
+ symbolsCollector.setFile(filePathId, arguments);
symbolsCollector.collectSymbols();
diff --git a/src/tools/clangrefactoringbackend/source/symbolindexer.h b/src/tools/clangrefactoringbackend/source/symbolindexer.h
index ffa2269e9b..eebea22670 100644
--- a/src/tools/clangrefactoringbackend/source/symbolindexer.h
+++ b/src/tools/clangrefactoringbackend/source/symbolindexer.h
@@ -37,7 +37,7 @@ namespace ClangBackEnd {
class SymbolsCollectorInterface;
-class SymbolIndexer : public ClangPathWatcherNotifier
+class SymbolIndexer final : public ClangPathWatcherNotifier
{
public:
SymbolIndexer(SymbolIndexerTaskQueueInterface &symbolIndexerTaskQueue,
@@ -47,10 +47,8 @@ public:
FileStatusCache &fileStatusCache,
Sqlite::TransactionInterface &transactionInterface);
- void updateProjectParts(V2::ProjectPartContainers &&projectParts,
- const V2::FileContainers &generatedFiles);
- void updateProjectPart(V2::ProjectPartContainer &&projectPart,
- const V2::FileContainers &generatedFiles);
+ void updateProjectParts(V2::ProjectPartContainers &&projectParts);
+ void updateProjectPart(V2::ProjectPartContainer &&projectPart);
void pathsWithIdsChanged(const Utils::SmallStringVector &ids) override;
void pathsChanged(const FilePathIds &filePathIds) override;
diff --git a/src/tools/clangrefactoringbackend/source/symbolindexing.cpp b/src/tools/clangrefactoringbackend/source/symbolindexing.cpp
index c1e934eb2e..4f62b859f0 100644
--- a/src/tools/clangrefactoringbackend/source/symbolindexing.cpp
+++ b/src/tools/clangrefactoringbackend/source/symbolindexing.cpp
@@ -27,10 +27,9 @@
namespace ClangBackEnd {
-void SymbolIndexing::updateProjectParts(V2::ProjectPartContainers &&projectParts,
- const V2::FileContainers &generatedFiles)
+void SymbolIndexing::updateProjectParts(V2::ProjectPartContainers &&projectParts)
{
- m_indexer.updateProjectParts(std::move(projectParts), generatedFiles);
+ m_indexer.updateProjectParts(std::move(projectParts));
}
} // namespace ClangBackEnd
diff --git a/src/tools/clangrefactoringbackend/source/symbolindexing.h b/src/tools/clangrefactoringbackend/source/symbolindexing.h
index 07188690c7..8f7821bddb 100644
--- a/src/tools/clangrefactoringbackend/source/symbolindexing.h
+++ b/src/tools/clangrefactoringbackend/source/symbolindexing.h
@@ -55,10 +55,11 @@ public:
using Storage = ClangBackEnd::SymbolStorage<StatementFactory>;
SymbolIndexing(Sqlite::Database &database,
- FilePathCachingInterface &filePathCache)
+ FilePathCachingInterface &filePathCache,
+ const GeneratedFiles &generatedFiles)
: m_filePathCache(filePathCache),
m_statementFactory(database),
- m_collectorManger(database),
+ m_collectorManger(database, generatedFiles),
m_indexerScheduler(m_collectorManger, m_symbolStorage, database, m_indexerQueue, std::thread::hardware_concurrency())
{
}
@@ -82,8 +83,7 @@ public:
}
}
- void updateProjectParts(V2::ProjectPartContainers &&projectParts,
- const V2::FileContainers &generatedFiles) override;
+ void updateProjectParts(V2::ProjectPartContainers &&projectParts) override;
private:
FilePathCachingInterface &m_filePathCache;
diff --git a/src/tools/clangrefactoringbackend/source/symbolindexinginterface.h b/src/tools/clangrefactoringbackend/source/symbolindexinginterface.h
index 0151f29f7e..70e16d7429 100644
--- a/src/tools/clangrefactoringbackend/source/symbolindexinginterface.h
+++ b/src/tools/clangrefactoringbackend/source/symbolindexinginterface.h
@@ -37,8 +37,7 @@ public:
SymbolIndexingInterface(const SymbolIndexingInterface&) = delete;
SymbolIndexingInterface &operator=(const SymbolIndexingInterface&) = delete;
- virtual void updateProjectParts(V2::ProjectPartContainers &&projectParts,
- const V2::FileContainers &generatedFiles) = 0;
+ virtual void updateProjectParts(V2::ProjectPartContainers &&projectParts) = 0;
protected:
~SymbolIndexingInterface() = default;
diff --git a/src/tools/clangrefactoringbackend/source/symbolscollector.cpp b/src/tools/clangrefactoringbackend/source/symbolscollector.cpp
index 57815da0ac..53e0bbba6e 100644
--- a/src/tools/clangrefactoringbackend/source/symbolscollector.cpp
+++ b/src/tools/clangrefactoringbackend/source/symbolscollector.cpp
@@ -44,12 +44,12 @@ void SymbolsCollector::addFiles(const FilePathIds &filePathIds,
m_collectMacrosSourceFileCallbacks.addSourceFiles(filePathIds);
}
-void SymbolsCollector::addFile(FilePathId filePathId, const Utils::SmallStringVector &arguments)
+void SymbolsCollector::setFile(FilePathId filePathId, const Utils::SmallStringVector &arguments)
{
addFiles({filePathId}, arguments);
}
-void SymbolsCollector::addUnsavedFiles(const V2::FileContainers &unsavedFiles)
+void SymbolsCollector::setUnsavedFiles(const V2::FileContainers &unsavedFiles)
{
m_clangTool.addUnsavedFiles(unsavedFiles);
}
diff --git a/src/tools/clangrefactoringbackend/source/symbolscollector.h b/src/tools/clangrefactoringbackend/source/symbolscollector.h
index 1b6c494895..70213555d6 100644
--- a/src/tools/clangrefactoringbackend/source/symbolscollector.h
+++ b/src/tools/clangrefactoringbackend/source/symbolscollector.h
@@ -46,9 +46,9 @@ public:
void addFiles(const FilePathIds &filePathIds,
const Utils::SmallStringVector &arguments);
- void addFile(FilePathId filePathId, const Utils::SmallStringVector &arguments) override;
+ void setFile(FilePathId filePathId, const Utils::SmallStringVector &arguments) override;
- void addUnsavedFiles(const V2::FileContainers &unsavedFiles) override;
+ void setUnsavedFiles(const V2::FileContainers &unsavedFiles) override;
void clear() override;
diff --git a/src/tools/clangrefactoringbackend/source/symbolscollectorinterface.h b/src/tools/clangrefactoringbackend/source/symbolscollectorinterface.h
index 2bf344d4b1..540866630f 100644
--- a/src/tools/clangrefactoringbackend/source/symbolscollectorinterface.h
+++ b/src/tools/clangrefactoringbackend/source/symbolscollectorinterface.h
@@ -48,9 +48,9 @@ public:
SymbolsCollectorInterface(const SymbolsCollectorInterface &) = delete;
SymbolsCollectorInterface &operator=(const SymbolsCollectorInterface &) = delete;
- virtual void addFile(FilePathId filePathId, const Utils::SmallStringVector &arguments) = 0;
+ virtual void setFile(FilePathId filePathId, const Utils::SmallStringVector &arguments) = 0;
- virtual void addUnsavedFiles(const V2::FileContainers &unsavedFiles) = 0;
+ virtual void setUnsavedFiles(const V2::FileContainers &unsavedFiles) = 0;
virtual void clear() = 0;
diff --git a/src/tools/clangrefactoringbackend/source/symbolscollectormanager.cpp b/src/tools/clangrefactoringbackend/source/symbolscollectormanager.cpp
deleted file mode 100644
index c6cc5e283e..0000000000
--- a/src/tools/clangrefactoringbackend/source/symbolscollectormanager.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#include "symbolscollectormanager.h"
-
-#include "symbolscollector.h"
-
-namespace ClangBackEnd {
-
-
-
-
-} // namespace ClangBackEnd
diff --git a/src/tools/clangrefactoringbackend/source/symbolscollectormanager.h b/src/tools/clangrefactoringbackend/source/symbolscollectormanager.h
index 5443911640..d5a020904f 100644
--- a/src/tools/clangrefactoringbackend/source/symbolscollectormanager.h
+++ b/src/tools/clangrefactoringbackend/source/symbolscollectormanager.h
@@ -27,6 +27,7 @@
#include "symbolscollectormanagerinterface.h"
#include "symbolscollectorinterface.h"
+#include "generatedfiles.h"
#include <memory>
@@ -36,13 +37,16 @@ class Database;
namespace ClangBackEnd {
+class GeneratedFiles;
class SymbolsCollector;
template<typename SymbolsCollector>
class SymbolsCollectorManager final : public SymbolsCollectorManagerInterface
{
public:
- SymbolsCollectorManager(Sqlite::Database &database)
- : m_database(database)
+ SymbolsCollectorManager(Sqlite::Database &database,
+ const GeneratedFiles &generatedFiles)
+ : m_database(database),
+ m_generatedFiles(generatedFiles)
{}
SymbolsCollector &unusedSymbolsCollector() override
@@ -56,11 +60,11 @@ public:
auto freeCollectors = std::distance(split, m_collectors.end());
if (freeCollectors > 0)
- return usedCollector(*split->get());
+ return initializedCollector(*split->get());
m_collectors.emplace_back(std::make_unique<SymbolsCollector>(m_database));
- return usedCollector(*m_collectors.back().get());
+ return initializedCollector(*m_collectors.back().get());
}
const std::vector<std::unique_ptr<SymbolsCollector>> &collectors() const
@@ -69,15 +73,17 @@ public:
}
private:
- SymbolsCollector &usedCollector(SymbolsCollector &collector)
+ SymbolsCollector &initializedCollector(SymbolsCollector &collector)
{
collector.setIsUsed(true);
+ collector.setUnsavedFiles(m_generatedFiles.fileContainers());
return collector;
}
private:
std::vector<std::unique_ptr<SymbolsCollector>> m_collectors;
Sqlite::Database &m_database;
+ const GeneratedFiles &m_generatedFiles;
};
} // namespace ClangBackEnd
diff --git a/src/tools/clangrefactoringbackend/source/symbolscollectormanagerinterface.h b/src/tools/clangrefactoringbackend/source/symbolscollectormanagerinterface.h
index 12a9699070..b0cb3a0332 100644
--- a/src/tools/clangrefactoringbackend/source/symbolscollectormanagerinterface.h
+++ b/src/tools/clangrefactoringbackend/source/symbolscollectormanagerinterface.h
@@ -25,6 +25,8 @@
#pragma once
+#include <filecontainerv2.h>
+
#include <vector>
namespace ClangBackEnd {
diff --git a/tests/unit/unittest/gtest-creator-printing.cpp b/tests/unit/unittest/gtest-creator-printing.cpp
index 0a6b3a7134..5e078d5b71 100644
--- a/tests/unit/unittest/gtest-creator-printing.cpp
+++ b/tests/unit/unittest/gtest-creator-printing.cpp
@@ -149,17 +149,17 @@ std::ostream &operator<<(std::ostream &out, const LineColumn &lineColumn)
void PrintTo(Utils::SmallStringView text, ::std::ostream *os)
{
- *os << text;
+ *os << "\"" << text << "\"";
}
void PrintTo(const Utils::SmallString &text, ::std::ostream *os)
{
- *os << text;
+ *os << "\"" << text << "\"";
}
void PrintTo(const Utils::PathString &text, ::std::ostream *os)
{
- *os << text;
+ *os << "\"" << text << "\"";
}
} // namespace Utils
diff --git a/tests/unit/unittest/mocksymbolindexertaskqueue.h b/tests/unit/unittest/mocksymbolindexertaskqueue.h
index b17fecd516..52be4cb942 100644
--- a/tests/unit/unittest/mocksymbolindexertaskqueue.h
+++ b/tests/unit/unittest/mocksymbolindexertaskqueue.h
@@ -33,7 +33,7 @@ class MockSymbolIndexerTaskQueue : public ClangBackEnd::SymbolIndexerTaskQueueIn
{
public:
MOCK_METHOD1(addOrUpdateTasks,
- void (std::vector< ClangBackEnd::SymbolIndexerTask> &&tasks));
+ void (std::vector<ClangBackEnd::SymbolIndexerTask> &&tasks));
MOCK_METHOD1(removeTasks,
void (const std::vector<int> &projectPartIds));
MOCK_METHOD0(processTasks, void());
diff --git a/tests/unit/unittest/mocksymbolindexing.h b/tests/unit/unittest/mocksymbolindexing.h
index 967a5f6aab..048840d976 100644
--- a/tests/unit/unittest/mocksymbolindexing.h
+++ b/tests/unit/unittest/mocksymbolindexing.h
@@ -32,14 +32,12 @@
class MockSymbolIndexing : public ClangBackEnd::SymbolIndexingInterface
{
public:
- MOCK_METHOD2(updateProjectParts,
- void(const ClangBackEnd::V2::ProjectPartContainers &projectParts,
- const ClangBackEnd::V2::FileContainers &generatedFiles));
+ MOCK_METHOD1(updateProjectParts,
+ void(const ClangBackEnd::V2::ProjectPartContainers &projectParts));
- void updateProjectParts(ClangBackEnd::V2::ProjectPartContainers &&projectParts,
- const ClangBackEnd::V2::FileContainers &generatedFiles) override
+ void updateProjectParts(ClangBackEnd::V2::ProjectPartContainers &&projectParts) override
{
- updateProjectParts(projectParts, generatedFiles);
+ updateProjectParts(projectParts);
}
};
diff --git a/tests/unit/unittest/mocksymbolscollector.h b/tests/unit/unittest/mocksymbolscollector.h
index bf82f538ae..1bced44da9 100644
--- a/tests/unit/unittest/mocksymbolscollector.h
+++ b/tests/unit/unittest/mocksymbolscollector.h
@@ -44,16 +44,17 @@ public:
{
ON_CALL(*this, setIsUsed(_)).WillByDefault(Invoke(this, &MockSymbolsCollector::setIsUsed2));
ON_CALL(*this, isUsed()).WillByDefault(Invoke(this, &MockSymbolsCollector::isUsed2));
+ ON_CALL(*this, setUnsavedFiles(_)).WillByDefault(Invoke(this, &MockSymbolsCollector::setHasUnsavedFiles));
}
MOCK_METHOD0(collectSymbols,
void());
- MOCK_METHOD2(addFile,
+ MOCK_METHOD2(setFile,
void(ClangBackEnd::FilePathId filePathId,
const Utils::SmallStringVector &arguments));
- MOCK_METHOD1(addUnsavedFiles,
+ MOCK_METHOD1(setUnsavedFiles,
void(const ClangBackEnd::V2::FileContainers &unsavedFiles));
MOCK_METHOD0(clear,
@@ -93,6 +94,12 @@ public:
return used;
}
+ void setHasUnsavedFiles(const ClangBackEnd::V2::FileContainers &unsavedFiles)
+ {
+ hasUnsavedFiles = true;
+ }
+
public:
bool used = false;
+ bool hasUnsavedFiles = false;
};
diff --git a/tests/unit/unittest/refactoringserver-test.cpp b/tests/unit/unittest/refactoringserver-test.cpp
index 51cae8697e..82fff5ce2f 100644
--- a/tests/unit/unittest/refactoringserver-test.cpp
+++ b/tests/unit/unittest/refactoringserver-test.cpp
@@ -94,7 +94,8 @@ protected:
Sqlite::Database database{":memory:", Sqlite::JournalMode::Memory};
ClangBackEnd::RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database};
ClangBackEnd::FilePathCaching filePathCache{database};
- ClangBackEnd::RefactoringServer refactoringServer{mockSymbolIndexing, filePathCache};
+ ClangBackEnd::GeneratedFiles generatedFiles;
+ ClangBackEnd::RefactoringServer refactoringServer{mockSymbolIndexing, filePathCache, generatedFiles};
Utils::SmallString sourceContent{"void f()\n {}"};
FileContainer source{{TESTDATA_DIR, "query_simplefunction.cpp"},
sourceContent.clone(),
@@ -304,12 +305,21 @@ TEST_F(RefactoringServer, UpdateGeneratedFilesSetMemberWhichIsUsedForSymbolIndex
"void f();",
{}}};
+ refactoringServer.updateGeneratedFiles(Utils::clone(unsaved));
- EXPECT_CALL(mockSymbolIndexing,
- updateProjectParts(_, unsaved));
+ ASSERT_THAT(generatedFiles.fileContainers(), ElementsAre(unsaved.front()));
+}
+TEST_F(RefactoringServer, RemoveGeneratedFilesSetMemberWhichIsUsedForSymbolIndexing)
+{
+ FileContainers unsaved{{{TESTDATA_DIR, "query_simplefunction.h"},
+ "void f();",
+ {}}};
refactoringServer.updateGeneratedFiles(Utils::clone(unsaved));
- refactoringServer.updateProjectParts({});
+
+ refactoringServer.removeGeneratedFiles({{{TESTDATA_DIR, "query_simplefunction.h"}}});
+
+ ASSERT_THAT(generatedFiles.fileContainers(), IsEmpty());
}
TEST_F(RefactoringServer, UpdateProjectPartsCallsSymbolIndexingUpdateProjectParts)
@@ -323,7 +333,7 @@ TEST_F(RefactoringServer, UpdateProjectPartsCallsSymbolIndexingUpdateProjectPart
EXPECT_CALL(mockSymbolIndexing,
- updateProjectParts(projectParts, _));
+ updateProjectParts(projectParts));
refactoringServer.updateProjectParts({Utils::clone(projectParts)});
}
diff --git a/tests/unit/unittest/symbolindexer-test.cpp b/tests/unit/unittest/symbolindexer-test.cpp
index 8ce8e40c7a..69e8927c5a 100644
--- a/tests/unit/unittest/symbolindexer-test.cpp
+++ b/tests/unit/unittest/symbolindexer-test.cpp
@@ -99,6 +99,8 @@ protected:
ON_CALL(mockStorage, fetchLowestLastModifiedTime(A<FilePathId>())).WillByDefault(Return(QDateTime::currentSecsSinceEpoch()));
mockCollector.setIsUsed(false);
+
+ generatedFiles.update(unsaved);
}
void TearDown()
@@ -179,7 +181,8 @@ protected:
NiceMock<MockSymbolStorage> mockStorage;
NiceMock<MockClangPathWatcher> mockPathWatcher;
ClangBackEnd::FileStatusCache fileStatusCache{filePathCache};
- SymbolsCollectorManager<NiceMock<MockSymbolsCollector>> collectorManger{data->database};
+ ClangBackEnd::GeneratedFiles generatedFiles;
+ SymbolsCollectorManager<NiceMock<MockSymbolsCollector>> collectorManger{data->database, generatedFiles};
SymbolIndexerTaskScheduler indexerScheduler{collectorManger, mockStorage, mockSqliteTransactionBackend, indexerQueue, 1};
SymbolIndexerTaskQueue indexerQueue{indexerScheduler};
ClangBackEnd::SymbolIndexer indexer{indexerQueue,
@@ -195,9 +198,9 @@ std::unique_ptr<Data> SymbolIndexer::data;
TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddFilesInCollector)
{
- EXPECT_CALL(mockCollector, addFile(main1PathId, projectPart1.arguments));
+ EXPECT_CALL(mockCollector, setFile(main1PathId, projectPart1.arguments));
- indexer.updateProjectParts({projectPart1}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddFilesWithPrecompiledHeaderInCollector)
@@ -205,7 +208,7 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddFilesWithPrecompiledHeaderInColl
ON_CALL(mockStorage, fetchProjectPartArtefact(TypedEq<Utils::SmallStringView>(projectPart1.projectPartId))).WillByDefault(Return(emptyArtefact));
ON_CALL(mockStorage, fetchPrecompiledHeader(Eq(artefact.projectPartId))).WillByDefault(Return(projectPartPch));
- EXPECT_CALL(mockCollector, addFile(main1PathId,
+ EXPECT_CALL(mockCollector, setFile(main1PathId,
ElementsAre(Eq("-I"),
Eq(TESTDATA_DIR),
Eq("-Wno-pragma-once-outside-header"),
@@ -214,76 +217,76 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddFilesWithPrecompiledHeaderInColl
Eq("-Xclang"),
Eq("/path/to/pch"))));
- indexer.updateProjectParts({projectPart1}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddFilesWithoutPrecompiledHeaderInCollector)
{
ON_CALL(mockStorage, fetchProjectPartArtefact(TypedEq<Utils::SmallStringView>(projectPart1.projectPartId))).WillByDefault(Return(emptyArtefact));
- EXPECT_CALL(mockCollector, addFile(main1PathId,
+ EXPECT_CALL(mockCollector, setFile(main1PathId,
ElementsAre(Eq("-I"),
Eq(TESTDATA_DIR),
Eq("-Wno-pragma-once-outside-header"))));
- indexer.updateProjectParts({projectPart1}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsClearInCollector)
{
EXPECT_CALL(mockCollector, clear()).Times(2);
- indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1, projectPart2});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddFilesInCollectorForEveryProjectPart)
{
- EXPECT_CALL(mockCollector, addFile(_, _)).Times(2);
+ EXPECT_CALL(mockCollector, setFile(_, _)).Times(2);
- indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1, projectPart2});
}
TEST_F(SymbolIndexer, UpdateProjectPartsDoesNotCallAddFilesInCollectorForEmptyEveryProjectParts)
{
- EXPECT_CALL(mockCollector, addFile(_, _))
+ EXPECT_CALL(mockCollector, setFile(_, _))
.Times(0);
- indexer.updateProjectParts({}, {});
+ indexer.updateProjectParts({});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallscollectSymbolsInCollector)
{
EXPECT_CALL(mockCollector, collectSymbols()).Times(2);;
- indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1, projectPart2});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsSymbolsInCollector)
{
EXPECT_CALL(mockCollector, symbols()).Times(2);
- indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1, projectPart2});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsSourceLocationsInCollector)
{
EXPECT_CALL(mockCollector, sourceLocations()).Times(2);
- indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1, projectPart2});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddUnsavedFilesInCollector)
{
- EXPECT_CALL(mockCollector, addUnsavedFiles(unsaved)).Times(2);
+ EXPECT_CALL(mockCollector, setUnsavedFiles(unsaved)).Times(2);
- indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1, projectPart2});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddSymbolsAndSourceLocationsInStorage)
{
EXPECT_CALL(mockStorage, addSymbolsAndSourceLocations(symbolEntries, sourceLocations)).Times(2);
- indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1, projectPart2});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsUpdateProjectPartsInStorage)
@@ -297,7 +300,7 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsUpdateProjectPartsInStorage)
ElementsAre(CompilerMacro{"BAR", "1"}, CompilerMacro{"FOO", "0"}),
ElementsAre("/includes")));
- indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1, projectPart2});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsUpdateProjectPartSources)
@@ -305,7 +308,7 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsUpdateProjectPartSources)
EXPECT_CALL(mockStorage, updateProjectPartSources(TypedEq<Utils::SmallStringView>("project1"), ElementsAre(IsFileId(1, 1), IsFileId(42, 23))));
EXPECT_CALL(mockStorage, updateProjectPartSources(TypedEq<Utils::SmallStringView>("project2"), ElementsAre(IsFileId(1, 1), IsFileId(42, 23))));
- indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1, projectPart2});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsInsertOrUpdateUsedMacros)
@@ -313,7 +316,7 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsInsertOrUpdateUsedMacros)
EXPECT_CALL(mockStorage, insertOrUpdateUsedMacros(Eq(usedMacros)))
.Times(2);
- indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1, projectPart2});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsInsertFileStatuses)
@@ -321,7 +324,7 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsInsertFileStatuses)
EXPECT_CALL(mockStorage, insertFileStatuses(Eq(fileStatus)))
.Times(2);
- indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1, projectPart2});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsInsertOrUpdateSourceDependencies)
@@ -329,7 +332,7 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsInsertOrUpdateSourceDependencies)
EXPECT_CALL(mockStorage, insertOrUpdateSourceDependencies(Eq(sourceDependencies)))
.Times(2);
- indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1, projectPart2});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsFetchProjectPartArtefacts)
@@ -337,7 +340,7 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsFetchProjectPartArtefacts)
EXPECT_CALL(mockStorage, fetchProjectPartArtefact(TypedEq<Utils::SmallStringView>(projectPart1.projectPartId)));
EXPECT_CALL(mockStorage, fetchProjectPartArtefact(TypedEq<Utils::SmallStringView>(projectPart2.projectPartId)));
- indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1, projectPart2});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsInOrder)
@@ -348,8 +351,7 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsInOrder)
EXPECT_CALL(mockStorage, fetchProjectPartArtefact(TypedEq<Utils::SmallStringView>(projectPart1.projectPartId)));
EXPECT_CALL(mockStorage, insertOrUpdateProjectPart(Eq(projectPart1.projectPartId), Eq(projectPart1.arguments), Eq(projectPart1.compilerMacros), Eq(projectPart1.includeSearchPaths)));
EXPECT_CALL(mockSqliteTransactionBackend, commit());
- EXPECT_CALL(mockCollector, addFile(main1PathId, projectPart1.arguments));
- EXPECT_CALL(mockCollector, addUnsavedFiles(unsaved));
+ EXPECT_CALL(mockCollector, setFile(main1PathId, projectPart1.arguments));
EXPECT_CALL(mockCollector, collectSymbols());
EXPECT_CALL(mockSqliteTransactionBackend, immediateBegin());
EXPECT_CALL(mockStorage, addSymbolsAndSourceLocations(symbolEntries, sourceLocations));
@@ -359,7 +361,7 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsInOrder)
EXPECT_CALL(mockStorage, insertOrUpdateSourceDependencies(Eq(sourceDependencies)));
EXPECT_CALL(mockSqliteTransactionBackend, commit());
- indexer.updateProjectParts({projectPart1}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1});
}
TEST_F(SymbolIndexer, CallSetNotifier)
@@ -381,10 +383,10 @@ TEST_F(SymbolIndexer, UpdateChangedPathCallsInOrder)
{
InSequence s;
- EXPECT_CALL(mockSqliteTransactionBackend, immediateBegin()).Times(0);
+ EXPECT_CALL(mockSqliteTransactionBackend, deferredBegin());
EXPECT_CALL(mockStorage, fetchProjectPartArtefact(sourceFileIds[0])).WillOnce(Return(artefact));
EXPECT_CALL(mockSqliteTransactionBackend, commit());
- EXPECT_CALL(mockCollector, addFile(Eq(sourceFileIds[0]), Eq(artefact.compilerArguments)));
+ EXPECT_CALL(mockCollector, setFile(Eq(sourceFileIds[0]), Eq(artefact.compilerArguments)));
EXPECT_CALL(mockCollector, collectSymbols());
EXPECT_CALL(mockSqliteTransactionBackend, immediateBegin());
EXPECT_CALL(mockStorage, addSymbolsAndSourceLocations(symbolEntries, sourceLocations));
@@ -401,10 +403,10 @@ TEST_F(SymbolIndexer, HandleEmptyOptionalArtifactInUpdateChangedPath)
{
InSequence s;
- EXPECT_CALL(mockSqliteTransactionBackend, immediateBegin()).Times(0);
+ EXPECT_CALL(mockSqliteTransactionBackend, deferredBegin());
EXPECT_CALL(mockStorage, fetchProjectPartArtefact(sourceFileIds[0])).WillOnce(Return(emptyArtefact));
EXPECT_CALL(mockSqliteTransactionBackend, commit());
- EXPECT_CALL(mockCollector, addFile(_, _)).Times(0);
+ EXPECT_CALL(mockCollector, setFile(_, _)).Times(0);
EXPECT_CALL(mockCollector, collectSymbols()).Times(0);
EXPECT_CALL(mockSqliteTransactionBackend, immediateBegin()).Times(0);
EXPECT_CALL(mockStorage, addSymbolsAndSourceLocations(_, _)).Times(0);
@@ -425,7 +427,7 @@ TEST_F(SymbolIndexer, UpdateChangedPathIsUsingPrecompiledHeader)
.WillByDefault(Return(projectPartPch));
std::vector<SymbolIndexerTask> symbolIndexerTask;
- EXPECT_CALL(mockCollector, addFile(Eq(sourceFileIds[0]),
+ EXPECT_CALL(mockCollector, setFile(Eq(sourceFileIds[0]),
ElementsAre(Eq("-DFOO"),
Eq("-Xclang"),
Eq("-include-pch"),
@@ -441,7 +443,7 @@ TEST_F(SymbolIndexer, UpdateChangedPathIsNotUsingPrecompiledHeaderIfItNotExists)
.WillByDefault(Return(artefact));
std::vector<SymbolIndexerTask> symbolIndexerTask;
- EXPECT_CALL(mockCollector, addFile(Eq(sourceFileIds[0]),
+ EXPECT_CALL(mockCollector, setFile(Eq(sourceFileIds[0]),
ElementsAre(Eq("-DFOO"))));
indexer.pathsChanged({sourceFileIds[0]});
@@ -492,7 +494,7 @@ TEST_F(SymbolIndexer, DontReparseInUpdateProjectPartsIfDefinesAreTheSame)
EXPECT_CALL(mockStorage, fetchProjectPartArtefact(TypedEq<Utils::SmallStringView>(projectPart1.projectPartId))).WillRepeatedly(Return(artefact));
EXPECT_CALL(mockStorage, insertOrUpdateProjectPart(Eq(projectPart1.projectPartId), Eq(projectPart1.arguments), Eq(projectPart1.compilerMacros), Eq(projectPart1.includeSearchPaths)));
EXPECT_CALL(mockSqliteTransactionBackend, commit());
- EXPECT_CALL(mockCollector, addFile(_, _)).Times(0);
+ EXPECT_CALL(mockCollector, setFile(_, _)).Times(0);
EXPECT_CALL(mockCollector, collectSymbols()).Times(0);
EXPECT_CALL(mockSqliteTransactionBackend, immediateBegin()).Times(0);
EXPECT_CALL(mockStorage, addSymbolsAndSourceLocations(_, _)).Times(0);
@@ -502,7 +504,7 @@ TEST_F(SymbolIndexer, DontReparseInUpdateProjectPartsIfDefinesAreTheSame)
EXPECT_CALL(mockStorage, insertOrUpdateSourceDependencies(_)).Times(0);
EXPECT_CALL(mockSqliteTransactionBackend, commit()).Times(0);
- indexer.updateProjectPart(std::move(projectPart1), {});
+ indexer.updateProjectPart(std::move(projectPart1));
}
TEST_F(SymbolIndexer, PathsChangedUpdatesFileStatusCache)
@@ -575,9 +577,9 @@ TEST_F(SymbolIndexer, OutdatedFilesAreParsedInUpdateProjectParts)
ON_CALL(mockStorage, fetchLowestLastModifiedTime(A<FilePathId>()))
.WillByDefault(Return(0));
- EXPECT_CALL(mockCollector, addFile(Eq(main1PathId), _));
+ EXPECT_CALL(mockCollector, setFile(Eq(main1PathId), _));
- indexer.updateProjectParts({projectPart1}, {});
+ indexer.updateProjectParts({projectPart1});
}
TEST_F(SymbolIndexer, UpToDateFilesAreNotParsedInUpdateProjectParts)
@@ -588,9 +590,9 @@ TEST_F(SymbolIndexer, UpToDateFilesAreNotParsedInUpdateProjectParts)
ON_CALL(mockStorage, fetchLowestLastModifiedTime(A<FilePathId>()))
.WillByDefault(Return(QDateTime::currentSecsSinceEpoch()));
- EXPECT_CALL(mockCollector, addFile(_, _)).Times(0);
+ EXPECT_CALL(mockCollector, setFile(_, _)).Times(0);
- indexer.updateProjectParts({projectPart1}, {});
+ indexer.updateProjectParts({projectPart1});
}
}
diff --git a/tests/unit/unittest/symbolindexing-test.cpp b/tests/unit/unittest/symbolindexing-test.cpp
index 916867e4b3..5df58bff4b 100644
--- a/tests/unit/unittest/symbolindexing-test.cpp
+++ b/tests/unit/unittest/symbolindexing-test.cpp
@@ -81,7 +81,8 @@ protected:
Sqlite::Database database{":memory:", Sqlite::JournalMode::Memory};
RefactoringDatabaseInitializer<Sqlite::Database> initializer{database};
FilePathCaching filePathCache{database};
- ClangBackEnd::SymbolIndexing indexing{database, filePathCache};
+ ClangBackEnd::GeneratedFiles generatedFiles;
+ ClangBackEnd::SymbolIndexing indexing{database, filePathCache, generatedFiles};
StatementFactory queryFactory{database};
Query query{queryFactory};
PathString main1Path = TESTDATA_DIR "/symbolindexing_main1.cpp";
@@ -95,7 +96,7 @@ protected:
TEST_F(SymbolIndexing, Locations)
{
- indexing.indexer().updateProjectParts({projectPart1}, {});
+ indexing.indexer().updateProjectParts({projectPart1});
indexing.syncTasks();
auto locations = query.locationsAt(filePathId(TESTDATA_DIR "/symbolindexing_main1.cpp"), 1, 6);
@@ -108,7 +109,7 @@ TEST_F(SymbolIndexing, Locations)
TEST_F(SymbolIndexing, DISABLED_TemplateFunction)
{
- indexing.indexer().updateProjectParts({projectPart1}, {});
+ indexing.indexer().updateProjectParts({projectPart1});
indexing.syncTasks();
auto locations = query.locationsAt(filePathId(TESTDATA_DIR "/symbolindexing_main1.cpp"), 21, 24);
@@ -120,7 +121,7 @@ TEST_F(SymbolIndexing, DISABLED_TemplateFunction)
TEST_F(SymbolIndexing, PathsAreUpdated)
{
- indexing.indexer().updateProjectParts({projectPart1}, {});
+ indexing.indexer().updateProjectParts({projectPart1});
indexing.indexer().pathsChanged({filePathId(main1Path)});
indexing.indexer().pathsChanged({filePathId(main1Path)});
diff --git a/tests/unit/unittest/symbolscollector-test.cpp b/tests/unit/unittest/symbolscollector-test.cpp
index f20e26b7f5..99ce331e94 100644
--- a/tests/unit/unittest/symbolscollector-test.cpp
+++ b/tests/unit/unittest/symbolscollector-test.cpp
@@ -178,7 +178,7 @@ protected:
TEST_F(SymbolsCollector, CollectSymbolName)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_simple.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_simple.cpp"), {"cc"});
collector.collectSymbols();
@@ -188,7 +188,7 @@ TEST_F(SymbolsCollector, CollectSymbolName)
TEST_F(SymbolsCollector, SymbolMatchesLocation)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_simple.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_simple.cpp"), {"cc"});
collector.collectSymbols();
@@ -200,7 +200,7 @@ TEST_F(SymbolsCollector, SymbolMatchesLocation)
TEST_F(SymbolsCollector, OtherSymboldMatchesLocation)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_simple.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_simple.cpp"), {"cc"});
collector.collectSymbols();
@@ -212,7 +212,7 @@ TEST_F(SymbolsCollector, OtherSymboldMatchesLocation)
TEST_F(SymbolsCollector, CollectFilePath)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_simple.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_simple.cpp"), {"cc"});
collector.collectSymbols();
@@ -225,7 +225,7 @@ TEST_F(SymbolsCollector, CollectFilePath)
TEST_F(SymbolsCollector, CollectLineColumn)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_simple.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_simple.cpp"), {"cc"});
collector.collectSymbols();
@@ -237,7 +237,7 @@ TEST_F(SymbolsCollector, CollectLineColumn)
TEST_F(SymbolsCollector, CollectReference)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_simple.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_simple.cpp"), {"cc"});
collector.collectSymbols();
@@ -249,7 +249,7 @@ TEST_F(SymbolsCollector, CollectReference)
TEST_F(SymbolsCollector, ReferencedSymboldMatchesLocation)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_simple.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_simple.cpp"), {"cc"});
collector.collectSymbols();
@@ -264,8 +264,8 @@ TEST_F(SymbolsCollector, DISABLED_ON_WINDOWS(CollectInUnsavedFile))
FileContainers unsaved{{{TESTDATA_DIR, "symbolscollector_generated_file.h"},
"void function();",
{}}};
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_unsaved.cpp")}, {"cc"});
- collector.addUnsavedFiles(std::move(unsaved));
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_unsaved.cpp"), {"cc"});
+ collector.setUnsavedFiles(std::move(unsaved));
collector.collectSymbols();
@@ -275,7 +275,7 @@ TEST_F(SymbolsCollector, DISABLED_ON_WINDOWS(CollectInUnsavedFile))
TEST_F(SymbolsCollector, SourceFiles)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_main.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_main.cpp"), {"cc"});
collector.collectSymbols();
@@ -287,7 +287,7 @@ TEST_F(SymbolsCollector, SourceFiles)
TEST_F(SymbolsCollector, MainFileInSourceFiles)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_main.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_main.cpp"), {"cc"});
ASSERT_THAT(collector.sourceFiles(),
ElementsAre(filePathId(TESTDATA_DIR "/symbolscollector_main.cpp")));
@@ -295,7 +295,7 @@ TEST_F(SymbolsCollector, MainFileInSourceFiles)
TEST_F(SymbolsCollector, ResetMainFileInSourceFiles)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_main.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_main.cpp"), {"cc"});
ASSERT_THAT(collector.sourceFiles(),
ElementsAre(filePathId(TESTDATA_DIR "/symbolscollector_main.cpp")));
@@ -303,7 +303,7 @@ TEST_F(SymbolsCollector, ResetMainFileInSourceFiles)
TEST_F(SymbolsCollector, DontDuplicateSourceFiles)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_main.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_main.cpp"), {"cc"});
collector.collectSymbols();
collector.collectSymbols();
@@ -316,7 +316,7 @@ TEST_F(SymbolsCollector, DontDuplicateSourceFiles)
TEST_F(SymbolsCollector, ClearSourceFiles)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_main.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_main.cpp"), {"cc"});
collector.clear();
@@ -325,7 +325,7 @@ TEST_F(SymbolsCollector, ClearSourceFiles)
TEST_F(SymbolsCollector, ClearSymbols)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_main.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_main.cpp"), {"cc"});
collector.collectSymbols();
collector.clear();
@@ -335,7 +335,7 @@ TEST_F(SymbolsCollector, ClearSymbols)
TEST_F(SymbolsCollector, ClearSourceLocations)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_main.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_main.cpp"), {"cc"});
collector.collectSymbols();
collector.clear();
@@ -345,7 +345,7 @@ TEST_F(SymbolsCollector, ClearSourceLocations)
TEST_F(SymbolsCollector, ClearFileStatus)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_main.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_main.cpp"), {"cc"});
collector.collectSymbols();
collector.clear();
@@ -355,7 +355,7 @@ TEST_F(SymbolsCollector, ClearFileStatus)
TEST_F(SymbolsCollector, ClearUsedMacros)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_defines.h")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_defines.h"), {"cc"});
collector.collectSymbols();
collector.clear();
@@ -365,7 +365,7 @@ TEST_F(SymbolsCollector, ClearUsedMacros)
TEST_F(SymbolsCollector, DontCollectSymbolsAfterFilesAreCleared)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_main.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_main.cpp"), {"cc"});
collector.clear();
collector.collectSymbols();
@@ -375,7 +375,7 @@ TEST_F(SymbolsCollector, DontCollectSymbolsAfterFilesAreCleared)
TEST_F(SymbolsCollector, DontCollectSourceFilesAfterFilesAreCleared)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_main.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_main.cpp"), {"cc"});
collector.clear();
collector.collectSymbols();
@@ -385,7 +385,7 @@ TEST_F(SymbolsCollector, DontCollectSourceFilesAfterFilesAreCleared)
TEST_F(SymbolsCollector, DontCollectFileStatusAfterFilesAreCleared)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_main.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_main.cpp"), {"cc"});
collector.clear();
collector.collectSymbols();
@@ -395,7 +395,7 @@ TEST_F(SymbolsCollector, DontCollectFileStatusAfterFilesAreCleared)
TEST_F(SymbolsCollector, DontCollectUsedMacrosAfterFilesAreCleared)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_main.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_main.cpp"), {"cc"});
collector.clear();
collector.collectSymbols();
@@ -406,7 +406,7 @@ TEST_F(SymbolsCollector, DontCollectUsedMacrosAfterFilesAreCleared)
TEST_F(SymbolsCollector, CollectUsedMacrosWithExternalDefine)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc", "-DCOMPILER_ARGUMENT"});
+ collector.setFile(fileId, {"cc", "-DCOMPILER_ARGUMENT"});
collector.collectSymbols();
@@ -423,7 +423,7 @@ TEST_F(SymbolsCollector, CollectUsedMacrosWithExternalDefine)
TEST_F(SymbolsCollector, CollectUsedMacrosWithoutExternalDefine)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc"});
+ collector.setFile(fileId, {"cc"});
collector.collectSymbols();
@@ -440,7 +440,7 @@ TEST_F(SymbolsCollector, CollectUsedMacrosWithoutExternalDefine)
TEST_F(SymbolsCollector, DontCollectHeaderGuards)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc"});
+ collector.setFile(fileId, {"cc"});
collector.collectSymbols();
@@ -451,7 +451,7 @@ TEST_F(SymbolsCollector, DontCollectHeaderGuards)
TEST_F(SymbolsCollector, DISABLED_DontCollectDynamicLibraryExports)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc"});
+ collector.setFile(fileId, {"cc"});
collector.collectSymbols();
@@ -462,7 +462,7 @@ TEST_F(SymbolsCollector, DISABLED_DontCollectDynamicLibraryExports)
TEST_F(SymbolsCollector, CollectMacroDefinitionSourceLocation)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc", "-DCOMPILER_ARGUMENT"});
+ collector.setFile(fileId, {"cc", "-DCOMPILER_ARGUMENT"});
collector.collectSymbols();
@@ -473,7 +473,7 @@ TEST_F(SymbolsCollector, CollectMacroDefinitionSourceLocation)
TEST_F(SymbolsCollector, CollectMacroUsageInIfNotDefSourceLocation)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc", "-DCOMPILER_ARGUMENT"});
+ collector.setFile(fileId, {"cc", "-DCOMPILER_ARGUMENT"});
collector.collectSymbols();
@@ -484,7 +484,7 @@ TEST_F(SymbolsCollector, CollectMacroUsageInIfNotDefSourceLocation)
TEST_F(SymbolsCollector, CollectSecondMacroUsageInIfNotDefSourceLocation)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc", "-DCOMPILER_ARGUMENT"});
+ collector.setFile(fileId, {"cc", "-DCOMPILER_ARGUMENT"});
collector.collectSymbols();
@@ -495,7 +495,7 @@ TEST_F(SymbolsCollector, CollectSecondMacroUsageInIfNotDefSourceLocation)
TEST_F(SymbolsCollector, CollectMacroUsageCompilerArgumentSourceLocation)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc", "-DCOMPILER_ARGUMENT"});
+ collector.setFile(fileId, {"cc", "-DCOMPILER_ARGUMENT"});
collector.collectSymbols();
@@ -506,7 +506,7 @@ TEST_F(SymbolsCollector, CollectMacroUsageCompilerArgumentSourceLocation)
TEST_F(SymbolsCollector, CollectMacroUsageInIfDefSourceLocation)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc", "-DCOMPILER_ARGUMENT"});
+ collector.setFile(fileId, {"cc", "-DCOMPILER_ARGUMENT"});
collector.collectSymbols();
@@ -517,7 +517,7 @@ TEST_F(SymbolsCollector, CollectMacroUsageInIfDefSourceLocation)
TEST_F(SymbolsCollector, CollectMacroUsageInDefinedSourceLocation)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc", "-DCOMPILER_ARGUMENT"});
+ collector.setFile(fileId, {"cc", "-DCOMPILER_ARGUMENT"});
collector.collectSymbols();
@@ -528,7 +528,7 @@ TEST_F(SymbolsCollector, CollectMacroUsageInDefinedSourceLocation)
TEST_F(SymbolsCollector, CollectMacroUsageExpansionSourceLocation)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc", "-DCOMPILER_ARGUMENT"});
+ collector.setFile(fileId, {"cc", "-DCOMPILER_ARGUMENT"});
collector.collectSymbols();
@@ -539,7 +539,7 @@ TEST_F(SymbolsCollector, CollectMacroUsageExpansionSourceLocation)
TEST_F(SymbolsCollector, CollectMacroUsageUndefSourceLocation)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc", "-DCOMPILER_ARGUMENT"});
+ collector.setFile(fileId, {"cc", "-DCOMPILER_ARGUMENT"});
collector.collectSymbols();
@@ -550,7 +550,7 @@ TEST_F(SymbolsCollector, CollectMacroUsageUndefSourceLocation)
TEST_F(SymbolsCollector, CollectMacroUsageBuiltInSourceLocation)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc", "-DCOMPILER_ARGUMENT"});
+ collector.setFile(fileId, {"cc", "-DCOMPILER_ARGUMENT"});
collector.collectSymbols();
@@ -561,7 +561,7 @@ TEST_F(SymbolsCollector, CollectMacroUsageBuiltInSourceLocation)
TEST_F(SymbolsCollector, CollectMacroDefinitionSymbols)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc"});
+ collector.setFile(fileId, {"cc"});
collector.collectSymbols();
@@ -572,7 +572,7 @@ TEST_F(SymbolsCollector, CollectMacroDefinitionSymbols)
TEST_F(SymbolsCollector, CollectMacroBuiltInSymbols)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc"});
+ collector.setFile(fileId, {"cc"});
collector.collectSymbols();
@@ -583,7 +583,7 @@ TEST_F(SymbolsCollector, CollectMacroBuiltInSymbols)
TEST_F(SymbolsCollector, CollectMacroCompilerArgumentSymbols)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc", "-DCOMPILER_ARGUMENT"});
+ collector.setFile(fileId, {"cc", "-DCOMPILER_ARGUMENT"});
collector.collectSymbols();
@@ -594,7 +594,7 @@ TEST_F(SymbolsCollector, CollectMacroCompilerArgumentSymbols)
TEST_F(SymbolsCollector, CollectFileStatuses)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_main.cpp");
- collector.addFiles({fileId}, {"cc"});
+ collector.setFile(fileId, {"cc"});
collector.collectSymbols();
@@ -611,7 +611,7 @@ TEST_F(SymbolsCollector, CollectSourceDependencies)
auto header1FileId = filePathId(TESTDATA_DIR "/symbolscollector_header1.h");
auto header2FileId = filePathId(TESTDATA_DIR "/symbolscollector_header2.h");
auto header3FileId = filePathId(TESTDATA_DIR "/symbolscollector_header3.h");
- collector.addFiles({mainFileId}, {"cc", "-I" TESTDATA_DIR});
+ collector.setFile(mainFileId, {"cc", "-I" TESTDATA_DIR});
collector.collectSymbols();
@@ -624,7 +624,7 @@ TEST_F(SymbolsCollector, CollectSourceDependencies)
TEST_F(SymbolsCollector, IsClassSymbol)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_symbolkind.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_symbolkind.cpp"), {"cc"});
collector.collectSymbols();
@@ -638,7 +638,7 @@ TEST_F(SymbolsCollector, IsClassSymbol)
TEST_F(SymbolsCollector, IsStructSymbol)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_symbolkind.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_symbolkind.cpp"), {"cc"});
collector.collectSymbols();
@@ -652,7 +652,7 @@ TEST_F(SymbolsCollector, IsStructSymbol)
TEST_F(SymbolsCollector, IsEnumerationSymbol)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_symbolkind.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_symbolkind.cpp"), {"cc"});
collector.collectSymbols();
@@ -670,7 +670,7 @@ TEST_F(SymbolsCollector, IsEnumerationSymbol)
TEST_F(SymbolsCollector, IsUnionSymbol)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_symbolkind.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_symbolkind.cpp"), {"cc"});
collector.collectSymbols();
@@ -684,7 +684,7 @@ TEST_F(SymbolsCollector, IsUnionSymbol)
TEST_F(SymbolsCollector, DISABLED_ON_NON_WINDOWS(IsMsvcInterfaceSymbol))
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_symbolkind.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_symbolkind.cpp"), {"cc"});
collector.collectSymbols();
@@ -698,7 +698,7 @@ TEST_F(SymbolsCollector, DISABLED_ON_NON_WINDOWS(IsMsvcInterfaceSymbol))
TEST_F(SymbolsCollector, IsFunctionSymbol)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_symbolkind.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_symbolkind.cpp"), {"cc"});
collector.collectSymbols();
@@ -711,7 +711,7 @@ TEST_F(SymbolsCollector, IsFunctionSymbol)
TEST_F(SymbolsCollector, IsVariableSymbol)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_symbolkind.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_symbolkind.cpp"), {"cc"});
collector.collectSymbols();
@@ -724,7 +724,7 @@ TEST_F(SymbolsCollector, IsVariableSymbol)
TEST_F(SymbolsCollector, IndexUnmodifiedHeaderFilesAtFirstRun)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_unmodified.cpp")}, {"cc", "-I", {TESTDATA_DIR, "/include"}});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_unmodified.cpp"), {"cc", "-I", {TESTDATA_DIR, "/include"}});
collector.collectSymbols();
@@ -741,10 +741,10 @@ TEST_F(SymbolsCollector, IndexUnmodifiedHeaderFilesAtFirstRun)
TEST_F(SymbolsCollector, DontIndexUnmodifiedHeaderFilesAtSecondRun)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_unmodified.cpp")}, {"cc", "-I", {TESTDATA_DIR, "/include"}});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_unmodified.cpp"), {"cc", "-I", {TESTDATA_DIR, "/include"}});
collector.collectSymbols();
collector.clear();
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_unmodified2.cpp")}, {"cc", "-I", {TESTDATA_DIR, "/include"}});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_unmodified2.cpp"), {"cc", "-I", {TESTDATA_DIR, "/include"}});
collector.collectSymbols();
@@ -760,11 +760,11 @@ TEST_F(SymbolsCollector, DontIndexUnmodifiedHeaderFilesAtSecondRun)
TEST_F(SymbolsCollector, DontIndexUnmodifiedHeaderFilesAtTouchHeader)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_unmodified3.cpp")}, {"cc", "-I", {TESTDATA_DIR, "/include"}});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_unmodified3.cpp"), {"cc", "-I", {TESTDATA_DIR, "/include"}});
collector.collectSymbols();
collector.clear();
touchFile(TESTDATA_DIR "/include/symbolscollector_unmodified_header2.h");
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_unmodified3.cpp")}, {"cc", "-I", {TESTDATA_DIR, "/include"}});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_unmodified3.cpp"), {"cc", "-I", {TESTDATA_DIR, "/include"}});
collector.collectSymbols();
@@ -780,7 +780,7 @@ TEST_F(SymbolsCollector, DontIndexUnmodifiedHeaderFilesAtTouchHeader)
TEST_F(SymbolsCollector, DontIndexSystemIncudes)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_unmodified.cpp")}, {"cc", "-isystem", {TESTDATA_DIR, "/include"}});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_unmodified.cpp"), {"cc", "-isystem", {TESTDATA_DIR, "/include"}});
collector.collectSymbols();
diff --git a/tests/unit/unittest/symbolscollectormanager-test.cpp b/tests/unit/unittest/symbolscollectormanager-test.cpp
index 18b210b80a..3a740b1e89 100644
--- a/tests/unit/unittest/symbolscollectormanager-test.cpp
+++ b/tests/unit/unittest/symbolscollectormanager-test.cpp
@@ -38,7 +38,8 @@ class SymbolsCollectorManager : public testing::Test
protected:
Sqlite::Database database{":memory:", Sqlite::JournalMode::Memory};
ClangBackEnd::RefactoringDatabaseInitializer<Sqlite::Database> initializer{database};
- ClangBackEnd::SymbolsCollectorManager<NiceMock<MockSymbolsCollector>> manager{database};
+ ClangBackEnd::GeneratedFiles generatedFiles;
+ ClangBackEnd::SymbolsCollectorManager<NiceMock<MockSymbolsCollector>> manager{database, generatedFiles};
};
TEST_F(SymbolsCollectorManager, CreateUnsedSystemCollector)
@@ -77,4 +78,21 @@ TEST_F(SymbolsCollectorManager, AsGetReusedUnusedSymbolsCollectorItIsSetUsed)
ASSERT_TRUE(collector2.isUsed());
}
+TEST_F(SymbolsCollectorManager, UnusedSystemCollectorIsInitializedWithUnsavedFiles)
+{
+ auto &collector = manager.unusedSymbolsCollector();
+
+ ASSERT_TRUE(collector.hasUnsavedFiles);
+}
+
+TEST_F(SymbolsCollectorManager, ReusedSystemCollectorIsInitializedWithUnsavedFiles)
+{
+ auto &collector = manager.unusedSymbolsCollector();
+ collector.setIsUsed(false);
+
+ auto &collector2 = manager.unusedSymbolsCollector();
+
+ ASSERT_TRUE(collector2.hasUnsavedFiles);
+}
+
}
diff --git a/tests/unit/unittest/unittest.pro b/tests/unit/unittest/unittest.pro
index c0ae7bd230..4ca129f0df 100644
--- a/tests/unit/unittest/unittest.pro
+++ b/tests/unit/unittest/unittest.pro
@@ -14,7 +14,10 @@ OBJECTS_DIR = $$OUT_PWD/obj # workaround for qmake bug in object_parallel_to_sou
!msvc:force_debug_info:QMAKE_CXXFLAGS += -fno-omit-frame-pointer
DEFINES += \
+ QT_NO_CAST_TO_ASCII \
QT_RESTRICTED_CAST_FROM_ASCII \
+ QT_USE_FAST_OPERATOR_PLUS \
+ QT_USE_FAST_CONCATENATION \
UNIT_TESTS \
DONT_CHECK_MESSAGE_COUNTER \
TESTDATA_DIR=\"R\\\"xxx($$PWD/data)xxx\\\"\"