Skip to content

Commit 7638a8d

Browse files
authored
chore(deps): switch to solar meta crate (#307)
1 parent b28f2f3 commit 7638a8d

File tree

6 files changed

+31
-34
lines changed

6 files changed

+31
-34
lines changed

Cargo.toml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ semver = { version = "1.0", features = ["serde"] }
5454
serde = { version = "1", features = ["derive", "rc"] }
5555
serde_json = "1.0"
5656
similar-asserts = "1"
57-
solar-parse = { version = "=0.1.6", default-features = false }
58-
solar-sema = { version = "=0.1.6", default-features = false }
57+
solar = { package = "solar-compiler", version = "=0.1.6", default-features = false }
5958
svm = { package = "svm-rs", version = "0.5", default-features = false }
6059
tempfile = "3.20"
6160
thiserror = "2"
@@ -70,7 +69,4 @@ tokio = { version = "1.47", features = ["rt-multi-thread"] }
7069
snapbox = "0.6.21"
7170

7271
[patch.crates-io]
73-
# solar-parse = { git = "https://github.com/paradigmxyz/solar", branch = "main" }
74-
# solar-sema = { git = "https://github.com/paradigmxyz/solar", branch = "main" }
75-
# solar-ast = { git = "https://github.com/paradigmxyz/solar", branch = "main" }
76-
# solar-interface = { git = "https://github.com/paradigmxyz/solar", branch = "main" }
72+
# solar = { package = "solar-compiler", git = "https://github.com/paradigmxyz/solar", branch = "main" }

crates/compilers/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ rayon.workspace = true
3131
thiserror.workspace = true
3232
path-slash.workspace = true
3333
yansi.workspace = true
34-
solar-parse.workspace = true
35-
solar-sema.workspace = true
34+
solar.workspace = true
3635
futures-util = { workspace = true, optional = true }
3736
tokio = { workspace = true, optional = true }
3837

crates/compilers/src/cache/iface.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{parse_one_source, replace_source_content};
2-
use solar_parse::{
2+
use solar::parse::{
33
ast::{self, Span},
44
interface::diagnostics::EmittedDiagnostics,
55
};
@@ -21,8 +21,8 @@ pub(crate) fn interface_repr(content: &str, path: &Path) -> Result<String, Emitt
2121
/// Preserves all libraries and interfaces.
2222
pub(crate) fn interface_representation_ast(
2323
content: &str,
24-
sess: &solar_sema::interface::Session,
25-
ast: &solar_parse::ast::SourceUnit<'_>,
24+
sess: &solar::sema::interface::Session,
25+
ast: &solar::parse::ast::SourceUnit<'_>,
2626
) -> String {
2727
let mut spans_to_remove: Vec<Span> = Vec::new();
2828
for item in ast.items.iter() {

crates/compilers/src/compilers/solc/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,14 +369,14 @@ impl SourceParser for SolParser {
369369

370370
fn new(config: &crate::ProjectPathsConfig) -> Self {
371371
Self {
372-
compiler: solar_sema::Compiler::new(Self::session_with_opts(
373-
solar_sema::interface::config::Opts {
372+
compiler: solar::sema::Compiler::new(Self::session_with_opts(
373+
solar::sema::interface::config::Opts {
374374
include_paths: config.include_paths.iter().cloned().collect(),
375375
base_path: Some(config.root.clone()),
376376
import_remappings: config
377377
.remappings
378378
.iter()
379-
.map(|r| solar_sema::interface::config::ImportRemapping {
379+
.map(|r| solar::sema::interface::config::ImportRemapping {
380380
context: r.context.clone().unwrap_or_default(),
381381
prefix: r.name.clone(),
382382
path: r.path.clone(),

crates/compilers/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ use foundry_compilers_core::error::{Result, SolcError, SolcIoError};
6464
use output::sources::{VersionedSourceFile, VersionedSourceFiles};
6565
use project::ProjectCompiler;
6666
use semver::Version;
67-
use solar_parse::{
67+
use solar::parse::{
6868
interface::{diagnostics::EmittedDiagnostics, source_map::FileName, Session},
6969
Parser,
7070
};
@@ -925,11 +925,11 @@ pub fn replace_source_content(
925925
pub(crate) fn parse_one_source<R>(
926926
content: &str,
927927
path: &Path,
928-
f: impl FnOnce(&Session, &solar_parse::ast::SourceUnit<'_>) -> R,
928+
f: impl FnOnce(&Session, &solar::parse::ast::SourceUnit<'_>) -> R,
929929
) -> Result<R, EmittedDiagnostics> {
930930
let sess = Session::builder().with_buffer_emitter(Default::default()).build();
931-
let res = sess.enter_sequential(|| -> solar_parse::interface::Result<_> {
932-
let arena = solar_parse::ast::Arena::new();
931+
let res = sess.enter_sequential(|| -> solar::parse::interface::Result<_> {
932+
let arena = solar::parse::ast::Arena::new();
933933
let filename = FileName::Real(path.to_path_buf());
934934
let mut parser = Parser::from_source_code(&sess, &arena, filename, content.to_string())?;
935935
let ast = parser.parse_file().map_err(|e| e.emit())?;

crates/compilers/src/resolver/parse.rs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
use foundry_compilers_core::utils;
22
use semver::VersionReq;
3-
use solar_parse::{ast, interface::sym};
4-
use solar_sema::interface;
3+
use solar::{
4+
parse::{ast, interface::sym},
5+
sema::interface,
6+
};
57
use std::{
68
ops::Range,
79
path::{Path, PathBuf},
810
};
911

1012
/// Solidity parser.
1113
///
12-
/// Holds a [`solar_sema::Compiler`] that is used to parse sources incrementally.
14+
/// Holds a [`solar::sema::Compiler`] that is used to parse sources incrementally.
1315
/// After project compilation ([`Graph::resolve`]), this will contain all sources parsed by
1416
/// [`Graph`].
1517
///
@@ -20,13 +22,13 @@ use std::{
2022
#[derive(derive_more::Debug)]
2123
pub struct SolParser {
2224
#[debug(ignore)]
23-
pub(crate) compiler: solar_sema::Compiler,
25+
pub(crate) compiler: solar::sema::Compiler,
2426
}
2527

2628
impl Clone for SolParser {
2729
fn clone(&self) -> Self {
2830
Self {
29-
compiler: solar_sema::Compiler::new(Self::session_with_opts(
31+
compiler: solar::sema::Compiler::new(Self::session_with_opts(
3032
self.compiler.sess().opts.clone(),
3133
)),
3234
}
@@ -35,24 +37,24 @@ impl Clone for SolParser {
3537

3638
impl SolParser {
3739
/// Returns a reference to the compiler.
38-
pub fn compiler(&self) -> &solar_sema::Compiler {
40+
pub fn compiler(&self) -> &solar::sema::Compiler {
3941
&self.compiler
4042
}
4143

4244
/// Returns a mutable reference to the compiler.
43-
pub fn compiler_mut(&mut self) -> &mut solar_sema::Compiler {
45+
pub fn compiler_mut(&mut self) -> &mut solar::sema::Compiler {
4446
&mut self.compiler
4547
}
4648

4749
/// Consumes the parser and returns the compiler.
48-
pub fn into_compiler(self) -> solar_sema::Compiler {
50+
pub fn into_compiler(self) -> solar::sema::Compiler {
4951
self.compiler
5052
}
5153

5254
pub(crate) fn session_with_opts(
53-
opts: solar_sema::interface::config::Opts,
54-
) -> solar_sema::interface::Session {
55-
let sess = solar_sema::interface::Session::builder()
55+
opts: solar::sema::interface::config::Opts,
56+
) -> solar::sema::interface::Session {
57+
let sess = solar::sema::interface::Session::builder()
5658
.with_buffer_emitter(Default::default())
5759
.opts(opts)
5860
.build();
@@ -137,8 +139,8 @@ impl SolData {
137139
}
138140

139141
pub(crate) fn parse_from(
140-
sess: &solar_sema::interface::Session,
141-
s: &solar_sema::Source<'_>,
142+
sess: &solar::sema::interface::Session,
143+
s: &solar::sema::Source<'_>,
142144
) -> Self {
143145
let content = s.file.src.as_str();
144146
let file = s.file.name.as_real().unwrap();
@@ -189,7 +191,7 @@ impl SolDataBuilder {
189191
content: &str,
190192
file: &Path,
191193
ast: Result<
192-
(&solar_sema::interface::Session, &solar_parse::ast::SourceUnit<'_>),
194+
(&solar::sema::interface::Session, &solar::parse::ast::SourceUnit<'_>),
193195
Option<String>,
194196
>,
195197
) -> SolData {
@@ -208,8 +210,8 @@ impl SolDataBuilder {
208210

209211
fn parse_from_ast(
210212
&mut self,
211-
sess: &solar_sema::interface::Session,
212-
ast: &solar_parse::ast::SourceUnit<'_>,
213+
sess: &solar::sema::interface::Session,
214+
ast: &solar::parse::ast::SourceUnit<'_>,
213215
) {
214216
for item in ast.items.iter() {
215217
let loc = sess.source_map().span_to_source(item.span).unwrap().1;

0 commit comments

Comments
 (0)