Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Q
qt-creator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tobias Hunger
qt-creator
Commits
8519ca11
Commit
8519ca11
authored
Jul 16, 2010
by
Christian Kamm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
QmlJS: Allow 'follow symbol' to jump to the target of a file import.
Task-number: QTCREATORBUG-1736
parent
37efd0e1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
0 deletions
+35
-0
src/libs/qmljs/qmljsbind.cpp
src/libs/qmljs/qmljsbind.cpp
+1
-0
src/libs/qmljs/qmljsbind.h
src/libs/qmljs/qmljsbind.h
+1
-0
src/plugins/qmljseditor/qmljseditor.cpp
src/plugins/qmljseditor/qmljseditor.cpp
+33
-0
No files found.
src/libs/qmljs/qmljsbind.cpp
View file @
8519ca11
...
...
@@ -181,6 +181,7 @@ bool Bind::visit(AST::Program *)
bool
Bind
::
visit
(
UiImport
*
ast
)
{
ImportInfo
info
;
info
.
ast
=
ast
;
if
(
ast
->
versionToken
.
isValid
())
{
const
QString
versionString
=
_doc
->
source
().
mid
(
ast
->
versionToken
.
offset
,
ast
->
versionToken
.
length
);
...
...
src/libs/qmljs/qmljsbind.h
View file @
8519ca11
...
...
@@ -54,6 +54,7 @@ public:
struct
ImportInfo
{
QString
name
;
ComponentVersion
version
;
AST
::
UiImport
*
ast
;
};
QList
<
ImportInfo
>
fileImports
()
const
;
...
...
src/plugins/qmljseditor/qmljseditor.cpp
View file @
8519ca11
...
...
@@ -35,6 +35,7 @@
#include "qmloutlinemodel.h"
#include <qmljs/qmljsindenter.h>
#include <qmljs/qmljsbind.h>
#include <qmljs/qmljscheck.h>
#include <qmljs/qmljsdocument.h>
#include <qmljs/qmljsicontextpane.h>
...
...
@@ -525,6 +526,12 @@ QList<AST::Node *> SemanticInfo::astPath(int cursorPosition) const
return
path
;
}
static
bool
importContainsCursor
(
UiImport
*
importAst
,
unsigned
cursorPosition
)
{
return
cursorPosition
>=
importAst
->
firstSourceLocation
().
begin
()
&&
cursorPosition
<=
importAst
->
lastSourceLocation
().
end
();
}
AST
::
Node
*
SemanticInfo
::
nodeUnderCursor
(
int
pos
)
const
{
if
(
!
document
)
...
...
@@ -532,6 +539,19 @@ AST::Node *SemanticInfo::nodeUnderCursor(int pos) const
const
unsigned
cursorPosition
=
pos
;
foreach
(
const
Bind
::
ImportInfo
&
import
,
document
->
bind
()
->
fileImports
())
{
if
(
importContainsCursor
(
import
.
ast
,
cursorPosition
))
return
import
.
ast
;
}
foreach
(
const
Bind
::
ImportInfo
&
import
,
document
->
bind
()
->
directoryImports
())
{
if
(
importContainsCursor
(
import
.
ast
,
cursorPosition
))
return
import
.
ast
;
}
foreach
(
const
Bind
::
ImportInfo
&
import
,
document
->
bind
()
->
libraryImports
())
{
if
(
importContainsCursor
(
import
.
ast
,
cursorPosition
))
return
import
.
ast
;
}
CollectASTNodes
nodes
;
nodes
.
accept
(
document
->
ast
());
...
...
@@ -1226,6 +1246,19 @@ TextEditor::BaseTextEditor::Link QmlJSTextEditor::findLinkAt(const QTextCursor &
AST
::
Node
*
node
=
semanticInfo
.
nodeUnderCursor
(
cursorPosition
);
if
(
AST
::
UiImport
*
importAst
=
cast
<
AST
::
UiImport
*>
(
node
))
{
// if it's a file import, link to the file
foreach
(
const
Bind
::
ImportInfo
&
import
,
semanticInfo
.
document
->
bind
()
->
fileImports
())
{
if
(
import
.
ast
==
importAst
)
{
BaseTextEditor
::
Link
link
(
import
.
name
);
link
.
begin
=
importAst
->
firstSourceLocation
().
begin
();
link
.
end
=
importAst
->
lastSourceLocation
().
end
();
return
link
;
}
}
return
Link
();
}
LookupContext
::
Ptr
lookupContext
=
LookupContext
::
create
(
semanticInfo
.
document
,
semanticInfo
.
snapshot
,
semanticInfo
.
astPath
(
cursorPosition
));
const
Interpreter
::
Value
*
value
=
lookupContext
->
evaluate
(
node
);
...
...
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