Store indices to disk (#279)

This commit is contained in:
ykiko
2025-10-19 21:53:57 +08:00
committed by GitHub
parent eda7f03a37
commit dffa884e5a
22 changed files with 979 additions and 514 deletions

View File

@@ -58,7 +58,7 @@ suite<"MergedIndex"> suite = [] {
auto& graph = tu_index.graph;
for(auto& [fid, index]: tu_index.file_indices) {
llvm::StringRef path = graph.paths[graph.path_id(fid)];
merged_indices[path].merge("main.cpp", graph.include_location_id(fid), index);
merged_indices[path].merge(0, graph.include_location_id(fid), index);
}
for(auto& [path, merged]: merged_indices) {
@@ -67,10 +67,8 @@ suite<"MergedIndex"> suite = [] {
merged.serialize(os);
index::MergedIndexView view(s.data());
auto merged2 = view.deserialize();
expect(merged == merged2);
auto view = index::MergedIndex(s);
expect(merged == view);
}
};
};

View File

View File

@@ -22,7 +22,8 @@ suite<"TUIndex"> suite = [] {
llvm::StringRef file = "") -> std::vector<index::Occurrence> {
auto offset = tester.point(pos, file);
auto fid = file.empty() ? tester.unit->interested_file() : tester.unit->file_id(file);
auto& index = tu_index.file_indices[fid];
auto& index = fid == tester.unit->interested_file() ? tu_index.main_file_index
: tu_index.file_indices[fid];
auto it = std::ranges::lower_bound(
index.occurrences,
@@ -74,7 +75,8 @@ suite<"TUIndex"> suite = [] {
dump(range));
auto fid = file.empty() ? tester.unit->interested_file() : tester.unit->file_id(file);
auto& index = tu_index.file_indices[fid];
auto& index = fid == tester.unit->interested_file() ? tu_index.main_file_index
: tu_index.file_indices[fid];
auto it = index.relations.find(occurrences.front().target);
fatal / expect(it != index.relations.end(), location)
@@ -98,8 +100,7 @@ suite<"TUIndex"> suite = [] {
}
)");
expect(eq(tu_index.file_indices.size(), 1));
auto& index = tu_index.file_indices.begin()->second;
auto& index = tu_index.main_file_index;
expect(eq(index.relations.size(), 2));
expect(eq(index.occurrences.size(), 3));