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
6672f89f
Commit
6672f89f
authored
Feb 09, 2009
by
Roberto Raggi
Browse files
Annotate the ClassSpecifierAST node with the class symbol.
parent
1dcabe5a
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/shared/cplusplus/AST.h
View file @
6672f89f
...
...
@@ -515,6 +515,9 @@ public:
DeclarationAST
*
member_specifiers
;
unsigned
rbrace_token
;
public:
// annotations
Class
*
class_symbol
;
public:
virtual
unsigned
firstToken
()
const
;
virtual
unsigned
lastToken
()
const
;
...
...
src/shared/cplusplus/CheckSpecifier.cpp
View file @
6672f89f
...
...
@@ -300,6 +300,7 @@ bool CheckSpecifier::visit(ClassSpecifierAST *ast)
{
Name
*
className
=
semantic
()
->
check
(
ast
->
name
,
_scope
);
Class
*
klass
=
control
()
->
newClass
(
ast
->
firstToken
(),
className
);
ast
->
class_symbol
=
klass
;
unsigned
classKey
=
tokenKind
(
ast
->
classkey_token
);
if
(
classKey
==
T_CLASS
)
klass
->
setClassKey
(
Class
::
ClassKey
);
...
...
tests/auto/cplusplus/lookup/tst_lookup.cpp
View file @
6672f89f
#include <QtTest>
#include <QObject>
#include <AST.h>
#include <ASTVisitor.h>
#include <TranslationUnit.h>
#include <CppDocument.h>
#include <LookupContext.h>
#include <Symbols.h>
...
...
@@ -8,6 +12,29 @@
CPLUSPLUS_USE_NAMESPACE
class
ClassSymbols
:
protected
ASTVisitor
,
public
QMap
<
ClassSpecifierAST
*
,
Class
*>
{
public:
ClassSymbols
(
Control
*
control
)
:
ASTVisitor
(
control
)
{
}
void
operator
()(
AST
*
ast
)
{
accept
(
ast
);
}
protected:
virtual
bool
visit
(
ClassSpecifierAST
*
ast
)
{
Class
*
classSymbol
=
ast
->
class_symbol
;
Q_ASSERT
(
classSymbol
!=
0
);
insert
(
ast
,
classSymbol
);
return
true
;
}
};
class
tst_Lookup
:
public
QObject
{
Q_OBJECT
...
...
@@ -50,6 +77,17 @@ void tst_Lookup::base_class_defined_1()
QCOMPARE
(
candidates
.
size
(),
1
);
QCOMPARE
(
candidates
.
at
(
0
),
baseClass
);
TranslationUnit
*
unit
=
doc
->
translationUnit
();
QVERIFY
(
unit
!=
0
);
TranslationUnitAST
*
ast
=
unit
->
ast
()
->
asTranslationUnit
();
QVERIFY
(
ast
!=
0
);
ClassSymbols
classSymbols
(
doc
->
control
());
classSymbols
(
ast
);
QCOMPARE
(
classSymbols
.
size
(),
2
);
}
QTEST_APPLESS_MAIN
(
tst_Lookup
)
...
...
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