Skip to content

Commit

Permalink
sway-fmt-v2 formatting should use tokens directly from sway-parse (#2097
Browse files Browse the repository at this point in the history
)
  • Loading branch information
kayagokalp authored Jun 28, 2022
1 parent 1a64db9 commit c118e2d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
16 changes: 12 additions & 4 deletions sway-fmt-v2/src/items/item_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,22 @@ impl Format for ItemStruct {

/// Format the struct if the multiline is passed as false struct will be formatted into a single line.
///
/// Example (multiline : false):
/// ## Examples
///
/// (multiline : false):
///
/// ```rust,ignore
/// struct Foo { bar: u64, baz: bool }
/// ```
///
/// (multiline : true):
///
/// Example (multiline : true):
/// ```rust,ignore
/// struct Foo {
/// bar: u64,
/// baz: bool,
/// bar: u64,
/// baz: bool,
/// }
/// ```
fn format_struct(
item_struct: &ItemStruct,
formatted_code: &mut FormattedCode,
Expand Down
7 changes: 3 additions & 4 deletions sway-fmt-v2/src/utils/program_type.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use sway_parse::ModuleKind;
use sway_parse::{token::PunctKind, ModuleKind};
use sway_types::Spanned;

/// Insert the program type without applying a formatting to it.
Expand All @@ -24,7 +24,6 @@ pub(crate) fn insert_program_type(push_to: &mut String, module_kind: ModuleKind)
push_to.push_str(name.as_str());
}
};
push_to.push(';');
push_to.push('\n');
push_to.push('\n');
push_to.push(PunctKind::Semicolon.as_char());
push_to.push_str("\n\n");
}

0 comments on commit c118e2d

Please sign in to comment.