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 <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2020-08-28 17:46:52 +02:00
parent 1652396ece
commit f1062f1366
2 changed files with 22 additions and 36 deletions

View File

@@ -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<const Name *>(id), scope);
}
void FindUsages::reportResult(unsigned tokenIndex, const QList<LookupItem> &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) {

View File

@@ -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<LookupItem> &candidates);
void reportResult(unsigned tokenIndex);
bool checkCandidates(const QList<LookupItem> &candidates) const;
void checkExpression(unsigned startToken, unsigned endToken, Scope *scope = nullptr);