Skip to content

#### Class diagram for updated Parser and ParseItem in doc parser #131

@Dargon789

Description

@Dargon789

Reviewer's Guide

This PR updates the workspace to version 1.4.2 and bumps dependencies, refactors and extends the formatter and parser to support Yul context, tab width configuration, and improved multiline/function header formatting, simplifies sequence conversions to borrow data, patches cheatcode account loading, adds new formatting and fork tests, updates CI config, and refines Anvil fork logic for inclusive predating.

Class diagram for updated Parser and ParseItem in doc parser

classDiagram
    class Parser {
        - comments: Vec<SolangComment>
        - items: Vec<ParseItem>
        - source: String
        - tab_width: usize
        + new(comments: Vec<SolangComment>, source: String, tab_width: usize)
        + items() -> Vec<ParseItem>
    }
    class ParseItem {
        - source: ParseSource
        - code: String
        + with_code(source: &str, tab_width: usize) -> Self
    }
    Parser --> ParseItem
Loading

Class diagram for SensitiveScriptSequence and ScriptSequence conversion changes

classDiagram
    class ScriptSequence {
        - transactions: VecDeque<SensitiveTransactionMetadata>
        - paths: Option<(PathBuf, PathBuf)>
        - timestamp: u128
        + save(...)
    }
    class SensitiveScriptSequence {
        - transactions: VecDeque<SensitiveTransactionMetadata>
        + from(sequence: &ScriptSequence) -> Self
    }
    ScriptSequence --> SensitiveScriptSequence : conversion
Loading

Class diagram for SensitiveMultiChainSequence and MultiChainSequence conversion changes

classDiagram
    class MultiChainSequence {
        - deployments: Vec<ScriptSequence>
        - timestamp: u128
        + save(...)
    }
    class SensitiveMultiChainSequence {
        - deployments: Vec<SensitiveScriptSequence>
        + from_multi_sequence(sequence: &MultiChainSequence) -> Self
    }
    MultiChainSequence --> SensitiveMultiChainSequence : conversion
Loading

Class diagram for State changes in Solidity and Yul formatting

classDiagram
    class State {
        + print_lit_inner(lit: &ast::Lit, is_yul: bool)
        + print_lit(lit: &ast::Lit)
        + print_lit_yul(lit: &ast::Lit)
        + print_num_literal(source: &str, is_yul: bool)
    }
    class Solidity_formatting
    class Yul_formatting
    State <|-- Solidity_formatting
    State <|-- Yul_formatting
Loading

Class diagram for Cheatcode trait implementation changes (mockCall variants)

classDiagram
    class Cheatcode {
        + apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result
    }
    class mockCall_1Call {
        + apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result
    }
    class mockCall_3Call {
        + apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result
    }
    class mockCalls_1Call {
        + apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result
    }
    class make_acc_non_empty {
    }
    Cheatcode <|-- mockCall_1Call
    Cheatcode <|-- mockCall_3Call
    Cheatcode <|-- mockCalls_1Call
    mockCall_1Call ..> make_acc_non_empty : uses
    mockCall_3Call ..> make_acc_non_empty : uses
    mockCalls_1Call ..> make_acc_non_empty : uses
Loading

File-Level Changes

Change Details Files
Refactor literal printing to support Yul context
  • Extracted print_lit_inner taking is_yul flag
  • Extended print_num_literal signature with is_yul
  • Updated add_underscores calls to pass is_yul
  • Added print_lit and print_lit_yul wrappers
crates/fmt/src/state/common.rs
crates/fmt/src/state/sol.rs
crates/fmt/src/state/yul.rs
crates/fmt/src/state/mod.rs
Enhance multiline function header formatting
  • Added branch for MultilineFuncHeaderStyle::All when inlining not allowed
  • Adjusted inlining threshold by adding constant offset
crates/fmt/src/state/sol.rs
Introduce tab_width option in documentation parser
  • Added tab_width field to Parser
  • Updated Parser::new and DocBuilder to accept tab_width
  • Propagated tab_width into ParseItem.with_code and trimming logic
crates/doc/src/parser/mod.rs
crates/doc/src/parser/item.rs
crates/doc/src/builder.rs
Refactor ScriptSequence to borrow instead of clone
  • Changed From to From<&ScriptSequence>
  • Updated SensitiveScriptSequence construction using references
  • Adjusted path handling to use as_ref and avoid unnecessary cloning
crates/script-sequence/src/sequence.rs
crates/script/src/multi_sequence.rs
Improve cheatcode account initialization
  • Replaced direct journaled_state.load_account calls with make_acc_non_empty
  • Ignored returned placeholder value to maintain behavior
crates/cheatcodes/src/evm/mock.rs
Add and update formatter and fork tests
  • Added account info fork test for specific block number
  • Registered new ReprosFunctionDefs formatter tests
  • Included new testdata for line_length=120 and multiline headers
  • Updated existing IfStatement2 and Yul test fixtures
crates/anvil/tests/it/fork.rs
crates/fmt/tests/formatter.rs
crates/fmt/testdata/IfStatement2/fmt.sol
crates/fmt/testdata/ReprosFunctionDefs/all.120.fmt.sol
crates/fmt/testdata/Yul/fmt.sol
Bump workspace version, dependencies, and CI config
  • Incremented workspace package to 1.4.2
  • Updated alloy-dyn-abi to 1.4.1
  • Added .circleci/cargo.yml for caching and checks
Cargo.toml
.circleci/cargo.yml
Refine Anvil fork request handling
  • Replaced predates_fork with predates_fork_inclusive in block forking logic
crates/anvil/src/eth/api.rs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Originally posted by @sourcery-ai[bot] in #130 (comment)

Metadata

Metadata

Assignees

Labels

P-highT-bugbugSomething isn't workingdependenciesPull requests that update a dependency filedocumentationImprovements or additions to documentationduplicateThis issue or pull request already existsenhancementNew feature or requestgithub_actionsPull requests that update GitHub Actions codegood first issueGood for newcomershelp wantedExtra attention is neededinvalidThis doesn't seem rightquestionFurther information is requestedrustPull requests that update rust code

Projects

Status

Backlog

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions