forked from qt-creator/qt-creator
QmlDesigner: Remove SourcePathCache::sourceContextAndSourceId()
SourcePathCache::sourceId() already contains the source id. Change-Id: I2ba783aea99af4d54c1beeda250f9b5e8f2460f4 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io> Reviewed-by: Burak Hancerli <burak.hancerli@qt.io>
This commit is contained in:
committed by
Thomas Hartmann
parent
8862233fb8
commit
72faa129c3
@@ -594,7 +594,8 @@ void ProjectStorageUpdater::updateDirectory(const Utils::PathString &directoryPa
|
||||
NanotraceHR::Tracer tracer{"update directory", category(), keyValue("directory", directoryPath)};
|
||||
|
||||
SourcePath qmldirPath{directoryPath + "/qmldir"};
|
||||
auto [directoryId, qmldirSourceId] = m_pathCache.sourceContextAndSourceId(qmldirPath);
|
||||
SourceId qmldirSourceId = m_pathCache.sourceId(qmldirPath);
|
||||
SourceContextId directoryId = qmldirSourceId.contextId();
|
||||
|
||||
auto directoryState = fileState(directoryId, package, notUpdatedSourceIds);
|
||||
if (isExisting(directoryState))
|
||||
|
@@ -49,8 +49,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<SourceContextId, SourceId> sourceContextAndSourceId(
|
||||
SourcePathView sourcePath) const override
|
||||
SourceId sourceId(SourcePathView sourcePath) const override
|
||||
{
|
||||
Utils::SmallStringView sourceContextPath = sourcePath.directory();
|
||||
|
||||
@@ -60,12 +59,7 @@ public:
|
||||
|
||||
auto sourceId = m_sourcePathCache.id(sourceName);
|
||||
|
||||
return {sourceContextId, SourceId::create(sourceId, sourceContextId)};
|
||||
}
|
||||
|
||||
SourceId sourceId(SourcePathView sourcePath) const override
|
||||
{
|
||||
return sourceContextAndSourceId(sourcePath).second;
|
||||
return SourceId::create(sourceId, sourceContextId);
|
||||
}
|
||||
|
||||
SourceId sourceId(SourceContextId sourceContextId,
|
||||
|
@@ -22,9 +22,6 @@ public:
|
||||
|
||||
virtual void populateIfEmpty() = 0;
|
||||
|
||||
virtual std::pair<SourceContextId, SourceId>
|
||||
sourceContextAndSourceId(SourcePathView sourcePath) const = 0;
|
||||
|
||||
virtual SourceId sourceId(SourcePathView sourcePath) const = 0;
|
||||
|
||||
virtual SourceId sourceId(SourceContextId sourceContextId,
|
||||
|
@@ -32,11 +32,6 @@ public:
|
||||
sourceContextId,
|
||||
(Utils::SmallStringView directoryPath),
|
||||
(const, override));
|
||||
using SourceContextAndSourceId = std::pair<QmlDesigner::SourceContextId, QmlDesigner::SourceId>;
|
||||
MOCK_METHOD(SourceContextAndSourceId,
|
||||
sourceContextAndSourceId,
|
||||
(QmlDesigner::SourcePathView sourcePath),
|
||||
(const, override));
|
||||
MOCK_METHOD(Utils::PathString,
|
||||
sourceContextPath,
|
||||
(QmlDesigner::SourceContextId directoryPathId),
|
||||
|
@@ -372,89 +372,4 @@ TEST_F(SourcePathCache, get_file_path_after_populate_if_empty)
|
||||
ASSERT_THAT(path, Eq("/path/to/file.cpp"));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, source_context_and_source_id_with_out_any_entry_call_source_context_id)
|
||||
{
|
||||
EXPECT_CALL(storageMock, fetchSourceContextId(Eq("/path/to")));
|
||||
|
||||
cache.sourceContextAndSourceId(SourcePathView("/path/to/file.cpp"));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, source_context_and_source_id_with_out_any_entry_calls)
|
||||
{
|
||||
EXPECT_CALL(storageMock, fetchSourceNameId(Eq("file.cpp")));
|
||||
|
||||
cache.sourceContextAndSourceId(SourcePathView("/path/to/file.cpp"));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, source_context_and_source_id_of_source_id_with_out_any_entry)
|
||||
{
|
||||
SourcePathView path("/path/to/file.cpp");
|
||||
|
||||
auto sourceId = cache.sourceId(path);
|
||||
|
||||
ASSERT_THAT(sourceId.contextId(), sourceContextId5);
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, source_context_and_source_id_if_entry_exists_dont_call_in_strorage)
|
||||
{
|
||||
cache.sourceContextAndSourceId(SourcePathView("/path/to/file.cpp"));
|
||||
|
||||
EXPECT_CALL(storageMock, fetchSourceContextId(Eq("/path/to"))).Times(0);
|
||||
EXPECT_CALL(storageMock, fetchSourceNameId(Eq("file.cpp"))).Times(0);
|
||||
|
||||
cache.sourceContextAndSourceId(SourcePathView("/path/to/file.cpp"));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache,
|
||||
source_context_and_source_id_if_directory_entry_exists_dont_call_fetch_source_context_id_but_still_call_fetch_source_id)
|
||||
{
|
||||
cache.sourceContextAndSourceId(SourcePathView("/path/to/file2.cpp"));
|
||||
|
||||
EXPECT_CALL(storageMock, fetchSourceContextId(Eq("/path/to"))).Times(0);
|
||||
EXPECT_CALL(storageMock, fetchSourceNameId(Eq("file.cpp")));
|
||||
|
||||
cache.sourceContextAndSourceId(SourcePathView("/path/to/file.cpp"));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, source_context_and_source_id_get_source_id_with_cached_value)
|
||||
{
|
||||
cache.sourceContextAndSourceId(SourcePathView("/path/to/file.cpp"));
|
||||
|
||||
auto sourceId = cache.sourceContextAndSourceId(SourcePathView("/path/to/file.cpp"));
|
||||
|
||||
ASSERT_THAT(sourceId, Pair(sourceContextId5, sourceId542));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, get_source_context_and_source_id_with_source_context_id_cached)
|
||||
{
|
||||
cache.sourceContextAndSourceId(SourcePathView("/path/to/file.cpp"));
|
||||
|
||||
auto sourceContextAndSourceId = cache.sourceContextAndSourceId(
|
||||
SourcePathView("/path/to/file2.cpp"));
|
||||
|
||||
ASSERT_THAT(sourceContextAndSourceId, Pair(sourceContextId5, sourceId563));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, get_source_context_and_source_id_file_names_are_unique_for_every_directory)
|
||||
{
|
||||
auto sourceContextAndSourceId = cache.sourceContextAndSourceId(
|
||||
SourcePathView("/path/to/file.cpp"));
|
||||
|
||||
auto sourceContextAndSourceId2 = cache.sourceContextAndSourceId(
|
||||
SourcePathView("/path2/to/file.cpp"));
|
||||
|
||||
ASSERT_THAT(sourceContextAndSourceId, Ne(sourceContextAndSourceId2));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, get_source_context_and_source_id_duplicate_file_paths_are_equal)
|
||||
{
|
||||
auto sourceContextAndSourceId = cache.sourceContextAndSourceId(
|
||||
SourcePathView("/path/to/file.cpp"));
|
||||
|
||||
auto sourceContextAndSourceId2 = cache.sourceContextAndSourceId(
|
||||
SourcePathView("/path/to/file.cpp"));
|
||||
|
||||
ASSERT_THAT(sourceContextAndSourceId, Eq(sourceContextAndSourceId2));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
Reference in New Issue
Block a user