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
7e0e62cb
Commit
7e0e62cb
authored
Oct 07, 2009
by
Roberto Raggi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Find the canonical virtual method.
parent
afedec33
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
110 additions
and
28 deletions
+110
-28
src/libs/cplusplus/LookupContext.cpp
src/libs/cplusplus/LookupContext.cpp
+92
-19
src/libs/cplusplus/LookupContext.h
src/libs/cplusplus/LookupContext.h
+10
-3
src/plugins/cppeditor/cppeditor.cpp
src/plugins/cppeditor/cppeditor.cpp
+3
-3
src/plugins/cpptools/cppfindreferences.cpp
src/plugins/cpptools/cppfindreferences.cpp
+3
-2
src/plugins/cpptools/cppmodelmanager.cpp
src/plugins/cpptools/cppmodelmanager.cpp
+2
-1
No files found.
src/libs/cplusplus/LookupContext.cpp
View file @
7e0e62cb
...
...
@@ -30,6 +30,7 @@
#include "LookupContext.h"
#include "ResolveExpression.h"
#include "Overview.h"
#include "CppBindings.h"
#include <CoreTypes.h>
#include <Symbols.h>
...
...
@@ -501,6 +502,97 @@ void LookupContext::expand(Scope *scope,
}
}
static
void
visibleClassBindings_helper
(
ClassBinding
*
classBinding
,
QList
<
ClassBinding
*>
*
allClassBindings
,
QSet
<
ClassBinding
*>
*
processed
)
{
if
(
!
classBinding
)
return
;
else
if
(
processed
->
contains
(
classBinding
))
return
;
processed
->
insert
(
classBinding
);
foreach
(
ClassBinding
*
baseClassBinding
,
classBinding
->
baseClassBindings
)
visibleClassBindings_helper
(
baseClassBinding
,
allClassBindings
,
processed
);
allClassBindings
->
append
(
classBinding
);
}
static
QList
<
ClassBinding
*>
visibleClassBindings
(
Symbol
*
symbol
,
NamespaceBinding
*
globalNamespace
)
{
QList
<
ClassBinding
*>
classBindings
;
if
(
!
symbol
)
return
classBindings
;
else
if
(
Class
*
klass
=
symbol
->
asClass
())
{
QSet
<
ClassBinding
*>
processed
;
visibleClassBindings_helper
(
NamespaceBinding
::
find
(
klass
,
globalNamespace
),
&
classBindings
,
&
processed
);
}
return
classBindings
;
}
Symbol
*
LookupContext
::
canonicalSymbol
(
Symbol
*
symbol
,
NamespaceBinding
*
globalNamespace
)
{
Symbol
*
canonicalSymbol
=
LookupContext
::
canonicalSymbol
(
symbol
);
if
(
Identifier
*
symbolId
=
canonicalSymbol
->
identifier
())
{
if
(
symbolId
&&
canonicalSymbol
->
type
()
->
isFunctionType
())
{
Class
*
enclosingClass
=
canonicalSymbol
->
scope
()
->
owner
()
->
asClass
();
const
QList
<
ClassBinding
*>
classBindings
=
visibleClassBindings
(
enclosingClass
,
globalNamespace
);
foreach
(
ClassBinding
*
baseClassBinding
,
classBindings
)
{
if
(
!
baseClassBinding
)
continue
;
foreach
(
Class
*
baseClass
,
baseClassBinding
->
symbols
)
{
if
(
!
baseClass
)
continue
;
for
(
Symbol
*
c
=
baseClass
->
members
()
->
lookat
(
symbolId
);
c
;
c
=
c
->
next
())
{
if
(
!
symbolId
->
isEqualTo
(
c
->
identifier
()))
continue
;
else
if
(
Function
*
f
=
c
->
type
()
->
asFunctionType
())
{
if
(
f
->
isVirtual
())
return
LookupContext
::
canonicalSymbol
(
f
);
}
}
}
}
}
}
return
canonicalSymbol
;
}
Symbol
*
LookupContext
::
canonicalSymbol
(
const
QList
<
Symbol
*>
&
candidates
,
NamespaceBinding
*
globalNamespaceBinding
)
{
if
(
candidates
.
isEmpty
())
return
0
;
return
canonicalSymbol
(
candidates
.
first
(),
globalNamespaceBinding
);
}
Symbol
*
LookupContext
::
canonicalSymbol
(
const
QList
<
QPair
<
FullySpecifiedType
,
Symbol
*>
>
&
results
,
NamespaceBinding
*
globalNamespaceBinding
)
{
QList
<
Symbol
*>
candidates
;
QPair
<
FullySpecifiedType
,
Symbol
*>
result
;
foreach
(
result
,
results
)
candidates
.
append
(
result
.
second
);
// ### not exacly.
return
canonicalSymbol
(
candidates
,
globalNamespaceBinding
);
}
Symbol
*
LookupContext
::
canonicalSymbol
(
Symbol
*
symbol
)
{
Symbol
*
canonical
=
symbol
;
...
...
@@ -531,22 +623,3 @@ Symbol *LookupContext::canonicalSymbol(Symbol *symbol)
return
canonical
;
}
Symbol
*
LookupContext
::
canonicalSymbol
(
const
QList
<
Symbol
*>
&
candidates
)
{
if
(
candidates
.
isEmpty
())
return
0
;
return
canonicalSymbol
(
candidates
.
first
());
}
Symbol
*
LookupContext
::
canonicalSymbol
(
const
QList
<
QPair
<
FullySpecifiedType
,
Symbol
*>
>
&
results
)
{
QList
<
Symbol
*>
candidates
;
QPair
<
FullySpecifiedType
,
Symbol
*>
result
;
foreach
(
result
,
results
)
candidates
.
append
(
result
.
second
);
// ### not exacly.
return
canonicalSymbol
(
candidates
);
}
src/libs/cplusplus/LookupContext.h
View file @
7e0e62cb
...
...
@@ -54,9 +54,14 @@ public:
Document
::
Ptr
document
(
const
QString
&
fileName
)
const
;
Snapshot
snapshot
()
const
;
static
Symbol
*
canonicalSymbol
(
Symbol
*
symbol
);
static
Symbol
*
canonicalSymbol
(
const
QList
<
Symbol
*>
&
candidates
);
static
Symbol
*
canonicalSymbol
(
const
QList
<
QPair
<
FullySpecifiedType
,
Symbol
*>
>
&
candidates
);
// ### FIXME
static
Symbol
*
canonicalSymbol
(
const
QList
<
Symbol
*>
&
candidates
,
NamespaceBinding
*
globalNamespaceBinding
);
static
Symbol
*
canonicalSymbol
(
Symbol
*
symbol
,
NamespaceBinding
*
globalNamespaceBinding
);
static
Symbol
*
canonicalSymbol
(
const
QList
<
QPair
<
FullySpecifiedType
,
Symbol
*>
>
&
candidates
,
NamespaceBinding
*
globalNamespaceBinding
);
QList
<
Symbol
*>
resolve
(
Name
*
name
)
const
{
return
resolve
(
name
,
visibleScopes
());
}
...
...
@@ -126,6 +131,8 @@ public:
QList
<
Scope
*>
*
expandedScopes
)
const
;
private:
static
Symbol
*
canonicalSymbol
(
Symbol
*
symbol
);
QList
<
Symbol
*>
resolveQualifiedNameId
(
QualifiedNameId
*
q
,
const
QList
<
Scope
*>
&
visibleScopes
,
ResolveMode
mode
)
const
;
...
...
src/plugins/cppeditor/cppeditor.cpp
View file @
7e0e62cb
...
...
@@ -58,6 +58,7 @@
#include <cplusplus/MatchingText.h>
#include <cplusplus/BackwardsScanner.h>
#include <cplusplus/FastPreprocessor.h>
#include <cplusplus/CppBindings.h>
#include <cpptools/cppmodelmanagerinterface.h>
...
...
@@ -838,8 +839,6 @@ CPlusPlus::Symbol *CPPEditor::findCanonicalSymbol(const QTextCursor &cursor,
const
QString
code
=
expressionUnderCursor
(
tc
);
// qDebug() << "code:" << code;
const
QString
fileName
=
const_cast
<
CPPEditor
*>
(
this
)
->
file
()
->
fileName
();
TypeOfExpression
typeOfExpression
;
typeOfExpression
.
setSnapshot
(
snapshot
);
...
...
@@ -849,7 +848,8 @@ CPlusPlus::Symbol *CPPEditor::findCanonicalSymbol(const QTextCursor &cursor,
lastVisibleSymbol
,
TypeOfExpression
::
Preprocess
);
Symbol
*
canonicalSymbol
=
LookupContext
::
canonicalSymbol
(
results
);
NamespaceBindingPtr
glo
=
bind
(
doc
,
snapshot
);
Symbol
*
canonicalSymbol
=
LookupContext
::
canonicalSymbol
(
results
,
glo
.
data
());
return
canonicalSymbol
;
}
...
...
src/plugins/cpptools/cppfindreferences.cpp
View file @
7e0e62cb
...
...
@@ -152,7 +152,8 @@ protected:
bool
checkCandidates
(
const
QList
<
Symbol
*>
&
candidates
)
const
{
if
(
Symbol
*
canonicalSymbol
=
LookupContext
::
canonicalSymbol
(
candidates
))
{
if
(
Symbol
*
canonicalSymbol
=
LookupContext
::
canonicalSymbol
(
candidates
,
_globalNamespaceBinding
.
data
()))
{
#if 0
qDebug() << "*** canonical symbol:" << canonicalSymbol->fileName()
<< canonicalSymbol->line() << canonicalSymbol->column()
...
...
@@ -498,7 +499,7 @@ static void find_helper(QFutureInterface<Utils::FileSearchResult> &future,
files
+=
snapshot
.
dependsOn
(
sourceFile
);
}
qDebug
()
<<
"done in:"
<<
tm
.
elapsed
()
<<
"number of files to parse:"
<<
files
.
size
();
//
qDebug() << "done in:" << tm.elapsed() << "number of files to parse:" << files.size();
future
.
setProgressRange
(
0
,
files
.
size
());
...
...
src/plugins/cpptools/cppmodelmanager.cpp
View file @
7e0e62cb
...
...
@@ -752,7 +752,8 @@ QList<int> CppModelManager::references(CPlusPlus::Symbol *symbol,
CPlusPlus
::
Document
::
Ptr
doc
,
const
CPlusPlus
::
Snapshot
&
snapshot
)
{
return
m_findReferences
->
references
(
LookupContext
::
canonicalSymbol
(
symbol
),
doc
,
snapshot
);
NamespaceBindingPtr
glo
=
bind
(
doc
,
snapshot
);
return
m_findReferences
->
references
(
LookupContext
::
canonicalSymbol
(
symbol
,
glo
.
data
()),
doc
,
snapshot
);
}
void
CppModelManager
::
findUsages
(
CPlusPlus
::
Symbol
*
symbol
)
...
...
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