Implement function to get the QmlJS AST path to a given location.

Will be useful for improved scope chain building.
This commit is contained in:
Christian Kamm
2010-02-19 10:16:33 +01:00
parent c289897351
commit 8274197366
2 changed files with 18 additions and 0 deletions

View File

@@ -510,6 +510,21 @@ AST::Node *SemanticInfo::declaringMember(int cursorPosition) const
return declaringMember;
}
QList<AST::Node *> SemanticInfo::astPath(int cursorPosition) const
{
QList<AST::Node *> path;
foreach (const Range &range, ranges) {
if (range.begin.isNull() || range.end.isNull()) {
continue;
} else if (cursorPosition >= range.begin.position() && cursorPosition <= range.end.position()) {
path += range.ast;
}
}
return path;
}
AST::Node *SemanticInfo::nodeUnderCursor(int pos) const
{
if (! document)