C++: Rename ClassOrNamespace -> LookupScope

Change-Id: Ide74482b133dd1fec40a725d9aa81bd749385f37
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
Orgad Shaneh
2015-04-20 17:42:34 +03:00
committed by Orgad Shaneh
parent 9e1e11db60
commit cb350bfeb2
29 changed files with 461 additions and 464 deletions

View File

@@ -100,7 +100,7 @@ public:
TemplateArgumentIterator firstTemplateArgument() const { return _templateArguments.begin(); } TemplateArgumentIterator firstTemplateArgument() const { return _templateArguments.begin(); }
TemplateArgumentIterator lastTemplateArgument() const { return _templateArguments.end(); } TemplateArgumentIterator lastTemplateArgument() const { return _templateArguments.end(); }
bool isSpecialization() const { return _isSpecialization; } bool isSpecialization() const { return _isSpecialization; }
// this is temporary solution needed in ClassOrNamespace::nestedType // this is temporary solution needed in LookupScope::nestedType
// when we try to find correct specialization for instantiation // when we try to find correct specialization for instantiation
void setIsSpecialization(bool isSpecialization) { _isSpecialization = isSpecialization; } void setIsSpecialization(bool isSpecialization) { _isSpecialization = isSpecialization; }

View File

@@ -379,7 +379,7 @@ FullySpecifiedType SubstitutionMap::apply(const Name *name, Rewrite *) const
} }
UseMinimalNames::UseMinimalNames(ClassOrNamespace *target) UseMinimalNames::UseMinimalNames(LookupScope *target)
: _target(target) : _target(target)
{ {

View File

@@ -89,13 +89,13 @@ private:
class CPLUSPLUS_EXPORT UseMinimalNames: public Substitution class CPLUSPLUS_EXPORT UseMinimalNames: public Substitution
{ {
public: public:
UseMinimalNames(ClassOrNamespace *target); UseMinimalNames(LookupScope *target);
virtual ~UseMinimalNames(); virtual ~UseMinimalNames();
virtual FullySpecifiedType apply(const Name *name, Rewrite *rewrite) const; virtual FullySpecifiedType apply(const Name *name, Rewrite *rewrite) const;
private: private:
ClassOrNamespace *_target; LookupScope *_target;
}; };
class CPLUSPLUS_EXPORT UseQualifiedNames: public UseMinimalNames class CPLUSPLUS_EXPORT UseQualifiedNames: public UseMinimalNames

View File

@@ -97,7 +97,7 @@ QString CPlusPlus::toString(const LookupItem &it, const QString &id)
return result; return result;
} }
QString CPlusPlus::toString(const ClassOrNamespace *binding, QString id) QString CPlusPlus::toString(const LookupScope *binding, QString id)
{ {
if (!binding) if (!binding)
return QString::fromLatin1("%0: (null)").arg(id); return QString::fromLatin1("%0: (null)").arg(id);
@@ -128,7 +128,7 @@ void CPlusPlus::dump(const LookupItem &it)
qDebug() << qPrintable(toString(it)); qDebug() << qPrintable(toString(it));
} }
void CPlusPlus::dump(const ClassOrNamespace *binding) void CPlusPlus::dump(const LookupScope *binding)
{ {
qDebug() << qPrintable(toString(binding)); qDebug() << qPrintable(toString(binding));
} }

View File

