MCPcopy Create free account
hub / github.com/KDE/kdevelop / encounterParent

Method encounterParent

plugins/qmljs/duchain/expressionvisitor.cpp:296–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

294}
295
296bool 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
331bool ExpressionVisitor::encounterDeclarationInContext(const QualifiedIdentifier& id, DUContext* context)
332{

Callers

nothing calls this directly

Calls 5

isQmlFileFunction · 0.85
getOwnerOfContextFunction · 0.85
typeMethod · 0.45
parentContextMethod · 0.45
abstractTypeMethod · 0.45

Tested by

no test coverage detected