forked from qt-creator/qt-creator
Added Symbol::enclosingNamespaceScope(), Symbol::enclosingClassScope(), and so on...
This commit is contained in:
@@ -55,6 +55,7 @@
|
|||||||
#include "MemoryPool.h"
|
#include "MemoryPool.h"
|
||||||
#include "SymbolVisitor.h"
|
#include "SymbolVisitor.h"
|
||||||
#include "NameVisitor.h"
|
#include "NameVisitor.h"
|
||||||
|
#include "Scope.h"
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
@@ -313,6 +314,61 @@ void Symbol::setScope(Scope *scope)
|
|||||||
_scope = scope;
|
_scope = scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Scope *Symbol::enclosingNamespaceScope() const
|
||||||
|
{
|
||||||
|
if (! _scope)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
else if (_scope->isNamespaceScope())
|
||||||
|
return _scope;
|
||||||
|
|
||||||
|
return _scope->enclosingNamespaceScope();
|
||||||
|
}
|
||||||
|
|
||||||
|
Scope *Symbol::enclosingClassScope() const
|
||||||
|
{
|
||||||
|
if (! _scope)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
else if (_scope->isNamespaceScope())
|
||||||
|
return _scope;
|
||||||
|
|
||||||
|
return _scope->enclosingNamespaceScope();
|
||||||
|
}
|
||||||
|
|
||||||
|
Scope *Symbol::enclosingEnumScope() const
|
||||||
|
{
|
||||||
|
if (! _scope)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
else if (_scope->isEnumScope())
|
||||||
|
return _scope;
|
||||||
|
|
||||||
|
return _scope->enclosingEnumScope();
|
||||||
|
}
|
||||||
|
|
||||||
|
Scope *Symbol::enclosingFunctionScope() const
|
||||||
|
{
|
||||||
|
if (! _scope)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
else if (_scope->isFunctionScope())
|
||||||
|
return _scope;
|
||||||
|
|
||||||
|
return _scope->enclosingFunctionScope();
|
||||||
|
}
|
||||||
|
|
||||||
|
Scope *Symbol::enclosingBlockScope() const
|
||||||
|
{
|
||||||
|
if (! _scope)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
else if (_scope->isBlockScope())
|
||||||
|
return _scope;
|
||||||
|
|
||||||
|
return _scope->enclosingBlockScope();
|
||||||
|
}
|
||||||
|
|
||||||
unsigned Symbol::index() const
|
unsigned Symbol::index() const
|
||||||
{ return _index; }
|
{ return _index; }
|
||||||
|
|
||||||
|
|||||||
@@ -248,6 +248,21 @@ public:
|
|||||||
|
|
||||||
bool isGenerated() const;
|
bool isGenerated() const;
|
||||||
|
|
||||||
|
/// Returns the eclosing namespace scope.
|
||||||
|
Scope *enclosingNamespaceScope() const;
|
||||||
|
|
||||||
|
/// Returns the enclosing class scope.
|
||||||
|
Scope *enclosingClassScope() const;
|
||||||
|
|
||||||
|
/// Returns the enclosing enum scope.
|
||||||
|
Scope *enclosingEnumScope() const;
|
||||||
|
|
||||||
|
/// Returns the enclosing function scope.
|
||||||
|
Scope *enclosingFunctionScope() const;
|
||||||
|
|
||||||
|
/// Returns the enclosing Block scope.
|
||||||
|
Scope *enclosingBlockScope() const;
|
||||||
|
|
||||||
void setScope(Scope *scope); // ### make me private
|
void setScope(Scope *scope); // ### make me private
|
||||||
void setSourceLocation(unsigned sourceLocation); // ### make me private
|
void setSourceLocation(unsigned sourceLocation); // ### make me private
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user