CPlusPlus: Make Usage::Type QFlags-based

We want to extend the enum with more non-exclusive values.

Change-Id: I4d8ebe1f7327139c7817b9f621b4b74a883c5e09
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2022-11-02 12:16:38 +01:00
parent 0b1d265991
commit d891e18edc
7 changed files with 422 additions and 424 deletions

View File

@@ -17,18 +17,24 @@ namespace CPlusPlus {
class CPLUSPLUS_EXPORT Usage
{
public:
enum class Type { Declaration, Initialization, Read, Write, WritableRef, Other };
enum class Tag {
Declaration = 1 << 0,
Read = 1 << 1,
Write = 1 << 2,
WritableRef = 1 << 3,
};
using Tags = QFlags<Tag>;
Usage() = default;
Usage(const Utils::FilePath &path, const QString &lineText, const QString &func, Type t,
Usage(const Utils::FilePath &path, const QString &lineText, const QString &func, Tags t,
int line, int col, int len)
: path(path), lineText(lineText), containingFunction(func), type(t),
: path(path), lineText(lineText), containingFunction(func), tags(t),
line(line), col(col), len(len) {}
Utils::FilePath path;
QString lineText;
QString containingFunction;
Type type = Type::Other;
Tags tags;
int line = 0;
int col = 0;
int len = 0;
@@ -55,7 +61,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);
Usage::Tags getTags(int line, int column, int tokenIndex);
QString getContainingFunction(int line, int column);
bool checkCandidates(const QList<LookupItem> &candidates) const;
@@ -287,7 +293,7 @@ private:
TypeOfExpression typeofExpression;
Scope *_currentScope = nullptr;
const bool _categorize = false;
class GetUsageType;
class GetUsageTags;
};
} // namespace CPlusPlus