Skip to content

Commit 2b9316b

Browse files
committed
Add incremental invalidation engine
Introduces a worklist-based invalidation engine that cascades changes through the graph when documents are updated or deleted. Uses ChildName/NestedName edges from the name_dependents index to propagate invalidation with two distinct modes: - Structural cascade (UnresolveName): declaration removed or scope broken - Ancestor cascade (UnresolveReferences): ancestor chain changed Replaces the has_unresolved_dependency runtime check with explicit invalidation variants determined at queue time.
1 parent 13ca67a commit 2b9316b

6 files changed

Lines changed: 1416 additions & 135 deletions

File tree

rust/rubydex-sys/src/graph_api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ mod tests {
611611
indexer.index();
612612

613613
let mut graph = Graph::new();
614-
graph.update(indexer.local_graph());
614+
graph.consume_document_changes(indexer.local_graph());
615615
let mut resolver = Resolver::new(&mut graph);
616616
resolver.resolve_all();
617617

rust/rubydex/src/indexing.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl Job for IndexingJob {
9595
/// Indexes a single source string in memory, dispatching to the appropriate indexer based on `language_id`.
9696
pub fn index_source(graph: &mut Graph, uri: &str, source: &str, language_id: &LanguageId) {
9797
let local_graph = build_local_graph(uri.to_string(), source, language_id);
98-
graph.update(local_graph);
98+
graph.consume_document_changes(local_graph);
9999
}
100100

101101
/// Indexes the given paths, reading the content from disk and populating the given `Graph` instance.
@@ -123,7 +123,7 @@ pub fn index_files(graph: &mut Graph, paths: Vec<PathBuf>) -> Vec<Errors> {
123123

124124
// Merge graphs as they arrive, overlapping with indexing work on other threads.
125125
while let Ok(local_graph) = local_graphs_rx.recv() {
126-
graph.update(local_graph);
126+
graph.consume_document_changes(local_graph);
127127
}
128128

129129
for handle in handles {

rust/rubydex/src/model/declaration.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,10 @@ impl Namespace {
482482
all_namespaces!(self, it => it.member(str_id))
483483
}
484484

485+
pub fn remove_member(&mut self, str_id: &StringId) -> Option<DeclarationId> {
486+
all_namespaces!(self, it => it.remove_member(str_id))
487+
}
488+
485489
#[must_use]
486490
pub fn singleton_class(&self) -> Option<&DeclarationId> {
487491
all_namespaces!(self, it => it.singleton_class_id())

0 commit comments

Comments
 (0)