@@ -5,7 +5,7 @@ use forge_lint::{
55 sol:: { SolLint , SolLintError , SolidityLinter } ,
66} ;
77use foundry_cli:: {
8- opts:: BuildOpts ,
8+ opts:: { BuildOpts , configure_pcx_from_solc , get_solar_sources_from_compile_output } ,
99 utils:: { FoundryPathExt , LoadConfig } ,
1010} ;
1111use foundry_common:: { compile:: ProjectCompiler , shell} ;
@@ -69,15 +69,15 @@ impl LintArgs {
6969 } else if path. is_sol ( ) {
7070 inputs. push ( path. to_path_buf ( ) ) ;
7171 } else {
72- warn ! ( "Cannot process path {}" , path. display( ) ) ;
72+ warn ! ( "cannot process path {}" , path. display( ) ) ;
7373 }
7474 }
7575 inputs
7676 }
7777 } ;
7878
7979 if input. is_empty ( ) {
80- sh_println ! ( "Nothing to lint" ) ?;
80+ sh_println ! ( "nothing to lint" ) ?;
8181 return Ok ( ( ) ) ;
8282 }
8383
@@ -95,7 +95,7 @@ impl LintArgs {
9595 let severity = self . severity . unwrap_or ( config. lint . severity . clone ( ) ) ;
9696
9797 if project. compiler . solc . is_none ( ) {
98- return Err ( eyre ! ( "Linting not supported for this language" ) ) ;
98+ return Err ( eyre ! ( "linting not supported for this language" ) ) ;
9999 }
100100
101101 let linter = SolidityLinter :: new ( path_config)
@@ -107,7 +107,19 @@ impl LintArgs {
107107 . with_mixed_case_exceptions ( & config. lint . mixed_case_exceptions ) ;
108108
109109 let mut output = ProjectCompiler :: new ( ) . files ( input. iter ( ) . cloned ( ) ) . compile ( & project) ?;
110+ let solar_sources = get_solar_sources_from_compile_output ( & config, & output, Some ( & input) ) ?;
111+ if solar_sources. input . sources . is_empty ( ) {
112+ return Err ( eyre ! (
113+ "unable to lint. Solar only supports Solidity versions prior to 0.8.0"
114+ ) ) ;
115+ }
116+
110117 let compiler = output. parser_mut ( ) . solc_mut ( ) . compiler_mut ( ) ;
118+ compiler. enter_mut ( |compiler| {
119+ compiler. drop_asts ( ) ;
120+ let mut pcx = compiler. parse ( ) ;
121+ configure_pcx_from_solc ( & mut pcx, & config. project_paths ( ) , & solar_sources, true ) ;
122+ } ) ;
111123 linter. lint ( & input, config. deny , compiler) ?;
112124
113125 Ok ( ( ) )
0 commit comments