@@ -72,24 +72,24 @@ void LuaAstNode::AddChild(std::shared_ptr<LuaAstNode> child)
7272 {
7373 return ;
7474 }
75- auto source = GetSource ();
75+
76+ if (child->_textRange .IsEmpty ())
77+ {
78+ return ;
79+ }
80+
81+ const auto source = GetSource ();
7682 if (child->GetSource () != source)
7783 {
7884 return ;
7985 }
8086
81- if (_textRange.StartOffset == 0 && _textRange. EndOffset == 0 )
87+ if (_textRange.IsEmpty () )
8288 {
8389 _textRange = child->_textRange ;
8490 }
85-
8691 else
8792 {
88- if (child->_textRange .StartOffset == 0 && child->_textRange .EndOffset == 0 )
89- {
90- return ;
91- }
92-
9393 if (_textRange.StartOffset > child->_textRange .StartOffset )
9494 {
9595 _textRange.StartOffset = child->_textRange .StartOffset ;
@@ -173,23 +173,23 @@ void LuaAstNode::AddChildBefore(ChildIterator it, std::shared_ptr<LuaAstNode> ch
173173{
174174 if (it == _children.begin ())
175175 {
176- auto source = GetSource ();
176+ if (child->_textRange .IsEmpty ())
177+ {
178+ return ;
179+ }
180+
181+ const auto source = GetSource ();
177182 if (child->GetSource () != source)
178183 {
179184 return ;
180185 }
181186
182- if (_textRange.StartOffset == 0 && _textRange. EndOffset == 0 )
187+ if (_textRange.IsEmpty () )
183188 {
184189 _textRange = child->_textRange ;
185190 }
186191 else
187192 {
188- if (child->_textRange .StartOffset == 0 && child->_textRange .EndOffset == 0 )
189- {
190- return ;
191- }
192-
193193 if (_textRange.StartOffset > child->_textRange .StartOffset )
194194 {
195195 _textRange.StartOffset = child->_textRange .StartOffset ;
@@ -203,7 +203,7 @@ void LuaAstNode::AddChildBefore(ChildIterator it, std::shared_ptr<LuaAstNode> ch
203203 _text = std::string_view (source + _textRange.StartOffset ,
204204 _textRange.EndOffset - _textRange.StartOffset + 1 );
205205 }
206- else if (it == _children.end ())
206+ else if (it == _children.end ())
207207 {
208208 return AddChild (child);
209209 }
0 commit comments