Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qt-creator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Hunger
qt-creator
Commits
19526744
Commit
19526744
authored
16 years ago
by
Roberto Raggi
Browse files
Options
Downloads
Patches
Plain Diff
Highlight the uses of an id.
parent
55ed11ee
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/plugins/duieditor/duieditor.cpp
+30
-10
30 additions, 10 deletions
src/plugins/duieditor/duieditor.cpp
src/plugins/duieditor/duieditor.h
+1
-1
1 addition, 1 deletion
src/plugins/duieditor/duieditor.h
with
31 additions
and
11 deletions
src/plugins/duieditor/duieditor.cpp
+
30
−
10
View file @
19526744
...
@@ -39,8 +39,6 @@
...
@@ -39,8 +39,6 @@
#include
"parser/javascriptastvisitor_p.h"
#include
"parser/javascriptastvisitor_p.h"
#include
"parser/javascriptast_p.h"
#include
"parser/javascriptast_p.h"
#include
<indenter.h>
#include
<coreplugin/icore.h>
#include
<coreplugin/icore.h>
#include
<coreplugin/actionmanager/actionmanager.h>
#include
<coreplugin/actionmanager/actionmanager.h>
#include
<texteditor/basetextdocument.h>
#include
<texteditor/basetextdocument.h>
...
@@ -69,11 +67,12 @@ namespace Internal {
...
@@ -69,11 +67,12 @@ namespace Internal {
class
IdDeclarations
:
protected
Visitor
class
IdDeclarations
:
protected
Visitor
{
{
public:
public:
typedef
QMap
<
QString
,
Q
Pair
<
AST
::
SourceLocation
,
AST
::
SourceLocation
>
>
Result
;
typedef
QMap
<
QString
,
Q
List
<
AST
::
SourceLocation
>
>
Result
;
Result
operator
()(
AST
::
Node
*
node
)
Result
operator
()(
AST
::
Node
*
node
)
{
{
_ids
.
clear
();
_ids
.
clear
();
_maybeIds
.
clear
();
accept
(
node
);
accept
(
node
);
return
_ids
;
return
_ids
;
}
}
...
@@ -107,17 +106,37 @@ protected:
...
@@ -107,17 +106,37 @@ protected:
if
(
AST
::
ExpressionStatement
*
stmt
=
AST
::
cast
<
AST
::
ExpressionStatement
*>
(
node
->
statement
))
{
if
(
AST
::
ExpressionStatement
*
stmt
=
AST
::
cast
<
AST
::
ExpressionStatement
*>
(
node
->
statement
))
{
if
(
AST
::
IdentifierExpression
*
idExpr
=
AST
::
cast
<
AST
::
IdentifierExpression
*>
(
stmt
->
expression
))
{
if
(
AST
::
IdentifierExpression
*
idExpr
=
AST
::
cast
<
AST
::
IdentifierExpression
*>
(
stmt
->
expression
))
{
if
(
idExpr
->
name
)
{
if
(
idExpr
->
name
)
{
_ids
[
idExpr
->
name
->
asString
()]
=
qMakePair
(
idExpr
->
firstSourceLocation
(),
const
QString
id
=
idExpr
->
name
->
asString
();
idExpr
->
lastSourceLocation
());
QList
<
AST
::
SourceLocation
>
*
locs
=
&
_ids
[
id
];
locs
->
append
(
idExpr
->
firstSourceLocation
());
locs
->
append
(
_maybeIds
.
value
(
id
));
_maybeIds
.
remove
(
id
);
}
}
}
}
}
}
}
}
accept
(
node
->
statement
);
return
false
;
}
virtual
bool
visit
(
AST
::
IdentifierExpression
*
node
)
{
if
(
node
->
name
)
{
const
QString
name
=
node
->
name
->
asString
();
if
(
_ids
.
contains
(
name
))
_ids
[
name
].
append
(
node
->
identifierToken
);
else
_maybeIds
[
name
].
append
(
node
->
identifierToken
);
}
return
false
;
return
false
;
}
}
private
:
private
:
Result
_ids
;
Result
_ids
;
Result
_maybeIds
;
};
};
class
FindDeclarations
:
protected
Visitor
class
FindDeclarations
:
protected
Visitor
...
@@ -477,15 +496,16 @@ void ScriptEditor::updateMethodBoxIndex()
...
@@ -477,15 +496,16 @@ void ScriptEditor::updateMethodBoxIndex()
tc
.
movePosition
(
QTextCursor
::
EndOfWord
,
QTextCursor
::
KeepAnchor
);
tc
.
movePosition
(
QTextCursor
::
EndOfWord
,
QTextCursor
::
KeepAnchor
);
const
QString
wordUnderCursor
=
tc
.
selectedText
();
const
QString
wordUnderCursor
=
tc
.
selectedText
();
const
QPair
<
AST
::
SourceLocation
,
AST
::
SourceLocation
>
id
=
m_ids
.
value
(
wordUnderCursor
);
QList
<
QTextEdit
::
ExtraSelection
>
selections
;
QList
<
QTextEdit
::
ExtraSelection
>
selections
;
if
(
id
.
first
.
offset
&&
id
.
second
.
offset
)
{
foreach
(
const
AST
::
SourceLocation
&
loc
,
m_ids
.
value
(
wordUnderCursor
))
{
if
(
!
loc
.
isValid
())
continue
;
QTextEdit
::
ExtraSelection
sel
;
QTextEdit
::
ExtraSelection
sel
;
sel
.
format
.
setBackground
(
Qt
::
yellow
);
sel
.
format
.
setBackground
(
Qt
::
yellow
);
sel
.
cursor
=
textCursor
();
sel
.
cursor
=
textCursor
();
sel
.
cursor
.
setPosition
(
id
.
first
.
begin
());
sel
.
cursor
.
setPosition
(
loc
.
begin
());
sel
.
cursor
.
setPosition
(
id
.
second
.
end
(),
QTextCursor
::
KeepAnchor
);
sel
.
cursor
.
setPosition
(
loc
.
end
(),
QTextCursor
::
KeepAnchor
);
selections
.
append
(
sel
);
selections
.
append
(
sel
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/plugins/duieditor/duieditor.h
+
1
−
1
View file @
19526744
...
@@ -120,7 +120,7 @@ private:
...
@@ -120,7 +120,7 @@ private:
QComboBox
*
m_methodCombo
;
QComboBox
*
m_methodCombo
;
QList
<
Declaration
>
m_declarations
;
QList
<
Declaration
>
m_declarations
;
QStringList
m_words
;
QStringList
m_words
;
QMap
<
QString
,
Q
Pair
<
JavaScript
::
AST
::
SourceLocation
,
JavaScript
::
AST
::
SourceLocation
>
>
m_ids
;
QMap
<
QString
,
Q
List
<
JavaScript
::
AST
::
SourceLocation
>
>
m_ids
;
// ### use QMultiMap
};
};
}
// namespace Internal
}
// namespace Internal
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment