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
0f301f86
Commit
0f301f86
authored
Aug 10, 2010
by
Roberto Raggi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New implementation of CPlusPlus::FindUsages
parent
f72a080d
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
2042 additions
and
287 deletions
+2042
-287
src/libs/cplusplus/FindUsages.cpp
src/libs/cplusplus/FindUsages.cpp
+1814
-247
src/libs/cplusplus/FindUsages.h
src/libs/cplusplus/FindUsages.h
+200
-28
src/plugins/cppeditor/cppeditor.cpp
src/plugins/cppeditor/cppeditor.cpp
+7
-7
src/plugins/cpptools/cppfindreferences.cpp
src/plugins/cpptools/cppfindreferences.cpp
+13
-5
src/shared/cplusplus/Control.cpp
src/shared/cplusplus/Control.cpp
+6
-0
src/shared/cplusplus/Control.h
src/shared/cplusplus/Control.h
+2
-0
No files found.
src/libs/cplusplus/FindUsages.cpp
View file @
0f301f86
This diff is collapsed.
Click to expand it.
src/libs/cplusplus/FindUsages.h
View file @
0f301f86
This diff is collapsed.
Click to expand it.
src/plugins/cppeditor/cppeditor.cpp
View file @
0f301f86
...
...
@@ -739,12 +739,14 @@ void CPPEditor::markSymbolsNow()
setExtraSelections
(
CodeSemanticsSelection
,
selections
);
}
static
QList
<
int
>
lazyFindReferences
(
Scope
*
scope
,
QString
code
,
const
LookupContext
&
contex
t
)
static
QList
<
int
>
lazyFindReferences
(
Scope
*
scope
,
QString
code
,
Document
::
Ptr
doc
,
Snapshot
snapsho
t
)
{
TypeOfExpression
typeOfExpression
;
typeOfExpression
.
init
(
context
.
thisDocument
(),
context
.
snapshot
(),
context
.
bindings
());
if
(
Symbol
*
canonicalSymbol
=
CanonicalSymbol
::
canonicalSymbol
(
scope
,
code
,
typeOfExpression
))
return
CppTools
::
CppModelManagerInterface
::
instance
()
->
references
(
canonicalSymbol
,
context
);
snapshot
.
insert
(
doc
);
typeOfExpression
.
init
(
doc
,
snapshot
);
if
(
Symbol
*
canonicalSymbol
=
CanonicalSymbol
::
canonicalSymbol
(
scope
,
code
,
typeOfExpression
))
{
return
CppTools
::
CppModelManagerInterface
::
instance
()
->
references
(
canonicalSymbol
,
typeOfExpression
.
context
());
}
return
QList
<
int
>
();
}
...
...
@@ -758,12 +760,10 @@ void CPPEditor::markSymbols(const QTextCursor &tc, const SemanticInfo &info)
CanonicalSymbol
cs
(
this
,
info
);
QString
expression
;
if
(
Scope
*
scope
=
cs
.
getScopeAndExpression
(
this
,
info
,
tc
,
&
expression
))
{
LookupContext
context
(
info
.
doc
,
info
.
snapshot
);
m_references
.
cancel
();
m_referencesRevision
=
info
.
revision
;
m_referencesCursorPosition
=
position
();
m_references
=
QtConcurrent
::
run
(
&
lazyFindReferences
,
scope
,
expression
,
contex
t
);
m_references
=
QtConcurrent
::
run
(
&
lazyFindReferences
,
scope
,
expression
,
info
.
doc
,
info
.
snapsho
t
);
m_referencesWatcher
.
setFuture
(
m_references
);
}
else
{
const
QList
<
QTextEdit
::
ExtraSelection
>
selections
=
extraSelections
(
CodeSemanticsSelection
);
...
...
src/plugins/cpptools/cppfindreferences.cpp
View file @
0f301f86
...
...
@@ -52,6 +52,7 @@
#include <cplusplus/CppDocument.h>
#include <cplusplus/Overview.h>
#include <cplusplus/FindUsages.h>
#include <QtCore/QTime>
#include <QtCore/QTimer>
...
...
@@ -108,18 +109,25 @@ public:
return
usages
;
// skip this document, it's not using symbolId.
}
QByteArray
source
=
snapshot
.
preprocessedCode
(
getSource
(
fileName
,
workingCopy
),
fileName
)
;
Document
::
Ptr
doc
;
QByteArray
source
;
Document
::
Ptr
doc
=
snapshot
.
documentFromSource
(
source
,
fileName
);
if
(
symbolDocument
&&
fileName
==
symbolDocument
->
fileName
())
doc
=
symbolDocument
;
else
{
source
=
snapshot
.
preprocessedCode
(
getSource
(
fileName
,
workingCopy
),
fileName
);
doc
=
snapshot
.
documentFromSource
(
source
,
fileName
);
doc
->
tokenize
();
}
Control
*
control
=
doc
->
control
();
if
(
control
->
findIdentifier
(
symbolId
->
chars
(),
symbolId
->
size
())
!=
0
)
{
if
(
doc
!=
symbolDocument
)
doc
->
check
();
FindUsages
process
(
doc
,
snapshot
);
process
(
symbol
);
usages
=
process
.
usages
();
}
...
...
src/shared/cplusplus/Control.cpp
View file @
0f301f86
...
...
@@ -56,6 +56,7 @@
#include "TypeMatcher.h"
#include <map>
#include <set>
#include <algorithm>
using
namespace
CPlusPlus
;
...
...
@@ -770,3 +771,8 @@ const Identifier *Control::objcCopyId() const
const
Identifier
*
Control
::
objcNonatomicId
()
const
{
return
d
->
objcNonatomicId
;
}
bool
Control
::
hasSymbol
(
Symbol
*
symbol
)
const
{
return
std
::
find
(
d
->
symbols
.
begin
(),
d
->
symbols
.
end
(),
symbol
)
!=
d
->
symbols
.
end
();
}
src/shared/cplusplus/Control.h
View file @
0f301f86
...
...
@@ -209,6 +209,8 @@ public:
const
NumericLiteral
*
findOrInsertNumericLiteral
(
const
char
*
chars
,
unsigned
size
);
const
NumericLiteral
*
findOrInsertNumericLiteral
(
const
char
*
chars
);
bool
hasSymbol
(
Symbol
*
symbol
)
const
;
private:
class
Data
;
friend
class
Data
;
...
...
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