Debian Codegraph @

src/parser/pattern.rs

raw symbols SCIP
1 use superrust-analyzer cargo fluent-syntax 0.12.0 parser/::errorsrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/::{ErrorKindrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/ErrorKind#, ParserErrorrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/ParserError#};
2 use superrust-analyzer cargo fluent-syntax 0.12.0 parser/::{corerust-analyzer cargo fluent-syntax 0.12.0 parser/core/::Parserrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#, corerust-analyzer cargo fluent-syntax 0.12.0 parser/core/::Resultrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Result#, slicerust-analyzer cargo fluent-syntax 0.12.0 parser/slice/::Slicerust-analyzer cargo fluent-syntax 0.12.0 parser/slice/Slice#};
3 use craterust-analyzer cargo fluent-syntax 0.12.0 crate/::astrust-analyzer cargo fluent-syntax 0.12.0 ast/;
4
5 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)]
6 enum TextElementTerminationrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementTermination# {
7 LineFeedrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementTermination#LineFeed#,
8 Crlfrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementTermination#Crlf#,
9 PlaceableStartrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementTermination#PlaceableStart#,
10 Eofrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementTermination#Eof#,
11 }
12
13 // This enum tracks the placement of the text element in the pattern, which is needed for
14 // dedentation logic.
15 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)]
16 enum TextElementPositionrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementPosition# {
17 InitialLineStartrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementPosition#InitialLineStart#,
18 LineStartrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementPosition#LineStart#,
19 Continuationrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementPosition#Continuation#,
20 }
21
22 // This enum allows us to mark pointers in the source which will later become text elements
23 // but without slicing them out of the source string. This makes the indentation adjustments
24 // cheaper since they'll happen on the pointers, rather than extracted slices.
25 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
26 enum PatternElementPlaceholdersrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/PatternElementPlaceholders#<S> {
27 Placeablerust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/PatternElementPlaceholders#Placeable#(astrust-analyzer cargo fluent-syntax 0.12.0 ast/::Expressionrust-analyzer cargo fluent-syntax 0.12.0 ast/Expression#<S>),
28 // (start, end, indent, position)
29 TextElementrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/PatternElementPlaceholders#TextElement#(usize, usize, usize, TextElementPositionrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementPosition#),
30 }
31
32 // This enum tracks whether the text element is blank or not.
33 // This is important to identify text elements which should not be taken into account
34 // when calculating common indent.
35 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)]
36 enum TextElementTyperust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementType# {
37 Blankrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementType#Blank#,
38 NonBlankrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementType#NonBlank#,
39 }
40
41 impl<'s, S> Parserrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#<S>
42 where
43 S: Slicerust-analyzer cargo fluent-syntax 0.12.0 parser/slice/Slice#<'s>,
44 {
45 pub(superrust-analyzer cargo fluent-syntax 0.12.0 parser/) fn get_patternrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[`Parser<S>`]get_pattern().(&mut self) -> Resultrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<astrust-analyzer cargo fluent-syntax 0.12.0 ast/::Patternrust-analyzer cargo fluent-syntax 0.12.0 ast/Pattern#<S>>> {
46 let mut elements = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
47 let mut last_non_blank = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
48 let mut common_indent = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
49
50 self.skip_blank_inlinerust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]skip_blank_inline().();
51
52 let mut text_element_role = if self.skip_eolrust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]skip_eol().() {
53 self.skip_blank_blockrust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]skip_blank_block().();
54 TextElementPositionrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementPosition#::LineStartrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementPosition#LineStart#
55 } else {
56 TextElementPositionrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementPosition#::InitialLineStartrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementPosition#InitialLineStart#
57 };
58
59 while self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().self.lengthrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#length. {
60 if self.take_byte_ifrust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]take_byte_if().(b'{') {
61 if text_element_role rust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[TextElementPosition][`PartialEq<Self>`]eq().==rust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[TextElementPosition][`PartialEq<Self>`]eq(). rust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[TextElementPosition][`PartialEq<Self>`]eq().TextElementPositionrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementPosition#::LineStartrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementPosition#LineStart# {
62 common_indent = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(0);
63 }
64 let exp = self.get_placeablerust-analyzer cargo fluent-syntax 0.12.0 parser/core/impl#[`Parser<S>`]get_placeable().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
65 last_non_blank = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(elements.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().());
66 elements.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(PatternElementPlaceholdersrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/PatternElementPlaceholders#::Placeablerust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/PatternElementPlaceholders#Placeable#(exp));
67 text_element_role = TextElementPositionrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementPosition#::Continuationrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementPosition#Continuation#;
68 } else {
69 let slice_start = self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr.;
70 let mut indent = 0;
71 if text_element_role rust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[TextElementPosition][`PartialEq<Self>`]eq().==rust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[TextElementPosition][`PartialEq<Self>`]eq(). rust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[TextElementPosition][`PartialEq<Self>`]eq().TextElementPositionrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementPosition#::LineStartrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementPosition#LineStart# {
72 indent = self.skip_blank_inlinerust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]skip_blank_inline().();
73 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(b) = get_current_byterust-analyzer cargo fluent-syntax 0.12.0 parser/macros/get_current_byte!!(self) {
74 if indent rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 {
75 if b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().&b'\r' && b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().&b'\n' {
76 break;
77 }
78 } else if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().Selfrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[`Parser<S>`]::is_byte_pattern_continuationrust-analyzer cargo fluent-syntax 0.12.0 parser/helper/impl#[`Parser<S>`]is_byte_pattern_continuation().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().b) {
79 self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr. = slice_start;
80 break;
81 }
82 } else {
83 break;
84 }
85 }
86 let (start, end, text_element_type, termination_reason) = self.get_text_slicerust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[`Parser<S>`]get_text_slice().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
87 if start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().end {
88 if text_element_role rust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[TextElementPosition][`PartialEq<Self>`]eq().==rust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[TextElementPosition][`PartialEq<Self>`]eq(). rust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[TextElementPosition][`PartialEq<Self>`]eq().TextElementPositionrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementPosition#::LineStartrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementPosition#LineStart#
89 && text_element_type rust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[TextElementType][`PartialEq<Self>`]eq().==rust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[TextElementType][`PartialEq<Self>`]eq(). rust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[TextElementType][`PartialEq<Self>`]eq().TextElementTyperust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementType#::NonBlankrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementType#NonBlank#
90 {
91 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(common) = common_indent {
92 if indent rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().common {
93 common_indent = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(indent);
94 }
95 } else {
96 common_indent = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(indent);
97 }
98 }
99 if text_element_role rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().TextElementPositionrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementPosition#::LineStartrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementPosition#LineStart#
100 || text_element_type rust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[TextElementType][`PartialEq<Self>`]eq().==rust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[TextElementType][`PartialEq<Self>`]eq(). rust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[TextElementType][`PartialEq<Self>`]eq().TextElementTyperust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementType#::NonBlankrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementType#NonBlank#
101 || termination_reason rust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[TextElementTermination][`PartialEq<Self>`]eq().==rust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[TextElementTermination][`PartialEq<Self>`]eq(). rust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[TextElementTermination][`PartialEq<Self>`]eq().TextElementTerminationrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementTermination#::LineFeedrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementTermination#LineFeed#
102 {
103 if text_element_type rust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[TextElementType][`PartialEq<Self>`]eq().==rust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[TextElementType][`PartialEq<Self>`]eq(). rust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[TextElementType][`PartialEq<Self>`]eq().TextElementTyperust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementType#::NonBlankrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementType#NonBlank# {
104 last_non_blank = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(elements.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().());
105 }
106 elements.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(PatternElementPlaceholdersrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/PatternElementPlaceholders#::TextElementrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/PatternElementPlaceholders#TextElement#(
107 slice_start,
108 end,
109 indent,
110 text_element_role,
111 ));
112 }
113 }
114
115 text_element_role = match termination_reason {
116 TextElementTerminationrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementTermination#::LineFeedrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementTermination#LineFeed# => TextElementPositionrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementPosition#::LineStartrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementPosition#LineStart#,
117 TextElementTerminationrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementTermination#::Crlfrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementTermination#Crlf# => TextElementPositionrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementPosition#::LineStartrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementPosition#LineStart#,
118 TextElementTerminationrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementTermination#::PlaceableStartrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementTermination#PlaceableStart# => TextElementPositionrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementPosition#::Continuationrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementPosition#Continuation#,
119 TextElementTerminationrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementTermination#::Eofrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementTermination#Eof# => TextElementPositionrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementPosition#::Continuationrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementPosition#Continuation#,
120 };
121 }
122 }
123
124 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(last_non_blank) = last_non_blank {
125 let elements = elements
126 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
127 .takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(last_non_blank rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1)
128 .enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().()
129 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(i, elem)| match elem {
130 PatternElementPlaceholdersrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/PatternElementPlaceholders#::Placeablerust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/PatternElementPlaceholders#Placeable#(expression) => {
131 astrust-analyzer cargo fluent-syntax 0.12.0 ast/::PatternElementrust-analyzer cargo fluent-syntax 0.12.0 ast/PatternElement#::Placeablerust-analyzer cargo fluent-syntax 0.12.0 ast/PatternElement#Placeable# { expressionrust-analyzer cargo fluent-syntax 0.12.0 ast/PatternElement#Placeable#expression. }
132 }
133 PatternElementPlaceholdersrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/PatternElementPlaceholders#::TextElementrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/PatternElementPlaceholders#TextElement#(start, end, indent, role) => {
134 let start = if role rust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[TextElementPosition][`PartialEq<Self>`]eq().==rust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[TextElementPosition][`PartialEq<Self>`]eq(). rust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[TextElementPosition][`PartialEq<Self>`]eq().TextElementPositionrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementPosition#::LineStartrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementPosition#LineStart# {
135 common_indent.map_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map_or_else().(
136 || start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().indent,
137 |common_indent| start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().(indent, common_indent),
138 )
139 } else {
140 start
141 };
142 let mut value = self.sourcerust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#source..slicerust-analyzer cargo fluent-syntax 0.12.0 parser/slice/Slice#slice().(start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end);
143 if last_non_blank rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().i {
144 value.trimrust-analyzer cargo fluent-syntax 0.12.0 parser/slice/Slice#trim().();
145 }
146 astrust-analyzer cargo fluent-syntax 0.12.0 ast/::PatternElementrust-analyzer cargo fluent-syntax 0.12.0 ast/PatternElement#::TextElementrust-analyzer cargo fluent-syntax 0.12.0 ast/PatternElement#TextElement# { valuerust-analyzer cargo fluent-syntax 0.12.0 ast/PatternElement#TextElement#value. }
147 }
148 })
149 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
150 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(astrust-analyzer cargo fluent-syntax 0.12.0 ast/::Patternrust-analyzer cargo fluent-syntax 0.12.0 ast/Pattern# { elementsrust-analyzer cargo fluent-syntax 0.12.0 ast/Pattern#elements. }));
151 }
152
153 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)
154 }
155
156 fn get_text_slicerust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/impl#[`Parser<S>`]get_text_slice().(
157 &mut self,
158 ) -> Resultrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Result#<(usize, usize, TextElementTyperust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementType#, TextElementTerminationrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementTermination#)> {
159 let start_pos = self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr.;
160 let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(rest) = get_remaining_bytesrust-analyzer cargo fluent-syntax 0.12.0 parser/macros/get_remaining_bytes!!(self) else {
161 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((
162 start_pos,
163 self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr.,
164 TextElementTyperust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementType#::Blankrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementType#Blank#,
165 TextElementTerminationrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementTermination#::Eofrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementTermination#Eof#,
166 ));
167 };
168 let end = memchrrust-analyzer cargo memchr 2.7.4 crate/::memchr3rust-analyzer cargo memchr 2.7.4 memchr/memchr3().(b'\n', b'{', b'}', rest);
169 let element_type = |text: &[u8]| {
170 if text.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|&c| c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().b' ') {
171 TextElementTyperust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementType#::NonBlankrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementType#NonBlank#
172 } else {
173 TextElementTyperust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementType#::Blankrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementType#Blank#
174 }
175 };
176 match end.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|p| &rest[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeToInclusive#p]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().) {
177 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#([text @ .., b'}']) => {
178 self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().text.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().();
179 errorrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/error!!(ErrorKindrust-analyzer cargo fluent-syntax 0.12.0 parser/errors/ErrorKind#::UnbalancedClosingBracerust-analyzer cargo fluent-syntax 0.12.0 parser/errors/ErrorKind#UnbalancedClosingBrace#, self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr.)
180 }
181 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#([text @ .., b'\r', b'\n']) => {
182 self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().text.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1;
183 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((
184 start_pos,
185 self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1,
186 element_type(text),
187 TextElementTerminationrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementTermination#::Crlfrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementTermination#Crlf#,
188 ))
189 }
190 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#([text @ .., b'\n']) => {
191 self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().text.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1;
192 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((
193 start_pos,
194 self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr.,
195 element_type(text),
196 TextElementTerminationrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementTermination#::LineFeedrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementTermination#LineFeed#,
197 ))
198 }
199 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#([text @ .., b'{']) => {
200 self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().text.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().();
201 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((
202 start_pos,
203 self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr.,
204 element_type(text),
205 TextElementTerminationrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementTermination#::PlaceableStartrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementTermination#PlaceableStart#,
206 ))
207 }
208 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => {
209 self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().rest.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().();
210 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((
211 start_pos,
212 self.ptrrust-analyzer cargo fluent-syntax 0.12.0 parser/core/Parser#ptr.,
213 element_type(rest),
214 TextElementTerminationrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementTermination#::Eofrust-analyzer cargo fluent-syntax 0.12.0 parser/pattern/TextElementTermination#Eof#,
215 ))
216 }
217 _ => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!(),
218 }
219 }
220 }