@@ -61,38 +61,38 @@ std::shared_ptr<FormatElement> FormatElement::LastValidElement() const
6161 return nullptr ;
6262}
6363
64- void FormatElement::Serialize (FormatContext& ctx, 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, 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 {
7676 (*it)->Diagnosis (ctx, it, *this );
7777 }
78- }
78+ }
7979
8080void FormatElement::Format (FormatContext& ctx)
8181{
8282 // workaround
83- for ( auto it = _children. begin (); it != _children. end (); ++it)
84- {
85- (*it)-> Serialize (ctx, it, * this );
86- }
83+ auto root = std::make_shared<FormatElement> ();
84+ root-> AddChild ( shared_from_this ());
85+ auto it = root-> GetChildren (). begin ( );
86+ Serialize (ctx, it, *root);
8787}
8888
8989void FormatElement::DiagnosisCodeStyle (DiagnosisContext& ctx)
9090{
9191 // workaround
92- for ( auto it = _children. begin (); it != _children. end (); ++it)
93- {
94- (*it)-> Diagnosis (ctx, it, * this );
95- }
92+ auto root = std::make_shared<FormatElement> ();
93+ root-> AddChild ( shared_from_this ());
94+ auto it = root-> GetChildren (). begin ( );
95+ Diagnosis (ctx, it, *root);
9696}
9797
9898void FormatElement::AddTextRange (TextRange range)
@@ -139,7 +139,6 @@ int FormatElement::GetLastValidOffset(ChildIterator& it, FormatElement& parent)
139139
140140 for (; rIt != siblings.rend (); ++rIt)
141141 {
142-
143142 auto sibling = *rIt;
144143 if (sibling->HasValidTextRange ())
145144 {
@@ -153,7 +152,6 @@ int FormatElement::GetLastValidOffset(ChildIterator& it, FormatElement& parent)
153152
154153int FormatElement::GetNextValidOffset (ChildIterator& it, FormatElement& parent)
155154{
156-
157155 auto & siblings = parent.GetChildren ();
158156 ++it;
159157 for (; it != siblings.end (); ++it)
0 commit comments