103bool GenericScriptElement::iterateDirectSubpaths(
const DomItem &self, DirectVisitor visitor)
const
106 for (
auto it = m_children.begin(); it != m_children.end(); ++it) {
108 [&self, &visitor, &it](
auto &&e) {
return wrap(self, visitor, it->first, e); },
111 for (
auto it = m_values.begin(); it != m_values.end(); ++it) {
112 cont &= self.dvValueField(visitor, it->first, it->second);
117void GenericScriptElement::updatePathFromOwner(
const Path &p)
119 BaseT::updatePathFromOwner(p);
120 for (
auto it = m_children.begin(); it != m_children.end(); ++it) {
121 std::visit(qOverloadedVisitor{ [&p, &it](ScriptElementVariant &e) {
122 e.base()->updatePathFromOwner(p.field(it->first));
124 [&p, &it](ScriptList &list) {
125 list.updatePathFromOwner(p.field(it->first));
131void GenericScriptElement::createFileLocations(
const FileLocations::Tree &base)
133 BaseT::createFileLocations(base);
134 for (
auto it = m_children.begin(); it != m_children.end(); ++it) {
137 [&base](ScriptElementVariant &e) { e.base()->createFileLocations(base); },
138 [&base](ScriptList &list) { list.createFileLocations(base); } },
143bool BlockStatement::iterateDirectSubpaths(
const DomItem &self, DirectVisitor visitor)
const
147 cont &= wrap(self, visitor, Fields::statements, m_statements);
163bool IdentifierExpression::iterateDirectSubpaths(
const DomItem &self, DirectVisitor visitor)
const
166 cont &= self.dvValueField(visitor, Fields::identifier, m_name);
170bool Literal::iterateDirectSubpaths(
const DomItem &self, DirectVisitor visitor)
const
173 std::visit([&cont, &visitor,
174 &self](
auto &&e) { cont &= self.dvValueField(visitor, Fields::value, e); },
179bool IfStatement::iterateDirectSubpaths(
const DomItem &self, DirectVisitor visitor)
const
183 cont &= wrap(self, visitor, Fields::condition, m_condition);
184 cont &= wrap(self, visitor, Fields::consequence, m_consequence);
185 cont &= wrap(self, visitor, Fields::alternative, m_alternative);
189void IfStatement::updatePathFromOwner(
const Path &p)
191 BaseT::updatePathFromOwner(p);
192 if (
auto ptr = m_condition.base())
193 ptr->updatePathFromOwner(p.field(Fields::condition));
194 if (
auto ptr = m_consequence.base())
195 ptr->updatePathFromOwner(p.field(Fields::consequence));
196 if (
auto ptr = m_alternative.base())
197 ptr->updatePathFromOwner(p.field(Fields::alternative));
200void IfStatement::createFileLocations(
const FileLocations::Tree &base)
202 BaseT::createFileLocations(base);
203 if (
auto ptr = m_condition.base())
204 ptr->createFileLocations(base);
205 if (
auto ptr = m_consequence.base())
206 ptr->createFileLocations(base);
207 if (
auto ptr = m_alternative.base())
208 ptr->createFileLocations(base);
211bool ForStatement::iterateDirectSubpaths(
const DomItem &self, DirectVisitor visitor)
const
214 cont &= wrap(self, visitor, Fields::initializer, m_initializer);
215 cont &= wrap(self, visitor, Fields::declarations, m_declarations);
216 cont &= wrap(self, visitor, Fields::condition, m_condition);
217 cont &= wrap(self, visitor, Fields::expression, m_expression);
218 cont &= wrap(self, visitor, Fields::body, m_body);
222void ForStatement::updatePathFromOwner(
const Path &p)
224 BaseT::updatePathFromOwner(p);
225 if (
auto ptr = m_initializer.base())
226 ptr->updatePathFromOwner(p.field(Fields::initializer));
227 if (
auto ptr = m_declarations.base())
228 ptr->updatePathFromOwner(p.field(Fields::declarations));
229 if (
auto ptr = m_condition.base())
230 ptr->updatePathFromOwner(p.field(Fields::condition));
231 if (
auto ptr = m_expression.base())
232 ptr->updatePathFromOwner(p.field(Fields::expression));
233 if (
auto ptr = m_body.base())
234 ptr->updatePathFromOwner(p.field(Fields::body));
237void ForStatement::createFileLocations(
const FileLocations::Tree &base)
239 BaseT::createFileLocations(base);
240 if (
auto ptr = m_initializer.base())
241 ptr->createFileLocations(base);
242 if (
auto ptr = m_declarations.base())
243 ptr->createFileLocations(base);
244 if (
auto ptr = m_condition.base())
245 ptr->createFileLocations(base);
246 if (
auto ptr = m_expression.base())
247 ptr->createFileLocations(base);
248 if (
auto ptr = m_body.base())
249 ptr->createFileLocations(base);
252bool BinaryExpression::iterateDirectSubpaths(
const DomItem &self, DirectVisitor visitor)
const
255 cont &= wrap(self, visitor, Fields::left, m_left);
256 cont &= self.dvValueField(visitor, Fields::operation, m_operator);
257 cont &= wrap(self, visitor, Fields::right, m_right);
270void BinaryExpression::createFileLocations(
const FileLocations::Tree &base)
272 BaseT::createFileLocations(base);
273 if (
auto ptr = m_left.base())
274 ptr->createFileLocations(base);
275 if (
auto ptr = m_right.base())
276 ptr->createFileLocations(base);
279bool VariableDeclarationEntry::iterateDirectSubpaths(
const DomItem &self, DirectVisitor visitor)
const
282 cont &= self.dvValueField(visitor, Fields::scopeType, m_scopeType);
283 cont &= wrap(self, visitor, Fields::identifier, m_identifier);
284 cont &= wrap(self, visitor, Fields::initializer, m_initializer);
288void VariableDeclarationEntry::updatePathFromOwner(
const Path &p)
290 BaseT::updatePathFromOwner(p);
291 if (
auto ptr = m_identifier.base())
292 ptr->updatePathFromOwner(p.field(Fields::identifier));
293 if (
auto ptr = m_initializer.base())
294 ptr->updatePathFromOwner(p.field(Fields::initializer));
297void VariableDeclarationEntry::createFileLocations(
const FileLocations::Tree &base)
299 BaseT::createFileLocations(base);
300 if (
auto ptr = m_identifier.base())
301 ptr->createFileLocations(base);
302 if (
auto ptr = m_initializer.base())
303 ptr->createFileLocations(base);
306bool VariableDeclaration::iterateDirectSubpaths(
const DomItem &self, DirectVisitor visitor)
const
309 cont &= wrap(self, visitor, Fields::declarations, m_declarations);
325bool ReturnStatement::iterateDirectSubpaths(
const DomItem &self, DirectVisitor visitor)
const
328 cont &= wrap(self, visitor, Fields::expression, m_expression);
339void ReturnStatement::createFileLocations(
const FileLocations::Tree &base)
341 BaseT::createFileLocations(base);
342 if (
auto ptr = m_expression.base())
343 ptr->createFileLocations(base);
346void ScriptList::replaceKindForGenericChildren(DomType oldType, DomType newType)
348 for (
auto &it : m_list) {
349 if (
auto current = it.data()) {
350 if (
auto genericElement =
351 std::get_if<std::shared_ptr<ScriptElements::GenericScriptElement>>(
353 if ((*genericElement)->kind() == oldType)
354 (*genericElement)->setKind(newType);