diff options
author | Orgad Shaneh <orgad.shaneh@audiocodes.com> | 2013-07-17 00:01:45 +0300 |
---|---|---|
committer | Orgad Shaneh <orgads@gmail.com> | 2013-07-17 11:11:25 +0200 |
commit | ad9e7ccab6e8476c0cb478ea2e4f13354dc21635 (patch) | |
tree | 9c67e7cfec7e7d0603e9279de9227cdef1cac530 /src/plugins/cppeditor | |
parent | c67f7f63497b321f42ee0081f29b7e3804023a10 (diff) | |
download | qt-creator-ad9e7ccab6e8476c0cb478ea2e4f13354dc21635.tar.gz |
Fix coding style for else statements
Change-Id: I1309db70e98d678e150388c76ce665e988fdf081
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Diffstat (limited to 'src/plugins/cppeditor')
-rw-r--r-- | src/plugins/cppeditor/cppeditor.cpp | 24 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppeditorplugin.cpp | 3 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppfunctiondecldeflink.cpp | 15 | ||||
-rw-r--r-- | src/plugins/cppeditor/cpphighlighter.cpp | 21 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppquickfixes.cpp | 10 |
5 files changed, 28 insertions, 45 deletions
diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index b8626fc4e1..c20217930c 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -303,7 +303,7 @@ struct CanonicalSymbol if (classId && classId->isEqualTo(declId)) continue; // skip it, it's a ctor or a dtor. - else if (Function *funTy = r.declaration()->type()->asFunctionType()) { + if (Function *funTy = r.declaration()->type()->asFunctionType()) { if (funTy->isVirtual()) return r.declaration(); } @@ -1481,10 +1481,9 @@ CPPEditorWidget::Link CPPEditorWidget::findLinkAt(const QTextCursor &cursor, boo int depth = 0; for (; j < tokens.size(); ++j) { - if (tokens.at(j).is(T_LPAREN)) + if (tokens.at(j).is(T_LPAREN)) { ++depth; - - else if (tokens.at(j).is(T_RPAREN)) { + } else if (tokens.at(j).is(T_RPAREN)) { if (! --depth) break; } @@ -1576,15 +1575,13 @@ CPPEditorWidget::Link CPPEditorWidget::findLinkAt(const QTextCursor &cursor, boo const QChar ch = document()->characterAt(pos); if (ch.isSpace()) continue; - else { - if (ch == QLatin1Char('(') && ! expression.isEmpty()) { - tc.setPosition(pos); - if (TextEditor::TextBlockUserData::findNextClosingParenthesis(&tc, true)) - expression.append(tc.selectedText()); - } - - break; + if (ch == QLatin1Char('(') && ! expression.isEmpty()) { + tc.setPosition(pos); + if (TextEditor::TextBlockUserData::findNextClosingParenthesis(&tc, true)) + expression.append(tc.selectedText()); } + + break; } TypeOfExpression typeOfExpression; @@ -2070,9 +2067,8 @@ void CPPEditorWidget::updateSemanticInfo(const SemanticInfo &semanticInfo) if (! m_renameSelections.isEmpty()) setExtraSelections(CodeSemanticsSelection, m_renameSelections); // ### - else { + else markSymbols(textCursor(), semanticInfo); - } m_lastSemanticInfo.forced = false; // clear the forced flag diff --git a/src/plugins/cppeditor/cppeditorplugin.cpp b/src/plugins/cppeditor/cppeditorplugin.cpp index 24c046e17b..56ddd686f8 100644 --- a/src/plugins/cppeditor/cppeditorplugin.cpp +++ b/src/plugins/cppeditor/cppeditorplugin.cpp @@ -376,9 +376,8 @@ void CppEditorPlugin::currentEditorChanged(Core::IEditor *editor) if (! editor) return; - else if (CPPEditorWidget *textEditor = qobject_cast<CPPEditorWidget *>(editor->widget())) { + if (CPPEditorWidget *textEditor = qobject_cast<CPPEditorWidget *>(editor->widget())) textEditor->semanticRehighlight(/*force = */ true); - } } void CppEditorPlugin::openTypeHierarchy() diff --git a/src/plugins/cppeditor/cppfunctiondecldeflink.cpp b/src/plugins/cppeditor/cppfunctiondecldeflink.cpp index 2135ee25ad..35fa5ee86a 100644 --- a/src/plugins/cppeditor/cppfunctiondecldeflink.cpp +++ b/src/plugins/cppeditor/cppfunctiondecldeflink.cpp @@ -778,9 +778,8 @@ Utils::ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targ FullySpecifiedType type = rewriteType(newParam->type(), &env, control); newTargetParam = overview.prettyType(type, newParam->name()); hadChanges = true; - } // otherwise preserve as much as possible from the existing parameter - else { + } else { Symbol *targetParam = targetFunction->argumentAt(existingParamIndex); Symbol *sourceParam = sourceFunction->argumentAt(existingParamIndex); ParameterDeclarationAST *targetParamAst = targetParameterDecls.at(existingParamIndex); @@ -833,9 +832,8 @@ Utils::ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targ newTargetParam += overview.prettyType(replacementType, replacementName); newTargetParam += targetFile->textOf(parameterTypeEnd, parameterEnd); hadChanges = true; - } // change the name only? - else if (!namesEqual(targetParam->name(), replacementName)) { + } else if (!namesEqual(targetParam->name(), replacementName)) { DeclaratorIdAST *id = getDeclaratorId(targetParamAst->declarator); const QString &replacementNameStr = overview.prettyName(replacementName); if (id) { @@ -878,9 +876,8 @@ Utils::ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targ newTargetParam += rest; } hadChanges = true; - } // change nothing - though the parameter might still have moved - else { + } else { if (existingParamIndex != newParamIndex) hadChanges = true; newTargetParam = targetFile->textOf(parameterStart, parameterEnd); @@ -934,9 +931,8 @@ Utils::ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targ if (!targetFunction->isConst() && !targetFunction->isVolatile()) { cvString.prepend(QLatin1Char(' ')); changes.insert(targetFile->endOf(targetFunctionDeclarator->rparen_token), cvString); - } // modify/remove existing specifiers - else { + } else { SimpleSpecifierAST *constSpecifier = 0; SimpleSpecifierAST *volatileSpecifier = 0; for (SpecifierListAST *it = targetFunctionDeclarator->cv_qualifier_list; it; it = it->next) { @@ -954,9 +950,8 @@ Utils::ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targ changes.remove(targetFile->endOf(constSpecifier->specifier_token - 1), targetFile->endOf(constSpecifier)); if (!newFunction->isVolatile()) changes.remove(targetFile->endOf(volatileSpecifier->specifier_token - 1), targetFile->endOf(volatileSpecifier)); - } // otherwise adjust, remove or extend the one existing specifier - else { + } else { SimpleSpecifierAST *specifier = constSpecifier ? constSpecifier : volatileSpecifier; QTC_ASSERT(specifier, return changes); diff --git a/src/plugins/cppeditor/cpphighlighter.cpp b/src/plugins/cppeditor/cpphighlighter.cpp index 5b02d92502..762f11ce19 100644 --- a/src/plugins/cppeditor/cpphighlighter.cpp +++ b/src/plugins/cppeditor/cpphighlighter.cpp @@ -160,13 +160,11 @@ void CppHighlighter::highlightBlock(const QString &text) onlyHighlightComments = true; } - } else if (tk.is(T_NUMERIC_LITERAL)) + } else if (tk.is(T_NUMERIC_LITERAL)) { setFormat(tk.begin(), tk.length(), m_formats[CppNumberFormat]); - - else if (tk.isStringLiteral() || tk.isCharLiteral()) + } else if (tk.isStringLiteral() || tk.isCharLiteral()) { highlightLine(text, tk.begin(), tk.length(), m_formats[CppStringFormat]); - - else if (tk.isComment()) { + } else if (tk.isComment()) { const int startPosition = initialState ? previousTokenEnd : tk.begin(); if (tk.is(T_COMMENT) || tk.is(T_CPP_COMMENT)) highlightLine(text, startPosition, tk.end() - startPosition, m_formats[CppCommentFormat]); @@ -192,18 +190,15 @@ void CppHighlighter::highlightBlock(const QString &text) initialState = 0; } - } else if (tk.isKeyword() || CppTools::isQtKeyword(text.midRef(tk.begin(), tk.length())) || tk.isObjCAtKeyword()) + } else if (tk.isKeyword() || CppTools::isQtKeyword(text.midRef(tk.begin(), tk.length())) || tk.isObjCAtKeyword()) { setFormat(tk.begin(), tk.length(), m_formats[CppKeywordFormat]); - - else if (tk.isOperator()) + } else if (tk.isOperator()) { setFormat(tk.begin(), tk.length(), m_formats[CppOperatorFormat]); - - else if (i == 0 && tokens.size() > 1 && tk.is(T_IDENTIFIER) && tokens.at(1).is(T_COLON)) + } else if (i == 0 && tokens.size() > 1 && tk.is(T_IDENTIFIER) && tokens.at(1).is(T_COLON)) { setFormat(tk.begin(), tk.length(), m_formats[CppLabelFormat]); - - else if (tk.is(T_IDENTIFIER)) + } else if (tk.is(T_IDENTIFIER)) { highlightWord(text.midRef(tk.begin(), tk.length()), tk.begin(), tk.length()); - + } } // mark the trailing white spaces diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index 5eb4a4152a..fdc931e50a 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -624,10 +624,9 @@ void SplitSimpleDeclaration::match(const CppQuickFixInterface &interface, for (int index = path.size() - 1; index != -1; --index) { AST *node = path.at(index); - if (CoreDeclaratorAST *coreDecl = node->asCoreDeclarator()) + if (CoreDeclaratorAST *coreDecl = node->asCoreDeclarator()) { core_declarator = coreDecl; - - else if (SimpleDeclarationAST *simpleDecl = node->asSimpleDeclaration()) { + } else if (SimpleDeclarationAST *simpleDecl = node->asSimpleDeclaration()) { if (checkDeclaration(simpleDecl)) { SimpleDeclarationAST *declaration = simpleDecl; @@ -1702,7 +1701,7 @@ void AddLocalDeclaration::match(const CppQuickFixInterface &interface, QuickFixO foreach (const LookupItem &r, results) { if (! r.declaration()) continue; - else if (Declaration *d = r.declaration()->asDeclaration()) { + if (Declaration *d = r.declaration()->asDeclaration()) { if (! d->type()->isFunctionType()) { decl = d; break; @@ -4078,8 +4077,7 @@ void MoveFuncDefToDecl::match(const CppQuickFixInterface &interface, QuickFixOpe if (!declText.isEmpty()) break; } - } - else if (Namespace *matchingNamespace = isNamespaceFunction(interface->context(), func)) { + } else if (Namespace *matchingNamespace = isNamespaceFunction(interface->context(), func)) { // Dealing with free functions bool isHeaderFile = false; declFileName = correspondingHeaderOrSource(interface->fileName(), &isHeaderFile); |