From 4ff3ee2ff04279b3c2ca317a7bac1f08c4a11eb5 Mon Sep 17 00:00:00 2001
From: Roberto Raggi <roberto.raggi@nokia.com>
Date: Thu, 5 Aug 2010 17:06:16 +0200
Subject: [PATCH] Use Prototype instead of Function.

---
 src/libs/cplusplus/LookupContext.cpp           | 2 +-
 src/libs/cplusplus/ResolveExpression.cpp       | 2 +-
 src/plugins/cppeditor/cppeditor.cpp            | 4 ++--
 src/plugins/cppeditor/cpplocalsymbols.cpp      | 4 ++--
 src/plugins/cpptools/abstracteditorsupport.cpp | 2 +-
 src/plugins/cpptools/cppcodecompletion.cpp     | 4 ++--
 src/plugins/debugger/watchutils.cpp            | 4 ++--
 src/shared/cplusplus/Scope.cpp                 | 9 ++-------
 src/shared/cplusplus/Scope.h                   | 7 ++-----
 src/shared/cplusplus/Symbol.cpp                | 6 +++---
 src/shared/cplusplus/Symbol.h                  | 4 ++--
 11 files changed, 20 insertions(+), 28 deletions(-)

diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp
index bc2f2ca0c50..cdc1018e2de 100644
--- a/src/libs/cplusplus/LookupContext.cpp
+++ b/src/libs/cplusplus/LookupContext.cpp
@@ -280,7 +280,7 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
                 }
             }
 
-        } else if (scope->isFunctionScope()) {
+        } else if (scope->isPrototypeScope()) {
             Function *fun = scope->owner()->asFunction();
             bindings()->lookupInScope(name, fun->members(), &candidates, /*templateId = */ 0, /*binding=*/ 0);
 
diff --git a/src/libs/cplusplus/ResolveExpression.cpp b/src/libs/cplusplus/ResolveExpression.cpp
index 246becd86b4..6cb276d81b0 100644
--- a/src/libs/cplusplus/ResolveExpression.cpp
+++ b/src/libs/cplusplus/ResolveExpression.cpp
@@ -316,7 +316,7 @@ void ResolveExpression::thisObject()
 {
     Scope *scope = _scope;
     for (; scope; scope = scope->enclosingScope()) {
-        if (scope->isFunctionScope()) {
+        if (scope->isPrototypeScope()) {
             Function *fun = scope->owner()->asFunction();
             if (Scope *cscope = scope->enclosingClassScope()) {
                 Class *klass = cscope->owner()->asClass();
diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp
index 970a8d128ce..723c97f677a 100644
--- a/src/plugins/cppeditor/cppeditor.cpp
+++ b/src/plugins/cppeditor/cppeditor.cpp
@@ -1078,10 +1078,10 @@ void CPPEditor::switchDeclarationDefinition()
         Symbol *lastVisibleSymbol = thisDocument->lastVisibleSymbolAt(line, column);
 
         Scope *functionScope = 0;
-        if (scope->isFunctionScope())
+        if (scope->isPrototypeScope())
             functionScope = scope;
         else
-            functionScope = scope->enclosingFunctionScope();
+            functionScope = scope->enclosingPrototypeScope();
 
         if (! functionScope && lastVisibleSymbol) {
             if (Function *def = lastVisibleSymbol->asFunction())
diff --git a/src/plugins/cppeditor/cpplocalsymbols.cpp b/src/plugins/cppeditor/cpplocalsymbols.cpp
index 2c8677389b9..0ec5b58934c 100644
--- a/src/plugins/cppeditor/cpplocalsymbols.cpp
+++ b/src/plugins/cppeditor/cpplocalsymbols.cpp
@@ -130,7 +130,7 @@ protected:
         Scope *scope = _doc->scopeAt(line, column);
 
         while (scope) {
-            if (scope->isFunctionScope()) {
+            if (scope->isPrototypeScope()) {
                 Function *fun = scope->owner()->asFunction();
                 if (findMember(fun->members(), ast, line, column))
                     return false;
@@ -176,7 +176,7 @@ protected:
         Scope *scope = _doc->scopeAt(line, column);
 
         while (scope) {
-            if (scope->isFunctionScope()) {
+            if (scope->isPrototypeScope()) {
                 Function *fun = scope->owner()->asFunction();
                 if (findMember(fun->members(), ast, line, column))
                     return false;
diff --git a/src/plugins/cpptools/abstracteditorsupport.cpp b/src/plugins/cpptools/abstracteditorsupport.cpp
index 0502e5dd1d7..6a1578d64e3 100644
--- a/src/plugins/cpptools/abstracteditorsupport.cpp
+++ b/src/plugins/cpptools/abstracteditorsupport.cpp
@@ -68,7 +68,7 @@ QString AbstractEditorSupport::functionAt(const CppModelManagerInterface *modelM
         return QString();
     if (const CPlusPlus::Symbol *symbol = document->lastVisibleSymbolAt(line, column))
         if (const CPlusPlus::Scope *scope = symbol->scope())
-            if (const CPlusPlus::Scope *functionScope = scope->enclosingFunctionScope())
+            if (const CPlusPlus::Scope *functionScope = scope->enclosingPrototypeScope())
                 if (const CPlusPlus::Symbol *function = functionScope->owner()) {
                     const CPlusPlus::Overview o;
                     QString rc = o.prettyName(function->name());
diff --git a/src/plugins/cpptools/cppcodecompletion.cpp b/src/plugins/cpptools/cppcodecompletion.cpp
index 6da9059f235..946e0719042 100644
--- a/src/plugins/cpptools/cppcodecompletion.cpp
+++ b/src/plugins/cpptools/cppcodecompletion.cpp
@@ -1068,7 +1068,7 @@ void CppCodeCompletion::globalCompletion(Scope *currentScope)
                     }
                 }
             }
-        } else if (scope->isFunctionScope() || scope->isClassScope() || scope->isNamespaceScope()) {
+        } else if (scope->isPrototypeScope() || scope->isClassScope() || scope->isNamespaceScope()) {
             currentBinding = context.lookupType(scope->owner());
             break;
         }
@@ -1079,7 +1079,7 @@ void CppCodeCompletion::globalCompletion(Scope *currentScope)
             for (unsigned i = 0; i < scope->symbolCount(); ++i) {
                 addCompletionItem(scope->symbolAt(i));
             }
-        } else if (scope->isFunctionScope()) {
+        } else if (scope->isPrototypeScope()) {
             Function *fun = scope->owner()->asFunction();
             for (unsigned i = 0; i < fun->argumentCount(); ++i) {
                 addCompletionItem(fun->argumentAt(i));
diff --git a/src/plugins/debugger/watchutils.cpp b/src/plugins/debugger/watchutils.cpp
index 1c48b16881d..96797fbec92 100644
--- a/src/plugins/debugger/watchutils.cpp
+++ b/src/plugins/debugger/watchutils.cpp
@@ -120,7 +120,7 @@ QDebug operator<<(QDebug d, const Scope &scope)
         str << " enum";
     if (scope.isBlockScope())
         str << " block";
-    if (scope.isFunctionScope())
+    if (scope.isPrototypeScope())
         str << " function";
     if (scope.isPrototypeScope())
         str << " prototype";
@@ -374,7 +374,7 @@ int getUninitializedVariablesI(const CPlusPlus::Snapshot &snapshot,
             if (CPlusPlus::Block *block = function->memberAt(0)->asBlock())
                 innerMostScope = block->members();
     } else {
-        if (const CPlusPlus::Scope *functionScope = symbolAtLine->enclosingFunctionScope()) {
+        if (const CPlusPlus::Scope *functionScope = symbolAtLine->enclosingPrototypeScope()) {
             function = functionScope->owner()->asFunction();
             innerMostScope = symbolAtLine->isBlock() ?
                              symbolAtLine->asBlock()->members() :
diff --git a/src/shared/cplusplus/Scope.cpp b/src/shared/cplusplus/Scope.cpp
index 2b6b1418568..a38dce48401 100644
--- a/src/shared/cplusplus/Scope.cpp
+++ b/src/shared/cplusplus/Scope.cpp
@@ -118,7 +118,7 @@ Scope *Scope::enclosingEnumScope() const
     return scope;
 }
 
-Scope *Scope::enclosingFunctionScope() const
+Scope *Scope::enclosingPrototypeScope() const
 {
     Scope *scope = enclosingScope();
     for (; scope; scope = scope->enclosingScope()) {
@@ -166,11 +166,6 @@ bool Scope::isBlockScope() const
     return false;
 }
 
-bool Scope::isPrototypeScope() const
-{
-    return isFunctionScope();
-}
-
 bool Scope::isObjCClassScope() const
 {
     if (_owner)
@@ -185,7 +180,7 @@ bool Scope::isObjCProtocolScope() const
     return false;
 }
 
-bool Scope::isFunctionScope() const
+bool Scope::isPrototypeScope() const
 {
     if (_owner)
         return _owner->isFunction();
diff --git a/src/shared/cplusplus/Scope.h b/src/shared/cplusplus/Scope.h
index 8c0bee69af5..b98435100a5 100644
--- a/src/shared/cplusplus/Scope.h
+++ b/src/shared/cplusplus/Scope.h
@@ -87,8 +87,8 @@ public:
     /// Returns the enclosing enum scope.
     Scope *enclosingEnumScope() const;
 
-    /// Rerturns the enclosing function scope.
-    Scope *enclosingFunctionScope() const;
+    /// Rerturns the enclosing prototype scope.
+    Scope *enclosingPrototypeScope() const;
 
     /// Rerturns the enclosing Block scope.
     Scope *enclosingBlockScope() const;
@@ -105,9 +105,6 @@ public:
     /// Returns true if this scope's owner is a Block Symbol.
     bool isBlockScope() const;
 
-    /// Returns true if this scope's owner is a Function Symbol.
-    bool isFunctionScope() const;
-
     /// Returns true if this scope's owner is a Prototype Symbol.
     bool isPrototypeScope() const;
 
diff --git a/src/shared/cplusplus/Symbol.cpp b/src/shared/cplusplus/Symbol.cpp
index 7262522a11b..7b0ff6a0c95 100644
--- a/src/shared/cplusplus/Symbol.cpp
+++ b/src/shared/cplusplus/Symbol.cpp
@@ -283,15 +283,15 @@ Scope *Symbol::enclosingEnumScope() const
     return _scope->enclosingEnumScope();
 }
 
-Scope *Symbol::enclosingFunctionScope() const
+Scope *Symbol::enclosingPrototypeScope() const
 {
     if (! _scope)
         return 0;
 
-    else if (_scope->isFunctionScope())
+    else if (_scope->isPrototypeScope())
         return _scope;
 
-    return _scope->enclosingFunctionScope();
+    return _scope->enclosingPrototypeScope();
 }
 
 Scope *Symbol::enclosingBlockScope() const
diff --git a/src/shared/cplusplus/Symbol.h b/src/shared/cplusplus/Symbol.h
index 7de4e13d630..3835207ef3b 100644
--- a/src/shared/cplusplus/Symbol.h
+++ b/src/shared/cplusplus/Symbol.h
@@ -295,8 +295,8 @@ public:
     /// Returns the enclosing enum scope.
     Scope *enclosingEnumScope() const;
 
-    /// Returns the enclosing function scope.
-    Scope *enclosingFunctionScope() const;
+    /// Returns the enclosing prototype scope.
+    Scope *enclosingPrototypeScope() const;
 
     /// Returns the enclosing Block scope.
     Scope *enclosingBlockScope() const;
-- 
GitLab