Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
82741973
Commit
82741973
authored
Feb 19, 2010
by
Christian Kamm
Browse files
Implement function to get the QmlJS AST path to a given location.
Will be useful for improved scope chain building.
parent
c2898973
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/plugins/qmljseditor/qmljseditor.cpp
View file @
82741973
...
@@ -510,6 +510,21 @@ AST::Node *SemanticInfo::declaringMember(int cursorPosition) const
...
@@ -510,6 +510,21 @@ AST::Node *SemanticInfo::declaringMember(int cursorPosition) const
return
declaringMember
;
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
AST
::
Node
*
SemanticInfo
::
nodeUnderCursor
(
int
pos
)
const
{
{
if
(
!
document
)
if
(
!
document
)
...
...
src/plugins/qmljseditor/qmljseditor.h
View file @
82741973
...
@@ -115,6 +115,9 @@ public:
...
@@ -115,6 +115,9 @@ public:
// 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
;
// Returns the list of nodes that enclose the given position.
QList
<
QmlJS
::
AST
::
Node
*>
astPath
(
int
cursorPosition
)
const
;
public:
// attributes
public:
// attributes
QmlJS
::
Document
::
Ptr
document
;
QmlJS
::
Document
::
Ptr
document
;
QmlJS
::
Snapshot
snapshot
;
QmlJS
::
Snapshot
snapshot
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment