Commit 845cb2e4 authored by Nikolai Kosjar's avatar Nikolai Kosjar

C++: Better names for Scope's iterators

Scope::lastMember() was misleading.

Change-Id: I953d489b8a2a9b86321f73cad3b7b371c4acf91f
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarPrzemyslaw Gorszkowski <pgorszkowski@gmail.com>
parent d9c70f43
......@@ -530,7 +530,7 @@ void Bind::enumerator(EnumeratorAST *ast, Enum *symbol)
if (ExpressionAST *expr = ast->expression)
e->setConstantValue(asStringLiteral(expr->firstToken(), expr->lastToken()));
else if (!symbol->isEmpty())
calculateConstantValue(*(symbol->lastMember()-1), e, control());
calculateConstantValue(*(symbol->memberEnd()-1), e, control());
else
e->setConstantValue(control()->stringLiteral("0", 1));
......
......@@ -238,7 +238,7 @@ Scope::Scope(Clone *clone, Subst *subst, Scope *original)
, _startOffset(original->_startOffset)
, _endOffset(original->_endOffset)
{
for (iterator it = original->firstMember(), end = original->lastMember(); it != end; ++it)
for (iterator it = original->memberBegin(), end = original->memberEnd(); it != end; ++it)
addMember(clone->symbol(*it, subst));
}
......@@ -267,11 +267,11 @@ Symbol *Scope::memberAt(unsigned index) const
{ return _members ? _members->symbolAt(index) : 0; }
/// Returns the first Symbol in the scope.
Scope::iterator Scope::firstMember() const
Scope::iterator Scope::memberBegin() const
{ return _members ? _members->firstSymbol() : 0; }
/// Returns the last Symbol in the scope.
Scope::iterator Scope::lastMember() const
Scope::iterator Scope::memberEnd() const
{ return _members ? _members->lastSymbol() : 0; }
Symbol *Scope::find(const Identifier *id) const
......
......@@ -48,11 +48,11 @@ public:
typedef Symbol **iterator;
/// Returns the first Symbol in the scope.
iterator firstMember() const;
/// Returns member iterator to the beginning.
iterator memberBegin() const;
/// Returns the last Symbol in the scope.
iterator lastMember() const;
/// Returns member iterator to the end.
iterator memberEnd() const;
Symbol *find(const Identifier *id) const;
Symbol *find(OperatorNameId::Kind operatorId) const;
......
......@@ -384,8 +384,8 @@ void Parser::addSymbol(const ParserTreeItem::Ptr &item, const CPlusPlus::Symbol
// prevent showing a content of the functions
if (!symbol->isFunction()) {
if (const CPlusPlus::Scope *scope = symbol->asScope()) {
CPlusPlus::Scope::iterator cur = scope->firstMember();
CPlusPlus::Scope::iterator last = scope->lastMember();
CPlusPlus::Scope::iterator cur = scope->memberBegin();
CPlusPlus::Scope::iterator last = scope->memberEnd();
while (cur != last) {
const CPlusPlus::Symbol *curSymbol = *cur;
++cur;
......
......@@ -509,7 +509,7 @@ public:
QHash<const Function *, FunctionItem *> virtualFunctions;
foreach (const Class *clazz, baseClasses) {
ClassItem *itemBase = new ClassItem(printer.prettyName(clazz->name()), clazz);
for (Scope::iterator it = clazz->firstMember(); it != clazz->lastMember(); ++it) {
for (Scope::iterator it = clazz->memberBegin(); it != clazz->memberEnd(); ++it) {
if (const Function *func = (*it)->type()->asFunctionType()) {
// Filter virtual destructors
if (func->name()->asDestructorNameId())
......
......@@ -1513,7 +1513,7 @@ void CppCompletionAssistProcessor::completeNamespace(CPlusPlus::ClassOrNamespace
scopesVisited.insert(scope);
for (Scope::iterator it = scope->firstMember(); it != scope->lastMember(); ++it) {
for (Scope::iterator it = scope->memberBegin(); it != scope->memberEnd(); ++it) {
Symbol *member = *it;
addCompletionItem(member);
}
......@@ -1570,7 +1570,7 @@ void CppCompletionAssistProcessor::addClassMembersToCompletion(Scope *scope, boo
std::set<Class *> nestedAnonymouses;
for (Scope::iterator it = scope->firstMember(); it != scope->lastMember(); ++it) {
for (Scope::iterator it = scope->memberBegin(); it != scope->memberEnd(); ++it) {
Symbol *member = *it;
if (member->isFriend()
|| member->isQtPropertyDeclaration()
......
......@@ -141,8 +141,8 @@ static QByteArray idForSymbol(Symbol *symbol)
// add the index of this symbol within its enclosing scope
// (counting symbols without identifier of the same type)
int count = 0;
Scope::iterator it = scope->firstMember();
while (it != scope->lastMember() && *it != symbol) {
Scope::iterator it = scope->memberBegin();
while (it != scope->memberEnd() && *it != symbol) {
Symbol *val = *it;
++it;
if (val->identifier() || typeId(val) != uid)
......
......@@ -353,7 +353,7 @@ void PointerDeclarationFormatter::processIfWhileForStatement(ExpressionAST *expr
//
// The declaration for 's' will be handled in visit(SimpleDeclarationAST *ast),
// so handle declaration for 't' here.
Scope::iterator it = block->lastMember() - 1;
Scope::iterator it = block->memberEnd() - 1;
Symbol *symbol = *it;
if (symbol && symbol->asScope()) { // True if there is a "{ ... }" following.
--it;
......
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