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
d5c2dedd
Commit
d5c2dedd
authored
15 years ago
by
Roberto Raggi
Browse files
Options
Downloads
Patches
Plain Diff
Save the usages.
parent
376210f9
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/libs/cplusplus/FindUsages.cpp
+13
-5
13 additions, 5 deletions
src/libs/cplusplus/FindUsages.cpp
src/libs/cplusplus/FindUsages.h
+7
-3
7 additions, 3 deletions
src/libs/cplusplus/FindUsages.h
src/plugins/cpptools/cppfindreferences.cpp
+8
-4
8 additions, 4 deletions
src/plugins/cpptools/cppfindreferences.cpp
with
28 additions
and
12 deletions
src/libs/cplusplus/FindUsages.cpp
+
13
−
5
View file @
d5c2dedd
...
@@ -57,17 +57,23 @@ void FindUsages::setGlobalNamespaceBinding(NamespaceBindingPtr globalNamespaceBi
...
@@ -57,17 +57,23 @@ void FindUsages::setGlobalNamespaceBinding(NamespaceBindingPtr globalNamespaceBi
_globalNamespaceBinding
=
globalNamespaceBinding
;
_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
();
_processed
.
clear
();
_references
.
clear
();
_references
.
clear
();
_usages
.
clear
();
_declSymbol
=
symbol
;
_declSymbol
=
symbol
;
_id
=
id
;
_id
=
id
;
if
(
_declSymbol
&&
_id
)
{
if
(
_declSymbol
&&
_id
)
{
_exprDoc
=
Document
::
create
(
"<references>"
);
_exprDoc
=
Document
::
create
(
"<references>"
);
accept
(
ast
);
accept
(
ast
);
}
}
return
_references
;
}
}
QString
FindUsages
::
matchingLine
(
const
Token
&
tk
)
const
QString
FindUsages
::
matchingLine
(
const
Token
&
tk
)
const
...
@@ -120,9 +126,11 @@ void FindUsages::reportResult(unsigned tokenIndex)
...
@@ -120,9 +126,11 @@ void FindUsages::reportResult(unsigned tokenIndex)
const
int
len
=
tk
.
f
.
length
;
const
int
len
=
tk
.
f
.
length
;
if
(
_future
)
{
const
Usage
u
(
_doc
->
fileName
(),
line
,
lineText
,
col
,
len
);
_future
->
reportResult
(
Usage
(
_doc
->
fileName
(),
line
,
lineText
,
col
,
len
));
_usages
.
append
(
u
);
}
if
(
_future
)
_future
->
reportResult
(
u
);
_references
.
append
(
tokenIndex
);
_references
.
append
(
tokenIndex
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/libs/cplusplus/FindUsages.h
+
7
−
3
View file @
d5c2dedd
...
@@ -47,12 +47,12 @@ public:
...
@@ -47,12 +47,12 @@ public:
:
line
(
0
),
col
(
0
),
len
(
0
)
{}
:
line
(
0
),
col
(
0
),
len
(
0
)
{}
Usage
(
const
QString
&
path
,
int
line
,
const
QString
&
lineText
,
int
col
,
int
len
)
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
:
public
:
QString
path
;
QString
path
;
int
line
;
QString
lineText
;
QString
lineText
;
int
line
;
int
col
;
int
col
;
int
len
;
int
len
;
};
};
...
@@ -64,7 +64,10 @@ public:
...
@@ -64,7 +64,10 @@ public:
void
setGlobalNamespaceBinding
(
NamespaceBindingPtr
globalNamespaceBinding
);
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:
protected:
using
ASTVisitor
::
visit
;
using
ASTVisitor
::
visit
;
...
@@ -112,6 +115,7 @@ private:
...
@@ -112,6 +115,7 @@ private:
QList
<
PostfixExpressionAST
*>
_postfixExpressionStack
;
QList
<
PostfixExpressionAST
*>
_postfixExpressionStack
;
QList
<
QualifiedNameAST
*>
_qualifiedNameStack
;
QList
<
QualifiedNameAST
*>
_qualifiedNameStack
;
QList
<
int
>
_references
;
QList
<
int
>
_references
;
QList
<
Usage
>
_usages
;
LookupContext
_previousContext
;
LookupContext
_previousContext
;
int
_inSimpleDeclaration
;
int
_inSimpleDeclaration
;
QSet
<
unsigned
>
_processed
;
QSet
<
unsigned
>
_processed
;
...
...
This diff is collapsed.
Click to expand it.
src/plugins/cpptools/cppfindreferences.cpp
+
8
−
4
View file @
d5c2dedd
...
@@ -91,9 +91,10 @@ QList<int> CppFindReferences::references(Symbol *symbol,
...
@@ -91,9 +91,10 @@ QList<int> CppFindReferences::references(Symbol *symbol,
TranslationUnit
*
translationUnit
=
doc
->
translationUnit
();
TranslationUnit
*
translationUnit
=
doc
->
translationUnit
();
Q_ASSERT
(
translationUnit
!=
0
);
Q_ASSERT
(
translationUnit
!=
0
);
FindUsages
process
(
doc
,
snapshot
,
/*future = */
0
);
FindUsages
findUsages
(
doc
,
snapshot
,
/*future = */
0
);
process
.
setGlobalNamespaceBinding
(
bind
(
doc
,
snapshot
));
findUsages
.
setGlobalNamespaceBinding
(
bind
(
doc
,
snapshot
));
references
=
process
(
symbol
,
id
,
translationUnit
->
ast
());
findUsages
(
symbol
,
id
,
translationUnit
->
ast
());
references
=
findUsages
.
references
();
return
references
;
return
references
;
}
}
...
@@ -229,7 +230,10 @@ void CppFindReferences::findAll_helper(Symbol *symbol)
...
@@ -229,7 +230,10 @@ void CppFindReferences::findAll_helper(Symbol *symbol)
const
QMap
<
QString
,
QString
>
wl
=
_modelManager
->
workingCopy
();
const
QMap
<
QString
,
QString
>
wl
=
_modelManager
->
workingCopy
();
Core
::
ProgressManager
*
progressManager
=
Core
::
ICore
::
instance
()
->
progressManager
();
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
);
m_watcher
.
setFuture
(
result
);
Core
::
FutureProgress
*
progress
=
progressManager
->
addTask
(
result
,
tr
(
"Searching..."
),
Core
::
FutureProgress
*
progress
=
progressManager
->
addTask
(
result
,
tr
(
"Searching..."
),
...
...
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