forked from qt-creator/qt-creator
CppEditor: Simplify
bugprone-branch-clone readability-simplify-boolean-expr Change-Id: Id30a155e224370713d23b4b534fb82f5e630f36c Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -45,10 +45,7 @@ bool CMakeAutoCompleter::isInComment(const QTextCursor &cursor) const
|
|||||||
// NOTE: This doesn't handle '#' inside quotes, nor multi-line comments
|
// NOTE: This doesn't handle '#' inside quotes, nor multi-line comments
|
||||||
QTextCursor moved = cursor;
|
QTextCursor moved = cursor;
|
||||||
moved.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor);
|
moved.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor);
|
||||||
if (moved.selectedText().contains(QLatin1Char('#')))
|
return moved.selectedText().contains(QLatin1Char('#'));
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CMakeAutoCompleter::isInString(const QTextCursor &cursor) const
|
bool CMakeAutoCompleter::isInString(const QTextCursor &cursor) const
|
||||||
|
@@ -88,10 +88,7 @@ bool isPreviousLineCppStyleComment(const QTextCursor &cursor)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
const QString text = actual.text().trimmed();
|
const QString text = actual.text().trimmed();
|
||||||
if (text.startsWith(QLatin1String("///")) || text.startsWith(QLatin1String("//!")))
|
return text.startsWith(QLatin1String("///")) || text.startsWith(QLatin1String("//!"));
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if next line is a CppStyle Doxygen Comment
|
/// Check if next line is a CppStyle Doxygen Comment
|
||||||
@@ -106,10 +103,7 @@ bool isNextLineCppStyleComment(const QTextCursor &cursor)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
const QString text = actual.text().trimmed();
|
const QString text = actual.text().trimmed();
|
||||||
if (text.startsWith(QLatin1String("///")) || text.startsWith(QLatin1String("//!")))
|
return text.startsWith(QLatin1String("///")) || text.startsWith(QLatin1String("//!"));
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isCppStyleContinuation(const QTextCursor& cursor)
|
bool isCppStyleContinuation(const QTextCursor& cursor)
|
||||||
|
@@ -442,9 +442,7 @@ static bool canReplaceSpecifier(TranslationUnit *translationUnit, SpecifierAST *
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (specifier->asAttributeSpecifier())
|
return !specifier->asAttributeSpecifier();
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static SpecifierAST *findFirstReplaceableSpecifier(TranslationUnit *translationUnit, SpecifierListAST *list)
|
static SpecifierAST *findFirstReplaceableSpecifier(TranslationUnit *translationUnit, SpecifierListAST *list)
|
||||||
|
@@ -581,21 +581,11 @@ static bool checkDeclarationForSplit(SimpleDeclarationAST *declaration)
|
|||||||
|
|
||||||
for (SpecifierListAST *it = declaration->decl_specifier_list; it; it = it->next) {
|
for (SpecifierListAST *it = declaration->decl_specifier_list; it; it = it->next) {
|
||||||
SpecifierAST *specifier = it->value;
|
SpecifierAST *specifier = it->value;
|
||||||
|
if (specifier->asEnumSpecifier() || specifier->asClassSpecifier())
|
||||||
if (specifier->asEnumSpecifier() != nullptr)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
else if (specifier->asClassSpecifier() != nullptr)
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!declaration->declarator_list)
|
return declaration->declarator_list && declaration->declarator_list->next;
|
||||||
return false;
|
|
||||||
|
|
||||||
else if (!declaration->declarator_list->next)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -3502,9 +3492,7 @@ public:
|
|||||||
|
|
||||||
bool preVisit(AST *) override
|
bool preVisit(AST *) override
|
||||||
{
|
{
|
||||||
if (m_done)
|
return !m_done;
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void statement(StatementAST *stmt)
|
void statement(StatementAST *stmt)
|
||||||
|
Reference in New Issue
Block a user