forked from qt-creator/qt-creator
CppTools: Simplify
Change-Id: Id10cbcf541d8105265c531e63a64e2fd34e27379 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -461,11 +461,7 @@ Scope *CheckSymbols::enclosingScope() const
|
|||||||
bool CheckSymbols::preVisit(AST *ast)
|
bool CheckSymbols::preVisit(AST *ast)
|
||||||
{
|
{
|
||||||
_astStack.append(ast);
|
_astStack.append(ast);
|
||||||
|
return !isCanceled();
|
||||||
if (isCanceled())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckSymbols::postVisit(AST *)
|
void CheckSymbols::postVisit(AST *)
|
||||||
@@ -1256,13 +1252,12 @@ bool CheckSymbols::maybeAddTypeOrStatic(const QList<LookupItem> &candidates, Nam
|
|||||||
Symbol *c = r.declaration();
|
Symbol *c = r.declaration();
|
||||||
if (c->isUsingDeclaration()) // skip using declarations...
|
if (c->isUsingDeclaration()) // skip using declarations...
|
||||||
continue;
|
continue;
|
||||||
else if (c->isUsingNamespaceDirective()) // ... and using namespace directives.
|
if (c->isUsingNamespaceDirective()) // ... and using namespace directives.
|
||||||
continue;
|
continue;
|
||||||
else if (c->isTypedef() || c->isNamespace() ||
|
if (c->isTypedef() || c->isNamespace() ||
|
||||||
c->isStatic() || //consider also static variable
|
c->isStatic() || //consider also static variable
|
||||||
c->isClass() || c->isEnum() || isTemplateClass(c) ||
|
c->isClass() || c->isEnum() || isTemplateClass(c) ||
|
||||||
c->isForwardClassDeclaration() || c->isTypenameArgument() || c->enclosingEnum() != nullptr) {
|
c->isForwardClassDeclaration() || c->isTypenameArgument() || c->enclosingEnum()) {
|
||||||
|
|
||||||
int line, column;
|
int line, column;
|
||||||
getTokenStartPosition(startToken, &line, &column);
|
getTokenStartPosition(startToken, &line, &column);
|
||||||
const unsigned length = tok.utf16chars();
|
const unsigned length = tok.utf16chars();
|
||||||
@@ -1298,11 +1293,11 @@ bool CheckSymbols::maybeAddField(const QList<LookupItem> &candidates, NameAST *a
|
|||||||
Symbol *c = r.declaration();
|
Symbol *c = r.declaration();
|
||||||
if (!c)
|
if (!c)
|
||||||
continue;
|
continue;
|
||||||
else if (!c->isDeclaration())
|
if (!c->isDeclaration())
|
||||||
return false;
|
return false;
|
||||||
else if (!(c->enclosingScope() && c->enclosingScope()->isClass()))
|
if (!(c->enclosingScope() && c->enclosingScope()->isClass()))
|
||||||
return false; // shadowed
|
return false; // shadowed
|
||||||
else if (c->isTypedef() || (c->type() && c->type()->isFunctionType()))
|
if (c->isTypedef() || (c->type() && c->type()->isFunctionType()))
|
||||||
return false; // shadowed
|
return false; // shadowed
|
||||||
|
|
||||||
int line, column;
|
int line, column;
|
||||||
|
@@ -179,8 +179,8 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
|
|||||||
switch (kind) {
|
switch (kind) {
|
||||||
case T_LBRACE: enter(brace_list_open); break;
|
case T_LBRACE: enter(brace_list_open); break;
|
||||||
case T_RBRACE: leave(true); continue;
|
case T_RBRACE: leave(true); continue;
|
||||||
case T_SEMICOLON: leave(); continue;
|
case T_SEMICOLON:
|
||||||
case T_RPAREN: leave(); continue;
|
case T_RPAREN:
|
||||||
case T_COMMA: leave(); continue;
|
case T_COMMA: leave(); continue;
|
||||||
default: enter(assign_open); continue;
|
default: enter(assign_open); continue;
|
||||||
} break;
|
} break;
|
||||||
@@ -205,8 +205,8 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
|
|||||||
case assign_open:
|
case assign_open:
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case T_RBRACE: leave(true); continue;
|
case T_RBRACE: leave(true); continue;
|
||||||
case T_SEMICOLON: leave(); continue;
|
case T_SEMICOLON:
|
||||||
case T_RPAREN: leave(); continue;
|
case T_RPAREN:
|
||||||
case T_COMMA: leave(); continue;
|
case T_COMMA: leave(); continue;
|
||||||
default: tryExpression(); break;
|
default: tryExpression(); break;
|
||||||
} break;
|
} break;
|
||||||
|
@@ -51,9 +51,7 @@ bool CppCompletionAssistProvider::isActivationCharSequence(const QString &sequen
|
|||||||
const QChar &ch = sequence.at(2);
|
const QChar &ch = sequence.at(2);
|
||||||
const QChar &ch2 = sequence.at(1);
|
const QChar &ch2 = sequence.at(1);
|
||||||
const QChar &ch3 = sequence.at(0);
|
const QChar &ch3 = sequence.at(0);
|
||||||
if (activationSequenceChar(ch, ch2, ch3, nullptr, true, false) != 0)
|
return activationSequenceChar(ch, ch2, ch3, nullptr, true, false);
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CppCompletionAssistProvider::isContinuationChar(const QChar &c) const
|
bool CppCompletionAssistProvider::isContinuationChar(const QChar &c) const
|
||||||
|
@@ -374,7 +374,7 @@ Symbol *findDefinition(Symbol *symbol, const Snapshot &snapshot, SymbolFinder *s
|
|||||||
if (symbol->isFunction())
|
if (symbol->isFunction())
|
||||||
return nullptr; // symbol is a function definition.
|
return nullptr; // symbol is a function definition.
|
||||||
|
|
||||||
else if (!symbol->type()->isFunctionType())
|
if (!symbol->type()->isFunctionType())
|
||||||
return nullptr; // not a function declaration
|
return nullptr; // not a function declaration
|
||||||
|
|
||||||
return symbolFinder->findMatchingDefinition(symbol, snapshot);
|
return symbolFinder->findMatchingDefinition(symbol, snapshot);
|
||||||
|
@@ -172,10 +172,7 @@ bool CppRefactoringFile::isCursorOn(unsigned tokenIndex) const
|
|||||||
int start = startOf(tokenIndex);
|
int start = startOf(tokenIndex);
|
||||||
int end = endOf(tokenIndex);
|
int end = endOf(tokenIndex);
|
||||||
|
|
||||||
if (cursorBegin >= start && cursorBegin <= end)
|
return cursorBegin >= start && cursorBegin <= end;
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CppRefactoringFile::isCursorOn(const AST *ast) const
|
bool CppRefactoringFile::isCursorOn(const AST *ast) const
|
||||||
@@ -186,10 +183,7 @@ bool CppRefactoringFile::isCursorOn(const AST *ast) const
|
|||||||
int start = startOf(ast);
|
int start = startOf(ast);
|
||||||
int end = endOf(ast);
|
int end = endOf(ast);
|
||||||
|
|
||||||
if (cursorBegin >= start && cursorBegin <= end)
|
return cursorBegin >= start && cursorBegin <= end;
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::ChangeSet::Range CppRefactoringFile::range(unsigned tokenIndex) const
|
Utils::ChangeSet::Range CppRefactoringFile::range(unsigned tokenIndex) const
|
||||||
|
@@ -87,7 +87,7 @@ void SemanticHighlighter::onHighlighterResultAvailable(int from, int to)
|
|||||||
{
|
{
|
||||||
if (documentRevision() != m_revision)
|
if (documentRevision() != m_revision)
|
||||||
return; // outdated
|
return; // outdated
|
||||||
else if (!m_watcher || m_watcher->isCanceled())
|
if (!m_watcher || m_watcher->isCanceled())
|
||||||
return; // aborted
|
return; // aborted
|
||||||
|
|
||||||
qCDebug(log) << "onHighlighterResultAvailable()" << from << to;
|
qCDebug(log) << "onHighlighterResultAvailable()" << from << to;
|
||||||
|
Reference in New Issue
Block a user