1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Chain formatting module for TypeScript member chains
//
// This module implements prettier-compatible member chain formatting following
// prettier's linearize→group→conditionalGroup model from member-chain.js.
//
// ## Architecture
//
// 1. **Linearization** (analysis.rs): Flatten nested AST into a flat list of ChainNodes
// `a().b().c!.d` → [Base(a), Call(), Member(.b), Call(), NonNull(!), Member(.d)]
//
// 2. **Grouping** (analysis.rs): Group nodes by natural break points
// - First group: base + calls + non-null + numeric accessors + consecutive members
// - Remaining groups: members* + calls*, break at memberish after call
// - A member whose gap holds a LINE comment always starts a group (prettier's
// trailing-comment group split; the factory merge is refused for one too):
// only a group's first member reaches the chain-level gap emitters, a member
// printed inside a group can only defer the `//` to the line end
//
// 3. **Doc Building** (builder/): Build conditional docs with various break strategies
// - Member-only chains: use fill() for greedy packing
// - Chains with calls: use conditionalGroup([oneLine, expanded])
//
// ## Module Organization
//
// - **analysis.rs**: Linearization, grouping, merge decisions
// - **types.rs**: Core data structures (ChainNode, ChainGroup)
// - **inline_lookups.rs**: which lookups carry a break point, as marked by the chain's
// PARENT (prettier's `shouldInline` clauses a chain cannot answer for itself)
// - **printing.rs**: Node/group rendering
// - **adapter.rs**: chain-helper methods on the main Printer
// - **builder/**: Doc building logic split into focused submodules
// - mod.rs: Main build_chain_doc entry point
// - member_only.rs: Member-only chains using fill()
// - expansion.rs: Chain expansion analysis helpers
// - helpers.rs: Shared utilities and ChainPartsBuilder
//
// ## References
// - prettier/src/language-js/print/member-chain.js
// Re-export public API
// `group_chain_nodes` and `build_chain_doc` are deliberately NOT re-exported: they are two
// of the steps `build_linearized_chain_doc` performs, and handing them out separately is
// what let a caller assemble some of them and drop the head claim.
pub use ;
pub use ;
pub use call_prints_as_member_chain;
pub use build_lookup_after_operand_doc;
pub use find_bracket_position;
pub use ChainGroupVec;
pub use ;