CPlusPlus: Categorize "Find Usages" results

That is, find out whether a certain access was a read, a write, a
declaration or something else, and report the result to upper layers.
Follow-up patches can make this information visible to users.

Task-number: QTCREATORBUG-12734
Task-number: QTCREATORBUG-19373
Change-Id: Iee79e39dd1eb5a986a7e27846991e0e01b2c3a2f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2020-08-28 14:07:16 +02:00
parent 0ceb9f487c
commit 45dd074441
4 changed files with 569 additions and 16 deletions

View File

@@ -39,13 +39,15 @@ namespace CPlusPlus {
class CPLUSPLUS_EXPORT Usage
{
public:
Usage() = default;
Usage(const Utils::FilePath &path, const QString &lineText, int line, int col, int len)
: path(path), lineText(lineText), line(line), col(col), len(len) {}
enum class Type { Declaration, Read, Write, WritableRef, Other };
Usage() = default;
Usage(const Utils::FilePath &path, const QString &lineText, Type t, int line, int col, int len)
: path(path), lineText(lineText), type(t), line(line), col(col), len(len) {}
public:
Utils::FilePath path;
QString lineText;
Type type = Type::Other;
int line = 0;
int col = 0;
int len = 0;
@@ -71,6 +73,7 @@ protected:
void reportResult(unsigned tokenIndex, const Name *name, Scope *scope = nullptr);
void reportResult(unsigned tokenIndex, const QList<LookupItem> &candidates);
Usage::Type getType(int line, int column, int tokenIndex);
bool checkCandidates(const QList<LookupItem> &candidates) const;
void checkExpression(unsigned startToken, unsigned endToken, Scope *scope = nullptr);