| 294 | } |
| 295 | |
| 296 | bool ExpressionVisitor::encounterParent(const QString& declaration) |
| 297 | { |
| 298 | if (declaration != QLatin1String("parent") || |
| 299 | !QmlJS::isQmlFile(m_context)) { |
| 300 | return false; |
| 301 | } |
| 302 | |
| 303 | // Go up until we find a class context (the enclosing QML component) |
| 304 | const DUContext* parent = m_context; |
| 305 | Declaration* owner; |
| 306 | |
| 307 | while (parent && parent->type() != DUContext::Class) { |
| 308 | parent = parent->parentContext(); |
| 309 | } |
| 310 | |
| 311 | // Take the parent context of the current QML component, it is its parent |
| 312 | // component |
| 313 | if (parent) { |
| 314 | parent = parent->parentContext(); |
| 315 | } |
| 316 | |
| 317 | // Parent now points to the parent QML component. This is not always what |
| 318 | // the user wants when typing "parent", but already works well for |
| 319 | // "anchors.centerIn: parent" and things like that. |
| 320 | if (parent && |
| 321 | (owner = QmlJS::getOwnerOfContext(parent)) && |
| 322 | owner->abstractType()) { |
| 323 | encounterLvalue(DeclarationPointer(owner)); |
| 324 | instantiateCurrentDeclaration(); |
| 325 | return true; |
| 326 | } |
| 327 | |
| 328 | return false; |
| 329 | } |
| 330 | |
| 331 | bool ExpressionVisitor::encounterDeclarationInContext(const QualifiedIdentifier& id, DUContext* context) |
| 332 | { |
nothing calls this directly
no test coverage detected