@@ -249,31 +249,6 @@ impl<T> Spanned<T> {
249249 }
250250}
251251
252- /// Capture the import statement information together with aliases
253- pub fn capture_imports ( content : & str ) -> Vec < Spanned < SolImport > > {
254- let mut imports = vec ! [ ] ;
255- for cap in utils:: RE_SOL_IMPORT . captures_iter ( content) {
256- if let Some ( name_match) = [ "p1" , "p2" , "p3" , "p4" ] . iter ( ) . find_map ( |name| cap. name ( name) ) {
257- let statement_match = cap. get ( 0 ) . unwrap ( ) ;
258- let mut aliases = vec ! [ ] ;
259- for alias_cap in utils:: RE_SOL_IMPORT_ALIAS . captures_iter ( statement_match. as_str ( ) ) {
260- if let Some ( alias) = alias_cap. name ( "alias" ) {
261- let alias = alias. as_str ( ) . to_owned ( ) ;
262- let import_alias = match alias_cap. name ( "target" ) {
263- Some ( target) => SolImportAlias :: Contract ( alias, target. as_str ( ) . to_owned ( ) ) ,
264- None => SolImportAlias :: File ( alias) ,
265- } ;
266- aliases. push ( import_alias) ;
267- }
268- }
269- let sol_import =
270- SolImport :: new ( PathBuf :: from ( name_match. as_str ( ) ) ) . set_aliases ( aliases) ;
271- imports. push ( Spanned :: new ( sol_import, statement_match. range ( ) ) ) ;
272- }
273- }
274- imports
275- }
276-
277252fn library_is_inlined ( contract : & ast:: ItemContract < ' _ > ) -> bool {
278253 contract
279254 . body
@@ -289,59 +264,3 @@ fn library_is_inlined(contract: &ast::ItemContract<'_>) -> bool {
289264 )
290265 } )
291266}
292-
293- #[ cfg( test) ]
294- mod tests {
295- use super :: * ;
296-
297- #[ test]
298- fn can_capture_curly_imports ( ) {
299- let content = r#"
300- import { T } from "../Test.sol";
301- import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
302- import {DsTest} from "ds-test/test.sol";
303- "# ;
304-
305- let captured_imports =
306- capture_imports ( content) . into_iter ( ) . map ( |s| s. data . path ) . collect :: < Vec < _ > > ( ) ;
307-
308- let expected =
309- utils:: find_import_paths ( content) . map ( |m| m. as_str ( ) . into ( ) ) . collect :: < Vec < PathBuf > > ( ) ;
310-
311- assert_eq ! ( captured_imports, expected) ;
312-
313- assert_eq ! (
314- captured_imports,
315- vec![
316- PathBuf :: from( "../Test.sol" ) ,
317- "@openzeppelin/contracts/utils/ReentrancyGuard.sol" . into( ) ,
318- "ds-test/test.sol" . into( ) ,
319- ]
320- ) ;
321- }
322-
323- #[ test]
324- fn cap_capture_aliases ( ) {
325- let content = r#"
326- import * as T from "./Test.sol";
327- import { DsTest as Test } from "ds-test/test.sol";
328- import "ds-test/test.sol" as Test;
329- import { FloatMath as Math, Math as FloatMath } from "./Math.sol";
330- "# ;
331-
332- let caputred_imports =
333- capture_imports ( content) . into_iter ( ) . map ( |s| s. data . aliases ) . collect :: < Vec < _ > > ( ) ;
334- assert_eq ! (
335- caputred_imports,
336- vec![
337- vec![ SolImportAlias :: File ( "T" . into( ) ) ] ,
338- vec![ SolImportAlias :: Contract ( "Test" . into( ) , "DsTest" . into( ) ) ] ,
339- vec![ SolImportAlias :: File ( "Test" . into( ) ) ] ,
340- vec![
341- SolImportAlias :: Contract ( "Math" . into( ) , "FloatMath" . into( ) ) ,
342- SolImportAlias :: Contract ( "FloatMath" . into( ) , "Math" . into( ) ) ,
343- ] ,
344- ]
345- ) ;
346- }
347- }
0 commit comments