Commit 7446f5ca authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Describe the LookupContext API.

parent 6d6e18aa
......@@ -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;
}
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment