CppEditor: modernize-loop-convert

Change-Id: I80382880a3c35ef0b59729bd222a626bc5c4a32b
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
Nikolai Kosjar
2019-02-07 11:56:47 +01:00
parent 612393889a
commit 55f4c28889
2 changed files with 9 additions and 14 deletions

View File

@@ -674,8 +674,7 @@ void CppEditorWidget::switchDeclarationDefinition(bool inNextSplit)
ASTPath astPathFinder(d->m_lastSemanticInfo.doc); ASTPath astPathFinder(d->m_lastSemanticInfo.doc);
const QList<AST *> astPath = astPathFinder(textCursor()); const QList<AST *> astPath = astPathFinder(textCursor());
for (int i = 0, size = astPath.size(); i < size; ++i) { for (AST *ast : astPath) {
AST *ast = astPath.at(i);
if (FunctionDefinitionAST *functionDefinitionAST = ast->asFunctionDefinition()) { if (FunctionDefinitionAST *functionDefinitionAST = ast->asFunctionDefinition()) {
if ((functionDefinitionSymbol = functionDefinitionAST->symbol)) if ((functionDefinitionSymbol = functionDefinitionAST->symbol))
break; // Function definition found! break; // Function definition found!

View File

@@ -3920,8 +3920,7 @@ public:
ASTPath astPath(result.file->cppDocument()); ASTPath astPath(result.file->cppDocument());
const QList<AST *> path = astPath(s->line(), s->column()); const QList<AST *> path = astPath(s->line(), s->column());
SimpleDeclarationAST *simpleDecl = nullptr; SimpleDeclarationAST *simpleDecl = nullptr;
for (int idx = 0; idx < path.size(); ++idx) { for (AST *node : path) {
AST *node = path.at(idx);
simpleDecl = node->asSimpleDeclaration(); simpleDecl = node->asSimpleDeclaration();
if (simpleDecl) { if (simpleDecl) {
if (simpleDecl->symbols && !simpleDecl->symbols->next) { if (simpleDecl->symbols && !simpleDecl->symbols->next) {
@@ -3945,13 +3944,12 @@ public:
return FoundDeclaration(); return FoundDeclaration();
const LookupContext lc(result.file->cppDocument(), snapshot()); const LookupContext lc(result.file->cppDocument(), snapshot());
const QList<LookupItem> candidates = lc.lookup(func->name(), matchingNamespace); const QList<LookupItem> candidates = lc.lookup(func->name(), matchingNamespace);
for (int i = 0; i < candidates.size(); ++i) { for (const LookupItem &candidate : candidates) {
if (Symbol *s = candidates.at(i).declaration()) { if (Symbol *s = candidate.declaration()) {
if (s->asDeclaration()) { if (s->asDeclaration()) {
ASTPath astPath(result.file->cppDocument()); ASTPath astPath(result.file->cppDocument());
const QList<AST *> path = astPath(s->line(), s->column()); const QList<AST *> path = astPath(s->line(), s->column());
for (int idx = 0; idx < path.size(); ++idx) { for (AST *node : path) {
AST *node = path.at(idx);
SimpleDeclarationAST *simpleDecl = node->asSimpleDeclaration(); SimpleDeclarationAST *simpleDecl = node->asSimpleDeclaration();
if (simpleDecl) { if (simpleDecl) {
result.ast = functionDeclarator(simpleDecl); result.ast = functionDeclarator(simpleDecl);
@@ -5154,13 +5152,12 @@ void MoveFuncDefToDecl::match(const CppQuickFixInterface &interface, QuickFixOpe
const CppRefactoringFilePtr declFile = refactoring.file(declFileName); const CppRefactoringFilePtr declFile = refactoring.file(declFileName);
const LookupContext lc(declFile->cppDocument(), interface.snapshot()); const LookupContext lc(declFile->cppDocument(), interface.snapshot());
const QList<LookupItem> candidates = lc.lookup(func->name(), matchingNamespace); const QList<LookupItem> candidates = lc.lookup(func->name(), matchingNamespace);
for (int i = 0; i < candidates.size(); ++i) { for (const LookupItem &candidate : candidates) {
if (Symbol *s = candidates.at(i).declaration()) { if (Symbol *s = candidate.declaration()) {
if (s->asDeclaration()) { if (s->asDeclaration()) {
ASTPath astPath(declFile->cppDocument()); ASTPath astPath(declFile->cppDocument());
const QList<AST *> path = astPath(s->line(), s->column()); const QList<AST *> path = astPath(s->line(), s->column());
for (int idx = 0; idx < path.size(); ++idx) { for (AST *node : path) {
AST *node = path.at(idx);
if (SimpleDeclarationAST *simpleDecl = node->asSimpleDeclaration()) { if (SimpleDeclarationAST *simpleDecl = node->asSimpleDeclaration()) {
declRange = declFile->range(simpleDecl); declRange = declFile->range(simpleDecl);
declText = declFile->textOf(simpleDecl); declText = declFile->textOf(simpleDecl);
@@ -5604,8 +5601,7 @@ private:
static QByteArray escapeString(const QByteArray &contents) static QByteArray escapeString(const QByteArray &contents)
{ {
QByteArray newContents; QByteArray newContents;
for (int i = 0; i < contents.length(); ++i) { for (const quint8 c : contents) {
quint8 c = contents.at(i);
if (isascii(c) && isprint(c)) { if (isascii(c) && isprint(c)) {
newContents += c; newContents += c;
} else { } else {