diff --git a/src/libs/cplusplus/FindUsages.cpp b/src/libs/cplusplus/FindUsages.cpp index 9dac6cd9183..8b976d95326 100644 --- a/src/libs/cplusplus/FindUsages.cpp +++ b/src/libs/cplusplus/FindUsages.cpp @@ -111,49 +111,17 @@ void FindUsages::reportResult(unsigned tokenIndex, const Name *name, Scope *scop reportResult(tokenIndex, candidates); } -void FindUsages::reportResult(unsigned tokenIndex, const Identifier *id, Scope *scope) -{ - reportResult(tokenIndex, static_cast(id), scope); -} - void FindUsages::reportResult(unsigned tokenIndex, const QList &candidates) { if (_processed.contains(tokenIndex)) return; - const bool isStrongResult = checkCandidates(candidates); + if (!checkCandidates(candidates)) + return; - if (isStrongResult) - reportResult(tokenIndex); -} - -QString FindUsages::matchingLine(const Token &tk) const -{ - const char *beg = _source.constData(); - const char *cp = beg + tk.bytesBegin(); - for (; cp != beg - 1; --cp) { - if (*cp == '\n') - break; - } - - ++cp; - - const char *lineEnd = cp + 1; - for (; *lineEnd; ++lineEnd) { - if (*lineEnd == '\n') - break; - } - - return QString::fromUtf8(cp, lineEnd - cp); -} - -void FindUsages::reportResult(unsigned tokenIndex) -{ const Token &tk = tokenAt(tokenIndex); if (tk.generated()) return; - else if (_processed.contains(tokenIndex)) - return; _processed.insert(tokenIndex); @@ -175,6 +143,26 @@ void FindUsages::reportResult(unsigned tokenIndex) _references.append(tokenIndex); } +QString FindUsages::matchingLine(const Token &tk) const +{ + const char *beg = _source.constData(); + const char *cp = beg + tk.bytesBegin(); + for (; cp != beg - 1; --cp) { + if (*cp == '\n') + break; + } + + ++cp; + + const char *lineEnd = cp + 1; + for (; *lineEnd; ++lineEnd) { + if (*lineEnd == '\n') + break; + } + + return QString::fromUtf8(cp, lineEnd - cp); +} + bool FindUsages::isLocalScope(Scope *scope) { if (scope) { diff --git a/src/libs/cplusplus/FindUsages.h b/src/libs/cplusplus/FindUsages.h index 011bdd677eb..e0b37b12a89 100644 --- a/src/libs/cplusplus/FindUsages.h +++ b/src/libs/cplusplus/FindUsages.h @@ -70,9 +70,7 @@ protected: QString matchingLine(const Token &tk) const; void reportResult(unsigned tokenIndex, const Name *name, Scope *scope = nullptr); - void reportResult(unsigned tokenIndex, const Identifier *id, Scope *scope = nullptr); void reportResult(unsigned tokenIndex, const QList &candidates); - void reportResult(unsigned tokenIndex); bool checkCandidates(const QList &candidates) const; void checkExpression(unsigned startToken, unsigned endToken, Scope *scope = nullptr);