Skip to content

Commit ef335e2

Browse files
committed
refactor: add prelude for pretty related
1 parent 706d0f6 commit ef335e2

21 files changed

+36
-49
lines changed

crates/typstyle-core/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ mod utils;
88

99
pub use attr::AttrStore;
1010
pub use config::Config;
11-
use pretty::{ArenaDoc, PrettyPrinter};
11+
use pretty::{prelude::*, PrettyPrinter};
1212
use thiserror::Error;
1313
use typst_syntax::Source;
1414

crates/typstyle-core/src/pretty/code_chain.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use itertools::Itertools;
2-
use pretty::DocAllocator;
32
use typst_syntax::{ast::*, SyntaxKind, SyntaxNode};
43

54
use super::{
65
layout::chain::{iterate_deep_nodes, ChainStyle, ChainStylist},
6+
prelude::*,
77
util::has_comment_children,
8-
ArenaDoc, Context,
8+
Context,
99
};
1010
use crate::PrettyPrinter;
1111

crates/typstyle-core/src/pretty/code_flow.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use pretty::DocAllocator;
21
use typst_syntax::{ast::*, SyntaxKind, SyntaxNode};
32

43
use super::{
54
layout::flow::{FlowItem, FlowStylist},
5+
prelude::*,
66
util::is_comment_node,
7-
ArenaDoc, Context, Mode, PrettyPrinter,
7+
Context, Mode, PrettyPrinter,
88
};
99
use crate::ext::{BoolExt, StrExt};
1010

crates/typstyle-core/src/pretty/code_list.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ use typst_syntax::{ast::*, SyntaxKind};
22

33
use super::{
44
layout::list::{ListStyle, ListStylist},
5+
prelude::*,
56
style::FoldStyle,
67
util::{has_comment_children, is_only_one_and},
7-
ArenaDoc, Context, Mode, PrettyPrinter,
8+
Context, Mode, PrettyPrinter,
89
};
910

1011
impl<'a> PrettyPrinter<'a> {

crates/typstyle-core/src/pretty/code_misc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use typst_syntax::ast::*;
22

3-
use super::{ArenaDoc, Context, PrettyPrinter};
3+
use super::{prelude::*, Context, PrettyPrinter};
44

55
impl<'a> PrettyPrinter<'a> {
66
pub(super) fn convert_ident(&'a self, ident: Ident<'a>) -> ArenaDoc<'a> {

crates/typstyle-core/src/pretty/comment.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
use pretty::{Arena, DocAllocator};
21
use typst_syntax::{SyntaxKind, SyntaxNode};
32

4-
use super::{ArenaDoc, Context, PrettyPrinter};
3+
use super::{prelude::*, Context, PrettyPrinter};
54

65
impl<'a> PrettyPrinter<'a> {
76
pub(super) fn convert_comment(&'a self, _ctx: Context, node: &'a SyntaxNode) -> ArenaDoc<'a> {
@@ -97,9 +96,7 @@ fn align_multiline_simple<'a>(arena: &'a Arena<'a>, text: &'a str) -> ArenaDoc<'
9796

9897
#[cfg(test)]
9998
mod tests {
100-
use pretty::{Arena, DocAllocator};
101-
102-
use crate::pretty::comment::{align_multiline, align_multiline_simple, get_follow_leading};
99+
use super::*;
103100

104101
#[test]
105102
fn test_align() {

crates/typstyle-core/src/pretty/func_call.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use pretty::DocAllocator;
21
use typst_syntax::{ast::*, SyntaxKind, SyntaxNode};
32

43
use super::{
@@ -8,10 +7,11 @@ use super::{
87
list::{ListStyle, ListStylist},
98
plain::PlainStylist,
109
},
10+
prelude::*,
1111
style::FoldStyle,
1212
table,
1313
util::{get_parenthesized_args, get_parenthesized_args_untyped, has_parenthesized_args},
14-
ArenaDoc, Context, Mode, PrettyPrinter,
14+
Context, Mode, PrettyPrinter,
1515
};
1616
use crate::ext::StrExt;
1717

crates/typstyle-core/src/pretty/import.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
use std::collections::HashSet;
22

3-
use pretty::DocAllocator;
43
use typst_syntax::{ast::*, SyntaxKind, SyntaxNode};
54

65
use super::{
76
layout::{
87
flow::FlowItem,
98
list::{ListStyle, ListStylist},
109
},
10+
prelude::*,
1111
util::is_comment_node,
12-
ArenaDoc, Context, PrettyPrinter,
12+
Context, PrettyPrinter,
1313
};
1414

1515
impl<'a> PrettyPrinter<'a> {

crates/typstyle-core/src/pretty/layout/chain.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
use std::iter;
22

33
use itertools::Itertools;
4-
use pretty::DocAllocator;
54
use typst_syntax::{SyntaxKind, SyntaxNode};
65

76
use crate::{
87
ext::StrExt,
9-
pretty::{util::is_comment_node, ArenaDoc, Context, PrettyPrinter},
8+
pretty::{prelude::*, util::is_comment_node, Context, PrettyPrinter},
109
};
1110

1211
/// Intermediate representation in chain formatting.

crates/typstyle-core/src/pretty/layout/flow.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
use pretty::DocAllocator;
2-
3-
use crate::pretty::{ArenaDoc, PrettyPrinter};
1+
use crate::pretty::{prelude::*, PrettyPrinter};
42

53
/// An item in the flow. A space is added only when the item before and the item after both allow it.
64
pub struct FlowItem<'a>(pub Option<FlowItemRepr<'a>>);

0 commit comments

Comments
 (0)