| 321 | } |
| 322 | |
| 323 | QList<Variable*> Locals::updateLocals(const QStringList& locals) |
| 324 | { |
| 325 | QSet<QString> existing, current; |
| 326 | for (int i = 0; i < childItems.size(); i++) |
| 327 | { |
| 328 | Q_ASSERT(qobject_cast<KDevelop::Variable*>(child(i))); |
| 329 | auto* var= static_cast<KDevelop::Variable*>(child(i)); |
| 330 | existing << var->expression(); |
| 331 | } |
| 332 | |
| 333 | for (const QString& var : locals) { |
| 334 | current << var; |
| 335 | // If we currently don't display this local var, add it. |
| 336 | if( !existing.contains( var ) ) { |
| 337 | // FIXME: passing variableCollection this way is awkward. |
| 338 | // In future, variableCollection probably should get a |
| 339 | // method to create variable. |
| 340 | Variable* v = |
| 341 | currentSession()->variableController()->createVariable( |
| 342 | ICore::self()->debugController()->variableCollection(), |
| 343 | this, var ); |
| 344 | appendChild( v, false ); |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | for (int i = 0; i < childItems.size(); ++i) { |
| 349 | auto* v = static_cast<KDevelop::Variable*>(child(i)); |
| 350 | if (!current.contains(v->expression())) { |
| 351 | removeChild(i); |
| 352 | --i; |
| 353 | // FIXME: check that -var-delete is sent. |
| 354 | delete v; |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | |
| 359 | if (hasMore()) { |
| 360 | setHasMore(false); |
| 361 | } |
| 362 | |
| 363 | // Variables which changed just value are updated by a call to -var-update. |
| 364 | // Variables that changed type -- likewise. |
| 365 | |
| 366 | QList<Variable*> ret; |
| 367 | ret.reserve(childItems.size()); |
| 368 | for (TreeItem* i : std::as_const(childItems)) { |
| 369 | Q_ASSERT(qobject_cast<Variable*>(i)); |
| 370 | ret << static_cast<Variable*>(i); |
| 371 | } |
| 372 | return ret; |
| 373 | } |
| 374 | |
| 375 | void Locals::resetChanged() |
| 376 | { |
nothing calls this directly
no test coverage detected