Fix coding style for else statements

Change-Id: I1309db70e98d678e150388c76ce665e988fdf081
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
Orgad Shaneh
2013-07-17 00:01:45 +03:00
committed by Orgad Shaneh
parent c67f7f6349
commit ad9e7ccab6
101 changed files with 331 additions and 470 deletions

View File

@@ -57,10 +57,9 @@ static void parse(QFutureInterface<void> &future,
const QString fileName = files.at(i);
const bool isSourceFile = i < sourceCount;
if (isSourceFile)
if (isSourceFile) {
(void) preproc->run(conf);
else if (! processingHeaders) {
} else if (! processingHeaders) {
(void) preproc->run(conf);
processingHeaders = true;

View File

@@ -96,7 +96,7 @@ protected:
{
if (! doc)
return;
else if (! processed->contains(doc->globalNamespace())) {
if (! processed->contains(doc->globalNamespace())) {
processed->insert(doc->globalNamespace());
foreach (const Document::Include &i, doc->includes())
@@ -738,7 +738,7 @@ bool CheckSymbols::hasVirtualDestructor(Class *klass) const
for (Symbol *s = klass->find(id); s; s = s->next()) {
if (! s->name())
continue;
else if (s->name()->isDestructorNameId()) {
if (s->name()->isDestructorNameId()) {
if (Function *funTy = s->type()->asFunctionType()) {
if (funTy->isVirtual() && id->isEqualTo(s->identifier()))
return true;
@@ -1335,9 +1335,8 @@ NameAST *CheckSymbols::declaratorId(DeclaratorAST *ast) const
if (ast && ast->core_declarator) {
if (NestedDeclaratorAST *nested = ast->core_declarator->asNestedDeclarator())
return declaratorId(nested->declarator);
else if (DeclaratorIdAST *declId = ast->core_declarator->asDeclaratorId()) {
if (DeclaratorIdAST *declId = ast->core_declarator->asDeclaratorId())
return declId->name;
}
}
return 0;

View File

@@ -519,9 +519,9 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
int previousPreviousMarker = -1;
for (int i = size - 1; i >= 0; --i) {
if (m_currentState.at(i).type == cpp_macro_conditional) {
if (previousMarker == -1)
if (previousMarker == -1) {
previousMarker = i;
else {
} else {
previousPreviousMarker = i;
break;
}

View File

@@ -572,7 +572,7 @@ Class *asClassOrTemplateClassType(FullySpecifiedType ty)
{
if (Class *classTy = ty->asClassType())
return classTy;
else if (Template *templ = ty->asTemplateType()) {
if (Template *templ = ty->asTemplateType()) {
if (Symbol *decl = templ->declaration())
return decl->asClass();
}
@@ -595,7 +595,7 @@ Function *asFunctionOrTemplateFunctionType(FullySpecifiedType ty)
{
if (Function *funTy = ty->asFunctionType())
return funTy;
else if (Template *templ = ty->asTemplateType()) {
if (Template *templ = ty->asTemplateType()) {
if (Symbol *decl = templ->declaration())
return decl->asFunction();
}
@@ -799,13 +799,11 @@ int CppCompletionAssistProcessor::startOfOperator(int pos,
&& *kind != T_DOT))) {
*kind = T_EOF_SYMBOL;
start = pos;
}
// Include completion: can be triggered by slash, but only in a string
else if (*kind == T_SLASH && (tk.isNot(T_STRING_LITERAL) && tk.isNot(T_ANGLE_STRING_LITERAL))) {
} else if (*kind == T_SLASH && (tk.isNot(T_STRING_LITERAL) && tk.isNot(T_ANGLE_STRING_LITERAL))) {
*kind = T_EOF_SYMBOL;
start = pos;
}
else if (*kind == T_LPAREN) {
} else if (*kind == T_LPAREN) {
if (tokenIdx > 0) {
const Token &previousToken = tokens.at(tokenIdx - 1); // look at the token at the left of T_LPAREN
switch (previousToken.kind()) {
@@ -943,13 +941,11 @@ int CppCompletionAssistProcessor::startCompletionHelper()
startOfExpression = endOfExpression - expression.length();
if (m_model->m_completionOperator == T_LPAREN) {
if (expression.endsWith(QLatin1String("SIGNAL")))
if (expression.endsWith(QLatin1String("SIGNAL"))) {
m_model->m_completionOperator = T_SIGNAL;
else if (expression.endsWith(QLatin1String("SLOT")))
} else if (expression.endsWith(QLatin1String("SLOT"))) {
m_model->m_completionOperator = T_SLOT;
else if (m_interface->position() != endOfOperator) {
} else if (m_interface->position() != endOfOperator) {
// We don't want a function completion when the cursor isn't at the opening brace
expression.clear();
m_model->m_completionOperator = T_EOF_SYMBOL;
@@ -1225,7 +1221,7 @@ int CppCompletionAssistProcessor::startCompletionInternal(const QString fileName
return m_startPosition;
}
else if (m_model->m_completionOperator == T_SIGNAL || m_model->m_completionOperator == T_SLOT) {
if (m_model->m_completionOperator == T_SIGNAL || m_model->m_completionOperator == T_SLOT) {
// Apply signal/slot completion on 'this'
expression = QLatin1String("this");
}
@@ -1335,7 +1331,7 @@ void CppCompletionAssistProcessor::globalCompletion(CPlusPlus::Scope *currentSco
Symbol *member = scope->memberAt(i);
if (! member->name())
continue;
else if (UsingNamespaceDirective *u = member->asUsingNamespaceDirective()) {
if (UsingNamespaceDirective *u = member->asUsingNamespaceDirective()) {
if (ClassOrNamespace *b = binding->lookupType(u->name()))
usingBindings.append(b);
}

View File

@@ -84,7 +84,7 @@ protected:
if (Symbol *member = scope->memberAt(i)) {
if (member->isTypedef())
continue;
else if (! member->isGenerated() && (member->isDeclaration() || member->isArgument())) {
if (! member->isGenerated() && (member->isDeclaration() || member->isArgument())) {
if (member->name() && member->name()->isNameId()) {
const Identifier *id = member->identifier();
unsigned line, column;
@@ -106,10 +106,10 @@ protected:
const Identifier *id = identifier(simpleName->identifier_token);
for (int i = _scopeStack.size() - 1; i != -1; --i) {
if (Symbol *member = _scopeStack.at(i)->find(id)) {
if (member->isTypedef() ||
!(member->isDeclaration() || member->isArgument()))
if (member->isTypedef() || !(member->isDeclaration() || member->isArgument()))
continue;
else if (!member->isGenerated() && (member->sourceLocation() < firstToken || member->enclosingScope()->isFunction())) {
if (!member->isGenerated() && (member->sourceLocation() < firstToken
|| member->enclosingScope()->isFunction())) {
unsigned line, column;
getTokenStartPosition(simpleName->identifier_token, &line, &column);
localUses[member].append(

View File

@@ -74,11 +74,10 @@ protected:
if (_functionDefinition)
return false;
else if (FunctionDefinitionAST *def = ast->asFunctionDefinition()) {
if (FunctionDefinitionAST *def = ast->asFunctionDefinition())
return checkDeclaration(def);
}
else if (ObjCMethodDeclarationAST *method = ast->asObjCMethodDeclaration()) {
if (ObjCMethodDeclarationAST *method = ast->asObjCMethodDeclaration()) {
if (method->function_body)
return checkDeclaration(method);
}

View File

@@ -277,13 +277,11 @@ QList<IncludeGroup> IncludeGroup::detectIncludeGroupsByNewLines(QList<Document::
if (isFirst) {
isFirst = false;
currentIncludes << include;
}
// Include belongs to current group
else if (lastLine + 1 == include.line()) {
} else if (lastLine + 1 == include.line()) {
currentIncludes << include;
}
// Include is member of new group
else {
} else {
result << IncludeGroup(currentIncludes);
currentIncludes.clear();
currentIncludes << include;
@@ -312,13 +310,11 @@ QList<IncludeGroup> IncludeGroup::detectIncludeGroupsByIncludeDir(const QList<In
if (isFirst) {
isFirst = false;
currentIncludes << include;
}
// Include belongs to current group
else if (lastDir == currentDirPrefix) {
} else if (lastDir == currentDirPrefix) {
currentIncludes << include;
}
// Include is member of new group
else {
} else {
result << IncludeGroup(currentIncludes);
currentIncludes.clear();
currentIncludes << include;
@@ -347,13 +343,11 @@ QList<IncludeGroup> IncludeGroup::detectIncludeGroupsByIncludeType(const QList<I
if (isFirst) {
isFirst = false;
currentIncludes << include;
}
// Include belongs to current group
else if (lastIncludeType == currentIncludeType) {
} else if (lastIncludeType == currentIncludeType) {
currentIncludes << include;
}
// Include is member of new group
else {
} else {
result << IncludeGroup(currentIncludes);
currentIncludes.clear();
currentIncludes << include;

View File

@@ -176,7 +176,7 @@ Function *SymbolFinder::findMatchingDefinition(Symbol *declaration,
foreach (Function *fun, viableFunctions) {
if (! (fun->unqualifiedName() && fun->unqualifiedName()->isEqualTo(declaration->unqualifiedName())))
continue;
else if (fun->argumentCount() == declarationTy->argumentCount()) {
if (fun->argumentCount() == declarationTy->argumentCount()) {
if (! strict && ! best)
best = fun;
@@ -287,13 +287,9 @@ void SymbolFinder::findMatchingDeclaration(const LookupContext &context,
continue;
for (Symbol *s = scope->find(funcId); s; s = s->next()) {
if (! s->name())
if (! s->name() || ! funcId->isEqualTo(s->identifier()) || ! s->type()->isFunctionType())
continue;
else if (! funcId->isEqualTo(s->identifier()))
continue;
else if (! s->type()->isFunctionType())
continue;
else if (Declaration *decl = s->asDeclaration()) {
if (Declaration *decl = s->asDeclaration()) {
if (Function *declFunTy = decl->type()->asFunctionType()) {
if (functionType->isEqualTo(declFunTy))
typeMatch->prepend(decl);