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
354b9712
Commit
354b9712
authored
Aug 11, 2010
by
Roberto Raggi
Browse files
Merged ScopedSymbol and Scope.
parent
5accc966
Changes
33
Hide whitespace changes
Inline
Side-by-side
src/libs/cplusplus/CppDocument.cpp
View file @
354b9712
...
...
@@ -76,13 +76,13 @@ public:
}
protected:
bool
process
(
Scope
dSymbol
*
symbol
)
bool
process
(
Scope
*
symbol
)
{
if
(
!
_scope
)
{
Scope
*
scope
=
symbol
->
members
()
;
Scope
*
scope
=
symbol
;
for
(
unsigned
i
=
0
;
i
<
scope
->
symbol
Count
();
++
i
)
{
accept
(
scope
->
symbol
At
(
i
));
for
(
unsigned
i
=
0
;
i
<
scope
->
member
Count
();
++
i
)
{
accept
(
scope
->
member
At
(
i
));
if
(
_scope
)
return
false
;
...
...
@@ -388,14 +388,6 @@ Symbol *Document::globalSymbolAt(unsigned index) const
return
_globalNamespace
->
memberAt
(
index
);
}
Scope
*
Document
::
globalSymbols
()
const
{
if
(
!
_globalNamespace
)
return
0
;
return
_globalNamespace
->
members
();
}
Namespace
*
Document
::
globalNamespace
()
const
{
return
_globalNamespace
;
...
...
@@ -411,20 +403,20 @@ Scope *Document::scopeAt(unsigned line, unsigned column)
FindScopeAt
findScopeAt
(
_translationUnit
,
line
,
column
);
if
(
Scope
*
scope
=
findScopeAt
(
_globalNamespace
))
return
scope
;
return
global
Symbols
();
return
global
Namespace
();
}
Symbol
*
Document
::
lastVisibleSymbolAt
(
unsigned
line
,
unsigned
column
)
const
{
return
lastVisibleSymbolAt
(
line
,
column
,
global
Symbols
());
return
lastVisibleSymbolAt
(
line
,
column
,
global
Namespace
());
}
Symbol
*
Document
::
lastVisibleSymbolAt
(
unsigned
line
,
unsigned
column
,
Scope
*
scope
)
const
{
Symbol
*
previousSymbol
=
0
;
for
(
unsigned
i
=
0
;
i
<
scope
->
symbol
Count
();
++
i
)
{
Symbol
*
symbol
=
scope
->
symbol
At
(
i
);
for
(
unsigned
i
=
0
;
i
<
scope
->
member
Count
();
++
i
)
{
Symbol
*
symbol
=
scope
->
member
At
(
i
);
if
(
symbol
->
line
()
>
line
)
break
;
...
...
@@ -432,8 +424,8 @@ Symbol *Document::lastVisibleSymbolAt(unsigned line, unsigned column, Scope *sco
}
if
(
previousSymbol
)
{
if
(
Scope
dSymbol
*
scope
d
=
previousSymbol
->
asScope
dSymbol
())
{
if
(
Symbol
*
member
=
lastVisibleSymbolAt
(
line
,
column
,
scope
d
->
members
()
))
if
(
Scope
*
scope
=
previousSymbol
->
asScope
())
{
if
(
Symbol
*
member
=
lastVisibleSymbolAt
(
line
,
column
,
scope
))
return
member
;
}
}
...
...
@@ -558,7 +550,7 @@ void Document::check(CheckMode mode)
semantic
.
setSkipFunctionBodies
(
true
);
_globalNamespace
=
_control
->
newNamespace
(
0
);
Scope
*
globals
=
_globalNamespace
->
members
()
;
Scope
*
globals
=
_globalNamespace
;
if
(
!
_translationUnit
->
ast
())
return
;
// nothing to do.
...
...
src/libs/cplusplus/CppDocument.h
View file @
354b9712
...
...
@@ -84,7 +84,6 @@ public:
unsigned
globalSymbolCount
()
const
;
Symbol
*
globalSymbolAt
(
unsigned
index
)
const
;
Scope
*
globalSymbols
()
const
;
// ### deprecate?
Namespace
*
globalNamespace
()
const
;
void
setGlobalNamespace
(
Namespace
*
globalNamespace
);
// ### internal
...
...
src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp
View file @
354b9712
...
...
@@ -401,7 +401,7 @@ FullySpecifiedType DeprecatedGenTemplateInstance::instantiate(const Name *classN
{
if
(
className
)
{
if
(
const
TemplateNameId
*
templId
=
className
->
asTemplateNameId
())
{
if
(
Class
*
klass
=
candidate
->
enclosingSymbol
()
->
asClass
())
{
if
(
Class
*
klass
=
candidate
->
scope
()
->
asClass
())
{
DeprecatedGenTemplateInstance
::
Substitution
subst
;
for
(
unsigned
i
=
0
;
i
<
templId
->
templateArgumentCount
();
++
i
)
{
...
...
src/libs/cplusplus/FindUsages.cpp
View file @
354b9712
...
...
@@ -209,7 +209,7 @@ bool FindUsages::checkCandidates(const QList<LookupItem> &candidates) const
const
LookupItem
&
r
=
candidates
.
at
(
i
);
if
(
Symbol
*
s
=
r
.
declaration
())
{
if
(
_declSymbol
->
scope
()
&&
(
_declSymbol
->
scope
()
->
is
PrototypeScope
()
||
_declSymbol
->
scope
()
->
isBlock
Scope
()))
{
if
(
_declSymbol
->
scope
()
&&
(
_declSymbol
->
scope
()
->
is
Function
()
||
_declSymbol
->
scope
()
->
isBlock
()))
{
if
(
s
->
scope
()
!=
_declSymbol
->
scope
())
return
false
;
...
...
@@ -240,19 +240,12 @@ void FindUsages::checkExpression(unsigned startToken, unsigned endToken, Scope *
reportResult
(
endToken
,
results
);
}
Scope
*
FindUsages
::
switchScope
(
ScopedSymbol
*
symbol
)
{
if
(
!
symbol
)
return
_currentScope
;
// ### assert?
return
switchScope
(
symbol
->
members
());
}
Scope
*
FindUsages
::
switchScope
(
Scope
*
scope
)
{
Scope
*
previousScope
=
_currentScope
;
_currentScope
=
scope
;
return
previousScope
;
if
(
!
scope
)
return
_currentScope
;
return
switchScope
(
scope
);
}
void
FindUsages
::
statement
(
StatementAST
*
ast
)
...
...
@@ -345,7 +338,7 @@ bool FindUsages::visit(DeclaratorAST *ast)
return
false
;
}
void
FindUsages
::
declarator
(
DeclaratorAST
*
ast
,
Scope
dSymbol
*
symbol
)
void
FindUsages
::
declarator
(
DeclaratorAST
*
ast
,
Scope
*
symbol
)
{
if
(
!
ast
)
return
;
...
...
@@ -493,13 +486,13 @@ void FindUsages::memInitializer(MemInitializerAST *ast)
if
(
!
ast
)
return
;
if
(
_currentScope
->
is
PrototypeScope
())
{
Scope
*
classScope
=
_currentScope
->
enclosingClass
Scope
();
if
(
_currentScope
->
is
Function
())
{
Class
*
classScope
=
_currentScope
->
enclosingClass
();
if
(
!
classScope
)
{
if
(
ClassOrNamespace
*
binding
=
_context
.
lookupType
(
_currentScope
->
owner
()
))
{
if
(
ClassOrNamespace
*
binding
=
_context
.
lookupType
(
_currentScope
))
{
foreach
(
Symbol
*
s
,
binding
->
symbols
())
{
if
(
Class
*
k
=
s
->
asClass
())
{
classScope
=
k
->
members
()
;
classScope
=
k
;
break
;
}
}
...
...
@@ -658,7 +651,7 @@ void FindUsages::translationUnit(TranslationUnitAST *ast)
if
(
!
ast
)
return
;
Scope
*
previousScope
=
switchScope
(
_doc
->
global
Symbols
());
Scope
*
previousScope
=
switchScope
(
_doc
->
global
Namespace
());
for
(
DeclarationListAST
*
it
=
ast
->
declaration_list
;
it
;
it
=
it
->
next
)
{
this
->
declaration
(
it
->
value
);
}
...
...
src/libs/cplusplus/FindUsages.h
View file @
354b9712
...
...
@@ -71,7 +71,6 @@ protected:
using
ASTVisitor
::
translationUnit
;
Scope
*
switchScope
(
Scope
*
scope
);
Scope
*
switchScope
(
ScopedSymbol
*
symbol
);
QString
matchingLine
(
const
Token
&
tk
)
const
;
...
...
@@ -97,7 +96,7 @@ protected:
void
objCSelectorArgument
(
ObjCSelectorArgumentAST
*
ast
);
void
attribute
(
AttributeAST
*
ast
);
void
declarator
(
DeclaratorAST
*
ast
,
Scope
dSymbol
*
symbol
=
0
);
void
declarator
(
DeclaratorAST
*
ast
,
Scope
*
symbol
=
0
);
void
qtPropertyDeclarationItem
(
QtPropertyDeclarationItemAST
*
ast
);
void
qtInterfaceName
(
QtInterfaceNameAST
*
ast
);
void
baseSpecifier
(
BaseSpecifierAST
*
ast
);
...
...
src/libs/cplusplus/Icons.cpp
View file @
354b9712
...
...
@@ -99,7 +99,7 @@ Icons::IconType Icons::iconTypeForSymbol(const Symbol *symbol)
}
else
if
(
symbol
->
isPrivate
())
{
return
FuncPrivateIconType
;
}
}
else
if
(
symbol
->
scope
()
&&
symbol
->
scope
()
->
isEnum
Scope
())
{
}
else
if
(
symbol
->
scope
()
&&
symbol
->
scope
()
->
isEnum
())
{
return
EnumeratorIconType
;
}
else
if
(
symbol
->
isDeclaration
()
||
symbol
->
isArgument
())
{
if
(
symbol
->
isPublic
())
{
...
...
src/libs/cplusplus/LookupContext.cpp
View file @
354b9712
...
...
@@ -68,7 +68,7 @@ static void path_helper(Symbol *symbol, QList<const Name *> *names)
if
(
!
symbol
)
return
;
path_helper
(
symbol
->
enclosingSymbol
(),
names
);
path_helper
(
symbol
->
scope
(),
names
);
if
(
symbol
->
name
())
{
if
(
symbol
->
isClass
()
||
symbol
->
isNamespace
())
{
...
...
@@ -142,7 +142,7 @@ LookupContext &LookupContext::operator = (const LookupContext &other)
QList
<
const
Name
*>
LookupContext
::
fullyQualifiedName
(
Symbol
*
symbol
)
{
QList
<
const
Name
*>
qualifiedName
=
path
(
symbol
->
enclosingSymbol
());
QList
<
const
Name
*>
qualifiedName
=
path
(
symbol
->
scope
());
addNames
(
symbol
->
name
(),
&
qualifiedName
,
/*add all names*/
true
);
return
qualifiedName
;
}
...
...
@@ -238,7 +238,7 @@ ClassOrNamespace *LookupContext::globalNamespace() const
ClassOrNamespace
*
LookupContext
::
lookupType
(
const
Name
*
name
,
Scope
*
scope
)
const
{
if
(
ClassOrNamespace
*
b
=
bindings
()
->
lookupType
(
scope
->
owner
()
))
if
(
ClassOrNamespace
*
b
=
bindings
()
->
lookupType
(
scope
))
return
b
->
lookupType
(
name
);
return
0
;
...
...
@@ -256,18 +256,18 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
if
(
!
name
)
return
candidates
;
for
(;
scope
;
scope
=
scope
->
enclosingS
cope
())
{
if
((
name
->
isNameId
()
||
name
->
isTemplateNameId
())
&&
scope
->
isBlock
Scope
())
{
for
(;
scope
;
scope
=
scope
->
s
cope
())
{
if
((
name
->
isNameId
()
||
name
->
isTemplateNameId
())
&&
scope
->
isBlock
())
{
bindings
()
->
lookupInScope
(
name
,
scope
,
&
candidates
,
/*templateId = */
0
,
/*binding=*/
0
);
if
(
!
candidates
.
isEmpty
())
break
;
// it's a local.
for
(
unsigned
index
=
0
;
index
<
scope
->
symbol
Count
();
++
index
)
{
Symbol
*
member
=
scope
->
symbol
At
(
index
);
for
(
unsigned
index
=
0
;
index
<
scope
->
member
Count
();
++
index
)
{
Symbol
*
member
=
scope
->
member
At
(
index
);
if
(
UsingNamespaceDirective
*
u
=
member
->
asUsingNamespaceDirective
())
{
if
(
Namespace
*
enclosingNamespace
=
u
->
enclosingNamespace
Scope
()
->
owner
()
->
asNamespace
())
{
if
(
Namespace
*
enclosingNamespace
=
u
->
enclosingNamespace
()
->
asNamespace
())
{
if
(
ClassOrNamespace
*
b
=
bindings
()
->
lookupType
(
enclosingNamespace
))
{
if
(
ClassOrNamespace
*
uu
=
b
->
lookupType
(
u
->
name
()))
{
candidates
=
uu
->
find
(
name
);
...
...
@@ -280,9 +280,8 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
}
}
}
else
if
(
scope
->
isPrototypeScope
())
{
Function
*
fun
=
scope
->
owner
()
->
asFunction
();
bindings
()
->
lookupInScope
(
name
,
fun
->
members
(),
&
candidates
,
/*templateId = */
0
,
/*binding=*/
0
);
}
else
if
(
Function
*
fun
=
scope
->
asFunction
())
{
bindings
()
->
lookupInScope
(
name
,
fun
,
&
candidates
,
/*templateId = */
0
,
/*binding=*/
0
);
for
(
TemplateParameters
*
it
=
fun
->
templateParameters
();
it
&&
candidates
.
isEmpty
();
it
=
it
->
previous
())
bindings
()
->
lookupInScope
(
name
,
it
->
scope
(),
&
candidates
,
/* templateId = */
0
,
/*binding=*/
0
);
...
...
@@ -301,16 +300,13 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
// contunue, and look at the enclosing scope.
}
else
if
(
scope
->
isObjCMethodScope
())
{
ObjCMethod
*
method
=
scope
->
owner
()
->
asObjCMethod
();
bindings
()
->
lookupInScope
(
name
,
method
->
arguments
(),
&
candidates
,
/*templateId = */
0
,
/*binding=*/
0
);
}
else
if
(
ObjCMethod
*
method
=
scope
->
asObjCMethod
())
{
bindings
()
->
lookupInScope
(
name
,
method
,
&
candidates
,
/*templateId = */
0
,
/*binding=*/
0
);
if
(
!
candidates
.
isEmpty
())
break
;
// it's a formal argument.
}
else
if
(
scope
->
isClassScope
())
{
Class
*
klass
=
scope
->
owner
()
->
asClass
();
}
else
if
(
Class
*
klass
=
scope
->
asClass
())
{
for
(
TemplateParameters
*
it
=
klass
->
templateParameters
();
it
&&
candidates
.
isEmpty
();
it
=
it
->
previous
())
bindings
()
->
lookupInScope
(
name
,
it
->
scope
(),
&
candidates
,
/* templateId = */
0
,
/*binding=*/
0
);
...
...
@@ -324,15 +320,15 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
return
candidates
;
}
}
else
if
(
scope
->
i
sNamespace
Scope
())
{
if
(
ClassOrNamespace
*
binding
=
bindings
()
->
lookupType
(
s
cope
->
owner
()
))
}
else
if
(
Namespace
*
ns
=
scope
->
a
sNamespace
())
{
if
(
ClassOrNamespace
*
binding
=
bindings
()
->
lookupType
(
n
s
))
candidates
=
binding
->
find
(
name
);
if
(
!
candidates
.
isEmpty
())
return
candidates
;
}
else
if
(
scope
->
isObjCClass
Scope
()
||
scope
->
isObjCProtocol
Scope
())
{
if
(
ClassOrNamespace
*
binding
=
bindings
()
->
lookupType
(
scope
->
owner
()
))
}
else
if
(
scope
->
isObjCClass
()
||
scope
->
isObjCProtocol
())
{
if
(
ClassOrNamespace
*
binding
=
bindings
()
->
lookupType
(
scope
))
candidates
=
binding
->
find
(
name
);
if
(
!
candidates
.
isEmpty
())
...
...
@@ -456,8 +452,8 @@ void ClassOrNamespace::lookup_helper(const Name *name, ClassOrNamespace *binding
if
(
s
->
isFriend
())
continue
;
if
(
Scope
dSymbol
*
scope
d
=
s
->
asScope
dSymbol
())
{
if
(
Class
*
klass
=
scope
d
->
asClass
())
{
if
(
Scope
*
scope
=
s
->
asScope
())
{
if
(
Class
*
klass
=
scope
->
asClass
())
{
if
(
const
Identifier
*
id
=
klass
->
identifier
())
{
if
(
nameId
&&
nameId
->
isEqualTo
(
id
))
{
LookupItem
item
;
...
...
@@ -467,12 +463,12 @@ void ClassOrNamespace::lookup_helper(const Name *name, ClassOrNamespace *binding
}
}
}
_factory
->
lookupInScope
(
name
,
scope
d
->
members
()
,
result
,
templateId
,
binding
);
_factory
->
lookupInScope
(
name
,
scope
,
result
,
templateId
,
binding
);
}
}
foreach
(
Enum
*
e
,
binding
->
enums
())
_factory
->
lookupInScope
(
name
,
e
->
members
()
,
result
,
templateId
,
binding
);
_factory
->
lookupInScope
(
name
,
e
,
result
,
templateId
,
binding
);
foreach
(
ClassOrNamespace
*
u
,
binding
->
usings
())
lookup_helper
(
name
,
u
,
result
,
processed
,
binding
->
_templateId
);
...
...
@@ -490,7 +486,7 @@ void CreateBindings::lookupInScope(const Name *name, Scope *scope,
return
;
}
else
if
(
const
OperatorNameId
*
op
=
name
->
asOperatorNameId
())
{
for
(
Symbol
*
s
=
scope
->
lookat
(
op
->
kind
());
s
;
s
=
s
->
next
())
{
for
(
Symbol
*
s
=
scope
->
find
(
op
->
kind
());
s
;
s
=
s
->
next
())
{
if
(
!
s
->
name
())
continue
;
else
if
(
s
->
isFriend
())
...
...
@@ -505,7 +501,7 @@ void CreateBindings::lookupInScope(const Name *name, Scope *scope,
}
}
else
if
(
const
Identifier
*
id
=
name
->
identifier
())
{
for
(
Symbol
*
s
=
scope
->
lookat
(
id
);
s
;
s
=
s
->
next
())
{
for
(
Symbol
*
s
=
scope
->
find
(
id
);
s
;
s
=
s
->
next
())
{
if
(
s
->
isFriend
())
continue
;
// skip friends
else
if
(
!
id
->
isEqualTo
(
s
->
identifier
()))
...
...
src/libs/cplusplus/OverviewModel.cpp
View file @
354b9712
...
...
@@ -79,13 +79,9 @@ QModelIndex OverviewModel::index(int row, int column, const QModelIndex &parent)
Symbol
*
parentSymbol
=
static_cast
<
Symbol
*>
(
parent
.
internalPointer
());
Q_ASSERT
(
parentSymbol
);
ScopedSymbol
*
scopedSymbol
=
parentSymbol
->
asScopedSymbol
();
Q_ASSERT
(
scopedSymbol
);
Scope
*
scope
=
scopedSymbol
->
members
();
Q_ASSERT
(
scope
);
return
createIndex
(
row
,
0
,
scope
->
symbolAt
(
row
));
Scope
*
scope
=
parentSymbol
->
asScope
();
Q_ASSERT
(
scope
!=
0
);
return
createIndex
(
row
,
0
,
scope
->
memberAt
(
row
));
}
}
...
...
@@ -96,14 +92,12 @@ QModelIndex OverviewModel::parent(const QModelIndex &child) const
return
QModelIndex
();
if
(
Scope
*
scope
=
symbol
->
scope
())
{
Symbol
*
parentSymbol
=
scope
->
owner
();
if
(
parentSymbol
&&
parentSymbol
->
scope
())
{
if
(
scope
->
scope
())
{
QModelIndex
index
;
if
(
parentSymbol
->
scope
()
&&
parentSymbol
->
scope
()
->
owner
()
&&
parentSymbol
->
scope
()
->
owner
()
->
scope
())
// the parent doesn't have a parent
index
=
createIndex
(
parentSymbol
->
index
(),
0
,
parentSymbol
);
if
(
scope
->
scope
()
&&
scope
->
scope
()
->
scope
())
// the parent doesn't have a parent
index
=
createIndex
(
scope
->
index
(),
0
,
scope
);
else
//+1 to account for no symbol item
index
=
createIndex
(
parentSymbol
->
index
()
+
1
,
0
,
parentSymbol
);
index
=
createIndex
(
scope
->
index
()
+
1
,
0
,
scope
);
return
index
;
}
}
...
...
@@ -122,12 +116,9 @@ int OverviewModel::rowCount(const QModelIndex &parent) const
Symbol
*
parentSymbol
=
static_cast
<
Symbol
*>
(
parent
.
internalPointer
());
Q_ASSERT
(
parentSymbol
);
if
(
ScopedSymbol
*
scopedSymbol
=
parentSymbol
->
asScopedSymbol
())
{
if
(
!
scopedSymbol
->
isFunction
()
&&
!
scopedSymbol
->
isObjCMethod
())
{
Scope
*
parentScope
=
scopedSymbol
->
members
();
Q_ASSERT
(
parentScope
);
return
parentScope
->
symbolCount
();
if
(
Scope
*
parentScope
=
parentSymbol
->
asScope
())
{
if
(
!
parentScope
->
isFunction
()
&&
!
parentScope
->
isObjCMethod
())
{
return
parentScope
->
memberCount
();
}
}
return
0
;
...
...
src/libs/cplusplus/ResolveExpression.cpp
View file @
354b9712
...
...
@@ -88,7 +88,8 @@ QList<LookupItem> ResolveExpression::operator()(ExpressionAST *ast, Scope *scope
QList
<
LookupItem
>
ResolveExpression
::
resolve
(
ExpressionAST
*
ast
,
Scope
*
scope
)
{
Q_ASSERT
(
scope
!=
0
);
if
(
!
scope
)
return
QList
<
LookupItem
>
();
Scope
*
previousVisibleSymbol
=
_scope
;
_scope
=
scope
;
...
...
@@ -174,7 +175,7 @@ bool ResolveExpression::visit(BinaryExpressionAST *ast)
bool
ResolveExpression
::
visit
(
CastExpressionAST
*
ast
)
{
Scope
*
dummyScope
=
_context
.
expressionDocument
()
->
global
Symbols
();
Scope
*
dummyScope
=
_context
.
expressionDocument
()
->
global
Namespace
();
FullySpecifiedType
ty
=
sem
.
check
(
ast
->
type_id
,
dummyScope
);
addResult
(
ty
,
_scope
);
return
false
;
...
...
@@ -199,7 +200,7 @@ bool ResolveExpression::visit(ConditionalExpressionAST *ast)
bool
ResolveExpression
::
visit
(
CppCastExpressionAST
*
ast
)
{
Scope
*
dummyScope
=
_context
.
expressionDocument
()
->
global
Symbols
();
Scope
*
dummyScope
=
_context
.
expressionDocument
()
->
global
Namespace
();
FullySpecifiedType
ty
=
sem
.
check
(
ast
->
type_id
,
dummyScope
);
addResult
(
ty
,
_scope
);
return
false
;
...
...
@@ -221,7 +222,7 @@ bool ResolveExpression::visit(ArrayInitializerAST *)
bool
ResolveExpression
::
visit
(
NewExpressionAST
*
ast
)
{
if
(
ast
->
new_type_id
)
{
Scope
*
dummyScope
=
_context
.
expressionDocument
()
->
global
Symbols
();
Scope
*
dummyScope
=
_context
.
expressionDocument
()
->
global
Namespace
();
FullySpecifiedType
ty
=
sem
.
check
(
ast
->
new_type_id
->
type_specifier_list
,
dummyScope
);
ty
=
sem
.
check
(
ast
->
new_type_id
->
ptr_operator_list
,
ty
,
dummyScope
);
FullySpecifiedType
ptrTy
(
control
()
->
pointerType
(
ty
));
...
...
@@ -315,11 +316,9 @@ bool ResolveExpression::visit(ThisExpressionAST *)
void
ResolveExpression
::
thisObject
()
{
Scope
*
scope
=
_scope
;
for
(;
scope
;
scope
=
scope
->
enclosingScope
())
{
if
(
scope
->
isPrototypeScope
())
{
Function
*
fun
=
scope
->
owner
()
->
asFunction
();
if
(
Scope
*
cscope
=
scope
->
enclosingClassScope
())
{
Class
*
klass
=
cscope
->
owner
()
->
asClass
();
for
(;
scope
;
scope
=
scope
->
scope
())
{
if
(
Function
*
fun
=
scope
->
asFunction
())
{
if
(
Class
*
klass
=
scope
->
enclosingClass
())
{
FullySpecifiedType
classTy
(
control
()
->
namedType
(
klass
->
name
()));
FullySpecifiedType
ptrTy
(
control
()
->
pointerType
(
classTy
));
addResult
(
ptrTy
,
fun
->
scope
());
...
...
@@ -562,7 +561,7 @@ QList<LookupItem> ResolveExpression::getMembers(ClassOrNamespace *binding, const
Symbol
*
decl
=
m
.
declaration
();
if
(
Class
*
klass
=
decl
->
enclosingSymbol
()
->
asClass
())
{
if
(
Class
*
klass
=
decl
->
scope
()
->
asClass
())
{
if
(
klass
->
templateParameters
()
!=
0
)
{
SubstitutionMap
map
;
...
...
src/plugins/classview/classviewparser.cpp
View file @
354b9712
...
...
@@ -289,7 +289,7 @@ void Parser::addSymbol(const ParserTreeItem::Ptr &item, const CPlusPlus::Symbol
return
;
// skip static local functions
// if ((!symbol->scope() || symbol->scope()->
owner()->
isClass())
// if ((!symbol->scope() || symbol->scope()->isClass())
// && symbol->isStatic() && symbol->isFunction())
// return;
...
...
@@ -320,22 +320,19 @@ void Parser::addSymbol(const ParserTreeItem::Ptr &item, const CPlusPlus::Symbol
// prevent showing a content of the functions
if
(
!
symbol
->
isFunction
())
{
const
CPlusPlus
::
ScopedSymbol
*
scopedSymbol
=
symbol
->
asScopedSymbol
();
if
(
scopedSymbol
)
{
CPlusPlus
::
Scope
*
scope
=
scopedSymbol
->
members
();
if
(
scope
)
{
CPlusPlus
::
Scope
::
iterator
cur
=
scope
->
firstSymbol
();
while
(
cur
!=
scope
->
lastSymbol
())
{
const
CPlusPlus
::
Symbol
*
curSymbol
=
*
cur
;
++
cur
;
if
(
!
curSymbol
)
continue
;
// if (!symbol->isClass() && curSymbol->isStatic() && curSymbol->isFunction())
// return;
addSymbol
(
itemAdd
,
curSymbol
);
}
const
CPlusPlus
::
Scope
*
scope
=
symbol
->
asScope
();
if
(
scope
)
{
CPlusPlus
::
Scope
::
iterator
cur
=
scope
->
firstMember
();
while
(
cur
!=
scope
->
lastMember
())
{
const
CPlusPlus
::
Symbol
*
curSymbol
=
*
cur
;
++
cur
;
if
(
!
curSymbol
)
continue
;
// if (!symbol->isClass() && curSymbol->isStatic() && curSymbol->isFunction())
// return;
addSymbol
(
itemAdd
,
curSymbol
);
}
}
}
...
...
src/plugins/cppeditor/cppchecksymbols.cpp
View file @
354b9712
...
...
@@ -181,8 +181,8 @@ protected:
for
(
TemplateParameters
*
p
=
symbol
->
templateParameters
();
p
;
p
=
p
->
previous
())
{
Scope
*
scope
=
p
->
scope
();
for
(
unsigned
i
=
0
;
i
<
scope
->
symbol
Count
();
++
i
)
accept
(
scope
->
symbol
At
(
i
));
for
(
unsigned
i
=
0
;
i
<
scope
->
member
Count
();
++
i
)
accept
(
scope
->
member
At
(
i
));
}
return
true
;
...
...
@@ -201,7 +201,7 @@ protected:
virtual
bool
visit
(
Declaration
*
symbol
)
{
if
(
symbol
->
enclosingEnum
Scope
()
!=
0
)
if
(
symbol
->
enclosingEnum
()
!=
0
)
addStatic
(
symbol
->
name
());
if
(
Function
*
funTy
=
symbol
->
type
()
->
asFunctionType
())
{
...
...
@@ -211,7 +211,7 @@ protected:
if
(
symbol
->
isTypedef
())
addType
(
symbol
->
name
());
else
if
(
!
symbol
->
type
()
->
isFunctionType
()
&&
symbol
->
enclosingSymbol
()
->
isClass
())
else
if
(
!
symbol
->
type
()
->
isFunctionType
()
&&
symbol
->
scope
()
->
isClass
())
addMember
(
symbol
->
name
());
return
true
;
...
...
@@ -239,8 +239,8 @@ protected:
{
for
(
TemplateParameters
*
p
=
symbol
->
templateParameters
();
p
;
p
=
p
->
previous
())
{
Scope
*
scope
=
p
->
scope
();
for
(
unsigned
i
=
0
;
i
<
scope
->
symbol
Count
();
++
i
)
accept
(
scope
->
symbol
At
(
i
));
for
(
unsigned
i
=
0
;
i
<
scope
->
member
Count
();
++
i
)
accept
(
scope
->
member
At
(
i
));
}
addType
(
symbol
->
name
());
...
...
@@ -251,8 +251,8 @@ protected:
{
for
(
TemplateParameters
*
p
=
symbol
->
templateParameters
();
p
;
p
=
p
->
previous
())
{
Scope
*
scope
=
p
->
scope
();
for
(
unsigned
i
=
0
;
i
<
scope
->
symbol
Count
();
++
i
)
accept
(
scope
->
symbol
At
(
i
));
for
(
unsigned
i
=
0
;
i
<
scope
->
member
Count
();
++
i
)
accept
(
scope
->
member
At
(
i
));
}
addType
(
symbol
->
name
());
...
...
@@ -383,48 +383,48 @@ Scope *CheckSymbols::enclosingScope() const
if
(
NamespaceAST
*
ns
=
ast
->
asNamespace
())
{
if
(
ns
->
symbol
)
return
ns
->
symbol
->
members
()
;
return
ns
->
symbol
;
}
else
if
(
ClassSpecifierAST
*
classSpec
=
ast
->
asClassSpecifier
())
{
if
(
classSpec
->
symbol
)
return
classSpec
->
symbol
->
members
()
;
return
classSpec
->
symbol
;
}
else
if
(
FunctionDefinitionAST
*
funDef
=
ast
->
asFunctionDefinition
())
{
if
(
funDef
->
symbol
)
return
funDef
->
symbol
->
members
()
;
return
funDef
->
symbol
;
}
else
if
(
CompoundStatementAST
*
blockStmt
=
ast
->
asCompoundStatement
())
{
if
(
blockStmt
->
symbol
)
return
blockStmt
->
symbol
->
members
()
;
return
blockStmt
->
symbol
;
}
else
if
(
IfStatementAST
*
ifStmt
=
ast
->
asIfStatement
())
{
if
(
ifStmt
->
symbol
)
return
ifStmt
->
symbol
->
members
()
;
return
ifStmt
->
symbol
;
}
else
if
(
WhileStatementAST
*
whileStmt
=
ast
->
asWhileStatement
())
{
if
(
whileStmt
->
symbol
)
return
whileStmt
->
symbol
->
members
()
;
return
whileStmt
->
symbol
;
}
else
if
(
ForStatementAST
*
forStmt
=
ast
->
asForStatement
())
{
if
(
forStmt
->
symbol
)
return
forStmt
->
symbol
->
members
()
;
return
forStmt
->
symbol
;
}
else
if
(
ForeachStatementAST
*
foreachStmt
=
ast
->
asForeachStatement
())
{
if
(
foreachStmt
->
symbol
)
return
foreachStmt
->
symbol
->
members
()
;
return
foreachStmt
->
symbol
;
}
else
if
(
SwitchStatementAST
*
switchStmt
=
ast
->
asSwitchStatement
())
{
if
(
switchStmt
->
symbol
)
return
switchStmt
->
symbol
->
members
()
;
return
switchStmt
->
symbol
;
}
else
if
(
CatchClauseAST
*
catchClause
=
ast
->
asCatchClause
())