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
Tobias Hunger
qt-creator
Commits
d5c2dedd
Commit
d5c2dedd
authored
Dec 01, 2009
by
Roberto Raggi
Browse files
Save the usages.
parent
376210f9
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/libs/cplusplus/FindUsages.cpp
View file @
d5c2dedd
...
...
@@ -57,17 +57,23 @@ void FindUsages::setGlobalNamespaceBinding(NamespaceBindingPtr globalNamespaceBi
_globalNamespaceBinding
=
globalNamespaceBinding
;
}
QList
<
int
>
FindUsages
::
operator
()(
Symbol
*
symbol
,
const
Identifier
*
id
,
AST
*
ast
)
QList
<
Usage
>
FindUsages
::
usages
()
const
{
return
_usages
;
}
QList
<
int
>
FindUsages
::
references
()
const
{
return
_references
;
}
void
FindUsages
::
operator
()(
Symbol
*
symbol
,
const
Identifier
*
id
,
AST
*
ast
)
{
_processed
.
clear
();
_references
.
clear
();
_usages
.
clear
();
_declSymbol
=
symbol
;
_id
=
id
;
if
(
_declSymbol
&&
_id
)
{
_exprDoc
=
Document
::
create
(
"<references>"
);
accept
(
ast
);
}
return
_references
;
}
QString
FindUsages
::
matchingLine
(
const
Token
&
tk
)
const
...
...
@@ -120,9 +126,11 @@ void FindUsages::reportResult(unsigned tokenIndex)
const
int
len
=
tk
.
f
.
length
;
if
(
_future
)
{
_future
->
reportResult
(
Usage
(
_doc
->
fileName
(),
line
,
lineText
,
col
,
len
));
}
const
Usage
u
(
_doc
->
fileName
(),
line
,
lineText
,
col
,
len
);
_usages
.
append
(
u
);
if
(
_future
)
_future
->
reportResult
(
u
);
_references
.
append
(
tokenIndex
);
}
...
...
src/libs/cplusplus/FindUsages.h
View file @
d5c2dedd
...
...
@@ -47,12 +47,12 @@ public:
:
line
(
0
),
col
(
0
),
len
(
0
)
{}
Usage
(
const
QString
&
path
,
int
line
,
const
QString
&
lineText
,
int
col
,
int
len
)
:
path
(
path
),
line
(
line
),
lineText
(
lineText
),
col
(
col
),
len
(
len
)
{}
:
path
(
path
),
lineText
(
lineText
),
line
(
line
),
col
(
col
),
len
(
len
)
{}
public:
QString
path
;
int
line
;
QString
lineText
;
int
line
;
int
col
;
int
len
;
};
...
...
@@ -64,7 +64,10 @@ public:
void
setGlobalNamespaceBinding
(
NamespaceBindingPtr
globalNamespaceBinding
);
QList
<
int
>
operator
()(
Symbol
*
symbol
,
const
Identifier
*
id
,
AST
*
ast
);
void
operator
()(
Symbol
*
symbol
,
const
Identifier
*
id
,
AST
*
ast
);
QList
<
Usage
>
usages
()
const
;
QList
<
int
>
references
()
const
;
protected:
using
ASTVisitor
::
visit
;
...
...
@@ -112,6 +115,7 @@ private:
QList
<
PostfixExpressionAST
*>
_postfixExpressionStack
;
QList
<
QualifiedNameAST
*>
_qualifiedNameStack
;
QList
<
int
>
_references
;
QList
<
Usage
>
_usages
;
LookupContext
_previousContext
;
int
_inSimpleDeclaration
;
QSet
<
unsigned
>
_processed
;
...
...
src/plugins/cpptools/cppfindreferences.cpp
View file @
d5c2dedd
...
...
@@ -91,9 +91,10 @@ QList<int> CppFindReferences::references(Symbol *symbol,
TranslationUnit
*
translationUnit
=
doc
->
translationUnit
();
Q_ASSERT
(
translationUnit
!=
0
);
FindUsages
process
(
doc
,
snapshot
,
/*future = */
0
);
process
.
setGlobalNamespaceBinding
(
bind
(
doc
,
snapshot
));
references
=
process
(
symbol
,
id
,
translationUnit
->
ast
());
FindUsages
findUsages
(
doc
,
snapshot
,
/*future = */
0
);
findUsages
.
setGlobalNamespaceBinding
(
bind
(
doc
,
snapshot
));
findUsages
(
symbol
,
id
,
translationUnit
->
ast
());
references
=
findUsages
.
references
();
return
references
;
}
...
...
@@ -229,7 +230,10 @@ void CppFindReferences::findAll_helper(Symbol *symbol)
const
QMap
<
QString
,
QString
>
wl
=
_modelManager
->
workingCopy
();
Core
::
ProgressManager
*
progressManager
=
Core
::
ICore
::
instance
()
->
progressManager
();
QFuture
<
Usage
>
result
=
QtConcurrent
::
run
(
&
find_helper
,
wl
,
snapshot
,
symbol
);
QFuture
<
Usage
>
result
;
result
=
QtConcurrent
::
run
(
&
find_helper
,
wl
,
snapshot
,
symbol
);
m_watcher
.
setFuture
(
result
);
Core
::
FutureProgress
*
progress
=
progressManager
->
addTask
(
result
,
tr
(
"Searching..."
),
...
...
Write
Preview
Supports
Markdown
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