Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qt-creator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Hunger
qt-creator
Commits
2a8b5a2e
Commit
2a8b5a2e
authored
15 years ago
by
Roberto Raggi
Browse files
Options
Downloads
Patches
Plain Diff
Refactored the lookup of name and template name ids.
parent
09b98c02
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/libs/cplusplus/LookupContext.cpp
+21
-40
21 additions, 40 deletions
src/libs/cplusplus/LookupContext.cpp
src/libs/cplusplus/LookupContext.h
+0
-2
0 additions, 2 deletions
src/libs/cplusplus/LookupContext.h
with
21 additions
and
42 deletions
src/libs/cplusplus/LookupContext.cpp
+
21
−
40
View file @
2a8b5a2e
...
...
@@ -42,35 +42,6 @@
using
namespace
CPlusPlus
;
bool
LookupContext
::
isNameCompatibleWithIdentifier
(
Name
*
name
,
Identifier
*
id
)
{
if
(
!
name
)
{
return
false
;
}
else
if
(
NameId
*
nameId
=
name
->
asNameId
())
{
Identifier
*
identifier
=
nameId
->
identifier
();
return
identifier
->
isEqualTo
(
id
);
}
else
if
(
DestructorNameId
*
nameId
=
name
->
asDestructorNameId
())
{
Identifier
*
identifier
=
nameId
->
identifier
();
return
identifier
->
isEqualTo
(
id
);
}
else
if
(
TemplateNameId
*
templNameId
=
name
->
asTemplateNameId
())
{
Identifier
*
identifier
=
templNameId
->
identifier
();
return
identifier
->
isEqualTo
(
id
);
}
return
false
;
}
#ifndef CPLUSPLUS_WITH_NO_DEBUG
static
void
printScopes
(
const
QList
<
Scope
*>
&
scopes
)
{
qDebug
()
<<
"==========="
;
foreach
(
Scope
*
scope
,
scopes
)
{
qDebug
()
<<
"scope:"
<<
scope
<<
scope
->
owner
()
->
name
()
<<
scope
->
owner
()
->
fileName
()
<<
scope
->
owner
()
->
line
()
<<
scope
->
owner
()
->
column
();
}
}
#endif
/////////////////////////////////////////////////////////////////////
// LookupContext
/////////////////////////////////////////////////////////////////////
...
...
@@ -205,20 +176,30 @@ QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visible
else
if
(
OperatorNameId
*
opId
=
name
->
asOperatorNameId
())
return
resolveOperatorNameId
(
opId
,
visibleScopes
,
mode
);
else
if
(
Identifier
*
id
=
identifier
(
name
))
{
else
if
(
Identifier
*
id
=
name
->
identifier
())
{
for
(
int
scopeIndex
=
0
;
scopeIndex
<
visibleScopes
.
size
();
++
scopeIndex
)
{
Scope
*
scope
=
visibleScopes
.
at
(
scopeIndex
);
for
(
Symbol
*
symbol
=
scope
->
lookat
(
id
);
symbol
;
symbol
=
symbol
->
next
())
{
if
(
!
symbol
->
name
())
{
continue
;
}
else
if
(
!
maybeValidSymbol
(
symbol
,
mode
,
candidates
))
{
continue
;
}
else
if
(
QualifiedNameId
*
q
=
symbol
->
name
()
->
asQualifiedNameId
())
{
if
(
!
q
->
unqualifiedNameId
()
->
isEqualTo
(
name
))
if
(
!
symbol
->
name
())
continue
;
// nothing to do, the symbol is anonymous.
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
())
continue
;
if
(
q
->
nameCount
()
>
1
)
{
else
if
(
q
->
nameCount
()
>
1
)
{
Name
*
classOrNamespaceName
=
control
()
->
qualifiedNameId
(
q
->
names
(),
q
->
nameCount
()
-
1
);
...
...
@@ -242,13 +223,13 @@ QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visible
if
(
!
good
)
continue
;
}
}
else
if
(
!
isNameCompatibleWithIdentifier
(
symbol
->
name
(),
id
))
{
continue
;
}
else
if
(
symbol
->
name
()
->
isDestructorNameId
()
!=
name
->
isDestructorNameId
())
{
// ### FIXME: this is wrong!
continue
;
}
candidates
.
append
(
symbol
);
if
(
!
candidates
.
contains
(
symbol
))
candidates
.
append
(
symbol
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/libs/cplusplus/LookupContext.h
+
0
−
2
View file @
2a8b5a2e
...
...
@@ -133,8 +133,6 @@ private:
void
buildVisibleScopes_helper
(
Document
::
Ptr
doc
,
QList
<
Scope
*>
*
scopes
,
QSet
<
QString
>
*
processed
);
static
bool
isNameCompatibleWithIdentifier
(
Name
*
name
,
Identifier
*
id
);
static
bool
maybeValidSymbol
(
Symbol
*
symbol
,
ResolveMode
mode
,
const
QList
<
Symbol
*>
&
candidates
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment