summaryrefslogtreecommitdiff
path: root/src/shared/cplusplus/Symbol.cpp
diff options
context:
space:
mode:
authorRoberto Raggi <roberto.raggi@nokia.com>2009-06-03 14:15:49 +0200
committerRoberto Raggi <roberto.raggi@nokia.com>2009-06-03 14:15:49 +0200
commit19dd2b814fcd37b106048d202339d63d6232728e (patch)
tree7bb2e741a3a23c9b81b885caedb2b79075272d10 /src/shared/cplusplus/Symbol.cpp
parent7b44f1749a11928346b07511ae7a1470bcb93673 (diff)
downloadqt-creator-19dd2b814fcd37b106048d202339d63d6232728e.tar.gz
Added Symbol::enclosingNamespaceScope(), Symbol::enclosingClassScope(), and so on...
Diffstat (limited to 'src/shared/cplusplus/Symbol.cpp')
-rw-r--r--src/shared/cplusplus/Symbol.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/shared/cplusplus/Symbol.cpp b/src/shared/cplusplus/Symbol.cpp
index a012cca8ad..82d3e5c016 100644
--- a/src/shared/cplusplus/Symbol.cpp
+++ b/src/shared/cplusplus/Symbol.cpp
@@ -55,6 +55,7 @@
#include "MemoryPool.h"
#include "SymbolVisitor.h"
#include "NameVisitor.h"
+#include "Scope.h"
#include <cstddef>
#include <cassert>
@@ -313,6 +314,61 @@ void Symbol::setScope(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
{ return _index; }