CppTools: Simplify

Change-Id: Id10cbcf541d8105265c531e63a64e2fd34e27379
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Nikolai Kosjar
2019-10-31 16:15:03 +01:00
parent 5cd474522a
commit 32fe77564e
6 changed files with 18 additions and 31 deletions

View File

@@ -461,11 +461,7 @@ Scope *CheckSymbols::enclosingScope() const
bool CheckSymbols::preVisit(AST *ast)
{
_astStack.append(ast);
if (isCanceled())
return false;
return true;
return !isCanceled();
}
void CheckSymbols::postVisit(AST *)
@@ -1256,13 +1252,12 @@ bool CheckSymbols::maybeAddTypeOrStatic(const QList<LookupItem> &candidates, Nam
Symbol *c = r.declaration();
if (c->isUsingDeclaration()) // skip using declarations...
continue;
else if (c->isUsingNamespaceDirective()) // ... and using namespace directives.
if (c->isUsingNamespaceDirective()) // ... and using namespace directives.
continue;
else if (c->isTypedef() || c->isNamespace() ||
c->isStatic() || //consider also static variable
c->isClass() || c->isEnum() || isTemplateClass(c) ||
c->isForwardClassDeclaration() || c->isTypenameArgument() || c->enclosingEnum() != nullptr) {
if (c->isTypedef() || c->isNamespace() ||
c->isStatic() || //consider also static variable
c->isClass() || c->isEnum() || isTemplateClass(c) ||
c->isForwardClassDeclaration() || c->isTypenameArgument() || c->enclosingEnum()) {
int line, column;
getTokenStartPosition(startToken, &line, &column);
const unsigned length = tok.utf16chars();
@@ -1298,11 +1293,11 @@ bool CheckSymbols::maybeAddField(const QList<LookupItem> &candidates, NameAST *a
Symbol *c = r.declaration();
if (!c)
continue;
else if (!c->isDeclaration())
if (!c->isDeclaration())
return false;
else if (!(c->enclosingScope() && c->enclosingScope()->isClass()))
if (!(c->enclosingScope() && c->enclosingScope()->isClass()))
return false; // shadowed
else if (c->isTypedef() || (c->type() && c->type()->isFunctionType()))
if (c->isTypedef() || (c->type() && c->type()->isFunctionType()))
return false; // shadowed
int line, column;

View File

@@ -179,8 +179,8 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
switch (kind) {
case T_LBRACE: enter(brace_list_open); break;
case T_RBRACE: leave(true); continue;
case T_SEMICOLON: leave(); continue;
case T_RPAREN: leave(); continue;
case T_SEMICOLON:
case T_RPAREN:
case T_COMMA: leave(); continue;
default: enter(assign_open); continue;
} break;
@@ -205,8 +205,8 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
case assign_open:
switch (kind) {
case T_RBRACE: leave(true); continue;
case T_SEMICOLON: leave(); continue;
case T_RPAREN: leave(); continue;
case T_SEMICOLON:
case T_RPAREN:
case T_COMMA: leave(); continue;
default: tryExpression(); break;
} break;

View File

@@ -51,9 +51,7 @@ bool CppCompletionAssistProvider::isActivationCharSequence(const QString &sequen
const QChar &ch = sequence.at(2);
const QChar &ch2 = sequence.at(1);
const QChar &ch3 = sequence.at(0);
if (activationSequenceChar(ch, ch2, ch3, nullptr, true, false) != 0)
return true;
return false;
return activationSequenceChar(ch, ch2, ch3, nullptr, true, false);
}
bool CppCompletionAssistProvider::isContinuationChar(const QChar &c) const

View File

@@ -374,7 +374,7 @@ Symbol *findDefinition(Symbol *symbol, const Snapshot &snapshot, SymbolFinder *s
if (symbol->isFunction())
return nullptr; // symbol is a function definition.
else if (!symbol->type()->isFunctionType())
if (!symbol->type()->isFunctionType())
return nullptr; // not a function declaration
return symbolFinder->findMatchingDefinition(symbol, snapshot);

View File

@@ -172,10 +172,7 @@ bool CppRefactoringFile::isCursorOn(unsigned tokenIndex) const
int start = startOf(tokenIndex);
int end = endOf(tokenIndex);
if (cursorBegin >= start && cursorBegin <= end)
return true;
return false;
return cursorBegin >= start && cursorBegin <= end;
}
bool CppRefactoringFile::isCursorOn(const AST *ast) const
@@ -186,10 +183,7 @@ bool CppRefactoringFile::isCursorOn(const AST *ast) const
int start = startOf(ast);
int end = endOf(ast);
if (cursorBegin >= start && cursorBegin <= end)
return true;
return false;
return cursorBegin >= start && cursorBegin <= end;
}
Utils::ChangeSet::Range CppRefactoringFile::range(unsigned tokenIndex) const

View File

@@ -87,7 +87,7 @@ void SemanticHighlighter::onHighlighterResultAvailable(int from, int to)
{
if (documentRevision() != m_revision)
return; // outdated
else if (!m_watcher || m_watcher->isCanceled())
if (!m_watcher || m_watcher->isCanceled())
return; // aborted
qCDebug(log) << "onHighlighterResultAvailable()" << from << to;