Commit 8b90b96f authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlJSEditor: adding variant for declaringMember

declaringMemberNoProperties ignores grouped properties like font
and easing curve. It also skips Gradient and GradientStops
parent d2948c19
......@@ -511,6 +511,33 @@ AST::Node *SemanticInfo::declaringMember(int cursorPosition) const
return declaringMember;
}
QmlJS::AST::Node *SemanticInfo::declaringMemberNoProperties(int cursorPosition) const
{
AST::Node *node = declaringMember(cursorPosition);
if (UiObjectDefinition *objectDefinition = cast<UiObjectDefinition*>(node)) {
QString name = objectDefinition->qualifiedTypeNameId->name->asString();
if (!name.isNull() && name.at(0).isLower()) {
QList<AST::Node *> path = astPath(cursorPosition);
if (path.size() > 1)
return path.at(path.size() - 2);
} else if (name.contains("GradientStop")) {
QList<AST::Node *> path = astPath(cursorPosition);
if (path.size() > 2)
return path.at(path.size() - 3);
}
} else if (UiObjectBinding *objectBinding = cast<UiObjectBinding*>(node)) {
QString name = objectBinding->qualifiedTypeNameId->name->asString();
if (name.contains("Gradient")) {
QList<AST::Node *> path = astPath(cursorPosition);
if (path.size() > 1)
return path.at(path.size() - 2);
}
}
return node;
}
QList<AST::Node *> SemanticInfo::astPath(int cursorPosition) const
{
QList<AST::Node *> path;
......
......@@ -118,6 +118,7 @@ public:
// Returns the declaring member
QmlJS::AST::Node *declaringMember(int cursorPosition) const;
QmlJS::AST::Node *declaringMemberNoProperties(int cursorPosition) const;
// Returns the AST node under cursor
QmlJS::AST::Node *nodeUnderCursor(int cursorPosition) const;
......
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