Clang: Use PathString in more cases

Change-Id: I7bee469256a79b384bf7b8c1d5355f1df11c7b24
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Marco Bubke
2017-02-01 14:51:57 +01:00
parent 01a96537a8
commit 8f93ec3020
9 changed files with 20 additions and 20 deletions

View File

@@ -103,7 +103,7 @@ int main(int argc, char *argv[])
const QString connection = processArguments(application); const QString connection = processArguments(application);
StringCache<Utils::SmallString> filePathCache; StringCache<Utils::PathString> filePathCache;
ClangPathWatcher<QFileSystemWatcher, QTimer> includeWatcher(filePathCache); ClangPathWatcher<QFileSystemWatcher, QTimer> includeWatcher(filePathCache);
ApplicationEnvironment environment; ApplicationEnvironment environment;
PchGenerator<QProcess> pchGenerator(environment); PchGenerator<QProcess> pchGenerator(environment);

View File

@@ -55,12 +55,12 @@ public:
restartTimer(); restartTimer();
} }
Utils::SmallStringVector takeFilePaths() Utils::PathStringVector takeFilePaths()
{ {
return std::move(m_filePaths); return std::move(m_filePaths);
} }
virtual void setCallback(std::function<void(Utils::SmallStringVector &&)> &&callback) virtual void setCallback(std::function<void(Utils::PathStringVector &&)> &&callback)
{ {
QObject::connect(&m_timer, QObject::connect(&m_timer,
&Timer::timeout, &Timer::timeout,
@@ -79,7 +79,7 @@ unitttest_public:
} }
private: private:
Utils::SmallStringVector m_filePaths; Utils::PathStringVector m_filePaths;
Timer m_timer; Timer m_timer;
}; };

View File

@@ -68,7 +68,7 @@ template <typename FileSystemWatcher,
class ClangPathWatcher : public ClangPathWatcherInterface class ClangPathWatcher : public ClangPathWatcherInterface
{ {
public: public:
ClangPathWatcher(StringCache<Utils::SmallString> &pathCache, ClangPathWatcher(StringCache<Utils::PathString> &pathCache,
ClangPathWatcherNotifier *notifier=nullptr) ClangPathWatcherNotifier *notifier=nullptr)
: m_pathCache(pathCache), : m_pathCache(pathCache),
m_notifier(notifier) m_notifier(notifier)
@@ -77,14 +77,14 @@ public:
&FileSystemWatcher::fileChanged, &FileSystemWatcher::fileChanged,
[&] (const QString &filePath) { compressChangedFilePath(filePath); }); [&] (const QString &filePath) { compressChangedFilePath(filePath); });
m_changedFilePathCompressor.setCallback([&] (Utils::SmallStringVector &&filePaths) { m_changedFilePathCompressor.setCallback([&] (Utils::PathStringVector &&filePaths) {
addChangedPathForFilePath(std::move(filePaths)); addChangedPathForFilePath(std::move(filePaths));
}); });
} }
~ClangPathWatcher() ~ClangPathWatcher()
{ {
m_changedFilePathCompressor.setCallback([&] (Utils::SmallStringVector &&) {}); m_changedFilePathCompressor.setCallback([&] (Utils::PathStringVector &&) {});
} }
void updateIdPaths(const std::vector<IdPaths> &idPaths) override void updateIdPaths(const std::vector<IdPaths> &idPaths) override
@@ -366,7 +366,7 @@ unitttest_public:
m_changedFilePathCompressor.addFilePath(filePath); m_changedFilePathCompressor.addFilePath(filePath);
} }
WatcherEntries watchedEntriesForPaths(Utils::SmallStringVector &&filePaths) WatcherEntries watchedEntriesForPaths(Utils::PathStringVector &&filePaths)
{ {
std::vector<uint> pathIds = m_pathCache.stringIds(filePaths); std::vector<uint> pathIds = m_pathCache.stringIds(filePaths);
@@ -403,7 +403,7 @@ unitttest_public:
return std::move(ids); return std::move(ids);
} }
void addChangedPathForFilePath(Utils::SmallStringVector &&filePaths) void addChangedPathForFilePath(Utils::PathStringVector &&filePaths)
{ {
if (m_notifier) { if (m_notifier) {
WatcherEntries foundEntries = watchedEntriesForPaths(std::move(filePaths)); WatcherEntries foundEntries = watchedEntriesForPaths(std::move(filePaths));
@@ -414,7 +414,7 @@ unitttest_public:
} }
} }
StringCache<Utils::SmallString> &pathCache() StringCache<Utils::PathString> &pathCache()
{ {
return m_pathCache; return m_pathCache;
} }
@@ -429,7 +429,7 @@ private:
WatcherEntries m_watchedEntries; WatcherEntries m_watchedEntries;
ChangedFilePathCompressor<Timer> m_changedFilePathCompressor; ChangedFilePathCompressor<Timer> m_changedFilePathCompressor;
FileSystemWatcher m_fileSystemWatcher; FileSystemWatcher m_fileSystemWatcher;
StringCache<Utils::SmallString> &m_pathCache; StringCache<Utils::PathString> &m_pathCache;
ClangPathWatcherNotifier *m_notifier; ClangPathWatcherNotifier *m_notifier;
}; };

View File

@@ -36,7 +36,7 @@
namespace ClangBackEnd { namespace ClangBackEnd {
PchManagerServer::PchManagerServer(StringCache<Utils::SmallString> &filePathCache, PchManagerServer::PchManagerServer(StringCache<Utils::PathString> &filePathCache,
ClangPathWatcherInterface &fileSystemWatcher, ClangPathWatcherInterface &fileSystemWatcher,
PchCreatorInterface &pchCreator, PchCreatorInterface &pchCreator,
ProjectPartsInterface &projectParts) ProjectPartsInterface &projectParts)

View File

@@ -42,7 +42,7 @@ class PchManagerServer : public PchManagerServerInterface,
public PchGeneratorNotifierInterface public PchGeneratorNotifierInterface
{ {
public: public:
PchManagerServer(StringCache<Utils::SmallString> &filePathCache, PchManagerServer(StringCache<Utils::PathString> &filePathCache,
ClangPathWatcherInterface &fileSystemWatcher, ClangPathWatcherInterface &fileSystemWatcher,
PchCreatorInterface &pchCreator, PchCreatorInterface &pchCreator,
ProjectPartsInterface &projectParts); ProjectPartsInterface &projectParts);
@@ -56,7 +56,7 @@ public:
void taskFinished(TaskFinishStatus status, const ProjectPartPch &projectPartPch) override; void taskFinished(TaskFinishStatus status, const ProjectPartPch &projectPartPch) override;
private: private:
StringCache<Utils::SmallString> &m_filePathCache; StringCache<Utils::PathString> &m_filePathCache;
ClangPathWatcherInterface &m_fileSystemWatcher; ClangPathWatcherInterface &m_fileSystemWatcher;
PchCreatorInterface &m_pchCreator; PchCreatorInterface &m_pchCreator;
ProjectPartsInterface &m_projectParts; ProjectPartsInterface &m_projectParts;

View File

@@ -79,7 +79,7 @@ TEST_F(ChangedFilePathCompressor, CallTimeOutAfterAddingPath)
void ChangedFilePathCompressor::SetUp() void ChangedFilePathCompressor::SetUp()
{ {
compressor.setCallback([&] (Utils::SmallStringVector &&filePaths) { compressor.setCallback([&] (Utils::PathStringVector &&filePaths) {
mockCompressor.callbackCalled(filePaths); mockCompressor.callbackCalled(filePaths);
}); });
} }

View File

@@ -46,15 +46,15 @@ using ClangBackEnd::WatcherEntry;
class ClangPathWatcher : public testing::Test class ClangPathWatcher : public testing::Test
{ {
protected: protected:
ClangBackEnd::StringCache<Utils::SmallString> pathCache; ClangBackEnd::StringCache<Utils::PathString> pathCache;
NiceMock<MockClangPathWatcherNotifier> notifier; NiceMock<MockClangPathWatcherNotifier> notifier;
Watcher watcher{pathCache, &notifier}; Watcher watcher{pathCache, &notifier};
NiceMock<MockQFileSytemWatcher> &mockQFileSytemWatcher = watcher.fileSystemWatcher(); NiceMock<MockQFileSytemWatcher> &mockQFileSytemWatcher = watcher.fileSystemWatcher();
Utils::SmallString id1{"id4"}; Utils::SmallString id1{"id4"};
Utils::SmallString id2{"id2"}; Utils::SmallString id2{"id2"};
Utils::SmallString id3{"id3"}; Utils::SmallString id3{"id3"};
Utils::SmallString path1{"/path/path1"}; Utils::PathString path1{"/path/path1"};
Utils::SmallString path2{"/path/path2"}; Utils::PathString path2{"/path/path2"};
std::vector<uint> paths = watcher.pathCache().stringIds({path1, path2}); std::vector<uint> paths = watcher.pathCache().stringIds({path1, path2});
std::vector<uint> ids = watcher.idCache().stringIds({id1, id2, id3}); std::vector<uint> ids = watcher.idCache().stringIds({id1, id2, id3});
WatcherEntry watcherEntry1{ids[0], paths[0]}; WatcherEntry watcherEntry1{ids[0], paths[0]};

View File

@@ -38,6 +38,6 @@ public:
void ()); void ());
MOCK_METHOD1(callbackCalled, MOCK_METHOD1(callbackCalled,
void (const Utils::SmallStringVector &filePaths)); void (const Utils::PathStringVector &filePaths));
}; };

View File

@@ -59,7 +59,7 @@ protected:
NiceMock<MockPchCreator> mockPchCreator; NiceMock<MockPchCreator> mockPchCreator;
NiceMock<MockClangPathWatcher> mockClangPathWatcher; NiceMock<MockClangPathWatcher> mockClangPathWatcher;
NiceMock<MockProjectParts> mockProjectParts; NiceMock<MockProjectParts> mockProjectParts;
ClangBackEnd::StringCache<Utils::SmallString> filePathCache; ClangBackEnd::StringCache<Utils::PathString> filePathCache;
ClangBackEnd::PchManagerServer server{filePathCache, mockClangPathWatcher, mockPchCreator, mockProjectParts}; ClangBackEnd::PchManagerServer server{filePathCache, mockClangPathWatcher, mockPchCreator, mockProjectParts};
NiceMock<MockPchManagerClient> mockPchManagerClient; NiceMock<MockPchManagerClient> mockPchManagerClient;
SmallString projectPartId1 = "project1"; SmallString projectPartId1 = "project1";