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
2b95b46e
Commit
2b95b46e
authored
May 05, 2010
by
Roberto Raggi
Browse files
Improved CreateBindings::findClassOrNamespace(Symbol *)
parent
b84db9ba
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/libs/cplusplus/LookupContext.cpp
View file @
2b95b46e
...
...
@@ -45,6 +45,25 @@
using
namespace
CPlusPlus
;
static
void
fullyQualifiedName
(
Symbol
*
symbol
,
QList
<
const
Name
*>
*
names
)
{
if
(
!
symbol
)
return
;
fullyQualifiedName
(
symbol
->
enclosingSymbol
(),
names
);
if
(
symbol
->
name
()
&&
(
symbol
->
isClass
()
||
symbol
->
isNamespace
()))
{
if
(
const
QualifiedNameId
*
q
=
symbol
->
name
()
->
asQualifiedNameId
())
{
for
(
unsigned
i
=
0
;
i
<
q
->
nameCount
();
++
i
)
names
->
append
(
q
->
nameAt
(
i
));
}
else
if
(
symbol
->
name
()
->
isNameId
()
||
symbol
->
name
()
->
isTemplateNameId
())
{
names
->
append
(
symbol
->
name
());
}
}
}
/////////////////////////////////////////////////////////////////////
// LookupContext
/////////////////////////////////////////////////////////////////////
...
...
@@ -201,6 +220,14 @@ QList<Symbol *> LookupContext::lookup(const Name *name, Scope *scope) const
const
QualifiedNameId
*
q
=
fun
->
name
()
->
asQualifiedNameId
();
QList
<
QByteArray
>
path
;
QList
<
const
Name
*>
enclosingNames
;
fullyQualifiedName
(
scope
->
owner
(),
&
enclosingNames
);
foreach
(
const
Name
*
p
,
enclosingNames
)
{
if
(
const
Identifier
*
id
=
p
->
identifier
())
{
path
.
append
(
QByteArray
::
fromRawData
(
id
->
chars
(),
id
->
size
()));
}
}
for
(
unsigned
index
=
0
;
index
<
q
->
nameCount
()
-
1
;
++
index
)
{
if
(
const
Identifier
*
id
=
q
->
nameAt
(
index
)
->
identifier
())
path
.
append
(
QByteArray
::
fromRawData
(
id
->
chars
(),
id
->
size
()));
...
...
@@ -572,22 +599,20 @@ ClassOrNamespace *CreateBindings::globalNamespace() const
return
_globalNamespace
;
}
ClassOrNamespace
*
CreateBindings
::
findClassOrNamespace
(
Symbol
*
s
)
ClassOrNamespace
*
CreateBindings
::
findClassOrNamespace
(
Symbol
*
s
ymbol
)
{
// jump to the enclosing class or namespace.
for
(;
s
;
s
=
s
->
enclosingSymbol
())
{
if
(
s
->
isClass
()
||
s
->
isNamespace
())
break
;
}
QList
<
const
Name
*>
names
;
fullyQualifiedName
(
symbol
,
&
names
);
QList
<
QByteArray
>
path
;
for
(;
s
;
s
=
s
->
enclosingSymbol
())
{
if
(
const
Identifier
*
id
=
s
->
identifier
())
path
.
prepend
(
QByteArray
::
fromRawData
(
id
->
chars
(),
id
->
size
()));
}
if
(
names
.
isEmpty
())
return
_globalNamespace
;
ClassOrNamespace
*
e
=
_globalNamespace
->
findClassOrNamespace
(
path
);
return
e
;
ClassOrNamespace
*
b
=
_globalNamespace
->
lookupClassOrNamespace
(
names
.
at
(
0
));
for
(
int
i
=
1
;
b
&&
i
<
names
.
size
();
++
i
)
b
=
b
->
findClassOrNamespace
(
names
.
at
(
i
));
return
b
;
}
ClassOrNamespace
*
CreateBindings
::
findClassOrNamespace
(
const
QList
<
QByteArray
>
&
path
)
...
...
Write
Preview
Supports
Markdown
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