| 186 | {} |
| 187 | |
| 188 | void handle(const ResultRecord &r) override |
| 189 | { |
| 190 | MIVariable* variable = m_variable.data(); |
| 191 | if (!variable) |
| 192 | return; |
| 193 | |
| 194 | if (r.hasField(QStringLiteral("children"))) |
| 195 | { |
| 196 | auto* lastHandler = this; |
| 197 | const Value& children = r[QStringLiteral("children")]; |
| 198 | for (int i = 0; i < children.size(); ++i) { |
| 199 | const Value& child = children[i]; |
| 200 | const QString& exp = child[QStringLiteral("exp")].literal(); |
| 201 | // Detect pseudo children of a C++ struct or class that designate access specifiers, |
| 202 | // and expand their children (the actual data members of the variable) directly into the variable. |
| 203 | // This way the access specifiers are simply omitted from the KDevelop UI. |
| 204 | // Unlike an actual child variable named e.g. "public" of a C struct or of a dynamic varobj (provided |
| 205 | // by a Python-based pretty-printer), the record of a pseudo child does not contain the "type" field. |
| 206 | if (!child.hasField(QStringLiteral("type")) |
| 207 | && (exp == QLatin1String("public") || exp == QLatin1String("protected") |
| 208 | || exp == QLatin1String("private"))) { |
| 209 | // A pseudo child cannot have pseudo children of its own, so the maximum recursion depth here is 1. |
| 210 | // lastHandler always points to the last created handler. Only the *very* last created |
| 211 | // (and therefore the last to be invoked) handler ends up with m_isLastHandler = true. |
| 212 | lastHandler->m_isLastHandler = false; |
| 213 | lastHandler = new FetchMoreChildrenHandler(variable, m_session); |
| 214 | m_session->addCommand( |
| 215 | VarListChildren, |
| 216 | QLatin1String("--all-values \"%1\"").arg(child[QStringLiteral("name")].literal()), lastHandler); |
| 217 | } else { |
| 218 | variable->createChild(child); |
| 219 | // it's automatically appended to variable's children list |
| 220 | } |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | /* Note that we don't set hasMore to true if there are still active |
| 225 | commands. The reason is that we don't want the user to have |
| 226 | even theoretical ability to click on "..." item and confuse |
| 227 | us. */ |
| 228 | bool hasMore = false; |
| 229 | if (r.hasField(QStringLiteral("has_more"))) |
| 230 | hasMore = r[QStringLiteral("has_more")].toInt(); |
| 231 | |
| 232 | variable->setHasMore(hasMore); |
| 233 | if (m_isLastHandler) { |
| 234 | variable->emitAllChildrenFetched(); |
| 235 | } |
| 236 | } |
| 237 | bool handlesError() override { |
| 238 | // FIXME: handle error? |
| 239 | return false; |
nothing calls this directly
no test coverage detected