Commit fae3fb8a authored by Denis Steckelmacher's avatar Denis Steckelmacher

ExpressionVisitor and UseBuilder now recognize "anchors.parent" as being an...

ExpressionVisitor and UseBuilder now recognize "anchors.parent" as being an use of the "parent" member of "anchors"
parent 0fc595cf
......@@ -146,6 +146,19 @@ bool ExpressionVisitor::visit(QmlJS::AST::IdentifierExpression* node)
return false;
}
bool ExpressionVisitor::visit(QmlJS::AST::UiQualifiedId* node)
{
// "anchors.parent" results in an UiQualifiedId id having a "next" attribute.
// This node reprensents "anchors", the next one is for "parent"
encounter(node->name.toString());
for (node = node->next; node && lastDeclaration(); node = node->next) {
encounterFieldMember(node->name.toString());
}
return false;
}
/*
* Functions
*/
......@@ -184,7 +197,7 @@ void ExpressionVisitor::encounter(IntegralType::CommonIntegralTypes type)
void ExpressionVisitor::encounter(const QString& declaration, KDevelop::DUContext* context)
{
const QualifiedIdentifier name(declaration);
DeclarationPointer dec = QmlJS::getDeclaration(name, context ? context : m_context);
DeclarationPointer dec = QmlJS::getDeclarationOrSignal(name, context ? context : m_context);
if (dec && dec->abstractType()) {
encounterLvalue(dec);
......
......@@ -50,6 +50,8 @@ protected:
virtual bool visit(QmlJS::AST::BinaryExpression* node);
virtual bool visit(QmlJS::AST::IdentifierExpression* node);
virtual bool visit(QmlJS::AST::UiQualifiedId* node);
virtual bool visit(QmlJS::AST::FunctionExpression* node);
virtual bool visit(QmlJS::AST::CallExpression* node);
......
......@@ -55,8 +55,28 @@ bool UseBuilder::visit(QmlJS::AST::IdentifierExpression* node)
bool UseBuilder::visit(QmlJS::AST::UiQualifiedId* node)
{
newUse(node, node->identifierToken, node->name.toString());
return UseBuilderBase::visit(node);
ExpressionVisitor visitor(contextOnNode(node));
node->accept(&visitor);
// UiQualifiedId is also used for strings like "anchors.parent" (in a script
// binding for instance). ExpressionVisitor can be used to get its corresponding
// declaration.
QmlJS::AST::UiQualifiedId* lastNode = node;
while (lastNode->next) {
lastNode = lastNode->next;
}
if (visitor.lastDeclaration()) {
UseBuilderBase::newUse(
node,
m_session->locationsToRange(node->firstSourceLocation(), lastNode->lastSourceLocation()),
visitor.lastDeclaration()
);
}
return false;
}
bool UseBuilder::visit(QmlJS::AST::UiImport* node)
......
......@@ -5,6 +5,12 @@
Module {
Component {
name: "QModelIndex"
/**
* "toString" : "int childCount",
* "useCount" : 1
*/
Property { name: "childCount"; type: "int" }
}
/**
......@@ -20,7 +26,12 @@ Module {
* "toString" : "class AbstractItemModel"
*/
"QtQuick/AbstractItemModel 1.0"
]
]
/**
* "toString" : "plugins::QModelIndex rootItem"
*/
Property { name: "rootItem"; type: "QModelIndex" }
/**
* "type" : { "toString" : "plugins::QAbstractItemModel::LayoutChangeHint" },
......@@ -92,5 +103,7 @@ Module {
AbstractItemModel
{
id: bar
rootItem.childCount: "foo"
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment