From 7446f5cae220fd14b703e1fe15b8a6339241e320 Mon Sep 17 00:00:00 2001
From: Roberto Raggi <roberto.raggi@nokia.com>
Date: Tue, 11 May 2010 10:12:49 +0200
Subject: [PATCH] Describe the LookupContext API.

---
 src/libs/cplusplus/LookupContext.cpp | 16 +++++++-------
 src/libs/cplusplus/LookupContext.h   | 31 ++++++++++++++++++++++------
 2 files changed, 33 insertions(+), 14 deletions(-)

diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp
index 1dc8779b2ea..c5d6dedc96c 100644
--- a/src/libs/cplusplus/LookupContext.cpp
+++ b/src/libs/cplusplus/LookupContext.cpp
@@ -738,7 +738,7 @@ void CreateBindings::process(Document::Ptr doc)
     }
 }
 
-ClassOrNamespace *CreateBindings::enterEntity(Symbol *symbol)
+ClassOrNamespace *CreateBindings::enterClassOrNamespaceBinding(Symbol *symbol)
 {
     ClassOrNamespace *entity = _currentClassOrNamespace->findOrCreate(symbol->name());
     entity->addSymbol(symbol);
@@ -746,7 +746,7 @@ ClassOrNamespace *CreateBindings::enterEntity(Symbol *symbol)
     return switchCurrentClassOrNamespace(entity);
 }
 
-ClassOrNamespace *CreateBindings::enterGlobalEntity(Symbol *symbol)
+ClassOrNamespace *CreateBindings::enterGlobalClassOrNamespace(Symbol *symbol)
 {
     ClassOrNamespace *entity = _globalNamespace->findOrCreate(symbol->name());
     entity->addSymbol(symbol);
@@ -756,7 +756,7 @@ ClassOrNamespace *CreateBindings::enterGlobalEntity(Symbol *symbol)
 
 bool CreateBindings::visit(Namespace *ns)
 {
-    ClassOrNamespace *previous = enterEntity(ns);
+    ClassOrNamespace *previous = enterClassOrNamespaceBinding(ns);
 
     for (unsigned i = 0; i < ns->memberCount(); ++i)
         process(ns->memberAt(i));
@@ -792,7 +792,7 @@ bool CreateBindings::visit(Class *klass)
 bool CreateBindings::visit(ForwardClassDeclaration *klass)
 {
     if (! klass->isFriend()) {
-        ClassOrNamespace *previous = enterEntity(klass);
+        ClassOrNamespace *previous = enterClassOrNamespaceBinding(klass);
         _currentClassOrNamespace = previous;
     }
 
@@ -872,7 +872,7 @@ bool CreateBindings::visit(NamespaceAlias *a)
 
 bool CreateBindings::visit(ObjCClass *klass)
 {
-    ClassOrNamespace *previous = enterGlobalEntity(klass);
+    ClassOrNamespace *previous = enterGlobalClassOrNamespace(klass);
 
     process(klass->baseClass());
 
@@ -899,14 +899,14 @@ bool CreateBindings::visit(ObjCBaseClass *b)
 
 bool CreateBindings::visit(ObjCForwardClassDeclaration *klass)
 {
-    ClassOrNamespace *previous = enterGlobalEntity(klass);
+    ClassOrNamespace *previous = enterGlobalClassOrNamespace(klass);
     _currentClassOrNamespace = previous;
     return false;
 }
 
 bool CreateBindings::visit(ObjCProtocol *proto)
 {
-    ClassOrNamespace *previous = enterGlobalEntity(proto);
+    ClassOrNamespace *previous = enterGlobalClassOrNamespace(proto);
 
     for (unsigned i = 0; i < proto->protocolCount(); ++i)
         process(proto->protocolAt(i));
@@ -931,7 +931,7 @@ bool CreateBindings::visit(ObjCBaseProtocol *b)
 
 bool CreateBindings::visit(ObjCForwardProtocolDeclaration *proto)
 {
-    ClassOrNamespace *previous = enterGlobalEntity(proto);
+    ClassOrNamespace *previous = enterGlobalClassOrNamespace(proto);
     _currentClassOrNamespace = previous;
     return false;
 }
diff --git a/src/libs/cplusplus/LookupContext.h b/src/libs/cplusplus/LookupContext.h
index 72c10798e3b..88e273bd63b 100644
--- a/src/libs/cplusplus/LookupContext.h
+++ b/src/libs/cplusplus/LookupContext.h
@@ -115,33 +115,52 @@ public:
     CreateBindings(Document::Ptr thisDocument, const Snapshot &snapshot);
     virtual ~CreateBindings();
 
+    /// Returns the binding for the global namespace.
     ClassOrNamespace *globalNamespace() const;
 
-    ClassOrNamespace *findClassOrNamespace(Symbol *s); // ### rename
+    /// Finds the binding associated to the given symbol.
+    ClassOrNamespace *findClassOrNamespace(Symbol *symbol);
+
+    /// Find the binding with the given path.
+    /// \internal
     ClassOrNamespace *findClassOrNamespace(const QList<const Name *> &path);
 
+    /// Returns the Control that must be used to create temporary symbols.
     /// \internal
     Control *control() const;
 
+    /// Searches in \a scope for symbols with the given \a name.
+    /// Store the result in \a results.
     /// \internal
     void lookupInScope(const Name *name, Scope *scope, QList<Symbol *> *result,
                        const TemplateNameId *templateId);
 
+    /// Create bindings for the symbols reachable from \a rootSymbol.
     /// \internal
-    void process(Symbol *s, ClassOrNamespace *classOrNamespace);
+    void process(Symbol *rootSymbol, ClassOrNamespace *classOrNamespace);
 
+    /// Create an empty ClassOrNamespace binding with the given \a parent.
     /// \internal
     ClassOrNamespace *allocClassOrNamespace(ClassOrNamespace *parent);
 
 protected:
     using SymbolVisitor::visit;
 
+    /// Change the current ClassOrNamespace binding.
     ClassOrNamespace *switchCurrentClassOrNamespace(ClassOrNamespace *classOrNamespace);
-    ClassOrNamespace *enterEntity(Symbol *symbol);
-    ClassOrNamespace *enterGlobalEntity(Symbol *symbol);
 
-    void process(Document::Ptr doc);
-    void process(Symbol *symbol);
+    /// Enters the ClassOrNamespace binding associated with the given \a symbol.
+    ClassOrNamespace *enterClassOrNamespaceBinding(Symbol *symbol);
+
+    /// Enters a ClassOrNamespace binding for the given \a symbol in the global
+    /// namespace binding.
+    ClassOrNamespace *enterGlobalClassOrNamespace(Symbol *symbol);
+
+    /// Creates bindings for the given \a document.
+    void process(Document::Ptr document);
+
+    /// Creates bindings for the symbols reachable from the \a root symbol.
+    void process(Symbol *root);
 
     virtual bool visit(Namespace *ns);
     virtual bool visit(Class *klass);
-- 
GitLab