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
Marco Bubke
flatpak-qt-creator
Commits
99c33277
Commit
99c33277
authored
Oct 12, 2009
by
Roberto Raggi
Browse files
Improved support for private classes.
parent
eacb27f1
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/libs/cplusplus/LookupContext.cpp
View file @
99c33277
...
...
@@ -130,26 +130,66 @@ QList<Symbol *> LookupContext::resolveQualifiedNameId(QualifiedNameId *q,
const
QList
<
Scope
*>
&
visibleScopes
,
ResolveMode
mode
)
const
{
QList
<
S
cope
*>
scop
es
;
QList
<
S
ymbol
*>
candidat
es
;
if
(
q
->
nameCount
()
==
1
)
scopes
=
visibleScopes
;
// ### handle global scope lookup
else
scopes
=
resolveNestedNameSpecifier
(
q
,
visibleScopes
);
for
(
int
i
=
0
;
i
<
visibleScopes
.
size
();
++
i
)
{
Scope
*
scope
=
visibleScopes
.
at
(
i
);
QList
<
Scope
*>
expanded
;
foreach
(
Scope
*
scope
,
scopes
)
{
expanded
.
append
(
scope
)
;
for
(
Symbol
*
symbol
=
scope
->
lookat
(
q
);
symbol
;
symbol
=
symbol
->
next
())
{
if
(
!
symbol
->
name
())
continue
;
for
(
unsigned
i
=
0
;
i
<
scope
->
symbolCount
();
++
i
)
{
Symbol
*
member
=
scope
->
symbolAt
(
i
);
QualifiedNameId
*
qq
=
symbol
->
name
()
->
asQualifiedNameId
();
if
(
ScopedSymbol
*
scopedSymbol
=
member
->
asScopedSymbol
())
expandEnumOrAnonymousSymbol
(
scopedSymbol
,
&
expanded
);
if
(
!
qq
)
continue
;
else
if
(
!
maybeValidSymbol
(
symbol
,
mode
,
candidates
))
continue
;
if
(
!
q
->
unqualifiedNameId
()
->
isEqualTo
(
qq
->
unqualifiedNameId
()))
continue
;
else
if
(
qq
->
nameCount
()
==
q
->
nameCount
())
{
unsigned
j
=
0
;
for
(;
j
<
q
->
nameCount
();
++
j
)
{
Name
*
classOrNamespaceName1
=
q
->
nameAt
(
j
);
Name
*
classOrNamespaceName2
=
qq
->
nameAt
(
j
);
if
(
!
classOrNamespaceName1
->
isEqualTo
(
classOrNamespaceName2
))
break
;
}
if
(
j
==
q
->
nameCount
())
candidates
.
append
(
symbol
);
}
}
}
return
resolve
(
q
->
unqualifiedNameId
(),
expanded
,
mode
);
if
(
candidates
.
isEmpty
())
{
QList
<
Scope
*>
scopes
;
if
(
q
->
nameCount
()
==
1
)
scopes
=
visibleScopes
;
// ### handle global scope lookup
else
scopes
=
resolveNestedNameSpecifier
(
q
,
visibleScopes
);
QList
<
Scope
*>
expanded
;
foreach
(
Scope
*
scope
,
scopes
)
{
expanded
.
append
(
scope
);
for
(
unsigned
i
=
0
;
i
<
scope
->
symbolCount
();
++
i
)
{
Symbol
*
member
=
scope
->
symbolAt
(
i
);
if
(
ScopedSymbol
*
scopedSymbol
=
member
->
asScopedSymbol
())
expandEnumOrAnonymousSymbol
(
scopedSymbol
,
&
expanded
);
}
}
candidates
+=
resolve
(
q
->
unqualifiedNameId
(),
expanded
,
mode
);
}
return
candidates
;
}
QList
<
Symbol
*>
LookupContext
::
resolveOperatorNameId
(
OperatorNameId
*
opId
,
...
...
@@ -198,13 +238,11 @@ QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visible
else
if
(
!
maybeValidSymbol
(
symbol
,
mode
,
candidates
))
continue
;
// skip it, we're not looking for this kind of symbols
else
if
(
Identifier
*
symbolId
=
symbol
->
identifier
())
{
if
(
!
symbolId
->
isEqualTo
(
id
))
continue
;
// skip it, the symbol's id is not compatible with this lookup.
}
if
(
QualifiedNameId
*
q
=
symbol
->
name
()
->
asQualifiedNameId
())
{
if
(
name
->
isDestructorNameId
()
!=
q
->
unqualifiedNameId
()
->
isDestructorNameId
())
...
...
src/shared/cplusplus/Scope.cpp
View file @
99c33277
...
...
@@ -208,6 +208,21 @@ void Scope::enterSymbol(Symbol *symbol)
}
}
Symbol
*
Scope
::
lookat
(
Name
*
name
)
const
{
if
(
!
name
)
return
0
;
else
if
(
OperatorNameId
*
opId
=
name
->
asOperatorNameId
())
return
lookat
(
opId
->
kind
());
else
if
(
Identifier
*
id
=
name
->
identifier
())
return
lookat
(
id
);
else
return
0
;
}
Symbol
*
Scope
::
lookat
(
Identifier
*
id
)
const
{
if
(
!
_hash
||
!
id
)
...
...
src/shared/cplusplus/Scope.h
View file @
99c33277
...
...
@@ -129,6 +129,7 @@ public:
/// Returns the last Symbol in the scope.
iterator
lastSymbol
()
const
;
Symbol
*
lookat
(
Name
*
name
)
const
;
Symbol
*
lookat
(
Identifier
*
id
)
const
;
Symbol
*
lookat
(
int
operatorId
)
const
;
...
...
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