From f1062f1366c8d0ccf4e8a1c1498e90c7e6f1a846 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Fri, 28 Aug 2020 17:46:52 +0200 Subject: [PATCH] CPlusPlus: Dissolve some overloads of FindUsages::reportResult() These overloads did not add any value, but were just confusing. Change-Id: Icf3f69a30e2fccc4a4695e79bcf32457b2fb481b Reviewed-by: Christian Stenger --- src/libs/cplusplus/FindUsages.cpp | 56 ++++++++++++------------------- src/libs/cplusplus/FindUsages.h | 2 -- 2 files changed, 22 insertions(+), 36 deletions(-) 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);