forked from qt-creator/qt-creator
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:
@@ -111,49 +111,17 @@ void FindUsages::reportResult(unsigned tokenIndex, const Name *name, Scope *scop
|
|||||||
reportResult(tokenIndex, candidates);
|
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)
|
void FindUsages::reportResult(unsigned tokenIndex, const QList<LookupItem> &candidates)
|
||||||
{
|
{
|
||||||
if (_processed.contains(tokenIndex))
|
if (_processed.contains(tokenIndex))
|
||||||
return;
|
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);
|
const Token &tk = tokenAt(tokenIndex);
|
||||||
if (tk.generated())
|
if (tk.generated())
|
||||||
return;
|
return;
|
||||||
else if (_processed.contains(tokenIndex))
|
|
||||||
return;
|
|
||||||
|
|
||||||
_processed.insert(tokenIndex);
|
_processed.insert(tokenIndex);
|
||||||
|
|
||||||
@@ -175,6 +143,26 @@ void FindUsages::reportResult(unsigned tokenIndex)
|
|||||||
_references.append(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)
|
bool FindUsages::isLocalScope(Scope *scope)
|
||||||
{
|
{
|
||||||
if (scope) {
|
if (scope) {
|
||||||
|
@@ -70,9 +70,7 @@ protected:
|
|||||||
QString matchingLine(const Token &tk) const;
|
QString matchingLine(const Token &tk) const;
|
||||||
|
|
||||||
void reportResult(unsigned tokenIndex, const Name *name, Scope *scope = nullptr);
|
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, const QList<LookupItem> &candidates);
|
||||||
void reportResult(unsigned tokenIndex);
|
|
||||||
|
|
||||||
bool checkCandidates(const QList<LookupItem> &candidates) const;
|
bool checkCandidates(const QList<LookupItem> &candidates) const;
|
||||||
void checkExpression(unsigned startToken, unsigned endToken, Scope *scope = nullptr);
|
void checkExpression(unsigned startToken, unsigned endToken, Scope *scope = nullptr);
|
||||||
|
Reference in New Issue
Block a user