Skip to content
GitLab
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
c35bb422
Commit
c35bb422
authored
May 05, 2010
by
Roberto Raggi
Browse files
Introduce Namespace aliases and store the TranslationUnit instead of the Control.
parent
c8f03b46
Changes
11
Hide whitespace changes
Inline
Side-by-side
src/shared/cplusplus/CPlusPlusForwardDeclarations.h
View file @
c35bb422
...
...
@@ -119,6 +119,7 @@ class Argument;
class
TypenameArgument
;
class
Function
;
class
Namespace
;
class
NamespaceAlias
;
class
BaseClass
;
class
Block
;
class
Class
;
...
...
src/shared/cplusplus/CheckDeclaration.cpp
View file @
c35bb422
...
...
@@ -409,8 +409,27 @@ bool CheckDeclaration::visit(NamespaceAST *ast)
return
false
;
}
bool
CheckDeclaration
::
visit
(
NamespaceAliasDefinitionAST
*
)
bool
CheckDeclaration
::
visit
(
NamespaceAliasDefinitionAST
*
ast
)
{
const
Name
*
name
=
0
;
if
(
const
Identifier
*
id
=
identifier
(
ast
->
namespace_name_token
))
name
=
control
()
->
nameId
(
id
);
unsigned
sourceLocation
=
ast
->
firstToken
();
if
(
ast
->
namespace_name_token
)
sourceLocation
=
ast
->
namespace_name_token
;
const
Name
*
namespaceName
=
semantic
()
->
check
(
ast
->
name
,
_scope
);
NamespaceAlias
*
namespaceAlias
=
control
()
->
newNamespaceAlias
(
sourceLocation
,
name
);
namespaceAlias
->
setNamespaceName
(
namespaceName
);
namespaceAlias
->
setStartOffset
(
tokenAt
(
ast
->
firstToken
()).
offset
);
namespaceAlias
->
setEndOffset
(
tokenAt
(
ast
->
lastToken
()).
offset
);
//ast->symbol = namespaceAlias;
_scope
->
enterSymbol
(
namespaceAlias
);
return
false
;
}
...
...
src/shared/cplusplus/Control.cpp
View file @
c35bb422
...
...
@@ -385,6 +385,14 @@ public:
return
ns
;
}
NamespaceAlias
*
newNamespaceAlias
(
unsigned
sourceLocation
,
const
Name
*
name
)
{
NamespaceAlias
*
ns
=
new
NamespaceAlias
(
translationUnit
,
sourceLocation
,
name
);
symbols
.
push_back
(
ns
);
return
ns
;
}
UsingNamespaceDirective
*
newUsingNamespaceDirective
(
unsigned
sourceLocation
,
const
Name
*
name
)
{
UsingNamespaceDirective
*
u
=
new
UsingNamespaceDirective
(
translationUnit
,
...
...
@@ -672,6 +680,9 @@ Function *Control::newFunction(unsigned sourceLocation, const Name *name)
Namespace
*
Control
::
newNamespace
(
unsigned
sourceLocation
,
const
Name
*
name
)
{
return
d
->
newNamespace
(
sourceLocation
,
name
);
}
NamespaceAlias
*
Control
::
newNamespaceAlias
(
unsigned
sourceLocation
,
const
Name
*
name
)
{
return
d
->
newNamespaceAlias
(
sourceLocation
,
name
);
}
BaseClass
*
Control
::
newBaseClass
(
unsigned
sourceLocation
,
const
Name
*
name
)
{
return
d
->
newBaseClass
(
sourceLocation
,
name
);
}
...
...
src/shared/cplusplus/Control.h
View file @
c35bb422
...
...
@@ -131,6 +131,9 @@ public:
/// Creates a new Namespace symbol.
Namespace
*
newNamespace
(
unsigned
sourceLocation
,
const
Name
*
name
=
0
);
/// Creates a new Namespace symbol.
NamespaceAlias
*
newNamespaceAlias
(
unsigned
sourceLocation
,
const
Name
*
name
=
0
);
/// Creates a new BaseClass symbol.
BaseClass
*
newBaseClass
(
unsigned
sourceLocation
,
const
Name
*
name
=
0
);
...
...
src/shared/cplusplus/Scope.cpp
View file @
c35bb422
...
...
@@ -179,6 +179,13 @@ bool Scope::isObjCClassScope() const
return
false
;
}
bool
Scope
::
isObjCProtocolScope
()
const
{
if
(
_owner
)
return
_owner
->
isObjCProtocol
();
return
false
;
}
bool
Scope
::
isFunctionScope
()
const
{
Function
*
f
=
0
;
...
...
src/shared/cplusplus/Scope.h
View file @
c35bb422
...
...
@@ -114,6 +114,9 @@ public:
/// Returns true if this scope's owner is an ObjCClass Symbol.
bool
isObjCClassScope
()
const
;
/// Returns true if this scope's owner is an ObjCProtocol Symbol.
bool
isObjCProtocolScope
()
const
;
/// Returns true if this scope's owner is an ObjCMethod symbol.
bool
isObjCMethodScope
()
const
;
...
...
src/shared/cplusplus/Symbol.cpp
View file @
c35bb422
...
...
@@ -161,7 +161,7 @@ private:
};
Symbol
::
Symbol
(
TranslationUnit
*
translationUnit
,
unsigned
sourceLocation
,
const
Name
*
name
)
:
_
control
(
translationUnit
->
control
()
),
:
_
translationUnit
(
translationUnit
),
_sourceLocation
(
sourceLocation
),
_sourceOffset
(
0
),
_startOffset
(
0
),
...
...
@@ -183,10 +183,15 @@ Symbol::~Symbol()
{
}
Control
*
Symbol
::
control
()
const
{
return
_control
;
}
{
if
(
_translationUnit
)
return
_translationUnit
->
control
();
return
0
;
}
TranslationUnit
*
Symbol
::
translationUnit
()
const
{
return
_
control
->
translationUnit
()
;
}
{
return
_translationUnit
;
}
void
Symbol
::
visitSymbol
(
SymbolVisitor
*
visitor
)
{
...
...
src/shared/cplusplus/Symbol.h
View file @
c35bb422
...
...
@@ -239,6 +239,7 @@ public:
virtual
const
Enum
*
asEnum
()
const
{
return
0
;
}
virtual
const
Function
*
asFunction
()
const
{
return
0
;
}
virtual
const
Namespace
*
asNamespace
()
const
{
return
0
;
}
virtual
const
NamespaceAlias
*
asNamespaceAlias
()
const
{
return
0
;
}
virtual
const
Class
*
asClass
()
const
{
return
0
;
}
virtual
const
Block
*
asBlock
()
const
{
return
0
;
}
virtual
const
UsingNamespaceDirective
*
asUsingNamespaceDirective
()
const
{
return
0
;
}
...
...
@@ -261,6 +262,7 @@ public:
virtual
Enum
*
asEnum
()
{
return
0
;
}
virtual
Function
*
asFunction
()
{
return
0
;
}
virtual
Namespace
*
asNamespace
()
{
return
0
;
}
virtual
NamespaceAlias
*
asNamespaceAlias
()
{
return
0
;
}
virtual
Class
*
asClass
()
{
return
0
;
}
virtual
Block
*
asBlock
()
{
return
0
;
}
virtual
UsingNamespaceDirective
*
asUsingNamespaceDirective
()
{
return
0
;
}
...
...
@@ -324,7 +326,7 @@ protected:
TranslationUnit
*
translationUnit
()
const
;
private:
Control
*
_control
;
TranslationUnit
*
_translationUnit
;
unsigned
_sourceLocation
;
unsigned
_sourceOffset
;
unsigned
_startOffset
;
...
...
src/shared/cplusplus/SymbolVisitor.h
View file @
c35bb422
...
...
@@ -70,6 +70,7 @@ public:
virtual
bool
visit
(
UsingNamespaceDirective
*
)
{
return
true
;
}
virtual
bool
visit
(
UsingDeclaration
*
)
{
return
true
;
}
virtual
bool
visit
(
NamespaceAlias
*
)
{
return
true
;
}
virtual
bool
visit
(
Declaration
*
)
{
return
true
;
}
virtual
bool
visit
(
Argument
*
)
{
return
true
;
}
virtual
bool
visit
(
TypenameArgument
*
)
{
return
true
;
}
...
...
src/shared/cplusplus/Symbols.cpp
View file @
c35bb422
...
...
@@ -89,6 +89,27 @@ FullySpecifiedType UsingNamespaceDirective::type() const
void
UsingNamespaceDirective
::
visitSymbol0
(
SymbolVisitor
*
visitor
)
{
visitor
->
visit
(
this
);
}
NamespaceAlias
::
NamespaceAlias
(
TranslationUnit
*
translationUnit
,
unsigned
sourceLocation
,
const
Name
*
name
)
:
Symbol
(
translationUnit
,
sourceLocation
,
name
),
_namespaceName
(
0
)
{
}
NamespaceAlias
::~
NamespaceAlias
()
{
}
const
Name
*
NamespaceAlias
::
namespaceName
()
const
{
return
_namespaceName
;
}
void
NamespaceAlias
::
setNamespaceName
(
const
Name
*
namespaceName
)
{
_namespaceName
=
namespaceName
;
}
FullySpecifiedType
NamespaceAlias
::
type
()
const
{
return
FullySpecifiedType
();
}
void
NamespaceAlias
::
visitSymbol0
(
SymbolVisitor
*
visitor
)
{
visitor
->
visit
(
this
);
}
UsingDeclaration
::
UsingDeclaration
(
TranslationUnit
*
translationUnit
,
unsigned
sourceLocation
,
const
Name
*
name
)
:
Symbol
(
translationUnit
,
sourceLocation
,
name
)
...
...
src/shared/cplusplus/Symbols.h
View file @
c35bb422
...
...
@@ -110,6 +110,31 @@ protected:
virtual
void
visitSymbol0
(
SymbolVisitor
*
visitor
);
};
class
CPLUSPLUS_EXPORT
NamespaceAlias
:
public
Symbol
{
public:
NamespaceAlias
(
TranslationUnit
*
translationUnit
,
unsigned
sourceLocation
,
const
Name
*
name
);
virtual
~
NamespaceAlias
();
const
Name
*
namespaceName
()
const
;
void
setNamespaceName
(
const
Name
*
namespaceName
);
// Symbol's interface
virtual
FullySpecifiedType
type
()
const
;
virtual
const
NamespaceAlias
*
asNamespaceAlias
()
const
{
return
this
;
}
virtual
NamespaceAlias
*
asNamespaceAlias
()
{
return
this
;
}
protected:
virtual
void
visitSymbol0
(
SymbolVisitor
*
visitor
);
private:
const
Name
*
_namespaceName
;
};
class
CPLUSPLUS_EXPORT
Declaration
:
public
Symbol
{
public:
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment