11use super :: * ;
22use crate :: index:: { Index , IndexItem } ;
33use alloy_scope:: { ScopeIdx , Scopes } ;
4- use rustc_hash:: FxHashMap ;
4+ use rustc_hash:: { FxHashMap , FxHashSet } ;
55use text_size:: TextRange ;
66
77#[ derive( Debug , Clone , PartialEq ) ]
@@ -23,6 +23,7 @@ pub struct HirModule {
2323 behaviors : Index < Behavior , ( TypeIdx , TypeIdx ) > ,
2424 value_definitions : FxHashMap < ExpressionIdx , ValueDefinition > ,
2525 expression_groups : Vec < Vec < ExpressionIdx > > ,
26+ expression_dependencies : FxHashMap < ExpressionIdx , FxHashSet < ExpressionIdx > > ,
2627 scopes : Scopes ,
2728 warnings : Vec < LoweringWarning > ,
2829 errors : Vec < LoweringError > ,
@@ -76,6 +77,7 @@ impl HirModule {
7677 behaviors : Default :: default ( ) ,
7778 value_definitions : Default :: default ( ) ,
7879 expression_groups : Vec :: new ( ) ,
80+ expression_dependencies : Default :: default ( ) ,
7981 scopes : Default :: default ( ) ,
8082 warnings : Vec :: new ( ) ,
8183 errors : Vec :: new ( ) ,
@@ -94,6 +96,7 @@ impl HirModule {
9496 behaviors : Index < Behavior , ( TypeIdx , TypeIdx ) > ,
9597 value_definitions : FxHashMap < ExpressionIdx , ValueDefinition > ,
9698 expression_groups : Vec < Vec < ExpressionIdx > > ,
99+ expression_dependencies : FxHashMap < ExpressionIdx , FxHashSet < ExpressionIdx > > ,
97100 scopes : Scopes ,
98101 warnings : Vec < LoweringWarning > ,
99102 errors : Vec < LoweringError > ,
@@ -109,6 +112,7 @@ impl HirModule {
109112 behaviors,
110113 value_definitions,
111114 expression_groups,
115+ expression_dependencies,
112116 scopes,
113117 warnings,
114118 errors,
@@ -224,6 +228,13 @@ impl HirModule {
224228 self . expressions . get ( idx)
225229 }
226230
231+ pub fn get_expression_dependencies ( & self , idx : ExpressionIdx ) -> FxHashSet < ExpressionIdx > {
232+ self . expression_dependencies
233+ . get ( & idx)
234+ . cloned ( )
235+ . unwrap_or_default ( )
236+ }
237+
227238 pub fn get_expression_range ( & self , idx : ExpressionIdx ) -> TextRange {
228239 self . expressions . get_range ( idx)
229240 }
0 commit comments