mirror of
				https://github.com/rust-lang/rust-analyzer.git
				synced 2025-10-31 03:54:42 +00:00 
			
		
		
		
	In extract_module.rs, generate ast::Module instead of String
This commit is contained in:
		
							parent
							
								
									529d3b935d
								
							
						
					
					
						commit
						fcd4010b03
					
				
					 2 changed files with 126 additions and 66 deletions
				
			
		|  | @ -231,6 +231,23 @@ pub fn ty_fn_ptr<I: Iterator<Item = Param>>( | |||
|     } | ||||
| } | ||||
| 
 | ||||
| pub fn item_list(body: Option<Vec<ast::Item>>) -> ast::ItemList { | ||||
|     let is_break_braces = body.is_some(); | ||||
|     let body_newline = if is_break_braces { "\n" } else { "" }; | ||||
|     let body_indent = if is_break_braces { "    " } else { "" }; | ||||
| 
 | ||||
|     let body = match body { | ||||
|         Some(bd) => bd.iter().map(|elem| elem.to_string()).join("\n\n    "), | ||||
|         None => String::new(), | ||||
|     }; | ||||
|     ast_from_text(&format!("mod C {{{body_newline}{body_indent}{body}{body_newline}}}")) | ||||
| } | ||||
| 
 | ||||
| pub fn mod_(name: ast::Name, body: Option<ast::ItemList>) -> ast::Module { | ||||
|     let body = body.map_or(";".to_owned(), |body| format!(" {body}")); | ||||
|     ast_from_text(&format!("mod {name}{body}")) | ||||
| } | ||||
| 
 | ||||
| pub fn assoc_item_list(body: Option<Vec<ast::AssocItem>>) -> ast::AssocItemList { | ||||
|     let is_break_braces = body.is_some(); | ||||
|     let body_newline = if is_break_braces { "\n".to_owned() } else { String::new() }; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Hmikihiro
						Hmikihiro