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