Skip to content
GitLab
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
0bb575b1
Commit
0bb575b1
authored
Feb 01, 2010
by
Roberto Raggi
Browse files
Create a link for the QML/JS expression under cursor.
parent
7c887960
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/qmljseditor/qmljseditor.cpp
View file @
0bb575b1
...
...
@@ -835,6 +835,44 @@ void QmlJSTextEditor::createToolBar(QmlJSEditorEditable *editable)
TextEditor
::
BaseTextEditor
::
Link
QmlJSTextEditor
::
findLinkAt
(
const
QTextCursor
&
cursor
,
bool
/*resolveTarget*/
)
{
Link
link
;
const
SemanticInfo
semanticInfo
=
m_semanticInfo
;
if
(
semanticInfo
.
document
)
{
CollectASTNodes
nodes
;
nodes
.
accept
(
semanticInfo
.
document
->
ast
());
const
unsigned
cursorPosition
=
cursor
.
position
();
foreach
(
AST
::
UiQualifiedId
*
q
,
nodes
.
qualifiedIds
)
{
if
(
cursorPosition
>=
q
->
identifierToken
.
begin
())
{
for
(
AST
::
UiQualifiedId
*
tail
=
q
;
tail
;
tail
=
tail
->
next
)
{
if
(
!
tail
->
next
&&
cursorPosition
<=
tail
->
identifierToken
.
end
())
{
link
.
begin
=
tail
->
identifierToken
.
begin
();
link
.
end
=
tail
->
identifierToken
.
end
();
return
link
;
}
}
}
}
foreach
(
AST
::
IdentifierExpression
*
id
,
nodes
.
identifiers
)
{
if
(
cursorPosition
>=
id
->
identifierToken
.
begin
()
&&
cursorPosition
<=
id
->
identifierToken
.
end
())
{
link
.
begin
=
id
->
firstSourceLocation
().
begin
();
link
.
end
=
id
->
lastSourceLocation
().
end
();
return
link
;
}
}
foreach
(
AST
::
FieldMemberExpression
*
mem
,
nodes
.
fieldMembers
)
{
if
(
mem
->
name
&&
cursorPosition
>=
mem
->
identifierToken
.
begin
()
&&
cursorPosition
<=
mem
->
identifierToken
.
end
())
{
link
.
begin
=
mem
->
lastSourceLocation
().
begin
();
link
.
end
=
mem
->
lastSourceLocation
().
end
();
return
link
;
}
}
}
return
link
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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