CppTools: Fix "! condition" coding style

Change-Id: Ic7e634e4249fb64edbc2daceb65ec8e9b5f0f8b9
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Aurindam Jana <aurindam.jana@digia.com>
This commit is contained in:
Nikolai Kosjar
2013-07-24 11:59:39 +02:00
parent 782b9994d8
commit e2ce17ef00
15 changed files with 132 additions and 122 deletions

View File

@@ -59,7 +59,7 @@ static void parse(QFutureInterface<void> &future,
const bool isSourceFile = i < sourceCount; const bool isSourceFile = i < sourceCount;
if (isSourceFile) { if (isSourceFile) {
(void) preproc->run(conf); (void) preproc->run(conf);
} else if (! processingHeaders) { } else if (!processingHeaders) {
(void) preproc->run(conf); (void) preproc->run(conf);
processingHeaders = true; processingHeaders = true;
@@ -182,7 +182,7 @@ QFuture<void> BuiltinIndexingSupport::refreshSourceFiles(const QStringList &sour
m_synchronizer.clearFutures(); m_synchronizer.clearFutures();
foreach (const QFuture<void> &future, futures) { foreach (const QFuture<void> &future, futures) {
if (! (future.isFinished() || future.isCanceled())) if (!(future.isFinished() || future.isCanceled()))
m_synchronizer.addFuture(future); m_synchronizer.addFuture(future);
} }
} }

View File

@@ -94,9 +94,9 @@ public:
protected: protected:
void process(Document::Ptr doc, QSet<Namespace *> *processed) void process(Document::Ptr doc, QSet<Namespace *> *processed)
{ {
if (! doc) if (!doc)
return; return;
if (! processed->contains(doc->globalNamespace())) { if (!processed->contains(doc->globalNamespace())) {
processed->insert(doc->globalNamespace()); processed->insert(doc->globalNamespace());
foreach (const Document::Include &i, doc->includes()) foreach (const Document::Include &i, doc->includes())
@@ -115,7 +115,7 @@ protected:
void addType(const Name *name) void addType(const Name *name)
{ {
if (! name) { if (!name) {
return; return;
} else if (const QualifiedNameId *q = name->asQualifiedNameId()) { } else if (const QualifiedNameId *q = name->asQualifiedNameId()) {
@@ -130,7 +130,7 @@ protected:
void addField(const Name *name) void addField(const Name *name)
{ {
if (! name) { if (!name) {
return; return;
} else if (name->isNameId()) { } else if (name->isNameId()) {
@@ -142,7 +142,7 @@ protected:
void addFunction(const Name *name) void addFunction(const Name *name)
{ {
if (! name) { if (!name) {
return; return;
} else if (name->isNameId()) { } else if (name->isNameId()) {
@@ -153,7 +153,7 @@ protected:
void addStatic(const Name *name) void addStatic(const Name *name)
{ {
if (! name) { if (!name) {
return; return;
} else if (name->isNameId() || name->isTemplateNameId()) { } else if (name->isNameId() || name->isTemplateNameId()) {
@@ -196,7 +196,7 @@ protected:
if (symbol->isTypedef()) if (symbol->isTypedef())
addType(symbol->name()); addType(symbol->name());
else if (! symbol->type()->isFunctionType() && symbol->enclosingScope()->isClass()) else if (!symbol->type()->isFunctionType() && symbol->enclosingScope()->isClass())
addField(symbol->name()); addField(symbol->name());
return true; return true;
@@ -333,7 +333,7 @@ void CheckSymbols::run()
qSort(_macroUses.begin(), _macroUses.end(), sortByLinePredicate); qSort(_macroUses.begin(), _macroUses.end(), sortByLinePredicate);
_doc->clearDiagnosticMessages(); _doc->clearDiagnosticMessages();
if (! isCanceled()) { if (!isCanceled()) {
if (_doc->translationUnit()) { if (_doc->translationUnit()) {
accept(_doc->translationUnit()->ast()); accept(_doc->translationUnit()->ast());
_usages << QVector<Result>::fromList(_macroUses); _usages << QVector<Result>::fromList(_macroUses);
@@ -473,7 +473,7 @@ bool CheckSymbols::visit(NamespaceAST *ast)
{ {
if (ast->identifier_token) { if (ast->identifier_token) {
const Token &tok = tokenAt(ast->identifier_token); const Token &tok = tokenAt(ast->identifier_token);
if (! tok.generated()) { if (!tok.generated()) {
unsigned line, column; unsigned line, column;
getTokenStartPosition(ast->identifier_token, &line, &column); getTokenStartPosition(ast->identifier_token, &line, &column);
Result use(line, column, tok.length(), CppHighlightingSupport::TypeUse); Result use(line, column, tok.length(), CppHighlightingSupport::TypeUse);
@@ -499,7 +499,7 @@ bool CheckSymbols::visit(SimpleDeclarationAST *ast)
{ {
NameAST *declrIdNameAST = 0; NameAST *declrIdNameAST = 0;
if (ast->declarator_list && !ast->declarator_list->next) { if (ast->declarator_list && !ast->declarator_list->next) {
if (ast->symbols && ! ast->symbols->next && !ast->symbols->value->isGenerated()) { if (ast->symbols && !ast->symbols->next && !ast->symbols->value->isGenerated()) {
Symbol *decl = ast->symbols->value; Symbol *decl = ast->symbols->value;
if (NameAST *nameAST = declaratorId(ast->declarator_list->value)) { if (NameAST *nameAST = declaratorId(ast->declarator_list->value)) {
if (Function *funTy = decl->type()->asFunctionType()) { if (Function *funTy = decl->type()->asFunctionType()) {
@@ -559,7 +559,7 @@ bool CheckSymbols::visit(ElaboratedTypeSpecifierAST *ast)
bool CheckSymbols::visit(MemberAccessAST *ast) bool CheckSymbols::visit(MemberAccessAST *ast)
{ {
accept(ast->base_expression); accept(ast->base_expression);
if (! ast->member_name) if (!ast->member_name)
return false; return false;
if (const Name *name = ast->member_name->name) { if (const Name *name = ast->member_name->name) {
@@ -711,7 +711,7 @@ QByteArray CheckSymbols::textOf(AST *ast) const
void CheckSymbols::checkNamespace(NameAST *name) void CheckSymbols::checkNamespace(NameAST *name)
{ {
if (! name) if (!name)
return; return;
unsigned line, column; unsigned line, column;
@@ -730,13 +730,13 @@ void CheckSymbols::checkNamespace(NameAST *name)
bool CheckSymbols::hasVirtualDestructor(Class *klass) const bool CheckSymbols::hasVirtualDestructor(Class *klass) const
{ {
if (! klass) if (!klass)
return false; return false;
const Identifier *id = klass->identifier(); const Identifier *id = klass->identifier();
if (! id) if (!id)
return false; return false;
for (Symbol *s = klass->find(id); s; s = s->next()) { for (Symbol *s = klass->find(id); s; s = s->next()) {
if (! s->name()) if (!s->name())
continue; continue;
if (s->name()->isDestructorNameId()) { if (s->name()->isDestructorNameId()) {
if (Function *funTy = s->type()->asFunctionType()) { if (Function *funTy = s->type()->asFunctionType()) {
@@ -754,9 +754,9 @@ bool CheckSymbols::hasVirtualDestructor(ClassOrNamespace *binding) const
QList<ClassOrNamespace *> todo; QList<ClassOrNamespace *> todo;
todo.append(binding); todo.append(binding);
while (! todo.isEmpty()) { while (!todo.isEmpty()) {
ClassOrNamespace *b = todo.takeFirst(); ClassOrNamespace *b = todo.takeFirst();
if (b && ! processed.contains(b)) { if (b && !processed.contains(b)) {
processed.insert(b); processed.insert(b);
foreach (Symbol *s, b->symbols()) { foreach (Symbol *s, b->symbols()) {
if (Class *k = s->asClass()) { if (Class *k = s->asClass()) {
@@ -775,7 +775,7 @@ bool CheckSymbols::hasVirtualDestructor(ClassOrNamespace *binding) const
void CheckSymbols::checkName(NameAST *ast, Scope *scope) void CheckSymbols::checkName(NameAST *ast, Scope *scope)
{ {
if (ast && ast->name) { if (ast && ast->name) {
if (! scope) if (!scope)
scope = enclosingScope(); scope = enclosingScope();
if (ast->asDestructorName() != 0) { if (ast->asDestructorName() != 0) {
@@ -796,7 +796,7 @@ void CheckSymbols::checkName(NameAST *ast, Scope *scope)
} }
} }
} else if (maybeType(ast->name) || maybeStatic(ast->name)) { } else if (maybeType(ast->name) || maybeStatic(ast->name)) {
if (! maybeAddTypeOrStatic(_context.lookup(ast->name, scope), ast)) { if (!maybeAddTypeOrStatic(_context.lookup(ast->name, scope), ast)) {
// it can be a local variable // it can be a local variable
if (maybeField(ast->name)) if (maybeField(ast->name))
maybeAddField(_context.lookup(ast->name, scope), ast); maybeAddField(_context.lookup(ast->name, scope), ast);
@@ -895,7 +895,7 @@ ClassOrNamespace *CheckSymbols::checkNestedName(QualifiedNameAST *ast)
} }
accept(template_id->template_argument_list); accept(template_id->template_argument_list);
if (! binding) if (!binding)
continue; continue;
} }
@@ -1026,7 +1026,7 @@ bool CheckSymbols::visit(FunctionDefinitionAST *ast)
_astStack.append(thisFunction); _astStack.append(thisFunction);
bool processEntireDeclr = true; bool processEntireDeclr = true;
if (ast->declarator && ast->symbol && ! ast->symbol->isGenerated()) { if (ast->declarator && ast->symbol && !ast->symbol->isGenerated()) {
Function *fun = ast->symbol; Function *fun = ast->symbol;
if (NameAST *declId = declaratorId(ast->declarator)) { if (NameAST *declId = declaratorId(ast->declarator)) {
processEntireDeclr = false; processEntireDeclr = false;
@@ -1077,7 +1077,7 @@ bool CheckSymbols::visit(FunctionDefinitionAST *ast)
void CheckSymbols::addUse(NameAST *ast, Kind kind) void CheckSymbols::addUse(NameAST *ast, Kind kind)
{ {
if (! ast) if (!ast)
return; return;
if (QualifiedNameAST *q = ast->asQualifiedName()) if (QualifiedNameAST *q = ast->asQualifiedName())
@@ -1085,7 +1085,7 @@ void CheckSymbols::addUse(NameAST *ast, Kind kind)
if (DestructorNameAST *dtor = ast->asDestructorName()) if (DestructorNameAST *dtor = ast->asDestructorName())
ast = dtor->unqualified_name; ast = dtor->unqualified_name;
if (! ast) if (!ast)
return; // nothing to do return; // nothing to do
else if (ast->asOperatorFunctionId() != 0 || ast->asConversionFunctionId() != 0) else if (ast->asOperatorFunctionId() != 0 || ast->asConversionFunctionId() != 0)
return; // nothing to do return; // nothing to do
@@ -1100,7 +1100,7 @@ void CheckSymbols::addUse(NameAST *ast, Kind kind)
void CheckSymbols::addUse(unsigned tokenIndex, Kind kind) void CheckSymbols::addUse(unsigned tokenIndex, Kind kind)
{ {
if (! tokenIndex) if (!tokenIndex)
return; return;
const Token &tok = tokenAt(tokenIndex); const Token &tok = tokenAt(tokenIndex);
@@ -1120,7 +1120,7 @@ void CheckSymbols::addUse(const Result &use)
if (use.isInvalid()) if (use.isInvalid())
return; return;
if (! enclosingFunctionDefinition()) { if (!enclosingFunctionDefinition()) {
if (_usages.size() >= _chunkSize) { if (_usages.size() >= _chunkSize) {
if (use.line > _lineOfLastUsage) if (use.line > _lineOfLastUsage)
flush(); flush();
@@ -1137,7 +1137,7 @@ void CheckSymbols::addUse(const Result &use)
void CheckSymbols::addType(ClassOrNamespace *b, NameAST *ast) void CheckSymbols::addType(ClassOrNamespace *b, NameAST *ast)
{ {
unsigned startToken; unsigned startToken;
if (! b || !acceptName(ast, &startToken)) if (!b || !acceptName(ast, &startToken))
return; return;
const Token &tok = tokenAt(startToken); const Token &tok = tokenAt(startToken);
@@ -1218,11 +1218,11 @@ bool CheckSymbols::maybeAddField(const QList<LookupItem> &candidates, NameAST *a
foreach (const LookupItem &r, candidates) { foreach (const LookupItem &r, candidates) {
Symbol *c = r.declaration(); Symbol *c = r.declaration();
if (! c) if (!c)
continue; continue;
else if (! c->isDeclaration()) else if (!c->isDeclaration())
return false; return false;
else if (! (c->enclosingScope() && c->enclosingScope()->isClass())) else if (!(c->enclosingScope() && c->enclosingScope()->isClass()))
return false; // shadowed return false; // shadowed
else if (c->isTypedef() || (c->type() && c->type()->isFunctionType())) else if (c->isTypedef() || (c->type() && c->type()->isFunctionType()))
return false; // shadowed return false; // shadowed
@@ -1261,7 +1261,7 @@ bool CheckSymbols::maybeAddFunction(const QList<LookupItem> &candidates, NameAST
Symbol *c = r.declaration(); Symbol *c = r.declaration();
// Skip current if there's no declaration or name. // Skip current if there's no declaration or name.
if (! c || !c->name()) if (!c || !c->name())
continue; continue;
// In addition check for destructors, since the leading ~ is not taken into consideration. // In addition check for destructors, since the leading ~ is not taken into consideration.
@@ -1272,13 +1272,13 @@ bool CheckSymbols::maybeAddFunction(const QList<LookupItem> &candidates, NameAST
isConstructor = isConstructorDeclaration(c); isConstructor = isConstructorDeclaration(c);
Function *funTy = c->type()->asFunctionType(); Function *funTy = c->type()->asFunctionType();
if (! funTy) { if (!funTy) {
//Try to find a template function //Try to find a template function
if (Template * t = r.type()->asTemplateType()) if (Template * t = r.type()->asTemplateType())
if ((c = t->declaration())) if ((c = t->declaration()))
funTy = c->type()->asFunctionType(); funTy = c->type()->asFunctionType();
} }
if (! funTy) if (!funTy)
continue; // TODO: add diagnostic messages and color call-operators calls too? continue; // TODO: add diagnostic messages and color call-operators calls too?
if (argumentCount < funTy->minimumArgumentCount()) { if (argumentCount < funTy->minimumArgumentCount()) {
@@ -1286,7 +1286,7 @@ bool CheckSymbols::maybeAddFunction(const QList<LookupItem> &candidates, NameAST
kind = funTy->isVirtual() ? CppHighlightingSupport::VirtualMethodUse : CppHighlightingSupport::FunctionUse; kind = funTy->isVirtual() ? CppHighlightingSupport::VirtualMethodUse : CppHighlightingSupport::FunctionUse;
matchType = Match_TooFewArgs; matchType = Match_TooFewArgs;
} }
} else if (argumentCount > funTy->argumentCount() && ! funTy->isVariadic()) { } else if (argumentCount > funTy->argumentCount() && !funTy->isVariadic()) {
if (matchType != Match_Ok) { if (matchType != Match_Ok) {
matchType = Match_TooManyArgs; matchType = Match_TooManyArgs;
kind = funTy->isVirtual() ? CppHighlightingSupport::VirtualMethodUse : CppHighlightingSupport::FunctionUse; kind = funTy->isVirtual() ? CppHighlightingSupport::VirtualMethodUse : CppHighlightingSupport::FunctionUse;

View File

@@ -210,7 +210,7 @@ static void configureOverviewWithCodeStyleSettings(CPlusPlus::Overview &overview
CPlusPlus::Overview CppCodeStyleSettings::currentProjectCodeStyleOverview() CPlusPlus::Overview CppCodeStyleSettings::currentProjectCodeStyleOverview()
{ {
ProjectExplorer::Project *project = ProjectExplorer::ProjectExplorerPlugin::currentProject(); ProjectExplorer::Project *project = ProjectExplorer::ProjectExplorerPlugin::currentProject();
if (! project) if (!project)
return currentGlobalCodeStyleOverview(); return currentGlobalCodeStyleOverview();
ProjectExplorer::EditorConfiguration *editorConfiguration = project->editorConfiguration(); ProjectExplorer::EditorConfiguration *editorConfiguration = project->editorConfiguration();

View File

@@ -1498,7 +1498,7 @@ void CppToolsPlugin::test_completion_typedef_of_type_and_decl_of_type_no_replace
QCOMPARE(completions.size(), 2); QCOMPARE(completions.size(), 2);
QVERIFY(completions.contains(QLatin1String("S"))); QVERIFY(completions.contains(QLatin1String("S")));
QVERIFY(completions.contains(QLatin1String("m"))); QVERIFY(completions.contains(QLatin1String("m")));
QVERIFY(! replaceAccessOperator); QVERIFY(!replaceAccessOperator);
} }
void CppToolsPlugin::test_completion_typedef_of_pointer_and_decl_of_pointer_no_replace_access_operator() void CppToolsPlugin::test_completion_typedef_of_pointer_and_decl_of_pointer_no_replace_access_operator()
@@ -1524,7 +1524,7 @@ void CppToolsPlugin::test_completion_typedef_of_pointer_and_decl_of_pointer_no_r
QStringList completions = getCompletions(data, &replaceAccessOperator); QStringList completions = getCompletions(data, &replaceAccessOperator);
QCOMPARE(completions.size(), 0); QCOMPARE(completions.size(), 0);
QVERIFY(! replaceAccessOperator); QVERIFY(!replaceAccessOperator);
} }
void CppToolsPlugin::test_completion_typedef_of_type_and_decl_of_pointer_replace_access_operator() void CppToolsPlugin::test_completion_typedef_of_type_and_decl_of_pointer_replace_access_operator()
@@ -1636,7 +1636,7 @@ void CppToolsPlugin::test_completion_predecl_typedef_of_type_and_decl_type_no_re
QCOMPARE(completions.size(), 2); QCOMPARE(completions.size(), 2);
QVERIFY(completions.contains(QLatin1String("S"))); QVERIFY(completions.contains(QLatin1String("S")));
QVERIFY(completions.contains(QLatin1String("m"))); QVERIFY(completions.contains(QLatin1String("m")));
QVERIFY(! replaceAccessOperator); QVERIFY(!replaceAccessOperator);
} }
void CppToolsPlugin::test_completion_predecl_typedef_of_pointer_and_decl_of_pointer_no_replace_access_operator() void CppToolsPlugin::test_completion_predecl_typedef_of_pointer_and_decl_of_pointer_no_replace_access_operator()
@@ -1662,7 +1662,7 @@ void CppToolsPlugin::test_completion_predecl_typedef_of_pointer_and_decl_of_poin
QStringList completions = getCompletions(data, &replaceAccessOperator); QStringList completions = getCompletions(data, &replaceAccessOperator);
QCOMPARE(completions.size(), 0); QCOMPARE(completions.size(), 0);
QVERIFY(! replaceAccessOperator); QVERIFY(!replaceAccessOperator);
} }
void CppToolsPlugin::test_completion_predecl_typedef_of_pointer_and_decl_of_type_replace_access_operator() void CppToolsPlugin::test_completion_predecl_typedef_of_pointer_and_decl_of_type_replace_access_operator()

View File

@@ -218,7 +218,9 @@ void CppAssistProposalItem::applyContextualContent(TextEditor::BaseTextEditor *e
if (Function *function = symbol->type()->asFunctionType()) { if (Function *function = symbol->type()->asFunctionType()) {
// If the member is a function, automatically place the opening parenthesis, // If the member is a function, automatically place the opening parenthesis,
// except when it might take template parameters. // except when it might take template parameters.
if (! function->hasReturnType() && (function->unqualifiedName() && !function->unqualifiedName()->isDestructorNameId())) { if (!function->hasReturnType()
&& (function->unqualifiedName()
&& !function->unqualifiedName()->isDestructorNameId())) {
// Don't insert any magic, since the user might have just wanted to select the class // Don't insert any magic, since the user might have just wanted to select the class
/// ### port me /// ### port me
@@ -228,7 +230,7 @@ void CppAssistProposalItem::applyContextualContent(TextEditor::BaseTextEditor *e
if (function->argumentCount() == 0) if (function->argumentCount() == 0)
extraChars += QLatin1Char('<'); extraChars += QLatin1Char('<');
#endif #endif
} else if (!isDereferenced(editor, basePosition) && ! function->isAmbiguous()) { } else if (!isDereferenced(editor, basePosition) && !function->isAmbiguous()) {
// When the user typed the opening parenthesis, he'll likely also type the closing one, // When the user typed the opening parenthesis, he'll likely also type the closing one,
// in which case it would be annoying if we put the cursor after the already automatically // in which case it would be annoying if we put the cursor after the already automatically
// inserted closing parenthesis. // inserted closing parenthesis.
@@ -253,7 +255,7 @@ void CppAssistProposalItem::applyContextualContent(TextEditor::BaseTextEditor *e
} }
// If the function takes no arguments, automatically place the closing parenthesis // If the function takes no arguments, automatically place the closing parenthesis
if (!isOverloaded() && ! function->hasArguments() && skipClosingParenthesis) { if (!isOverloaded() && !function->hasArguments() && skipClosingParenthesis) {
extraChars += QLatin1Char(')'); extraChars += QLatin1Char(')');
if (endWithSemicolon) { if (endWithSemicolon) {
extraChars += semicolon; extraChars += semicolon;
@@ -392,7 +394,7 @@ int CppFunctionHintModel::activeArgument(const QString &prefix) const
++parcount; ++parcount;
else if (tk.is(T_RPAREN)) else if (tk.is(T_RPAREN))
--parcount; --parcount;
else if (! parcount && tk.is(T_COMMA)) else if (!parcount && tk.is(T_COMMA))
++argnr; ++argnr;
} }
@@ -504,8 +506,8 @@ public:
BasicProposalItem *operator()(Symbol *symbol) BasicProposalItem *operator()(Symbol *symbol)
{ {
//using declaration can be qualified //using declaration can be qualified
if (! symbol || ! symbol->name() || (symbol->name()->isQualifiedNameId() if (!symbol || !symbol->name() || (symbol->name()->isQualifiedNameId()
&& ! symbol->asUsingDeclaration())) && !symbol->asUsingDeclaration()))
return 0; return 0;
BasicProposalItem *previousItem = switchCompletionItem(0); BasicProposalItem *previousItem = switchCompletionItem(0);
@@ -986,7 +988,7 @@ bool CppCompletionAssistProcessor::tryObjCCompletion()
const QString expr = m_interface->textAt(startPos, m_interface->position() - startPos); const QString expr = m_interface->textAt(startPos, m_interface->position() - startPos);
Document::Ptr thisDocument = m_interface->snapshot().document(m_interface->fileName()); Document::Ptr thisDocument = m_interface->snapshot().document(m_interface->fileName());
if (! thisDocument) if (!thisDocument)
return false; return false;
m_model->m_typeOfExpression->init(thisDocument, m_interface->snapshot()); m_model->m_typeOfExpression->init(thisDocument, m_interface->snapshot());
@@ -1205,7 +1207,7 @@ int CppCompletionAssistProcessor::startCompletionInternal(const QString fileName
QString expression = expr.trimmed(); QString expression = expr.trimmed();
Document::Ptr thisDocument = m_interface->snapshot().document(fileName); Document::Ptr thisDocument = m_interface->snapshot().document(fileName);
if (! thisDocument) if (!thisDocument)
return -1; return -1;
m_model->m_typeOfExpression->init(thisDocument, m_interface->snapshot()); m_model->m_typeOfExpression->init(thisDocument, m_interface->snapshot());
@@ -1234,7 +1236,7 @@ int CppCompletionAssistProcessor::startCompletionInternal(const QString fileName
if (results.isEmpty()) { if (results.isEmpty()) {
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) {
if (! (expression.isEmpty() || expression == QLatin1String("this"))) { if (!(expression.isEmpty() || expression == QLatin1String("this"))) {
expression = QLatin1String("this"); expression = QLatin1String("this");
results = (*m_model->m_typeOfExpression)(utf8Exp, scope); results = (*m_model->m_typeOfExpression)(utf8Exp, scope);
} }
@@ -1330,7 +1332,7 @@ void CppCompletionAssistProcessor::globalCompletion(CPlusPlus::Scope *currentSco
if (ClassOrNamespace *binding = context.lookupType(scope)) { if (ClassOrNamespace *binding = context.lookupType(scope)) {
for (unsigned i = 0; i < scope->memberCount(); ++i) { for (unsigned i = 0; i < scope->memberCount(); ++i) {
Symbol *member = scope->memberAt(i); Symbol *member = scope->memberAt(i);
if (! member->name()) if (!member->name())
continue; continue;
if (UsingNamespaceDirective *u = member->asUsingNamespaceDirective()) { if (UsingNamespaceDirective *u = member->asUsingNamespaceDirective()) {
if (ClassOrNamespace *b = binding->lookupType(u->name())) if (ClassOrNamespace *b = binding->lookupType(u->name()))
@@ -1366,7 +1368,7 @@ void CppCompletionAssistProcessor::globalCompletion(CPlusPlus::Scope *currentSco
for (; currentBinding; currentBinding = currentBinding->parent()) { for (; currentBinding; currentBinding = currentBinding->parent()) {
const QList<Symbol *> symbols = currentBinding->symbols(); const QList<Symbol *> symbols = currentBinding->symbols();
if (! symbols.isEmpty()) { if (!symbols.isEmpty()) {
if (symbols.first()->isClass()) if (symbols.first()->isClass())
completeClass(currentBinding); completeClass(currentBinding);
else else
@@ -1399,7 +1401,7 @@ bool CppCompletionAssistProcessor::completeMember(const QList<CPlusPlus::LookupI
if (binding) if (binding)
completeClass(binding, /*static lookup = */ true); completeClass(binding, /*static lookup = */ true);
return ! m_completions.isEmpty(); return !m_completions.isEmpty();
} }
return false; return false;
@@ -1469,7 +1471,7 @@ bool CppCompletionAssistProcessor::completeScope(const QList<CPlusPlus::LookupIt
} }
} }
return ! m_completions.isEmpty(); return !m_completions.isEmpty();
} }
void CppCompletionAssistProcessor::completeNamespace(CPlusPlus::ClassOrNamespace *b) void CppCompletionAssistProcessor::completeNamespace(CPlusPlus::ClassOrNamespace *b)
@@ -1478,9 +1480,9 @@ void CppCompletionAssistProcessor::completeNamespace(CPlusPlus::ClassOrNamespace
QList<ClassOrNamespace *> bindingsToVisit; QList<ClassOrNamespace *> bindingsToVisit;
bindingsToVisit.append(b); bindingsToVisit.append(b);
while (! bindingsToVisit.isEmpty()) { while (!bindingsToVisit.isEmpty()) {
ClassOrNamespace *binding = bindingsToVisit.takeFirst(); ClassOrNamespace *binding = bindingsToVisit.takeFirst();
if (! binding || bindingsVisited.contains(binding)) if (!binding || bindingsVisited.contains(binding))
continue; continue;
bindingsVisited.insert(binding); bindingsVisited.insert(binding);
@@ -1498,9 +1500,9 @@ void CppCompletionAssistProcessor::completeNamespace(CPlusPlus::ClassOrNamespace
scopesToVisit.append(e); scopesToVisit.append(e);
} }
while (! scopesToVisit.isEmpty()) { while (!scopesToVisit.isEmpty()) {
Scope *scope = scopesToVisit.takeFirst(); Scope *scope = scopesToVisit.takeFirst();
if (! scope || scopesVisited.contains(scope)) if (!scope || scopesVisited.contains(scope))
continue; continue;
scopesVisited.insert(scope); scopesVisited.insert(scope);
@@ -1519,9 +1521,9 @@ void CppCompletionAssistProcessor::completeClass(CPlusPlus::ClassOrNamespace *b,
QList<ClassOrNamespace *> bindingsToVisit; QList<ClassOrNamespace *> bindingsToVisit;
bindingsToVisit.append(b); bindingsToVisit.append(b);
while (! bindingsToVisit.isEmpty()) { while (!bindingsToVisit.isEmpty()) {
ClassOrNamespace *binding = bindingsToVisit.takeFirst(); ClassOrNamespace *binding = bindingsToVisit.takeFirst();
if (! binding || bindingsVisited.contains(binding)) if (!binding || bindingsVisited.contains(binding))
continue; continue;
bindingsVisited.insert(binding); bindingsVisited.insert(binding);
@@ -1538,9 +1540,9 @@ void CppCompletionAssistProcessor::completeClass(CPlusPlus::ClassOrNamespace *b,
foreach (Enum *e, binding->unscopedEnums()) foreach (Enum *e, binding->unscopedEnums())
scopesToVisit.append(e); scopesToVisit.append(e);
while (! scopesToVisit.isEmpty()) { while (!scopesToVisit.isEmpty()) {
Scope *scope = scopesToVisit.takeFirst(); Scope *scope = scopesToVisit.takeFirst();
if (! scope || scopesVisited.contains(scope)) if (!scope || scopesVisited.contains(scope))
continue; continue;
scopesVisited.insert(scope); scopesVisited.insert(scope);
@@ -1554,7 +1556,7 @@ void CppCompletionAssistProcessor::completeClass(CPlusPlus::ClassOrNamespace *b,
|| member->isQtPropertyDeclaration() || member->isQtPropertyDeclaration()
|| member->isQtEnum()) { || member->isQtEnum()) {
continue; continue;
} else if (! staticLookup && (member->isTypedef() || } else if (!staticLookup && (member->isTypedef() ||
member->isEnum() || member->isEnum() ||
member->isClass())) { member->isClass())) {
continue; continue;
@@ -1592,11 +1594,11 @@ bool CppCompletionAssistProcessor::completeQtMethod(const QList<CPlusPlus::Looku
continue; // not a pointer or a reference to a pointer. continue; // not a pointer or a reference to a pointer.
NamedType *namedTy = ty->asNamedType(); NamedType *namedTy = ty->asNamedType();
if (! namedTy) // not a class name. if (!namedTy) // not a class name.
continue; continue;
ClassOrNamespace *b = context.lookupType(namedTy->name(), p.scope()); ClassOrNamespace *b = context.lookupType(namedTy->name(), p.scope());
if (! b) if (!b)
continue; continue;
QList<ClassOrNamespace *>todo; QList<ClassOrNamespace *>todo;
@@ -1617,17 +1619,17 @@ bool CppCompletionAssistProcessor::completeQtMethod(const QList<CPlusPlus::Looku
} }
foreach (Scope *scope, scopes) { foreach (Scope *scope, scopes) {
if (! scope->isClass()) if (!scope->isClass())
continue; continue;
for (unsigned i = 0; i < scope->memberCount(); ++i) { for (unsigned i = 0; i < scope->memberCount(); ++i) {
Symbol *member = scope->memberAt(i); Symbol *member = scope->memberAt(i);
Function *fun = member->type()->asFunctionType(); Function *fun = member->type()->asFunctionType();
if (! fun) if (!fun)
continue; continue;
if (wantSignals && ! fun->isSignal()) if (wantSignals && !fun->isSignal())
continue; continue;
else if (! wantSignals && ! fun->isSlot()) else if (!wantSignals && !fun->isSlot())
continue; continue;
unsigned count = fun->argumentCount(); unsigned count = fun->argumentCount();
@@ -1648,7 +1650,7 @@ bool CppCompletionAssistProcessor::completeQtMethod(const QList<CPlusPlus::Looku
signature = QString::fromLatin1(normalized, normalized.size()); signature = QString::fromLatin1(normalized, normalized.size());
if (! signatures.contains(signature)) { if (!signatures.contains(signature)) {
BasicProposalItem *ci = toCompletionItem(fun); BasicProposalItem *ci = toCompletionItem(fun);
if (!ci) if (!ci)
break; break;
@@ -1666,7 +1668,7 @@ bool CppCompletionAssistProcessor::completeQtMethod(const QList<CPlusPlus::Looku
} }
} }
return ! m_completions.isEmpty(); return !m_completions.isEmpty();
} }
void CppCompletionAssistProcessor::addSnippets() void CppCompletionAssistProcessor::addSnippets()
@@ -1703,7 +1705,7 @@ void CppCompletionAssistProcessor::addMacros_helper(const CPlusPlus::Snapshot &s
{ {
Document::Ptr doc = snapshot.document(fileName); Document::Ptr doc = snapshot.document(fileName);
if (! doc || processed->contains(doc->fileName())) if (!doc || processed->contains(doc->fileName()))
return; return;
processed->insert(doc->fileName()); processed->insert(doc->fileName());
@@ -1714,7 +1716,7 @@ void CppCompletionAssistProcessor::addMacros_helper(const CPlusPlus::Snapshot &s
foreach (const Macro &macro, doc->definedMacros()) { foreach (const Macro &macro, doc->definedMacros()) {
const QString macroName = QString::fromUtf8(macro.name().constData(), macro.name().length()); const QString macroName = QString::fromUtf8(macro.name().constData(), macro.name().length());
if (! macro.isHidden()) if (!macro.isHidden())
definedMacros->insert(macroName); definedMacros->insert(macroName);
else else
definedMacros->remove(macroName); definedMacros->remove(macroName);
@@ -1733,14 +1735,14 @@ bool CppCompletionAssistProcessor::completeConstructorOrFunction(const QList<CPl
if (Class *klass = asClassOrTemplateClassType(exprTy)) { if (Class *klass = asClassOrTemplateClassType(exprTy)) {
const Name *className = klass->name(); const Name *className = klass->name();
if (! className) if (!className)
continue; // nothing to do for anonymous classes. continue; // nothing to do for anonymous classes.
for (unsigned i = 0; i < klass->memberCount(); ++i) { for (unsigned i = 0; i < klass->memberCount(); ++i) {
Symbol *member = klass->memberAt(i); Symbol *member = klass->memberAt(i);
const Name *memberName = member->name(); const Name *memberName = member->name();
if (! memberName) if (!memberName)
continue; // skip anonymous member. continue; // skip anonymous member.
else if (memberName->isQualifiedNameId()) else if (memberName->isQualifiedNameId())
@@ -1764,10 +1766,13 @@ bool CppCompletionAssistProcessor::completeConstructorOrFunction(const QList<CPl
if (Function *fun = asFunctionOrTemplateFunctionType(ty)) { if (Function *fun = asFunctionOrTemplateFunctionType(ty)) {
if (! fun->name()) if (!fun->name()) {
continue; continue;
else if (! functions.isEmpty() && enclosingNonTemplateScope(functions.first()) != enclosingNonTemplateScope(fun)) } else if (!functions.isEmpty()
&& enclosingNonTemplateScope(functions.first())
!= enclosingNonTemplateScope(fun)) {
continue; // skip fun, it's an hidden declaration. continue; // skip fun, it's an hidden declaration.
}
bool newOverload = true; bool newOverload = true;
@@ -1814,7 +1819,7 @@ bool CppCompletionAssistProcessor::completeConstructorOrFunction(const QList<CPl
// check if function signature autocompletion is appropriate // check if function signature autocompletion is appropriate
// Also check if the function name is a destructor name. // Also check if the function name is a destructor name.
bool isDestructor = false; bool isDestructor = false;
if (! functions.isEmpty() && ! toolTipOnly) { if (!functions.isEmpty() && !toolTipOnly) {
// function definitions will only happen in class or namespace scope, // function definitions will only happen in class or namespace scope,
// so get the current location's enclosing scope. // so get the current location's enclosing scope.
@@ -1901,7 +1906,7 @@ bool CppCompletionAssistProcessor::completeConstructorOrFunction(const QList<CPl
} }
} }
if (! functions.empty() && !isDestructor) { if (!functions.empty() && !isDestructor) {
m_hintProposal = createHintProposal(functions); m_hintProposal = createHintProposal(functions);
return true; return true;
} }

View File

@@ -105,7 +105,7 @@ public:
if (Document::Ptr previousDoc = snapshot.document(fileName)) { if (Document::Ptr previousDoc = snapshot.document(fileName)) {
Control *control = previousDoc->control(); Control *control = previousDoc->control();
if (! control->findIdentifier(symbolId->chars(), symbolId->size())) if (!control->findIdentifier(symbolId->chars(), symbolId->size()))
return usages; // skip this document, it's not using symbolId. return usages; // skip this document, it's not using symbolId.
} }
Document::Ptr doc; Document::Ptr doc;
@@ -188,8 +188,11 @@ static void find_helper(QFutureInterface<Usage> &future,
const QString sourceFile = QString::fromUtf8(symbol->fileName(), symbol->fileNameLength()); const QString sourceFile = QString::fromUtf8(symbol->fileName(), symbol->fileNameLength());
QStringList files(sourceFile); QStringList files(sourceFile);
if (symbol->isClass() || symbol->isForwardClassDeclaration() || (symbol->enclosingScope() && ! symbol->isStatic() && if (symbol->isClass()
symbol->enclosingScope()->isNamespace())) { || symbol->isForwardClassDeclaration()
|| (symbol->enclosingScope()
&& !symbol->isStatic()
&& symbol->enclosingScope()->isNamespace())) {
foreach (const Document::Ptr &doc, context.snapshot()) { foreach (const Document::Ptr &doc, context.snapshot()) {
if (doc->fileName() == sourceFile) if (doc->fileName() == sourceFile)
continue; continue;

View File

@@ -84,7 +84,7 @@ protected:
if (Symbol *member = scope->memberAt(i)) { if (Symbol *member = scope->memberAt(i)) {
if (member->isTypedef()) if (member->isTypedef())
continue; continue;
if (! member->isGenerated() && (member->isDeclaration() || member->isArgument())) { if (!member->isGenerated() && (member->isDeclaration() || member->isArgument())) {
if (member->name() && member->name()->isNameId()) { if (member->name() && member->name()->isNameId()) {
const Identifier *id = member->identifier(); const Identifier *id = member->identifier();
unsigned line, column; unsigned line, column;

View File

@@ -150,7 +150,7 @@ QList<Locator::FilterEntry> CppLocatorFilter::matchesFor(QFutureInterface<Locato
QVariant id = qVariantFromValue(info); QVariant id = qVariantFromValue(info);
Locator::FilterEntry filterEntry(this, info.symbolName, id, info.icon); Locator::FilterEntry filterEntry(this, info.symbolName, id, info.icon);
if (! info.symbolType.isEmpty()) { if (!info.symbolType.isEmpty()) {
filterEntry.extraInfo = info.symbolType; filterEntry.extraInfo = info.symbolType;
} else { } else {
filterEntry.extraInfo = FileUtils::shortNativePath( filterEntry.extraInfo = FileUtils::shortNativePath(

View File

@@ -181,7 +181,7 @@ void CppModelManager::updateModifiedSourceFiles()
foreach (const Document::Ptr doc, snapshot) { foreach (const Document::Ptr doc, snapshot) {
const QDateTime lastModified = doc->lastModified(); const QDateTime lastModified = doc->lastModified();
if (! lastModified.isNull()) { if (!lastModified.isNull()) {
QFileInfo fileInfo(doc->fileName()); QFileInfo fileInfo(doc->fileName());
if (fileInfo.exists() && fileInfo.lastModified() != lastModified) if (fileInfo.exists() && fileInfo.lastModified() != lastModified)
@@ -293,7 +293,7 @@ bool CppModelManager::replaceDocument(Document::Ptr newDoc)
void CppModelManager::ensureUpdated() void CppModelManager::ensureUpdated()
{ {
QMutexLocker locker(&m_projectMutex); QMutexLocker locker(&m_projectMutex);
if (! m_dirty) if (!m_dirty)
return; return;
m_projectFiles = internalProjectFiles(); m_projectFiles = internalProjectFiles();
@@ -552,7 +552,7 @@ void CppModelManager::updateProjectInfo(const ProjectInfo &pinfo)
{ // only hold the mutex for a limited scope, so the dumping afterwards can aquire it without deadlocking. { // only hold the mutex for a limited scope, so the dumping afterwards can aquire it without deadlocking.
QMutexLocker locker(&m_projectMutex); QMutexLocker locker(&m_projectMutex);
if (! pinfo.isValid()) if (!pinfo.isValid())
return; return;
ProjectExplorer::Project *project = pinfo.project().data(); ProjectExplorer::Project *project = pinfo.project().data();
@@ -691,7 +691,7 @@ void CppModelManager::GC()
QSet<QString> processed; QSet<QString> processed;
QStringList todo = projectFiles(); QStringList todo = projectFiles();
while (! todo.isEmpty()) { while (!todo.isEmpty()) {
QString fn = todo.last(); QString fn = todo.last();
todo.removeLast(); todo.removeLast();

View File

@@ -141,7 +141,7 @@ const QString CppModelManagerInterface::configurationFileName()
CppModelManagerInterface::CppModelManagerInterface(QObject *parent) CppModelManagerInterface::CppModelManagerInterface(QObject *parent)
: QObject(parent) : QObject(parent)
{ {
Q_ASSERT(! g_instance); Q_ASSERT(!g_instance);
g_instance = this; g_instance = this;
} }

View File

@@ -134,10 +134,10 @@ public:
{ } { }
operator bool() const operator bool() const
{ return ! m_project.isNull(); } { return !m_project.isNull(); }
bool isValid() const bool isValid() const
{ return ! m_project.isNull(); } { return !m_project.isNull(); }
bool isNull() const bool isNull() const
{ return m_project.isNull(); } { return m_project.isNull(); }

View File

@@ -76,7 +76,7 @@ static unsigned firstTypeSpecifierWithoutFollowingAttribute(
SpecifierListAST *list, TranslationUnit *translationUnit, unsigned endToken, bool *found) SpecifierListAST *list, TranslationUnit *translationUnit, unsigned endToken, bool *found)
{ {
*found = false; *found = false;
if (! list || ! translationUnit || ! endToken) if (!list || !translationUnit || !endToken)
return 0; return 0;
for (SpecifierListAST *it = list; it; it = it->next) { for (SpecifierListAST *it = list; it; it = it->next) {
@@ -156,7 +156,7 @@ bool PointerDeclarationFormatter::visit(SimpleDeclarationAST *ast)
// characters from the beginning since our rewritten declaration // characters from the beginning since our rewritten declaration
// will contain all type specifiers. // will contain all type specifiers.
int charactersToRemove = 0; int charactersToRemove = 0;
if (! isFirstDeclarator) { if (!isFirstDeclarator) {
const int startAST = m_cppRefactoringFile->startOf(ast); const int startAST = m_cppRefactoringFile->startOf(ast);
const int startFirstDeclarator = m_cppRefactoringFile->startOf(firstDeclarator); const int startFirstDeclarator = m_cppRefactoringFile->startOf(firstDeclarator);
CHECK_RV(startAST < startFirstDeclarator, "No specifier", true); CHECK_RV(startAST < startFirstDeclarator, "No specifier", true);
@@ -188,8 +188,8 @@ bool PointerDeclarationFormatter::visit(SimpleDeclarationAST *ast)
m_cppRefactoringFile->cppDocument()->translationUnit(), m_cppRefactoringFile->cppDocument()->translationUnit(),
lastActivationToken, lastActivationToken,
&foundBegin); &foundBegin);
if (! foundBegin) { if (!foundBegin) {
CHECK_RV(! isFirstDeclarator, "Declaration without attributes not supported", true); CHECK_RV(!isFirstDeclarator, "Declaration without attributes not supported", true);
firstActivationToken = declarator->firstToken(); firstActivationToken = declarator->firstToken();
} }
@@ -380,7 +380,7 @@ void PointerDeclarationFormatter::checkAndRewrite(DeclaratorAST *declarator,
// Check for expanded tokens // Check for expanded tokens
for (unsigned token = tokenRange.start; token <= tokenRange.end; ++token) for (unsigned token = tokenRange.start; token <= tokenRange.end; ++token)
CHECK_R(! tokenAt(token).expanded(), "Token is expanded"); CHECK_R(!tokenAt(token).expanded(), "Token is expanded");
Range range(m_cppRefactoringFile->startOf(tokenRange.start), Range range(m_cppRefactoringFile->startOf(tokenRange.start),
m_cppRefactoringFile->endOf(tokenRange.end)); m_cppRefactoringFile->endOf(tokenRange.end));

View File

@@ -255,7 +255,7 @@ QString CppPreprocessor::resolveFile_helper(const QString &fileName, IncludeType
void CppPreprocessor::macroAdded(const Macro &macro) void CppPreprocessor::macroAdded(const Macro &macro)
{ {
if (! m_currentDoc) if (!m_currentDoc)
return; return;
m_currentDoc->appendMacro(macro); m_currentDoc->appendMacro(macro);
@@ -271,7 +271,7 @@ static inline const Macro revision(const CppModelManagerInterface::WorkingCopy &
void CppPreprocessor::passedMacroDefinitionCheck(unsigned offset, unsigned line, const Macro &macro) void CppPreprocessor::passedMacroDefinitionCheck(unsigned offset, unsigned line, const Macro &macro)
{ {
if (! m_currentDoc) if (!m_currentDoc)
return; return;
m_currentDoc->addMacroUse(revision(m_workingCopy, macro), offset, macro.name().length(), line, m_currentDoc->addMacroUse(revision(m_workingCopy, macro), offset, macro.name().length(), line,
@@ -280,7 +280,7 @@ void CppPreprocessor::passedMacroDefinitionCheck(unsigned offset, unsigned line,
void CppPreprocessor::failedMacroDefinitionCheck(unsigned offset, const ByteArrayRef &name) void CppPreprocessor::failedMacroDefinitionCheck(unsigned offset, const ByteArrayRef &name)
{ {
if (! m_currentDoc) if (!m_currentDoc)
return; return;
m_currentDoc->addUndefinedMacroUse(QByteArray(name.start(), name.size()), offset); m_currentDoc->addUndefinedMacroUse(QByteArray(name.start(), name.size()), offset);
@@ -288,7 +288,7 @@ void CppPreprocessor::failedMacroDefinitionCheck(unsigned offset, const ByteArra
void CppPreprocessor::notifyMacroReference(unsigned offset, unsigned line, const Macro &macro) void CppPreprocessor::notifyMacroReference(unsigned offset, unsigned line, const Macro &macro)
{ {
if (! m_currentDoc) if (!m_currentDoc)
return; return;
m_currentDoc->addMacroUse(revision(m_workingCopy, macro), offset, macro.name().length(), line, m_currentDoc->addMacroUse(revision(m_workingCopy, macro), offset, macro.name().length(), line,
@@ -299,7 +299,7 @@ void CppPreprocessor::startExpandingMacro(unsigned offset, unsigned line,
const Macro &macro, const Macro &macro,
const QVector<MacroArgumentReference> &actuals) const QVector<MacroArgumentReference> &actuals)
{ {
if (! m_currentDoc) if (!m_currentDoc)
return; return;
m_currentDoc->addMacroUse(revision(m_workingCopy, macro), offset, macro.name().length(), line, m_currentDoc->addMacroUse(revision(m_workingCopy, macro), offset, macro.name().length(), line,
@@ -308,7 +308,7 @@ void CppPreprocessor::startExpandingMacro(unsigned offset, unsigned line,
void CppPreprocessor::stopExpandingMacro(unsigned, const Macro &) void CppPreprocessor::stopExpandingMacro(unsigned, const Macro &)
{ {
if (! m_currentDoc) if (!m_currentDoc)
return; return;
} }
@@ -322,7 +322,7 @@ void CppPreprocessor::markAsIncludeGuard(const QByteArray &macroName)
void CppPreprocessor::mergeEnvironment(Document::Ptr doc) void CppPreprocessor::mergeEnvironment(Document::Ptr doc)
{ {
if (! doc) if (!doc)
return; return;
const QString fn = doc->fileName(); const QString fn = doc->fileName();
@@ -374,7 +374,7 @@ void CppPreprocessor::sourceNeeded(unsigned line, const QString &fileName, Inclu
QString contents; QString contents;
getFileContents(absoluteFileName, &contents, &editorRevision); getFileContents(absoluteFileName, &contents, &editorRevision);
if (m_currentDoc) { if (m_currentDoc) {
if (contents.isEmpty() && ! QFileInfo(absoluteFileName).isAbsolute()) { if (contents.isEmpty() && !QFileInfo(absoluteFileName).isAbsolute()) {
QString msg = QCoreApplication::translate( QString msg = QCoreApplication::translate(
"CppPreprocessor", "%1: No such file or directory").arg(fileName); "CppPreprocessor", "%1: No such file or directory").arg(fileName);

View File

@@ -276,7 +276,7 @@ void CppEditorSupport::onDocumentUpdated(Document::Ptr doc)
} }
// update semantic info in a future // update semantic info in a future
if (! m_initialized || if (!m_initialized ||
(m_textEditor->widget()->isVisible() (m_textEditor->widget()->isVisible()
&& (m_lastSemanticInfo.doc.isNull() && (m_lastSemanticInfo.doc.isNull()
|| m_lastSemanticInfo.doc->translationUnit()->ast() == 0 || m_lastSemanticInfo.doc->translationUnit()->ast() == 0
@@ -373,7 +373,7 @@ void CppEditorSupport::onDiagnosticsChanged()
c.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, m.length()); c.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, m.length());
} else { } else {
for (int i = 0; i < text.size(); ++i) { for (int i = 0; i < text.size(); ++i) {
if (! text.at(i).isSpace()) { if (!text.at(i).isSpace()) {
c.setPosition(c.position() + i); c.setPosition(c.position() + i);
break; break;
} }

View File

@@ -106,13 +106,13 @@ Function *SymbolFinder::findMatchingDefinition(Symbol *declaration,
QString declFile = QString::fromUtf8(declaration->fileName(), declaration->fileNameLength()); QString declFile = QString::fromUtf8(declaration->fileName(), declaration->fileNameLength());
Document::Ptr thisDocument = snapshot.document(declFile); Document::Ptr thisDocument = snapshot.document(declFile);
if (! thisDocument) { if (!thisDocument) {
qWarning() << "undefined document:" << declaration->fileName(); qWarning() << "undefined document:" << declaration->fileName();
return 0; return 0;
} }
Function *declarationTy = declaration->type()->asFunctionType(); Function *declarationTy = declaration->type()->asFunctionType();
if (! declarationTy) { if (!declarationTy) {
qWarning() << "not a function:" << declaration->fileName() qWarning() << "not a function:" << declaration->fileName()
<< declaration->line() << declaration->column(); << declaration->line() << declaration->column();
return 0; return 0;
@@ -126,7 +126,7 @@ Function *SymbolFinder::findMatchingDefinition(Symbol *declaration,
} }
const Identifier *id = declaration->identifier(); const Identifier *id = declaration->identifier();
if (id && ! doc->control()->findIdentifier(id->chars(), id->size())) if (id && !doc->control()->findIdentifier(id->chars(), id->size()))
continue; continue;
if (!id) { if (!id) {
@@ -143,13 +143,13 @@ Function *SymbolFinder::findMatchingDefinition(Symbol *declaration,
candidates.accept(doc->globalNamespace()); candidates.accept(doc->globalNamespace());
const QList<Function *> result = candidates.result(); const QList<Function *> result = candidates.result();
if (! result.isEmpty()) { if (!result.isEmpty()) {
LookupContext context(doc, snapshot); LookupContext context(doc, snapshot);
QList<Function *> viableFunctions; QList<Function *> viableFunctions;
ClassOrNamespace *enclosingType = context.lookupType(declaration); ClassOrNamespace *enclosingType = context.lookupType(declaration);
if (! enclosingType) if (!enclosingType)
continue; // nothing to do continue; // nothing to do
foreach (Function *fun, result) { foreach (Function *fun, result) {
@@ -168,16 +168,18 @@ Function *SymbolFinder::findMatchingDefinition(Symbol *declaration,
if (viableFunctions.isEmpty()) if (viableFunctions.isEmpty())
continue; continue;
else if (! strict && viableFunctions.length() == 1) else if (!strict && viableFunctions.length() == 1)
return viableFunctions.first(); return viableFunctions.first();
Function *best = 0; Function *best = 0;
foreach (Function *fun, viableFunctions) { foreach (Function *fun, viableFunctions) {
if (! (fun->unqualifiedName() && fun->unqualifiedName()->isEqualTo(declaration->unqualifiedName()))) if (!(fun->unqualifiedName()
&& fun->unqualifiedName()->isEqualTo(declaration->unqualifiedName()))) {
continue; continue;
}
if (fun->argumentCount() == declarationTy->argumentCount()) { if (fun->argumentCount() == declarationTy->argumentCount()) {
if (! strict && ! best) if (!strict && !best)
best = fun; best = fun;
const unsigned argc = declarationTy->argumentCount(); const unsigned argc = declarationTy->argumentCount();
@@ -185,7 +187,7 @@ Function *SymbolFinder::findMatchingDefinition(Symbol *declaration,
for (; argIt < argc; ++argIt) { for (; argIt < argc; ++argIt) {
Symbol *arg = fun->argumentAt(argIt); Symbol *arg = fun->argumentAt(argIt);
Symbol *otherArg = declarationTy->argumentAt(argIt); Symbol *otherArg = declarationTy->argumentAt(argIt);
if (! arg->type().isEqualTo(otherArg->type())) if (!arg->type().isEqualTo(otherArg->type()))
break; break;
} }
@@ -197,10 +199,10 @@ Function *SymbolFinder::findMatchingDefinition(Symbol *declaration,
} }
} }
if (strict && ! best) if (strict && !best)
continue; continue;
if (! best) if (!best)
best = viableFunctions.first(); best = viableFunctions.first();
return best; return best;
} }
@@ -211,7 +213,7 @@ Function *SymbolFinder::findMatchingDefinition(Symbol *declaration,
Class *SymbolFinder::findMatchingClassDeclaration(Symbol *declaration, const Snapshot &snapshot) Class *SymbolFinder::findMatchingClassDeclaration(Symbol *declaration, const Snapshot &snapshot)
{ {
if (! declaration->identifier()) if (!declaration->identifier())
return 0; return 0;
QString declFile = QString::fromUtf8(declaration->fileName(), declaration->fileNameLength()); QString declFile = QString::fromUtf8(declaration->fileName(), declaration->fileNameLength());
@@ -223,7 +225,7 @@ Class *SymbolFinder::findMatchingClassDeclaration(Symbol *declaration, const Sna
continue; continue;
} }
if (! doc->control()->findIdentifier(declaration->identifier()->chars(), if (!doc->control()->findIdentifier(declaration->identifier()->chars(),
declaration->identifier()->size())) declaration->identifier()->size()))
continue; continue;
@@ -252,12 +254,12 @@ void SymbolFinder::findMatchingDeclaration(const LookupContext &context,
return; return;
Scope *enclosingScope = functionType->enclosingScope(); Scope *enclosingScope = functionType->enclosingScope();
while (! (enclosingScope->isNamespace() || enclosingScope->isClass())) while (!(enclosingScope->isNamespace() || enclosingScope->isClass()))
enclosingScope = enclosingScope->enclosingScope(); enclosingScope = enclosingScope->enclosingScope();
QTC_ASSERT(enclosingScope != 0, return); QTC_ASSERT(enclosingScope != 0, return);
const Name *functionName = functionType->name(); const Name *functionName = functionType->name();
if (! functionName) if (!functionName)
return; // anonymous function names are not valid c++ return; // anonymous function names are not valid c++
ClassOrNamespace *binding = 0; ClassOrNamespace *binding = 0;
@@ -287,7 +289,7 @@ void SymbolFinder::findMatchingDeclaration(const LookupContext &context,
continue; continue;
for (Symbol *s = scope->find(funcId); s; s = s->next()) { for (Symbol *s = scope->find(funcId); s; s = s->next()) {
if (! s->name() || ! funcId->isEqualTo(s->identifier()) || ! s->type()->isFunctionType()) if (!s->name() || !funcId->isEqualTo(s->identifier()) || !s->type()->isFunctionType())
continue; continue;
if (Declaration *decl = s->asDeclaration()) { if (Declaration *decl = s->asDeclaration()) {
if (Function *declFunTy = decl->type()->asFunctionType()) { if (Function *declFunTy = decl->type()->asFunctionType()) {