Skip to content

Commit fd64e57

Browse files
authored
chore: solar-powered fmt rollout (#11570)
1 parent b9de877 commit fd64e57

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+1568
-6963
lines changed

Cargo.lock

Lines changed: 2 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ members = [
2020
"crates/evm/fuzz/",
2121
"crates/evm/traces/",
2222
"crates/fmt/",
23-
"crates/fmt-2/",
2423
"crates/forge/",
2524
"crates/script-sequence/",
2625
"crates/macros/",

crates/chisel/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ path = "bin/main.rs"
1919

2020
[dependencies]
2121
# forge
22+
forge-doc.workspace = true
2223
forge-fmt.workspace = true
2324
foundry-cli.workspace = true
2425
foundry-common.workspace = true

crates/chisel/src/dispatcher.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ use crate::{
99
};
1010
use alloy_primitives::{Address, hex};
1111
use eyre::{Context, Result};
12-
use forge_fmt::FormatterConfig;
13-
use foundry_config::RpcEndpointUrl;
12+
use foundry_config::{FormatterConfig, RpcEndpointUrl};
1413
use foundry_evm::{
1514
decode::decode_console_logs,
1615
traces::{
@@ -66,18 +65,8 @@ pub struct EtherscanABIResponse {
6665

6766
/// Helper function that formats solidity source with the given [FormatterConfig]
6867
pub fn format_source(source: &str, config: FormatterConfig) -> eyre::Result<String> {
69-
match forge_fmt::parse(source) {
70-
Ok(parsed) => {
71-
let mut formatted_source = String::default();
72-
73-
if forge_fmt::format_to(&mut formatted_source, parsed, config).is_err() {
74-
eyre::bail!("Could not format source!");
75-
}
76-
77-
Ok(formatted_source)
78-
}
79-
Err(_) => eyre::bail!("Formatter could not parse source!"),
80-
}
68+
let formatted = forge_fmt::format(source, config).into_result()?;
69+
Ok(formatted)
8170
}
8271

8372
impl ChiselDispatcher {

crates/chisel/src/source.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//! execution helpers.
66
77
use eyre::Result;
8-
use forge_fmt::solang_ext::{CodeLocationExt, SafeUnwrap};
8+
use forge_doc::solang_ext::{CodeLocationExt, SafeUnwrap};
99
use foundry_common::fs;
1010
use foundry_compilers::{
1111
Artifact, ProjectCompileOutput,

crates/cli/src/utils/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use alloy_json_abi::JsonAbi;
22
use alloy_primitives::{U256, map::HashMap};
33
use alloy_provider::{Provider, network::AnyNetwork};
44
use eyre::{ContextCompat, Result};
5+
use forge_fmt::FormatterConfig;
56
use foundry_common::{
67
provider::{ProviderBuilder, RetryProvider},
78
shell,
@@ -100,7 +101,7 @@ fn env_filter() -> tracing_subscriber::EnvFilter {
100101

101102
pub fn abi_to_solidity(abi: &JsonAbi, name: &str) -> Result<String> {
102103
let s = abi.to_sol(name, None);
103-
let s = forge_fmt::format(&s)?;
104+
let s = forge_fmt::format(&s, FormatterConfig::default()).into_result()?;
104105
Ok(s)
105106
}
106107

crates/doc/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ foundry-common.workspace = true
1919
foundry-compilers.workspace = true
2020
foundry-config.workspace = true
2121

22+
solar-interface.workspace = true
2223
alloy-primitives.workspace = true
2324

2425
derive_more.workspace = true

crates/doc/src/builder.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
use crate::{
22
AsDoc, BufWriter, Document, ParseItem, ParseSource, Parser, Preprocessor,
3-
document::DocumentContent, helpers::merge_toml_table,
3+
document::DocumentContent, helpers::merge_toml_table, solang_ext::Visitable,
44
};
55
use alloy_primitives::map::HashMap;
66
use eyre::{Context, Result};
7-
use forge_fmt::{FormatterConfig, Visitable};
87
use foundry_compilers::{compilers::solc::SOLC_EXTENSIONS, utils::source_files_iter};
9-
use foundry_config::{DocConfig, filter::expand_globs};
8+
use foundry_config::{DocConfig, FormatterConfig, filter::expand_globs};
109
use itertools::Itertools;
1110
use mdbook::MDBook;
1211
use rayon::prelude::*;

crates/doc/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ mod writer;
3131
pub use writer::{AsDoc, AsDocResult, BufWriter, Markdown};
3232

3333
pub use mdbook;
34+
35+
// old formatter dependencies
36+
pub mod solang_ext;

crates/doc/src/parser/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use forge_fmt::FormatterError;
1+
use solar_interface::diagnostics::EmittedDiagnostics;
22
use thiserror::Error;
33

44
/// The parser error.
@@ -7,7 +7,7 @@ use thiserror::Error;
77
pub enum ParserError {
88
/// Formatter error.
99
#[error(transparent)]
10-
Formatter(#[from] FormatterError),
10+
Formatter(EmittedDiagnostics),
1111
/// Internal parser error.
1212
#[error(transparent)]
1313
Internal(#[from] eyre::Error),

0 commit comments

Comments
 (0)