@@ -45,13 +45,13 @@ QString CPLUSPLUS_EXPORT toString(const Name *name, QString id = QLatin1String("
QString CPLUSPLUS_EXPORT toString(FullySpecifiedType ty, QString id = QLatin1String("Type")); QString CPLUSPLUS_EXPORT toString(FullySpecifiedType ty, QString id = QLatin1String("Type"));
QString CPLUSPLUS_EXPORT toString(const Symbol *s, QString id = QLatin1String("Symbol")); QString CPLUSPLUS_EXPORT toString(const Symbol *s, QString id = QLatin1String("Symbol"));
QString CPLUSPLUS_EXPORT toString(const LookupItem &it, const QString &id = QLatin1String("LookupItem")); QString CPLUSPLUS_EXPORT toString(const LookupItem &it, const QString &id = QLatin1String("LookupItem"));
QString CPLUSPLUS_EXPORT toString(const ClassOrNamespace *binding, QString id = QLatin1String("ClassOrNamespace")); QString CPLUSPLUS_EXPORT toString(const LookupScope *binding, QString id = QLatin1String("LookupScope"));
void CPLUSPLUS_EXPORT dump(const Name *name); void CPLUSPLUS_EXPORT dump(const Name *name);
void CPLUSPLUS_EXPORT dump(const FullySpecifiedType &ty); void CPLUSPLUS_EXPORT dump(const FullySpecifiedType &ty);
void CPLUSPLUS_EXPORT dump(const Symbol *s); void CPLUSPLUS_EXPORT dump(const Symbol *s);
void CPLUSPLUS_EXPORT dump(const LookupItem &it); void CPLUSPLUS_EXPORT dump(const LookupItem &it);
void CPLUSPLUS_EXPORT dump(const ClassOrNamespace *binding); void CPLUSPLUS_EXPORT dump(const LookupScope *binding);
} // namespace CPlusPlus } // namespace CPlusPlus

View File

@@ -532,7 +532,7 @@ void FindUsages::memInitializer(MemInitializerAST *ast)
if (_currentScope->isFunction()) { if (_currentScope->isFunction()) {
Class *classScope = _currentScope->enclosingClass(); Class *classScope = _currentScope->enclosingClass();
if (! classScope) { if (! classScope) {
if (ClassOrNamespace *binding = _context.lookupType(_currentScope)) { if (LookupScope *binding = _context.lookupType(_currentScope)) {
foreach (Symbol *s, binding->symbols()) { foreach (Symbol *s, binding->symbols()) {
if (Class *k = s->asClass()) { if (Class *k = s->asClass()) {
classScope = k; classScope = k;

File diff suppressed because it is too large Load Diff

View File

@@ -58,43 +58,43 @@ struct FullyQualifiedName
: fqn(fqn) : fqn(fqn)
{} {}
}; };
class ClassOrNamespacePrivate; class LookupScopePrivate;
class Instantiator; class Instantiator;
} // namespace Internal; } // namespace Internal;
class CreateBindings; class CreateBindings;
class CPLUSPLUS_EXPORT ClassOrNamespace class CPLUSPLUS_EXPORT LookupScope
{ {
Q_DISABLE_COPY(ClassOrNamespace) Q_DISABLE_COPY(LookupScope)
ClassOrNamespace(CreateBindings *factory, ClassOrNamespace *parent); LookupScope(CreateBindings *factory, LookupScope *parent);
public: public:
~ClassOrNamespace(); ~LookupScope();
ClassOrNamespace *instantiationOrigin() const; LookupScope *instantiationOrigin() const;
ClassOrNamespace *parent() const; LookupScope *parent() const;
QList<ClassOrNamespace *> usings() const; QList<LookupScope *> usings() const;
QList<Enum *> unscopedEnums() const; QList<Enum *> unscopedEnums() const;
QList<Symbol *> symbols() const; QList<Symbol *> symbols() const;
QList<LookupItem> lookup(const Name *name); QList<LookupItem> lookup(const Name *name);
QList<LookupItem> find(const Name *name); QList<LookupItem> find(const Name *name);
ClassOrNamespace *lookupType(const Name *name); LookupScope *lookupType(const Name *name);
ClassOrNamespace *lookupType(const Name *name, Block *block); LookupScope *lookupType(const Name *name, Block *block);
ClassOrNamespace *findType(const Name *name); LookupScope *findType(const Name *name);
ClassOrNamespace *findBlock(Block *block); LookupScope *findBlock(Block *block);
/// The class this ClassOrNamespace is based on. /// The class this LookupScope is based on.
Class *rootClass() const; Class *rootClass() const;
private: private:
Internal::ClassOrNamespacePrivate *d; Internal::LookupScopePrivate *d;
friend class Internal::ClassOrNamespacePrivate; friend class Internal::LookupScopePrivate;
friend class Internal::Instantiator; friend class Internal::Instantiator;
friend class CreateBindings; friend class CreateBindings;
}; };
@@ -108,12 +108,11 @@ public:
virtual ~CreateBindings(); virtual ~CreateBindings();
/// Returns the binding for the global namespace. /// Returns the binding for the global namespace.
ClassOrNamespace *globalNamespace() const; LookupScope *globalNamespace() const;
/// Finds the binding associated to the given symbol. /// Finds the binding associated to the given symbol.
ClassOrNamespace *lookupType(Symbol *symbol, ClassOrNamespace *enclosingBinding = 0); LookupScope *lookupType(Symbol *symbol, LookupScope *enclosingBinding = 0);
ClassOrNamespace *lookupType(const QList<const Name *> &path, LookupScope *lookupType(const QList<const Name *> &path, LookupScope *enclosingBinding = 0);
ClassOrNamespace *enclosingBinding = 0);
/// Returns the Control that must be used to create temporary symbols. /// Returns the Control that must be used to create temporary symbols.
/// \internal /// \internal
@@ -129,28 +128,28 @@ public:
/// Store the result in \a results. /// Store the result in \a results.
/// \internal /// \internal
void lookupInScope(const Name *name, Scope *scope, QList<LookupItem> *result, void lookupInScope(const Name *name, Scope *scope, QList<LookupItem> *result,
ClassOrNamespace *binding = 0); LookupScope *binding = 0);
/// Create bindings for the symbols reachable from \a rootSymbol. /// Create bindings for the symbols reachable from \a rootSymbol.
/// \internal /// \internal
void process(Symbol *rootSymbol, ClassOrNamespace *classOrNamespace); void process(Symbol *rootSymbol, LookupScope *lookupScope);
/// Create an empty ClassOrNamespace binding with the given \a parent. /// Create an empty LookupScope binding with the given \a parent.
/// \internal /// \internal
ClassOrNamespace *allocClassOrNamespace(ClassOrNamespace *parent); LookupScope *allocLookupScope(LookupScope *parent);
protected: protected:
using SymbolVisitor::visit; using SymbolVisitor::visit;
/// Change the current ClassOrNamespace binding. /// Change the current LookupScope binding.
ClassOrNamespace *switchCurrentClassOrNamespace(ClassOrNamespace *classOrNamespace); LookupScope *switchCurrentLookupScope(LookupScope *lookupScope);
/// Enters the ClassOrNamespace binding associated with the given \a symbol. /// Enters the LookupScope binding associated with the given \a symbol.
ClassOrNamespace *enterClassOrNamespaceBinding(Symbol *symbol); LookupScope *enterLookupScopeBinding(Symbol *symbol);
/// Enters a ClassOrNamespace binding for the given \a symbol in the global /// Enters a LookupScope binding for the given \a symbol in the global
/// namespace binding. /// namespace binding.
ClassOrNamespace *enterGlobalClassOrNamespace(Symbol *symbol); LookupScope *enterGlobalLookupScope(Symbol *symbol);
/// Creates bindings for the given \a document. /// Creates bindings for the given \a document.
void process(Document::Ptr document); void process(Document::Ptr document);
@@ -187,9 +186,9 @@ private:
Snapshot _snapshot; Snapshot _snapshot;
QSharedPointer<Control> _control; QSharedPointer<Control> _control;
QSet<Namespace *> _processed; QSet<Namespace *> _processed;
QList<ClassOrNamespace *> _entities; QList<LookupScope *> _entities;
ClassOrNamespace *_globalNamespace; LookupScope *_globalNamespace;
ClassOrNamespace *_currentClassOrNamespace; LookupScope *_currentLookupScope;
bool _expandTemplates; bool _expandTemplates;
}; };
@@ -214,16 +213,16 @@ public:
Document::Ptr document(const QString &fileName) const; Document::Ptr document(const QString &fileName) const;
Snapshot snapshot() const; Snapshot snapshot() const;
ClassOrNamespace *globalNamespace() const; LookupScope *globalNamespace() const;
QList<LookupItem> lookup(const Name *name, Scope *scope) const; QList<LookupItem> lookup(const Name *name, Scope *scope) const;
ClassOrNamespace *lookupType(const Name *name, Scope *scope, LookupScope *lookupType(const Name *name, Scope *scope,
ClassOrNamespace *enclosingBinding = 0, LookupScope *enclosingBinding = 0,
QSet<const Declaration *> typedefsBeingResolved QSet<const Declaration *> typedefsBeingResolved
= QSet<const Declaration *>()) const; = QSet<const Declaration *>()) const;
ClassOrNamespace *lookupType(Symbol *symbol, LookupScope *lookupType(Symbol *symbol,
ClassOrNamespace *enclosingBinding = 0) const; LookupScope *enclosingBinding = 0) const;
ClassOrNamespace *lookupParent(Symbol *symbol) const; LookupScope *lookupParent(Symbol *symbol) const;
/// \internal /// \internal
QSharedPointer<CreateBindings> bindings() const QSharedPointer<CreateBindings> bindings() const
@@ -232,7 +231,7 @@ public:
static QList<const Name *> fullyQualifiedName(Symbol *symbol); static QList<const Name *> fullyQualifiedName(Symbol *symbol);
static QList<const Name *> path(Symbol *symbol); static QList<const Name *> path(Symbol *symbol);
static const Name *minimalName(Symbol *symbol, ClassOrNamespace *target, Control *control); static const Name *minimalName(Symbol *symbol, LookupScope *target, Control *control);
void setExpandTemplates(bool expandTemplates) void setExpandTemplates(bool expandTemplates)
{ {
@@ -242,7 +241,7 @@ public:
} }
private: private:
QList<LookupItem> lookupByUsing(const Name *name, ClassOrNamespace *bindingScope) const; QList<LookupItem> lookupByUsing(const Name *name, LookupScope *bindingScope) const;
// The current expression. // The current expression.
Document::Ptr _expressionDocument; Document::Ptr _expressionDocument;

View File

@@ -77,10 +77,10 @@ Scope *LookupItem::scope() const
void LookupItem::setScope(Scope *scope) void LookupItem::setScope(Scope *scope)
{ _scope = scope; } { _scope = scope; }
ClassOrNamespace *LookupItem::binding() const LookupScope *LookupItem::binding() const
{ return _binding; } { return _binding; }
void LookupItem::setBinding(ClassOrNamespace *binding) void LookupItem::setBinding(LookupScope *binding)
{ _binding = binding; } { _binding = binding; }
bool LookupItem::operator == (const LookupItem &other) const bool LookupItem::operator == (const LookupItem &other) const

View File

@@ -37,7 +37,7 @@
namespace CPlusPlus { namespace CPlusPlus {
class ClassOrNamespace; class LookupScope;
class CPLUSPLUS_EXPORT LookupItem class CPLUSPLUS_EXPORT LookupItem
{ {
@@ -63,8 +63,8 @@ public:
/// Sets this item's scope. /// Sets this item's scope.
void setScope(Scope *scope); void setScope(Scope *scope);
ClassOrNamespace *binding() const; LookupScope *binding() const;
void setBinding(ClassOrNamespace *binding); void setBinding(LookupScope *binding);
bool operator == (const LookupItem &other) const; bool operator == (const LookupItem &other) const;
bool operator != (const LookupItem &other) const; bool operator != (const LookupItem &other) const;
@@ -73,7 +73,7 @@ private:
FullySpecifiedType _type; FullySpecifiedType _type;
Scope *_scope; Scope *_scope;
Symbol *_declaration; Symbol *_declaration;
ClassOrNamespace *_binding; LookupScope *_binding;
}; };
uint qHash(const CPlusPlus::LookupItem &result); uint qHash(const CPlusPlus::LookupItem &result);

View File

@@ -176,7 +176,7 @@ void ResolveExpression::addResults(const QList<LookupItem> &items)
} }
void ResolveExpression::addResult(const FullySpecifiedType &ty, Scope *scope, void ResolveExpression::addResult(const FullySpecifiedType &ty, Scope *scope,
ClassOrNamespace *binding) LookupScope *binding)
{ {
LookupItem item; LookupItem item;
item.setType(ty); item.setType(ty);
@@ -206,7 +206,7 @@ bool ResolveExpression::visit(BinaryExpressionAST *ast)
if (d->core_declarator) { if (d->core_declarator) {
if (DeclaratorIdAST *declaratorId = d->core_declarator->asDeclaratorId()) { if (DeclaratorIdAST *declaratorId = d->core_declarator->asDeclaratorId()) {
if (NameAST *nameAST = declaratorId->name) { if (NameAST *nameAST = declaratorId->name) {
if (ClassOrNamespace *binding = baseExpression(_results, T_ARROW)) { if (LookupScope *binding = baseExpression(_results, T_ARROW)) {
_results.clear(); _results.clear();
addResults(binding->lookup(nameAST->name)); addResults(binding->lookup(nameAST->name));
} }
@@ -487,7 +487,7 @@ bool ResolveExpression::visit(UnaryExpressionAST *ast)
added = true; added = true;
} else if (namedTy != 0) { } else if (namedTy != 0) {
const Name *starOp = control()->operatorNameId(OperatorNameId::StarOp); const Name *starOp = control()->operatorNameId(OperatorNameId::StarOp);
if (ClassOrNamespace *b = _context.lookupType(namedTy->name(), p.scope(), p.binding())) { if (LookupScope *b = _context.lookupType(namedTy->name(), p.scope(), p.binding())) {
foreach (const LookupItem &r, b->find(starOp)) { foreach (const LookupItem &r, b->find(starOp)) {
Symbol *overload = r.declaration(); Symbol *overload = r.declaration();
if (Function *funTy = overload->type()->asFunctionType()) { if (Function *funTy = overload->type()->asFunctionType()) {
@@ -746,7 +746,7 @@ bool ResolveExpression::visit(CallAST *ast)
Scope *scope = result.scope(); Scope *scope = result.scope();
if (NamedType *namedTy = ty->asNamedType()) { if (NamedType *namedTy = ty->asNamedType()) {
if (ClassOrNamespace *b = _context.lookupType(namedTy->name(), scope)) { if (LookupScope *b = _context.lookupType(namedTy->name(), scope)) {
foreach (const LookupItem &r, b->find(functionCallOp)) { foreach (const LookupItem &r, b->find(functionCallOp)) {
Symbol *overload = r.declaration(); Symbol *overload = r.declaration();
if (Function *funTy = overload->type()->asFunctionType()) { if (Function *funTy = overload->type()->asFunctionType()) {
@@ -797,7 +797,7 @@ bool ResolveExpression::visit(ArrayAccessAST *ast)
addResult(arrTy->elementType().simplified(), scope); addResult(arrTy->elementType().simplified(), scope);
} else if (NamedType *namedTy = ty->asNamedType()) { } else if (NamedType *namedTy = ty->asNamedType()) {
if (ClassOrNamespace *b = _context.lookupType(namedTy->name(), scope)) { if (LookupScope *b = _context.lookupType(namedTy->name(), scope)) {
foreach (const LookupItem &r, b->find(arrayAccessOp)) { foreach (const LookupItem &r, b->find(arrayAccessOp)) {
Symbol *overload = r.declaration(); Symbol *overload = r.declaration();
if (Function *funTy = overload->type()->asFunctionType()) { if (Function *funTy = overload->type()->asFunctionType()) {
@@ -812,7 +812,7 @@ bool ResolveExpression::visit(ArrayAccessAST *ast)
return false; return false;
} }
QList<LookupItem> ResolveExpression::getMembers(ClassOrNamespace *binding, const Name *memberName) const QList<LookupItem> ResolveExpression::getMembers(LookupScope *binding, const Name *memberName) const
{ {
Q_UNUSED(binding); Q_UNUSED(binding);
Q_UNUSED(memberName); Q_UNUSED(memberName);
@@ -881,17 +881,17 @@ bool ResolveExpression::visit(MemberAccessAST *ast)
// Remember the access operator. // Remember the access operator.
const int accessOp = tokenKind(ast->access_token); const int accessOp = tokenKind(ast->access_token);
if (ClassOrNamespace *binding = baseExpression(baseResults, accessOp)) if (LookupScope *binding = baseExpression(baseResults, accessOp))
addResults(binding->find(memberName)); addResults(binding->find(memberName));
return false; return false;
} }
ClassOrNamespace *ResolveExpression::findClass(const FullySpecifiedType &originalTy, Scope *scope, LookupScope *ResolveExpression::findClass(const FullySpecifiedType &originalTy, Scope *scope,
ClassOrNamespace *enclosingBinding) const LookupScope *enclosingBinding) const
{ {
FullySpecifiedType ty = originalTy.simplified(); FullySpecifiedType ty = originalTy.simplified();
ClassOrNamespace *binding = 0; LookupScope *binding = 0;
if (Class *klass = ty->asClassType()) { if (Class *klass = ty->asClassType()) {
if (scope->isBlock()) if (scope->isBlock())
@@ -909,9 +909,9 @@ ClassOrNamespace *ResolveExpression::findClass(const FullySpecifiedType &origina
return binding; return binding;
} }
ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &baseResults, LookupScope *ResolveExpression::baseExpression(const QList<LookupItem> &baseResults,
int accessOp, int accessOp,
bool *replacedDotOperator) const bool *replacedDotOperator) const
{ {
if (Q_UNLIKELY(debug)) if (Q_UNLIKELY(debug))
qDebug() << "In ResolveExpression::baseExpression with" << baseResults.size() << "results..."; qDebug() << "In ResolveExpression::baseExpression with" << baseResults.size() << "results...";
@@ -934,16 +934,16 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas
if (accessOp == T_ARROW) { if (accessOp == T_ARROW) {
if (PointerType *ptrTy = ty->asPointerType()) { if (PointerType *ptrTy = ty->asPointerType()) {
FullySpecifiedType type = ptrTy->elementType(); FullySpecifiedType type = ptrTy->elementType();
if (ClassOrNamespace *binding if (LookupScope *binding
= findClassForTemplateParameterInExpressionScope(r.binding(), = findClassForTemplateParameterInExpressionScope(r.binding(),
type)) { type)) {
return binding; return binding;
} }
if (ClassOrNamespace *binding = findClass(type, scope)) if (LookupScope *binding = findClass(type, scope))
return binding; return binding;
} else { } else {
ClassOrNamespace *binding LookupScope *binding
= findClassForTemplateParameterInExpressionScope(r.binding(), = findClassForTemplateParameterInExpressionScope(r.binding(),
ty); ty);
@@ -972,20 +972,20 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas
if (PointerType *ptrTy = retTy->asPointerType()) if (PointerType *ptrTy = retTy->asPointerType())
retTy = ptrTy->elementType(); retTy = ptrTy->elementType();
if (ClassOrNamespace *retBinding = findClass(retTy, functionScope)) if (LookupScope *retBinding = findClass(retTy, functionScope))
return retBinding; return retBinding;
if (scope != functionScope) { if (scope != functionScope) {
if (ClassOrNamespace *retBinding = findClass(retTy, scope)) if (LookupScope *retBinding = findClass(retTy, scope))
return retBinding; return retBinding;
} }
if (ClassOrNamespace *origin = binding->instantiationOrigin()) { if (LookupScope *origin = binding->instantiationOrigin()) {
foreach (Symbol *originSymbol, origin->symbols()) { foreach (Symbol *originSymbol, origin->symbols()) {
Scope *originScope = originSymbol->asScope(); Scope *originScope = originSymbol->asScope();
if (originScope && originScope != scope if (originScope && originScope != scope
&& originScope != functionScope) { && originScope != functionScope) {
if (ClassOrNamespace *retBinding if (LookupScope *retBinding
= findClass(retTy, originScope)) = findClass(retTy, originScope))
return retBinding; return retBinding;
} }
@@ -1002,19 +1002,19 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas
ty = ptrTy->elementType(); ty = ptrTy->elementType();
} }
if (ClassOrNamespace *binding if (LookupScope *binding
= findClassForTemplateParameterInExpressionScope(r.binding(), = findClassForTemplateParameterInExpressionScope(r.binding(),
ty)) { ty)) {
return binding; return binding;
} }
ClassOrNamespace *enclosingBinding = 0; LookupScope *enclosingBinding = 0;
if (ClassOrNamespace *binding = r.binding()) { if (LookupScope *binding = r.binding()) {
if (binding->instantiationOrigin()) if (binding->instantiationOrigin())
enclosingBinding = binding; enclosingBinding = binding;
} }
if (ClassOrNamespace *binding = findClass(ty, scope, enclosingBinding)) if (LookupScope *binding = findClass(ty, scope, enclosingBinding))
return binding; return binding;
} }
} }
@@ -1022,15 +1022,15 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas
return 0; return 0;
} }
ClassOrNamespace *ResolveExpression::findClassForTemplateParameterInExpressionScope( LookupScope *ResolveExpression::findClassForTemplateParameterInExpressionScope(
ClassOrNamespace *resultBinding, LookupScope *resultBinding,
const FullySpecifiedType &ty) const const FullySpecifiedType &ty) const
{ {
if (resultBinding) { if (resultBinding) {
if (ClassOrNamespace *origin = resultBinding->instantiationOrigin()) { if (LookupScope *origin = resultBinding->instantiationOrigin()) {
foreach (Symbol *originSymbol, origin->symbols()) { foreach (Symbol *originSymbol, origin->symbols()) {
if (Scope *originScope = originSymbol->asScope()) { if (Scope *originScope = originSymbol->asScope()) {
if (ClassOrNamespace *retBinding = findClass(ty, originScope)) if (LookupScope *retBinding = findClass(ty, originScope))
return retBinding; return retBinding;
} }
} }
@@ -1053,7 +1053,7 @@ bool ResolveExpression::visit(ObjCMessageExpressionAST *ast)
foreach (const LookupItem &result, receiverResults) { foreach (const LookupItem &result, receiverResults) {
FullySpecifiedType ty = result.type().simplified(); FullySpecifiedType ty = result.type().simplified();
ClassOrNamespace *binding = 0; LookupScope *binding = 0;
if (ObjCClass *clazz = ty->asObjCClassType()) { if (ObjCClass *clazz = ty->asObjCClassType()) {
// static access, e.g.: // static access, e.g.:

View File

@@ -53,25 +53,25 @@ public:
QList<LookupItem> resolve(ExpressionAST *ast, Scope *scope, bool ref = false); QList<LookupItem> resolve(ExpressionAST *ast, Scope *scope, bool ref = false);
QList<LookupItem> reference(ExpressionAST *ast, Scope *scope); QList<LookupItem> reference(ExpressionAST *ast, Scope *scope);
ClassOrNamespace *baseExpression(const QList<LookupItem> &baseResults, LookupScope *baseExpression(const QList<LookupItem> &baseResults,
int accessOp, int accessOp,
bool *replacedDotOperator = 0) const; bool *replacedDotOperator = 0) const;
const LookupContext &context() const; const LookupContext &context() const;
protected: protected:
ClassOrNamespace *findClass(const FullySpecifiedType &ty, Scope *scope, LookupScope *findClass(const FullySpecifiedType &ty, Scope *scope,
ClassOrNamespace *enclosingBinding = 0) const; LookupScope *enclosingBinding = 0) const;
QList<LookupItem> expression(ExpressionAST *ast); QList<LookupItem> expression(ExpressionAST *ast);
QList<LookupItem> switchResults(const QList<LookupItem> &symbols); QList<LookupItem> switchResults(const QList<LookupItem> &symbols);
QList<LookupItem> getMembers(ClassOrNamespace *binding, const Name *memberName) const; QList<LookupItem> getMembers(LookupScope *binding, const Name *memberName) const;
void thisObject(); void thisObject();
void addResult(const FullySpecifiedType &ty, Scope *scope, ClassOrNamespace *binding = 0); void addResult(const FullySpecifiedType &ty, Scope *scope, LookupScope *binding = 0);
void addResults(const QList<Symbol *> &symbols); void addResults(const QList<Symbol *> &symbols);
void addResults(const QList<LookupItem> &items); void addResults(const QList<LookupItem> &items);
@@ -125,8 +125,8 @@ protected:
private: private:
ClassOrNamespace *findClassForTemplateParameterInExpressionScope( LookupScope *findClassForTemplateParameterInExpressionScope(
ClassOrNamespace *resultBinding, LookupScope *resultBinding,
const FullySpecifiedType &ty) const; const FullySpecifiedType &ty) const;
Scope *_scope; Scope *_scope;

View File

@@ -37,7 +37,7 @@ static const bool debug = ! qgetenv("QTC_LOOKUPCONTEXT_DEBUG").isEmpty();
namespace CPlusPlus { namespace CPlusPlus {
void TypeResolver::resolve(FullySpecifiedType *type, Scope **scope, ClassOrNamespace *binding) void TypeResolver::resolve(FullySpecifiedType *type, Scope **scope, LookupScope *binding)
{ {
QSet<Symbol *> visited; QSet<Symbol *> visited;
_binding = binding; _binding = binding;
@@ -73,13 +73,13 @@ NamedType *TypeResolver::getNamedType(FullySpecifiedType &type) const
} }
QList<LookupItem> TypeResolver::getNamedTypeItems(const Name *name, Scope *scope, QList<LookupItem> TypeResolver::getNamedTypeItems(const Name *name, Scope *scope,
ClassOrNamespace *binding) const LookupScope *binding) const
{ {
QList<LookupItem> namedTypeItems = typedefsFromScopeUpToFunctionScope(name, scope); QList<LookupItem> namedTypeItems = typedefsFromScopeUpToFunctionScope(name, scope);
if (namedTypeItems.isEmpty()) { if (namedTypeItems.isEmpty()) {
if (binding) if (binding)
namedTypeItems = binding->lookup(name); namedTypeItems = binding->lookup(name);
if (ClassOrNamespace *scopeCon = _context.lookupType(scope)) if (LookupScope *scopeCon = _context.lookupType(scope))
namedTypeItems += scopeCon->lookup(name); namedTypeItems += scopeCon->lookup(name);
} }

View File

@@ -39,13 +39,13 @@ class TypeResolver
{ {
public: public:
TypeResolver(const LookupContext &context) : _context(context) {} TypeResolver(const LookupContext &context) : _context(context) {}
void resolve(FullySpecifiedType *type, Scope **scope, ClassOrNamespace *binding); void resolve(FullySpecifiedType *type, Scope **scope, LookupScope *binding);
private: private:
NamedType *getNamedType(FullySpecifiedType& type) const; NamedType *getNamedType(FullySpecifiedType& type) const;
QList<LookupItem> getNamedTypeItems(const Name *name, Scope *scope, QList<LookupItem> getNamedTypeItems(const Name *name, Scope *scope,
ClassOrNamespace *binding) const; LookupScope *binding) const;
static QList<LookupItem> typedefsFromScopeUpToFunctionScope(const Name *name, Scope *scope); static QList<LookupItem> typedefsFromScopeUpToFunctionScope(const Name *name, Scope *scope);
@@ -56,7 +56,7 @@ private:
const LookupContext &_context; const LookupContext &_context;
// binding has to be remembered in case of resolving typedefs for templates // binding has to be remembered in case of resolving typedefs for templates
ClassOrNamespace *_binding; LookupScope *_binding;
}; };
} // namespace CPlusPlus } // namespace CPlusPlus

View File

@@ -795,7 +795,7 @@ static void buildContextProperties(
Scope *typeScope = result.scope(); Scope *typeScope = result.scope();
if (!typeScope) if (!typeScope)
typeScope = scope; // incorrect but may be an ok fallback typeScope = scope; // incorrect but may be an ok fallback
ClassOrNamespace *binding = typeOf.context().lookupType(namedType->name(), typeScope); LookupScope *binding = typeOf.context().lookupType(namedType->name(), typeScope);
if (binding && !binding->symbols().isEmpty()) { if (binding && !binding->symbols().isEmpty()) {
// find the best 'Class' symbol // find the best 'Class' symbol
for (int i = binding->symbols().size() - 1; i >= 0; --i) { for (int i = binding->symbols().size() - 1; i >= 0; --i) {

View File

@@ -389,7 +389,7 @@ void CppEditorWidget::switchDeclarationDefinition(bool inNextSplit)
} else if (functionDefinitionSymbol) { } else if (functionDefinitionSymbol) {
const Snapshot snapshot = d->m_modelManager->snapshot(); const Snapshot snapshot = d->m_modelManager->snapshot();
LookupContext context(d->m_lastSemanticInfo.doc, snapshot); LookupContext context(d->m_lastSemanticInfo.doc, snapshot);
ClassOrNamespace *binding = context.lookupType(functionDefinitionSymbol); LookupScope *binding = context.lookupType(functionDefinitionSymbol);
const QList<LookupItem> declarations = context.lookup(functionDefinitionSymbol->name(), const QList<LookupItem> declarations = context.lookup(functionDefinitionSymbol->name(),
functionDefinitionSymbol->enclosingScope()); functionDefinitionSymbol->enclosingScope());

View File

@@ -327,10 +327,10 @@ bool CppClass::operator==(const CppClass &other)
void CppClass::lookupBases(Symbol *declaration, const LookupContext &context) void CppClass::lookupBases(Symbol *declaration, const LookupContext &context)
{ {
typedef QPair<ClassOrNamespace *, CppClass *> Data; typedef QPair<LookupScope *, CppClass *> Data;
if (ClassOrNamespace *clazz = context.lookupType(declaration)) { if (LookupScope *clazz = context.lookupType(declaration)) {
QSet<ClassOrNamespace *> visited; QSet<LookupScope *> visited;
QQueue<Data> q; QQueue<Data> q;
q.enqueue(qMakePair(clazz, this)); q.enqueue(qMakePair(clazz, this));
@@ -338,8 +338,8 @@ void CppClass::lookupBases(Symbol *declaration, const LookupContext &context)
Data current = q.dequeue(); Data current = q.dequeue();
clazz = current.first; clazz = current.first;
visited.insert(clazz); visited.insert(clazz);
const QList<ClassOrNamespace *> &bases = clazz->usings(); const QList<LookupScope *> &bases = clazz->usings();
foreach (ClassOrNamespace *baseClass, bases) { foreach (LookupScope *baseClass, bases) {
const QList<Symbol *> &symbols = baseClass->symbols(); const QList<Symbol *> &symbols = baseClass->symbols();
foreach (Symbol *symbol, symbols) { foreach (Symbol *symbol, symbols) {
if (symbol->isClass() && ( if (symbol->isClass() && (
@@ -429,7 +429,7 @@ CppVariable::CppVariable(Symbol *declaration, const LookupContext &context, Scop
} }
if (typeName) { if (typeName) {
if (ClassOrNamespace *clazz = context.lookupType(typeName, scope)) { if (LookupScope *clazz = context.lookupType(typeName, scope)) {
if (!clazz->symbols().isEmpty()) { if (!clazz->symbols().isEmpty()) {
Overview overview; Overview overview;
Symbol *symbol = clazz->symbols().at(0); Symbol *symbol = clazz->symbols().at(0);

View File

@@ -187,7 +187,7 @@ Class *VirtualFunctionHelper::staticClassOfFunctionCallExpression_internal() con
const QList<LookupItem> items = typeOfExpression(memberAccessAST->base_expression, const QList<LookupItem> items = typeOfExpression(memberAccessAST->base_expression,
m_expressionDocument, m_scope); m_expressionDocument, m_scope);
ResolveExpression resolveExpression(typeOfExpression.context()); ResolveExpression resolveExpression(typeOfExpression.context());
ClassOrNamespace *binding = resolveExpression.baseExpression(items, m_accessTokenKind); LookupScope *binding = resolveExpression.baseExpression(items, m_accessTokenKind);
if (binding) { if (binding) {
if (Class *klass = binding->rootClass()) { if (Class *klass = binding->rootClass()) {
result = klass; result = klass;

View File

@@ -607,7 +607,7 @@ ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targetOffse
SubstitutionEnvironment env; SubstitutionEnvironment env;
env.setContext(sourceContext); env.setContext(sourceContext);
env.switchScope(sourceFunction->enclosingScope()); env.switchScope(sourceFunction->enclosingScope());
ClassOrNamespace *targetCoN = targetContext.lookupType(targetFunction->enclosingScope()); LookupScope *targetCoN = targetContext.lookupType(targetFunction->enclosingScope());
if (!targetCoN) if (!targetCoN)
targetCoN = targetContext.globalNamespace(); targetCoN = targetContext.globalNamespace();
UseMinimalNames q(targetCoN); UseMinimalNames q(targetCoN);
@@ -653,7 +653,7 @@ ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targetOffse
SubstitutionEnvironment env; SubstitutionEnvironment env;
env.setContext(sourceContext); env.setContext(sourceContext);
env.switchScope(sourceFunction); env.switchScope(sourceFunction);
ClassOrNamespace *targetCoN = targetContext.lookupType(targetFunction); LookupScope *targetCoN = targetContext.lookupType(targetFunction);
if (!targetCoN) if (!targetCoN)
targetCoN = targetContext.globalNamespace(); targetCoN = targetContext.globalNamespace();
UseMinimalNames q(targetCoN); UseMinimalNames q(targetCoN);

View File

@@ -480,15 +480,15 @@ public:
// Determine base classes // Determine base classes
QList<const Class *> baseClasses; QList<const Class *> baseClasses;
QQueue<ClassOrNamespace *> baseClassQueue; QQueue<LookupScope *> baseClassQueue;
QSet<ClassOrNamespace *> visitedBaseClasses; QSet<LookupScope *> visitedBaseClasses;
if (ClassOrNamespace *clazz = interface.context().lookupType(m_classAST->symbol)) if (LookupScope *clazz = interface.context().lookupType(m_classAST->symbol))
baseClassQueue.enqueue(clazz); baseClassQueue.enqueue(clazz);
while (!baseClassQueue.isEmpty()) { while (!baseClassQueue.isEmpty()) {
ClassOrNamespace *clazz = baseClassQueue.dequeue(); LookupScope *clazz = baseClassQueue.dequeue();
visitedBaseClasses.insert(clazz); visitedBaseClasses.insert(clazz);
const QList<ClassOrNamespace *> bases = clazz->usings(); const QList<LookupScope *> bases = clazz->usings();
foreach (ClassOrNamespace *baseClass, bases) { foreach (LookupScope *baseClass, bases) {
foreach (Symbol *symbol, baseClass->symbols()) { foreach (Symbol *symbol, baseClass->symbols()) {
Class *base = symbol->asClass(); Class *base = symbol->asClass();
if (base if (base
@@ -690,7 +690,7 @@ public:
const LookupContext targetContext(headerFile->cppDocument(), snapshot()); const LookupContext targetContext(headerFile->cppDocument(), snapshot());
const Class *targetClass = m_classAST->symbol; const Class *targetClass = m_classAST->symbol;
ClassOrNamespace *targetCoN = targetContext.lookupType(targetClass->enclosingScope()); LookupScope *targetCoN = targetContext.lookupType(targetClass->enclosingScope());
if (!targetCoN) if (!targetCoN)
targetCoN = targetContext.globalNamespace(); targetCoN = targetContext.globalNamespace();
UseMinimalNames useMinimalNames(targetCoN); UseMinimalNames useMinimalNames(targetCoN);
@@ -778,7 +778,7 @@ public:
implementationDoc->translationUnit()->getPosition(insertPos, &line, &column); implementationDoc->translationUnit()->getPosition(insertPos, &line, &column);
Scope *targetScope = implementationDoc->scopeAt(line, column); Scope *targetScope = implementationDoc->scopeAt(line, column);
const LookupContext targetContext(implementationDoc, snapshot()); const LookupContext targetContext(implementationDoc, snapshot());
ClassOrNamespace *targetCoN = targetContext.lookupType(targetScope); LookupScope *targetCoN = targetContext.lookupType(targetScope);
if (!targetCoN) if (!targetCoN)
targetCoN = targetContext.globalNamespace(); targetCoN = targetContext.globalNamespace();

View File

@@ -211,7 +211,7 @@ Class *isMemberFunction(const LookupContext &context, Function *function)
if (!q->base()) if (!q->base())
return 0; return 0;
if (ClassOrNamespace *binding = context.lookupType(q->base(), enclosingScope)) { if (LookupScope *binding = context.lookupType(q->base(), enclosingScope)) {
foreach (Symbol *s, binding->symbols()) { foreach (Symbol *s, binding->symbols()) {
if (Class *matchingClass = s->asClass()) if (Class *matchingClass = s->asClass())
return matchingClass; return matchingClass;
@@ -249,7 +249,7 @@ Namespace *isNamespaceFunction(const LookupContext &context, Function *function)
if (!q->base()) if (!q->base())
return 0; return 0;
if (ClassOrNamespace *binding = context.lookupType(q->base(), enclosingScope)) { if (LookupScope *binding = context.lookupType(q->base(), enclosingScope)) {
foreach (Symbol *s, binding->symbols()) { foreach (Symbol *s, binding->symbols()) {
if (Namespace *matchingNamespace = s->asNamespace()) if (Namespace *matchingNamespace = s->asNamespace())
return matchingNamespace; return matchingNamespace;
@@ -1323,7 +1323,7 @@ void TranslateStringLiteral::match(const CppQuickFixInterface &interface,
for (int i = path.size() - 1; i >= 0; --i) { for (int i = path.size() - 1; i >= 0; --i) {
if (FunctionDefinitionAST *definition = path.at(i)->asFunctionDefinition()) { if (FunctionDefinitionAST *definition = path.at(i)->asFunctionDefinition()) {
Function *function = definition->symbol; Function *function = definition->symbol;
ClassOrNamespace *b = interface.context().lookupType(function); LookupScope *b = interface.context().lookupType(function);
if (b) { if (b) {
// Do we have a tr function? // Do we have a tr function?
foreach (const LookupItem &r, b->find(trName)) { foreach (const LookupItem &r, b->find(trName)) {
@@ -1584,7 +1584,7 @@ public:
SubstitutionEnvironment env; SubstitutionEnvironment env;
env.setContext(context()); env.setContext(context());
env.switchScope(result.first().scope()); env.switchScope(result.first().scope());
ClassOrNamespace *con = typeOfExpression.context().lookupType(scope); LookupScope *con = typeOfExpression.context().lookupType(scope);
if (!con) if (!con)
con = typeOfExpression.context().globalNamespace(); con = typeOfExpression.context().globalNamespace();
UseMinimalNames q(con); UseMinimalNames q(con);
@@ -2274,7 +2274,7 @@ Enum *findEnum(const QList<LookupItem> &results, const LookupContext &ctxt)
if (Enum *e = type->asEnumType()) if (Enum *e = type->asEnumType())
return e; return e;
if (const NamedType *namedType = type->asNamedType()) { if (const NamedType *namedType = type->asNamedType()) {
if (ClassOrNamespace *con = ctxt.lookupType(namedType->name(), result.scope())) { if (LookupScope *con = ctxt.lookupType(namedType->name(), result.scope())) {
const QList<Enum *> enums = con->unscopedEnums(); const QList<Enum *> enums = con->unscopedEnums();
const Name *referenceName = namedType->name(); const Name *referenceName = namedType->name();
if (const QualifiedNameId *qualifiedName = referenceName->asQualifiedNameId()) if (const QualifiedNameId *qualifiedName = referenceName->asQualifiedNameId())
@@ -2571,7 +2571,7 @@ public:
Document::Ptr targetDoc = targetFile->cppDocument(); Document::Ptr targetDoc = targetFile->cppDocument();
Scope *targetScope = targetDoc->scopeAt(m_loc.line(), m_loc.column()); Scope *targetScope = targetDoc->scopeAt(m_loc.line(), m_loc.column());
LookupContext targetContext(targetDoc, snapshot()); LookupContext targetContext(targetDoc, snapshot());
ClassOrNamespace *targetCoN = targetContext.lookupType(targetScope); LookupScope *targetCoN = targetContext.lookupType(targetScope);
if (!targetCoN) if (!targetCoN)
targetCoN = targetContext.globalNamespace(); targetCoN = targetContext.globalNamespace();
@@ -3173,7 +3173,7 @@ public:
SubstitutionEnvironment env; SubstitutionEnvironment env;
env.setContext(context()); env.setContext(context());
env.switchScope(refFunc); env.switchScope(refFunc);
ClassOrNamespace *targetCoN = context().lookupType(refFunc->enclosingScope()); LookupScope *targetCoN = context().lookupType(refFunc->enclosingScope());
if (!targetCoN) if (!targetCoN)
targetCoN = context().globalNamespace(); targetCoN = context().globalNamespace();
UseMinimalNames subs(targetCoN); UseMinimalNames subs(targetCoN);
@@ -4574,7 +4574,7 @@ QString definitionSignature(const CppQuickFixInterface *assist,
QTC_ASSERT(func, return QString()); QTC_ASSERT(func, return QString());
LookupContext cppContext(targetFile->cppDocument(), assist->snapshot()); LookupContext cppContext(targetFile->cppDocument(), assist->snapshot());
ClassOrNamespace *cppCoN = cppContext.lookupType(scope); LookupScope *cppCoN = cppContext.lookupType(scope);
if (!cppCoN) if (!cppCoN)
cppCoN = cppContext.globalNamespace(); cppCoN = cppContext.globalNamespace();
SubstitutionEnvironment env; SubstitutionEnvironment env;
@@ -5055,7 +5055,7 @@ public:
SubstitutionEnvironment env; SubstitutionEnvironment env;
env.setContext(context()); env.setContext(context());
env.switchScope(result.first().scope()); env.switchScope(result.first().scope());
ClassOrNamespace *con = typeOfExpression.context().lookupType(scope); LookupScope *con = typeOfExpression.context().lookupType(scope);
if (!con) if (!con)
con = typeOfExpression.context().globalNamespace(); con = typeOfExpression.context().globalNamespace();
UseMinimalNames q(con); UseMinimalNames q(con);
@@ -5654,7 +5654,7 @@ PointerType *determineConvertedType(NamedType *namedType, const LookupContext &c
{ {
if (!namedType) if (!namedType)
return 0; return 0;
if (ClassOrNamespace *binding = context.lookupType(namedType->name(), scope)) { if (LookupScope *binding = context.lookupType(namedType->name(), scope)) {
if (Symbol *objectClassSymbol = skipForwardDeclarations(binding->symbols())) { if (Symbol *objectClassSymbol = skipForwardDeclarations(binding->symbols())) {
if (Class *klass = objectClassSymbol->asClass()) { if (Class *klass = objectClassSymbol->asClass()) {
for (auto it = klass->memberBegin(), end = klass->memberEnd(); it != end; ++it) { for (auto it = klass->memberBegin(), end = klass->memberEnd(); it != end; ++it) {
@@ -5712,7 +5712,7 @@ Class *senderOrReceiverClass(const CppQuickFixInterface &interface,
NamedType *objectType = objectTypeBase->asNamedType(); NamedType *objectType = objectTypeBase->asNamedType();
QTC_ASSERT(objectType, return 0); QTC_ASSERT(objectType, return 0);
ClassOrNamespace *objectClassCON = context.lookupType(objectType->name(), objectPointerScope); LookupScope *objectClassCON = context.lookupType(objectType->name(), objectPointerScope);
QTC_ASSERT(objectClassCON, return 0); QTC_ASSERT(objectClassCON, return 0);
QTC_ASSERT(!objectClassCON->symbols().isEmpty(), return 0); QTC_ASSERT(!objectClassCON->symbols().isEmpty(), return 0);
@@ -5764,7 +5764,7 @@ bool findConnectReplacement(const CppQuickFixInterface &interface,
// Minimize qualification // Minimize qualification
Control *control = context.bindings()->control().data(); Control *control = context.bindings()->control().data();
ClassOrNamespace *functionCON = context.lookupParent(scope); LookupScope *functionCON = context.lookupParent(scope);
const Name *shortName = LookupContext::minimalName(method, functionCON, control); const Name *shortName = LookupContext::minimalName(method, functionCON, control);
if (!shortName->asQualifiedNameId()) if (!shortName->asQualifiedNameId())
shortName = control->qualifiedNameId(classOfMethod->name(), shortName); shortName = control->qualifiedNameId(classOfMethod->name(), shortName);

View File

@@ -673,7 +673,7 @@ bool CheckSymbols::visit(NewExpressionAST *ast)
if (highlightCtorDtorAsType) { if (highlightCtorDtorAsType) {
accept(ast->new_type_id); accept(ast->new_type_id);
} else { } else {
ClassOrNamespace *binding = 0; LookupScope *binding = 0;
NameAST *nameAST = 0; NameAST *nameAST = 0;
if (ast->new_type_id) { if (ast->new_type_id) {
for (SpecifierListAST *it = ast->new_type_id->type_specifier_list; it; it = it->next) { for (SpecifierListAST *it = ast->new_type_id->type_specifier_list; it; it = it->next) {
@@ -739,7 +739,7 @@ void CheckSymbols::checkNamespace(NameAST *name)
unsigned line, column; unsigned line, column;
getTokenStartPosition(name->firstToken(), &line, &column); getTokenStartPosition(name->firstToken(), &line, &column);
if (ClassOrNamespace *b = _context.lookupType(name->name, enclosingScope())) { if (LookupScope *b = _context.lookupType(name->name, enclosingScope())) {
foreach (Symbol *s, b->symbols()) { foreach (Symbol *s, b->symbols()) {
if (s->isNamespace()) if (s->isNamespace())
return; return;
@@ -772,14 +772,14 @@ bool CheckSymbols::hasVirtualDestructor(Class *klass) const
return false; return false;
} }
bool CheckSymbols::hasVirtualDestructor(ClassOrNamespace *binding) const bool CheckSymbols::hasVirtualDestructor(LookupScope *binding) const
{ {
QSet<ClassOrNamespace *> processed; QSet<LookupScope *> processed;
QList<ClassOrNamespace *> todo; QList<LookupScope *> todo;
todo.append(binding); todo.append(binding);
while (!todo.isEmpty()) { while (!todo.isEmpty()) {
ClassOrNamespace *b = todo.takeFirst(); LookupScope *b = todo.takeFirst();
if (b && !processed.contains(b)) { if (b && !processed.contains(b)) {
processed.insert(b); processed.insert(b);
foreach (Symbol *s, b->symbols()) { foreach (Symbol *s, b->symbols()) {
@@ -861,7 +861,7 @@ bool CheckSymbols::visit(QualifiedNameAST *ast)
{ {
if (ast->name) { if (ast->name) {
ClassOrNamespace *binding = checkNestedName(ast); LookupScope *binding = checkNestedName(ast);
if (binding && ast->unqualified_name) { if (binding && ast->unqualified_name) {
if (ast->unqualified_name->asDestructorName() != 0) { if (ast->unqualified_name->asDestructorName() != 0) {
@@ -890,9 +890,9 @@ bool CheckSymbols::visit(QualifiedNameAST *ast)
return false; return false;
} }
ClassOrNamespace *CheckSymbols::checkNestedName(QualifiedNameAST *ast) LookupScope *CheckSymbols::checkNestedName(QualifiedNameAST *ast)
{ {
ClassOrNamespace *binding = 0; LookupScope *binding = 0;
if (ast->name) { if (ast->name) {
if (NestedNameSpecifierListAST *it = ast->nested_name_specifier_list) { if (NestedNameSpecifierListAST *it = ast->nested_name_specifier_list) {
@@ -958,7 +958,7 @@ bool CheckSymbols::visit(MemInitializerAST *ast)
{ {
if (FunctionDefinitionAST *enclosingFunction = enclosingFunctionDefinition()) { if (FunctionDefinitionAST *enclosingFunction = enclosingFunctionDefinition()) {
if (ast->name && enclosingFunction->symbol) { if (ast->name && enclosingFunction->symbol) {
if (ClassOrNamespace *binding = _context.lookupType(enclosingFunction->symbol)) { if (LookupScope *binding = _context.lookupType(enclosingFunction->symbol)) {
foreach (Symbol *s, binding->symbols()) { foreach (Symbol *s, binding->symbols()) {
if (Class *klass = s->asClass()) { if (Class *klass = s->asClass()) {
NameAST *nameAST = ast->name; NameAST *nameAST = ast->name;
@@ -1161,7 +1161,7 @@ void CheckSymbols::addUse(const Result &use)
_usages.append(use); _usages.append(use);
} }
void CheckSymbols::addType(ClassOrNamespace *b, NameAST *ast) void CheckSymbols::addType(LookupScope *b, NameAST *ast)
{ {
unsigned startToken; unsigned startToken;
if (!b || !acceptName(ast, &startToken)) if (!b || !acceptName(ast, &startToken))

View File

@@ -105,7 +105,7 @@ protected:
const QList<Result> &otherUses); const QList<Result> &otherUses);
bool hasVirtualDestructor(CPlusPlus::Class *klass) const; bool hasVirtualDestructor(CPlusPlus::Class *klass) const;
bool hasVirtualDestructor(CPlusPlus::ClassOrNamespace *binding) const; bool hasVirtualDestructor(CPlusPlus::LookupScope *binding) const;
bool warning(unsigned line, unsigned column, const QString &text, unsigned length = 0); bool warning(unsigned line, unsigned column, const QString &text, unsigned length = 0);
bool warning(CPlusPlus::AST *ast, const QString &text); bool warning(CPlusPlus::AST *ast, const QString &text);
@@ -119,13 +119,13 @@ protected:
void checkNamespace(CPlusPlus::NameAST *name); void checkNamespace(CPlusPlus::NameAST *name);
void checkName(CPlusPlus::NameAST *ast, CPlusPlus::Scope *scope = 0); void checkName(CPlusPlus::NameAST *ast, CPlusPlus::Scope *scope = 0);
CPlusPlus::ClassOrNamespace *checkNestedName(CPlusPlus::QualifiedNameAST *ast); CPlusPlus::LookupScope *checkNestedName(CPlusPlus::QualifiedNameAST *ast);
void addUse(const Result &use); void addUse(const Result &use);
void addUse(unsigned tokenIndex, Kind kind); void addUse(unsigned tokenIndex, Kind kind);
void addUse(CPlusPlus::NameAST *name, Kind kind); void addUse(CPlusPlus::NameAST *name, Kind kind);
void addType(CPlusPlus::ClassOrNamespace *b, CPlusPlus::NameAST *ast); void addType(CPlusPlus::LookupScope *b, CPlusPlus::NameAST *ast);
bool maybeAddTypeOrStatic(const QList<CPlusPlus::LookupItem> &candidates, bool maybeAddTypeOrStatic(const QList<CPlusPlus::LookupItem> &candidates,
CPlusPlus::NameAST *ast); CPlusPlus::NameAST *ast);

View File

@@ -746,8 +746,8 @@ bool canCompleteClassNameAt2ndOr4thConnectArgument(
|| eater.eatConnectOpenParenthesisExpressionCommaAmpersandExpressionComma(); || eater.eatConnectOpenParenthesisExpressionCommaAmpersandExpressionComma();
} }
ClassOrNamespace *classOrNamespaceFromLookupItem(const LookupItem &lookupItem, LookupScope *lookupScopeFromLookupItem(const LookupItem &lookupItem,
const LookupContext &context) const LookupContext &context)
{ {
const Name *name = 0; const Name *name = 0;
@@ -776,7 +776,7 @@ ClassOrNamespace *classOrNamespaceFromLookupItem(const LookupItem &lookupItem,
Class *classFromLookupItem(const LookupItem &lookupItem, const LookupContext &context) Class *classFromLookupItem(const LookupItem &lookupItem, const LookupContext &context)
{ {
ClassOrNamespace *b = classOrNamespaceFromLookupItem(lookupItem, context); LookupScope *b = lookupScopeFromLookupItem(lookupItem, context);
if (!b) if (!b)
return 0; return 0;
@@ -789,7 +789,7 @@ Class *classFromLookupItem(const LookupItem &lookupItem, const LookupContext &co
const Name *minimalName(Symbol *symbol, Scope *targetScope, const LookupContext &context) const Name *minimalName(Symbol *symbol, Scope *targetScope, const LookupContext &context)
{ {
ClassOrNamespace *target = context.lookupType(targetScope); LookupScope *target = context.lookupType(targetScope);
if (!target) if (!target)
target = context.globalNamespace(); target = context.globalNamespace();
return context.minimalName(symbol, target, context.bindings()->control().data()); return context.minimalName(symbol, target, context.bindings()->control().data());
@@ -1211,12 +1211,12 @@ bool InternalCppCompletionAssistProcessor::tryObjCCompletion()
ty = ty->asPointerType()->elementType().simplified(); ty = ty->asPointerType()->elementType().simplified();
if (NamedType *namedTy = ty->asNamedType()) { if (NamedType *namedTy = ty->asNamedType()) {
ClassOrNamespace *binding = lookupContext.lookupType(namedTy->name(), item.scope()); LookupScope *binding = lookupContext.lookupType(namedTy->name(), item.scope());
completeObjCMsgSend(binding, false); completeObjCMsgSend(binding, false);
} }
} else { } else {
if (ObjCClass *clazz = ty->asObjCClassType()) { if (ObjCClass *clazz = ty->asObjCClassType()) {
ClassOrNamespace *binding = lookupContext.lookupType(clazz->name(), item.scope()); LookupScope *binding = lookupContext.lookupType(clazz->name(), item.scope());
completeObjCMsgSend(binding, true); completeObjCMsgSend(binding, true);
} }
} }
@@ -1265,7 +1265,7 @@ void InternalCppCompletionAssistProcessor::addCompletionItem(Symbol *symbol, int
} }
} }
void InternalCppCompletionAssistProcessor::completeObjCMsgSend(ClassOrNamespace *binding, void InternalCppCompletionAssistProcessor::completeObjCMsgSend(LookupScope *binding,
bool staticClassAccess) bool staticClassAccess)
{ {
QList<Scope*> memberScopes; QList<Scope*> memberScopes;
@@ -1534,26 +1534,26 @@ bool InternalCppCompletionAssistProcessor::globalCompletion(Scope *currentScope)
return !m_completions.isEmpty(); return !m_completions.isEmpty();
} }
QList<ClassOrNamespace *> usingBindings; QList<LookupScope *> usingBindings;
ClassOrNamespace *currentBinding = 0; LookupScope *currentBinding = 0;
for (Scope *scope = currentScope; scope; scope = scope->enclosingScope()) { for (Scope *scope = currentScope; scope; scope = scope->enclosingScope()) {
if (Block *block = scope->asBlock()) { if (Block *block = scope->asBlock()) {
if (ClassOrNamespace *binding = context.lookupType(scope)) { if (LookupScope *binding = context.lookupType(scope)) {
for (unsigned i = 0; i < scope->memberCount(); ++i) { for (unsigned i = 0; i < scope->memberCount(); ++i) {
Symbol *member = scope->memberAt(i); Symbol *member = scope->memberAt(i);
if (member->isEnum()) { if (member->isEnum()) {
if (ClassOrNamespace *b = binding->findBlock(block)) if (LookupScope *b = binding->findBlock(block))
completeNamespace(b); completeNamespace(b);
} }
if (!member->name()) if (!member->name())
continue; continue;
if (UsingNamespaceDirective *u = member->asUsingNamespaceDirective()) { if (UsingNamespaceDirective *u = member->asUsingNamespaceDirective()) {
if (ClassOrNamespace *b = binding->lookupType(u->name())) if (LookupScope *b = binding->lookupType(u->name()))
usingBindings.append(b); usingBindings.append(b);
} else if (Class *c = member->asClass()) { } else if (Class *c = member->asClass()) {
if (c->name()->isAnonymousNameId()) { if (c->name()->isAnonymousNameId()) {
if (ClassOrNamespace *b = binding->findBlock(block)) if (LookupScope *b = binding->findBlock(block))
completeClass(b); completeClass(b);
} }
} }
@@ -1580,7 +1580,7 @@ bool InternalCppCompletionAssistProcessor::globalCompletion(Scope *currentScope)
} }
for (; currentBinding; currentBinding = currentBinding->parent()) { for (; currentBinding; currentBinding = currentBinding->parent()) {
foreach (ClassOrNamespace* u, currentBinding->usings()) foreach (LookupScope* u, currentBinding->usings())
usingBindings.append(u); usingBindings.append(u);
const QList<Symbol *> symbols = currentBinding->symbols(); const QList<Symbol *> symbols = currentBinding->symbols();
@@ -1593,7 +1593,7 @@ bool InternalCppCompletionAssistProcessor::globalCompletion(Scope *currentScope)
} }
} }
foreach (ClassOrNamespace *b, usingBindings) foreach (LookupScope *b, usingBindings)
completeNamespace(b); completeNamespace(b);
addKeywords(); addKeywords();
@@ -1616,7 +1616,7 @@ bool InternalCppCompletionAssistProcessor::completeMember(const QList<LookupItem
if (!m_interface->languageFeatures().objCEnabled) if (!m_interface->languageFeatures().objCEnabled)
replaceDotForArrow = &m_model->m_replaceDotForArrow; replaceDotForArrow = &m_model->m_replaceDotForArrow;
if (ClassOrNamespace *binding = if (LookupScope *binding =
resolveExpression.baseExpression(baseResults, resolveExpression.baseExpression(baseResults,
m_model->m_completionOperator, m_model->m_completionOperator,
replaceDotForArrow)) { replaceDotForArrow)) {
@@ -1640,27 +1640,27 @@ bool InternalCppCompletionAssistProcessor::completeScope(const QList<LookupItem>
Scope *scope = result.scope(); Scope *scope = result.scope();
if (NamedType *namedTy = ty->asNamedType()) { if (NamedType *namedTy = ty->asNamedType()) {
if (ClassOrNamespace *b = context.lookupType(namedTy->name(), scope)) { if (LookupScope *b = context.lookupType(namedTy->name(), scope)) {
completeClass(b); completeClass(b);
break; break;
} }
} else if (Class *classTy = ty->asClassType()) { } else if (Class *classTy = ty->asClassType()) {
if (ClassOrNamespace *b = context.lookupType(classTy)) { if (LookupScope *b = context.lookupType(classTy)) {
completeClass(b); completeClass(b);
break; break;
} }
// it can be class defined inside a block // it can be class defined inside a block
if (classTy->enclosingScope()->isBlock()) { if (classTy->enclosingScope()->isBlock()) {
if (ClassOrNamespace *b = context.lookupType(classTy->name(), classTy->enclosingScope())) { if (LookupScope *b = context.lookupType(classTy->name(), classTy->enclosingScope())) {
completeClass(b); completeClass(b);
break; break;
} }
} }
} else if (Namespace *nsTy = ty->asNamespaceType()) { } else if (Namespace *nsTy = ty->asNamespaceType()) {
if (ClassOrNamespace *b = context.lookupType(nsTy)) { if (LookupScope *b = context.lookupType(nsTy)) {
completeNamespace(b); completeNamespace(b);
break; break;
} }
@@ -1668,7 +1668,7 @@ bool InternalCppCompletionAssistProcessor::completeScope(const QList<LookupItem>
} else if (Template *templ = ty->asTemplateType()) { } else if (Template *templ = ty->asTemplateType()) {
if (!result.binding()) if (!result.binding())
continue; continue;
if (ClassOrNamespace *b = result.binding()->lookupType(templ->name())) { if (LookupScope *b = result.binding()->lookupType(templ->name())) {
completeClass(b); completeClass(b);
break; break;
} }
@@ -1676,16 +1676,16 @@ bool InternalCppCompletionAssistProcessor::completeScope(const QList<LookupItem>
} else if (Enum *e = ty->asEnumType()) { } else if (Enum *e = ty->asEnumType()) {
// it can be class defined inside a block // it can be class defined inside a block
if (e->enclosingScope()->isBlock()) { if (e->enclosingScope()->isBlock()) {
if (ClassOrNamespace *b = context.lookupType(e)) { if (LookupScope *b = context.lookupType(e)) {
Block *block = e->enclosingScope()->asBlock(); Block *block = e->enclosingScope()->asBlock();
if (ClassOrNamespace *bb = b->findBlock(block)) { if (LookupScope *bb = b->findBlock(block)) {
completeNamespace(bb); completeNamespace(bb);
break; break;
} }
} }
} }
if (ClassOrNamespace *b = context.lookupType(e)) { if (LookupScope *b = context.lookupType(e)) {
completeNamespace(b); completeNamespace(b);
break; break;
} }
@@ -1696,14 +1696,14 @@ bool InternalCppCompletionAssistProcessor::completeScope(const QList<LookupItem>
return !m_completions.isEmpty(); return !m_completions.isEmpty();
} }
void InternalCppCompletionAssistProcessor::completeNamespace(ClassOrNamespace *b) void InternalCppCompletionAssistProcessor::completeNamespace(LookupScope *b)
{ {
QSet<ClassOrNamespace *> bindingsVisited; QSet<LookupScope *> bindingsVisited;
QList<ClassOrNamespace *> bindingsToVisit; QList<LookupScope *> bindingsToVisit;
bindingsToVisit.append(b); bindingsToVisit.append(b);
while (!bindingsToVisit.isEmpty()) { while (!bindingsToVisit.isEmpty()) {
ClassOrNamespace *binding = bindingsToVisit.takeFirst(); LookupScope *binding = bindingsToVisit.takeFirst();
if (!binding || bindingsVisited.contains(binding)) if (!binding || bindingsVisited.contains(binding))
continue; continue;
@@ -1736,14 +1736,14 @@ void InternalCppCompletionAssistProcessor::completeNamespace(ClassOrNamespace *b
} }
} }
void InternalCppCompletionAssistProcessor::completeClass(ClassOrNamespace *b, bool staticLookup) void InternalCppCompletionAssistProcessor::completeClass(LookupScope *b, bool staticLookup)
{ {
QSet<ClassOrNamespace *> bindingsVisited; QSet<LookupScope *> bindingsVisited;
QList<ClassOrNamespace *> bindingsToVisit; QList<LookupScope *> bindingsToVisit;
bindingsToVisit.append(b); bindingsToVisit.append(b);
while (!bindingsToVisit.isEmpty()) { while (!bindingsToVisit.isEmpty()) {
ClassOrNamespace *binding = bindingsToVisit.takeFirst(); LookupScope *binding = bindingsToVisit.takeFirst();
if (!binding || bindingsVisited.contains(binding)) if (!binding || bindingsVisited.contains(binding))
continue; continue;
@@ -1830,16 +1830,16 @@ bool InternalCppCompletionAssistProcessor::completeQtMethod(const QList<LookupIt
QSet<QString> signatures; QSet<QString> signatures;
foreach (const LookupItem &lookupItem, results) { foreach (const LookupItem &lookupItem, results) {
ClassOrNamespace *b = classOrNamespaceFromLookupItem(lookupItem, context); LookupScope *b = lookupScopeFromLookupItem(lookupItem, context);
if (!b) if (!b)
continue; continue;
QList<ClassOrNamespace *>todo; QList<LookupScope *>todo;
QSet<ClassOrNamespace *> processed; QSet<LookupScope *> processed;
QList<Scope *> scopes; QList<Scope *> scopes;
todo.append(b); todo.append(b);
while (!todo.isEmpty()) { while (!todo.isEmpty()) {
ClassOrNamespace *binding = todo.takeLast(); LookupScope *binding = todo.takeLast();
if (!processed.contains(binding)) { if (!processed.contains(binding)) {
processed.insert(binding); processed.insert(binding);
@@ -2048,7 +2048,7 @@ bool InternalCppCompletionAssistProcessor::completeConstructorOrFunction(const Q
Scope *scope = result.scope(); Scope *scope = result.scope();
if (NamedType *namedTy = ty->asNamedType()) { if (NamedType *namedTy = ty->asNamedType()) {
if (ClassOrNamespace *b = context.lookupType(namedTy->name(), scope)) { if (LookupScope *b = context.lookupType(namedTy->name(), scope)) {
foreach (const LookupItem &r, b->lookup(functionCallOp)) { foreach (const LookupItem &r, b->lookup(functionCallOp)) {
Symbol *overload = r.declaration(); Symbol *overload = r.declaration();
FullySpecifiedType overloadTy = overload->type().simplified(); FullySpecifiedType overloadTy = overload->type().simplified();
@@ -2130,7 +2130,7 @@ bool InternalCppCompletionAssistProcessor::completeConstructorOrFunction(const Q
SubstitutionEnvironment env; SubstitutionEnvironment env;
env.setContext(context); env.setContext(context);
env.switchScope(sc); env.switchScope(sc);
ClassOrNamespace *targetCoN = context.lookupType(sc); LookupScope *targetCoN = context.lookupType(sc);
if (!targetCoN) if (!targetCoN)
targetCoN = context.globalNamespace(); targetCoN = context.globalNamespace();
UseMinimalNames q(targetCoN); UseMinimalNames q(targetCoN);

View File

@@ -52,7 +52,7 @@
namespace CPlusPlus { namespace CPlusPlus {
class LookupItem; class LookupItem;
class ClassOrNamespace; class LookupScope;
class Function; class Function;
class LookupContext; class LookupContext;
} // namespace CPlusPlus } // namespace CPlusPlus
@@ -120,7 +120,7 @@ private:
const QString &expression, const QString &expression,
int endOfExpression); int endOfExpression);
void completeObjCMsgSend(CPlusPlus::ClassOrNamespace *binding, bool staticClassAccess); void completeObjCMsgSend(CPlusPlus::LookupScope *binding, bool staticClassAccess);
bool completeInclude(const QTextCursor &cursor); bool completeInclude(const QTextCursor &cursor);
void completeInclude(const QString &realPath, const QStringList &suffixes); void completeInclude(const QString &realPath, const QStringList &suffixes);
void completePreprocessor(); void completePreprocessor();
@@ -129,8 +129,8 @@ private:
bool toolTipOnly); bool toolTipOnly);
bool completeMember(const QList<CPlusPlus::LookupItem> &results); bool completeMember(const QList<CPlusPlus::LookupItem> &results);
bool completeScope(const QList<CPlusPlus::LookupItem> &results); bool completeScope(const QList<CPlusPlus::LookupItem> &results);
void completeNamespace(CPlusPlus::ClassOrNamespace *binding); void completeNamespace(CPlusPlus::LookupScope *binding);
void completeClass(CPlusPlus::ClassOrNamespace *b, bool staticLookup = true); void completeClass(CPlusPlus::LookupScope *b, bool staticLookup = true);
void addClassMembersToCompletion(CPlusPlus::Scope *scope, bool staticLookup); void addClassMembersToCompletion(CPlusPlus::Scope *scope, bool staticLookup);
enum CompleteQtMethodMode { enum CompleteQtMethodMode {
CompleteQt4Signals, CompleteQt4Signals,

View File

@@ -104,7 +104,7 @@ bool isOwnershipRAIIType(Symbol *symbol, const LookupContext &context)
Declaration *declaration = symbol->asDeclaration(); Declaration *declaration = symbol->asDeclaration();
const NamedType *namedType = declaration->type()->asNamedType(); const NamedType *namedType = declaration->type()->asNamedType();
if (namedType) { if (namedType) {
ClassOrNamespace *clazz = context.lookupType(namedType->name(), LookupScope *clazz = context.lookupType(namedType->name(),
declaration->enclosingScope()); declaration->enclosingScope());
if (clazz && !clazz->symbols().isEmpty()) { if (clazz && !clazz->symbols().isEmpty()) {
Overview overview; Overview overview;

View File

@@ -149,7 +149,7 @@ Function *SymbolFinder::findMatchingDefinition(Symbol *declaration,
QList<Function *> viableFunctions; QList<Function *> viableFunctions;
ClassOrNamespace *enclosingType = context.lookupType(declaration); LookupScope *enclosingType = context.lookupType(declaration);
if (!enclosingType) if (!enclosingType)
continue; // nothing to do continue; // nothing to do
@@ -232,7 +232,7 @@ Class *SymbolFinder::findMatchingClassDeclaration(Symbol *declaration, const Sna
LookupContext context(doc, snapshot); LookupContext context(doc, snapshot);
ClassOrNamespace *type = context.lookupType(declaration); LookupScope *type = context.lookupType(declaration);
if (!type) if (!type)
continue; continue;
@@ -281,7 +281,7 @@ void SymbolFinder::findMatchingDeclaration(const LookupContext &context,
if (!functionName) if (!functionName)
return; return;
ClassOrNamespace *binding = 0; LookupScope *binding = 0;
const QualifiedNameId *qName = functionName->asQualifiedNameId(); const QualifiedNameId *qName = functionName->asQualifiedNameId();
if (qName) { if (qName) {
if (qName->base()) if (qName->base())

View File

@@ -65,12 +65,12 @@ class MkVisitor: protected SymbolVisitor
{ {
const LookupContext &context; const LookupContext &context;
Overview oo; Overview oo;
QList<ClassOrNamespace *> interfaces; QList<LookupScope *> interfaces;
QList<ClassOrNamespace *> nodes; QList<LookupScope *> nodes;
bool isMiscNode(ClassOrNamespace *b) const bool isMiscNode(LookupScope *b) const
{ {
foreach (ClassOrNamespace *u, b->usings()) { foreach (LookupScope *u, b->usings()) {
if (oo(u->symbols().first()->name()) == QLatin1String("AST")) if (oo(u->symbols().first()->name()) == QLatin1String("AST"))
return true; return true;
} }
@@ -78,7 +78,7 @@ class MkVisitor: protected SymbolVisitor
return false; return false;
} }
QString getAcceptFunctionName(ClassOrNamespace *b, QString *retType) const QString getAcceptFunctionName(LookupScope *b, QString *retType) const
{ {
Q_ASSERT(b != 0); Q_ASSERT(b != 0);
@@ -131,7 +131,7 @@ public:
<< " Semantic(TranslationUnit *unit): ASTVisitor(unit) { translationUnit(unit->ast()->asTranslationUnit()); }" << std::endl << " Semantic(TranslationUnit *unit): ASTVisitor(unit) { translationUnit(unit->ast()->asTranslationUnit()); }" << std::endl
<< std::endl; << std::endl;
foreach (ClassOrNamespace *b, interfaces) { foreach (LookupScope *b, interfaces) {
Q_ASSERT(! b->symbols().isEmpty()); Q_ASSERT(! b->symbols().isEmpty());
Class *klass = 0; Class *klass = 0;
@@ -162,10 +162,10 @@ public:
std::cout << " using ASTVisitor::translationUnit;" << std::endl std::cout << " using ASTVisitor::translationUnit;" << std::endl
<< std::endl; << std::endl;
QHash<ClassOrNamespace *, QList<ClassOrNamespace *> > implements; QHash<LookupScope *, QList<LookupScope *> > implements;
foreach (ClassOrNamespace *b, nodes) { foreach (LookupScope *b, nodes) {
ClassOrNamespace *iface = 0; LookupScope *iface = 0;
foreach (ClassOrNamespace *u, b->usings()) { foreach (LookupScope *u, b->usings()) {
if (interfaces.contains(u)) { if (interfaces.contains(u)) {
iface = u; iface = u;
break; break;
@@ -175,8 +175,8 @@ public:
implements[iface].append(b); implements[iface].append(b);
} }
foreach (ClassOrNamespace *iface, interfaces) { foreach (LookupScope *iface, interfaces) {
foreach (ClassOrNamespace *b, implements.value(iface)) { foreach (LookupScope *b, implements.value(iface)) {
if (! isMiscNode(b)) if (! isMiscNode(b))
continue; continue;
@@ -195,9 +195,9 @@ public:
std::cout << std::endl; std::cout << std::endl;
foreach (ClassOrNamespace *iface, interfaces) { foreach (LookupScope *iface, interfaces) {
std::cout << " // " << qPrintable(oo(iface->symbols().first()->name())) << std::endl; std::cout << " // " << qPrintable(oo(iface->symbols().first()->name())) << std::endl;
foreach (ClassOrNamespace *b, implements.value(iface)) { foreach (LookupScope *b, implements.value(iface)) {
Class *klass = 0; Class *klass = 0;
foreach (Symbol *s, b->symbols()) foreach (Symbol *s, b->symbols())
if ((klass = s->asClass()) != 0) if ((klass = s->asClass()) != 0)
@@ -212,7 +212,7 @@ public:
} }
std::cout << "private:" << std::endl; std::cout << "private:" << std::endl;
foreach (ClassOrNamespace *b, interfaces) { foreach (LookupScope *b, interfaces) {
Q_ASSERT(! b->symbols().isEmpty()); Q_ASSERT(! b->symbols().isEmpty());
Class *klass = 0; Class *klass = 0;
@@ -245,7 +245,7 @@ public:
// implementation // implementation
foreach (ClassOrNamespace *b, interfaces) { foreach (LookupScope *b, interfaces) {
Q_ASSERT(! b->symbols().isEmpty()); Q_ASSERT(! b->symbols().isEmpty());
Class *klass = 0; Class *klass = 0;
@@ -280,9 +280,9 @@ public:
<< std::endl; << std::endl;
} }
foreach (ClassOrNamespace *iface, interfaces) { foreach (LookupScope *iface, interfaces) {
std::cout << "// " << qPrintable(oo(iface->symbols().first()->name())) << std::endl; std::cout << "// " << qPrintable(oo(iface->symbols().first()->name())) << std::endl;
foreach (ClassOrNamespace *b, implements.value(iface)) { foreach (LookupScope *b, implements.value(iface)) {
Class *klass = 0; Class *klass = 0;
foreach (Symbol *s, b->symbols()) foreach (Symbol *s, b->symbols())
if ((klass = s->asClass()) != 0) if ((klass = s->asClass()) != 0)
@@ -331,7 +331,7 @@ public:
Control *control = context.thisDocument()->control(); Control *control = context.thisDocument()->control();
const Name *n = control->identifier(name.toLatin1().constData()); const Name *n = control->identifier(name.toLatin1().constData());
if (ClassOrNamespace *bb = context.lookupType(n, klass)) { if (LookupScope *bb = context.lookupType(n, klass)) {
QString retTy; QString retTy;
QString funcName = getAcceptFunctionName(bb, &retTy); QString funcName = getAcceptFunctionName(bb, &retTy);
Q_ASSERT(! funcName.isEmpty()); Q_ASSERT(! funcName.isEmpty());
@@ -350,7 +350,7 @@ public:
continue; continue;
} }
if (ClassOrNamespace *ty = context.lookupType(namedTy->name(), klass)) { if (LookupScope *ty = context.lookupType(namedTy->name(), klass)) {
QString className = oo(ty->symbols().first()->name()); QString className = oo(ty->symbols().first()->name());
QString baseClassName = className; QString baseClassName = className;
if (baseClassName.endsWith(QLatin1String("AST"))) { if (baseClassName.endsWith(QLatin1String("AST"))) {
@@ -386,9 +386,9 @@ public:
protected: protected:
using SymbolVisitor::visit; using SymbolVisitor::visit;
QList<ClassOrNamespace *> baseClasses(ClassOrNamespace *b) { QList<LookupScope *> baseClasses(LookupScope *b) {
QList<ClassOrNamespace *> usings = b->usings(); QList<LookupScope *> usings = b->usings();
foreach (ClassOrNamespace *u, usings) foreach (LookupScope *u, usings)
usings += baseClasses(u); usings += baseClasses(u);
return usings; return usings;
} }
@@ -398,14 +398,14 @@ protected:
if (! className.endsWith(QLatin1String("AST"))) if (! className.endsWith(QLatin1String("AST")))
return false; return false;
ClassOrNamespace *b = context.lookupType(klass); LookupScope *b = context.lookupType(klass);
Q_ASSERT(b != 0); Q_ASSERT(b != 0);
const Identifier *accept0 = context.thisDocument()->control()->identifier("accept0"); const Identifier *accept0 = context.thisDocument()->control()->identifier("accept0");
if (Symbol *s = klass->find(accept0)) { if (Symbol *s = klass->find(accept0)) {
if (Function *meth = s->type()->asFunctionType()) { if (Function *meth = s->type()->asFunctionType()) {
if (! meth->isPureVirtual()) { if (! meth->isPureVirtual()) {
foreach (ClassOrNamespace *u, b->usings()) { foreach (LookupScope *u, b->usings()) {
if (interfaces.contains(u)) { if (interfaces.contains(u)) {
// qDebug() << oo(klass->name()) << "implements" << oo(u->symbols().first()->name()); // qDebug() << oo(klass->name()) << "implements" << oo(u->symbols().first()->name());
} else { } else {

View File

@@ -133,7 +133,7 @@ void tst_Lookup::base_class_defined_1()
const LookupContext ctx(doc, snapshot); const LookupContext ctx(doc, snapshot);
ClassOrNamespace *klass = ctx.lookupType(derivedClass->baseClassAt(0)->name(), derivedClass->enclosingScope()); LookupScope *klass = ctx.lookupType(derivedClass->baseClassAt(0)->name(), derivedClass->enclosingScope());
QVERIFY(klass != 0); QVERIFY(klass != 0);
QCOMPARE(klass->symbols().size(), 1); QCOMPARE(klass->symbols().size(), 1);
@@ -272,7 +272,7 @@ void tst_Lookup::simple_class_1()
const LookupContext context(doc, snapshot); const LookupContext context(doc, snapshot);
// check class resolving: // check class resolving:
ClassOrNamespace *klass = context.lookupType(impl->name(), impl->enclosingScope()); LookupScope *klass = context.lookupType(impl->name(), impl->enclosingScope());
QVERIFY(klass != 0); QVERIFY(klass != 0);
QCOMPARE(klass->symbols().size(), 2); QCOMPARE(klass->symbols().size(), 2);
QVERIFY(klass->symbols().contains(iface)); QVERIFY(klass->symbols().contains(iface));
@@ -336,7 +336,7 @@ void tst_Lookup::class_with_baseclass()
const LookupContext context(doc, snapshot); const LookupContext context(doc, snapshot);
ClassOrNamespace *objClass = context.lookupType(baseZoo->name(), zooImpl->enclosingScope()); LookupScope *objClass = context.lookupType(baseZoo->name(), zooImpl->enclosingScope());
QVERIFY(objClass != 0); QVERIFY(objClass != 0);
QVERIFY(objClass->symbols().contains(baseZoo)); QVERIFY(objClass->symbols().contains(baseZoo));