forked from qt-creator/qt-creator
QmlJSEditor: adding variant for declaringMember
declaringMemberNoProperties ignores grouped properties like font and easing curve. It also skips Gradient and GradientStops
This commit is contained in:
@@ -511,6 +511,33 @@ AST::Node *SemanticInfo::declaringMember(int cursorPosition) const
|
|||||||
return declaringMember;
|
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 *> SemanticInfo::astPath(int cursorPosition) const
|
||||||
{
|
{
|
||||||
QList<AST::Node *> path;
|
QList<AST::Node *> path;
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ public:
|
|||||||
|
|
||||||
// Returns the declaring member
|
// Returns the declaring member
|
||||||
QmlJS::AST::Node *declaringMember(int cursorPosition) const;
|
QmlJS::AST::Node *declaringMember(int cursorPosition) const;
|
||||||
|
QmlJS::AST::Node *declaringMemberNoProperties(int cursorPosition) const;
|
||||||
|
|
||||||
// Returns the AST node under cursor
|
// Returns the AST node under cursor
|
||||||
QmlJS::AST::Node *nodeUnderCursor(int cursorPosition) const;
|
QmlJS::AST::Node *nodeUnderCursor(int cursorPosition) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user