@@ -61,15 +61,15 @@ std::shared_ptr<FormatElement> FormatElement::LastValidElement() const
6161 return nullptr ;
6262}
6363
64- void FormatElement::Serialize (FormatContext& ctx, std::optional<FormatElement:: ChildIterator> selfIt, FormatElement& parent)
64+ void FormatElement::Serialize (FormatContext& ctx, ChildIterator& selfIt, FormatElement& parent)
6565{
6666 for (auto it = _children.begin (); it != _children.end (); ++it)
6767 {
6868 (*it)->Serialize (ctx, it, *this );
6969 }
7070}
7171
72- void FormatElement::Diagnosis (DiagnosisContext& ctx, std::optional<FormatElement:: ChildIterator> selfIt, FormatElement& parent)
72+ void FormatElement::Diagnosis (DiagnosisContext& ctx, ChildIterator& selfIt, FormatElement& parent)
7373{
7474 for (auto it = _children.begin (); it != _children.end (); ++it)
7575 {
@@ -80,13 +80,19 @@ void FormatElement::Diagnosis(DiagnosisContext& ctx, std::optional<FormatElement
8080void FormatElement::Format (FormatContext& ctx)
8181{
8282 // workaround
83- return Serialize (ctx, {}, *this );
83+ for (auto it = _children.begin (); it != _children.end (); ++it)
84+ {
85+ (*it)->Serialize (ctx, it, *this );
86+ }
8487}
8588
8689void FormatElement::DiagnosisCodeStyle (DiagnosisContext& ctx)
8790{
8891 // workaround
89- return Diagnosis (ctx, {}, *this );
92+ for (auto it = _children.begin (); it != _children.end (); ++it)
93+ {
94+ (*it)->Diagnosis (ctx, it, *this );
95+ }
9096}
9197
9298void FormatElement::AddTextRange (TextRange range)
@@ -126,10 +132,10 @@ int FormatElement::GetNextValidLine(FormatContext& ctx, ChildIterator it, Format
126132 }
127133}
128134
129- int FormatElement::GetLastValidOffset (ChildIterator it, FormatElement& parent)
135+ int FormatElement::GetLastValidOffset (ChildIterator& it, FormatElement& parent)
130136{
131137 auto & siblings = parent.GetChildren ();
132- auto rIt = std::reverse_iterator<decltype (it)>(it);
138+ auto rIt = std::reverse_iterator<std:: remove_reference_t < decltype (it)> >(it);
133139
134140 for (; rIt != siblings.rend (); ++rIt)
135141 {
@@ -145,7 +151,7 @@ int FormatElement::GetLastValidOffset(ChildIterator it, FormatElement& parent)
145151 return parent.GetTextRange ().StartOffset ;
146152}
147153
148- int FormatElement::GetNextValidOffset (ChildIterator it, FormatElement& parent)
154+ int FormatElement::GetNextValidOffset (ChildIterator& it, FormatElement& parent)
149155{
150156
151157 auto & siblings = parent.GetChildren ();
0 commit comments