mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-10-28 22:49:51 +00:00
Fix output selection issues for Foundry (#386)
### Description Fixes output selection issues for `Foundry` usage. - pruning to look at per file settings - source to include `ast` ### Note `Selection.files` field is reintroduced because that's the way `foundry` functions. it uses per-file output selection --------- Co-authored-by: xermicus <cyrill@parity.io>
This commit is contained in:
1 parent
7346d82dfa
commit
93c6387dae
3 files changed
+94
-24
No files matched your search
@@ -56,14 +56,22 @@ impl Output {
|
||||
messages: &mut Vec<SolcStandardJsonOutputError>,
|
||||
) -> Self {
|
||||
let sources = sources
|
||||
.keys()
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(index, path)| (path.to_owned(), Source::new(index)))
|
||||
.map(|(index, (path, source))| {
|
||||
(
|
||||
path.to_owned(),
|
||||
Source {
|
||||
id: index,
|
||||
ast: source.content().map(|x| serde_json::to_value(x).unwrap()),
|
||||
},
|
||||
)
|
||||
})
|
||||
.collect::<BTreeMap<String, Source>>();
|
||||
|
||||
Self {
|
||||
contracts: BTreeMap::new(),
|
||||
sources,
|
||||
sources: sources.clone(),
|
||||
errors: std::mem::take(messages),
|
||||
|
||||
version: None,
|
||||
@@ -92,27 +100,27 @@ impl Output {
|
||||
mut self,
|
||||
selection_to_prune: SolcStandardJsonInputSettingsSelection,
|
||||
) -> ! {
|
||||
let contracts = self
|
||||
.contracts
|
||||
.values_mut()
|
||||
.flat_map(|contracts| contracts.values_mut())
|
||||
.collect::<Vec<&mut Contract>>();
|
||||
for contract in contracts.into_iter() {
|
||||
if selection_to_prune
|
||||
.contains(&crate::SolcStandardJsonInputSettingsSelectionFileFlag::Metadata)
|
||||
{
|
||||
contract.metadata = serde_json::Value::Null;
|
||||
}
|
||||
if selection_to_prune
|
||||
.contains(&crate::SolcStandardJsonInputSettingsSelectionFileFlag::Yul)
|
||||
{
|
||||
contract.ir_optimized = String::new();
|
||||
}
|
||||
if let Some(ref mut evm) = contract.evm {
|
||||
for (path, contracts) in self.contracts.iter_mut() {
|
||||
for contract in contracts.values_mut() {
|
||||
if selection_to_prune.contains(
|
||||
&crate::SolcStandardJsonInputSettingsSelectionFileFlag::MethodIdentifiers,
|
||||
path,
|
||||
&crate::SolcStandardJsonInputSettingsSelectionFileFlag::Metadata,
|
||||
) {
|
||||
evm.method_identifiers.clear();
|
||||
contract.metadata = serde_json::Value::Null;
|
||||
}
|
||||
if selection_to_prune.contains(
|
||||
path,
|
||||
&crate::SolcStandardJsonInputSettingsSelectionFileFlag::Yul,
|
||||
) {
|
||||
contract.ir_optimized = String::new();
|
||||
}
|
||||
if let Some(ref mut evm) = contract.evm {
|
||||
if selection_to_prune.contains(
|
||||
path,
|
||||
&crate::SolcStandardJsonInputSettingsSelectionFileFlag::MethodIdentifiers,
|
||||
) {
|
||||
evm.method_identifiers.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user