diff --git a/Cargo.toml b/Cargo.toml index ebc76d0aa..006891b51 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,8 +54,7 @@ semver = { version = "1.0", features = ["serde"] } serde = { version = "1", features = ["derive", "rc"] } serde_json = "1.0" similar-asserts = "1" -solar-parse = { version = "=0.1.6", default-features = false } -solar-sema = { version = "=0.1.6", default-features = false } +solar = { package = "solar-compiler", version = "=0.1.6", default-features = false } svm = { package = "svm-rs", version = "0.5", default-features = false } tempfile = "3.20" thiserror = "2" @@ -70,7 +69,4 @@ tokio = { version = "1.47", features = ["rt-multi-thread"] } snapbox = "0.6.21" [patch.crates-io] -# solar-parse = { git = "https://github.com/paradigmxyz/solar", branch = "main" } -# solar-sema = { git = "https://github.com/paradigmxyz/solar", branch = "main" } -# solar-ast = { git = "https://github.com/paradigmxyz/solar", branch = "main" } -# solar-interface = { git = "https://github.com/paradigmxyz/solar", branch = "main" } +# solar = { package = "solar-compiler", git = "https://github.com/paradigmxyz/solar", branch = "main" } diff --git a/crates/compilers/Cargo.toml b/crates/compilers/Cargo.toml index dca0c1549..62ef396a0 100644 --- a/crates/compilers/Cargo.toml +++ b/crates/compilers/Cargo.toml @@ -31,8 +31,7 @@ rayon.workspace = true thiserror.workspace = true path-slash.workspace = true yansi.workspace = true -solar-parse.workspace = true -solar-sema.workspace = true +solar.workspace = true futures-util = { workspace = true, optional = true } tokio = { workspace = true, optional = true } diff --git a/crates/compilers/src/cache/iface.rs b/crates/compilers/src/cache/iface.rs index aea2e4393..1c49540e3 100644 --- a/crates/compilers/src/cache/iface.rs +++ b/crates/compilers/src/cache/iface.rs @@ -1,5 +1,5 @@ use crate::{parse_one_source, replace_source_content}; -use solar_parse::{ +use solar::parse::{ ast::{self, Span}, interface::diagnostics::EmittedDiagnostics, }; @@ -21,8 +21,8 @@ pub(crate) fn interface_repr(content: &str, path: &Path) -> Result, + sess: &solar::sema::interface::Session, + ast: &solar::parse::ast::SourceUnit<'_>, ) -> String { let mut spans_to_remove: Vec = Vec::new(); for item in ast.items.iter() { diff --git a/crates/compilers/src/compilers/solc/mod.rs b/crates/compilers/src/compilers/solc/mod.rs index ee31cf39c..6d6db9e48 100644 --- a/crates/compilers/src/compilers/solc/mod.rs +++ b/crates/compilers/src/compilers/solc/mod.rs @@ -369,14 +369,14 @@ impl SourceParser for SolParser { fn new(config: &crate::ProjectPathsConfig) -> Self { Self { - compiler: solar_sema::Compiler::new(Self::session_with_opts( - solar_sema::interface::config::Opts { + compiler: solar::sema::Compiler::new(Self::session_with_opts( + solar::sema::interface::config::Opts { include_paths: config.include_paths.iter().cloned().collect(), base_path: Some(config.root.clone()), import_remappings: config .remappings .iter() - .map(|r| solar_sema::interface::config::ImportRemapping { + .map(|r| solar::sema::interface::config::ImportRemapping { context: r.context.clone().unwrap_or_default(), prefix: r.name.clone(), path: r.path.clone(), diff --git a/crates/compilers/src/lib.rs b/crates/compilers/src/lib.rs index ad0ee4b7f..bac57fa43 100644 --- a/crates/compilers/src/lib.rs +++ b/crates/compilers/src/lib.rs @@ -64,7 +64,7 @@ use foundry_compilers_core::error::{Result, SolcError, SolcIoError}; use output::sources::{VersionedSourceFile, VersionedSourceFiles}; use project::ProjectCompiler; use semver::Version; -use solar_parse::{ +use solar::parse::{ interface::{diagnostics::EmittedDiagnostics, source_map::FileName, Session}, Parser, }; @@ -925,11 +925,11 @@ pub fn replace_source_content( pub(crate) fn parse_one_source( content: &str, path: &Path, - f: impl FnOnce(&Session, &solar_parse::ast::SourceUnit<'_>) -> R, + f: impl FnOnce(&Session, &solar::parse::ast::SourceUnit<'_>) -> R, ) -> Result { let sess = Session::builder().with_buffer_emitter(Default::default()).build(); - let res = sess.enter_sequential(|| -> solar_parse::interface::Result<_> { - let arena = solar_parse::ast::Arena::new(); + let res = sess.enter_sequential(|| -> solar::parse::interface::Result<_> { + let arena = solar::parse::ast::Arena::new(); let filename = FileName::Real(path.to_path_buf()); let mut parser = Parser::from_source_code(&sess, &arena, filename, content.to_string())?; let ast = parser.parse_file().map_err(|e| e.emit())?; diff --git a/crates/compilers/src/resolver/parse.rs b/crates/compilers/src/resolver/parse.rs index 26baf157a..2bb0189e6 100644 --- a/crates/compilers/src/resolver/parse.rs +++ b/crates/compilers/src/resolver/parse.rs @@ -1,7 +1,9 @@ use foundry_compilers_core::utils; use semver::VersionReq; -use solar_parse::{ast, interface::sym}; -use solar_sema::interface; +use solar::{ + parse::{ast, interface::sym}, + sema::interface, +}; use std::{ ops::Range, path::{Path, PathBuf}, @@ -9,7 +11,7 @@ use std::{ /// Solidity parser. /// -/// Holds a [`solar_sema::Compiler`] that is used to parse sources incrementally. +/// Holds a [`solar::sema::Compiler`] that is used to parse sources incrementally. /// After project compilation ([`Graph::resolve`]), this will contain all sources parsed by /// [`Graph`]. /// @@ -20,13 +22,13 @@ use std::{ #[derive(derive_more::Debug)] pub struct SolParser { #[debug(ignore)] - pub(crate) compiler: solar_sema::Compiler, + pub(crate) compiler: solar::sema::Compiler, } impl Clone for SolParser { fn clone(&self) -> Self { Self { - compiler: solar_sema::Compiler::new(Self::session_with_opts( + compiler: solar::sema::Compiler::new(Self::session_with_opts( self.compiler.sess().opts.clone(), )), } @@ -35,24 +37,24 @@ impl Clone for SolParser { impl SolParser { /// Returns a reference to the compiler. - pub fn compiler(&self) -> &solar_sema::Compiler { + pub fn compiler(&self) -> &solar::sema::Compiler { &self.compiler } /// Returns a mutable reference to the compiler. - pub fn compiler_mut(&mut self) -> &mut solar_sema::Compiler { + pub fn compiler_mut(&mut self) -> &mut solar::sema::Compiler { &mut self.compiler } /// Consumes the parser and returns the compiler. - pub fn into_compiler(self) -> solar_sema::Compiler { + pub fn into_compiler(self) -> solar::sema::Compiler { self.compiler } pub(crate) fn session_with_opts( - opts: solar_sema::interface::config::Opts, - ) -> solar_sema::interface::Session { - let sess = solar_sema::interface::Session::builder() + opts: solar::sema::interface::config::Opts, + ) -> solar::sema::interface::Session { + let sess = solar::sema::interface::Session::builder() .with_buffer_emitter(Default::default()) .opts(opts) .build(); @@ -137,8 +139,8 @@ impl SolData { } pub(crate) fn parse_from( - sess: &solar_sema::interface::Session, - s: &solar_sema::Source<'_>, + sess: &solar::sema::interface::Session, + s: &solar::sema::Source<'_>, ) -> Self { let content = s.file.src.as_str(); let file = s.file.name.as_real().unwrap(); @@ -189,7 +191,7 @@ impl SolDataBuilder { content: &str, file: &Path, ast: Result< - (&solar_sema::interface::Session, &solar_parse::ast::SourceUnit<'_>), + (&solar::sema::interface::Session, &solar::parse::ast::SourceUnit<'_>), Option, >, ) -> SolData { @@ -208,8 +210,8 @@ impl SolDataBuilder { fn parse_from_ast( &mut self, - sess: &solar_sema::interface::Session, - ast: &solar_parse::ast::SourceUnit<'_>, + sess: &solar::sema::interface::Session, + ast: &solar::parse::ast::SourceUnit<'_>, ) { for item in ast.items.iter() { let loc = sess.source_map().span_to_source(item.span).unwrap().1;