@@ -33,9 +33,6 @@ use ruff_python_parser::parse_expression_range;
3333use ruff_python_parser:: parse_unchecked_source;
3434use ruff_text_size:: TextRange ;
3535use ruff_text_size:: TextSize ;
36- use starlark_map:: small_map:: SmallMap ;
37-
38- use crate :: module:: module_name:: ModuleName ;
3936
4037/// Just used for convenient namespacing - not a real type
4138pub struct Ast ;
@@ -91,54 +88,6 @@ impl Ast {
9188 )
9289 }
9390
94- /// All the imports in this module, pointing to the first place that defines them.
95- pub fn imports (
96- module : & ModModule ,
97- module_name : ModuleName ,
98- is_init : bool ,
99- ) -> SmallMap < ModuleName , TextRange > {
100- fn stmts (
101- xs : & [ Stmt ] ,
102- module_name : ModuleName ,
103- is_init : bool ,
104- imports : & mut SmallMap < ModuleName , TextRange > ,
105- ) {
106- for x in xs {
107- stmt ( x, module_name, is_init, imports) ;
108- }
109- }
110- fn stmt (
111- x : & Stmt ,
112- module_name : ModuleName ,
113- is_init : bool ,
114- imports : & mut SmallMap < ModuleName , TextRange > ,
115- ) {
116- match x {
117- Stmt :: Import ( x) => {
118- for x in & x. names {
119- imports
120- . entry ( ModuleName :: from_name ( & x. name . id ) )
121- . or_insert ( x. name . range ) ;
122- }
123- }
124- Stmt :: ImportFrom ( x) => {
125- if let Some ( module_name) = module_name. new_maybe_relative (
126- is_init,
127- x. level ,
128- x. module . as_ref ( ) . map ( |x| & x. id ) ,
129- ) {
130- imports. entry ( module_name) . or_insert ( x. range ) ;
131- }
132- }
133- _ => { }
134- }
135- x. recurse ( & mut |xs| stmt ( xs, module_name, is_init, imports) ) ;
136- }
137- let mut imports = SmallMap :: new ( ) ;
138- stmts ( & module. body , module_name, is_init, & mut imports) ;
139- imports
140- }
141-
14291 /// Iterates over the branches of an if statement, returning the test and body.
14392 /// A test on `None` is an `else` branch that is always taken.
14493 pub fn if_branches ( x : & StmtIf ) -> impl Iterator < Item = ( Option < & Expr > , & [ Stmt ] ) > {
0 commit comments