forked from qt-creator/qt-creator
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:
@@ -119,7 +119,7 @@ void FindUsages::reportResult(unsigned tokenIndex, const QList<LookupItem> &cand
|
||||
const int len = tk.utf16chars();
|
||||
|
||||
const Usage u(Utils::FilePath::fromString(_doc->fileName()), lineText,
|
||||
getContainingFunction(line, col), getType(line, col, tokenIndex),
|
||||
getContainingFunction(line, col), getTags(line, col, tokenIndex),
|
||||
line, col - 1, len);
|
||||
_usages.append(u);
|
||||
_references.append(tokenIndex);
|
||||
@@ -143,86 +143,86 @@ QString FindUsages::getContainingFunction(int line, int column)
|
||||
return {};
|
||||
}
|
||||
|
||||
class FindUsages::GetUsageType
|
||||
class FindUsages::GetUsageTags
|
||||
{
|
||||
public:
|
||||
GetUsageType(FindUsages *findUsages, const QList<AST *> &astPath, int tokenIndex)
|
||||
GetUsageTags(FindUsages *findUsages, const QList<AST *> &astPath, int tokenIndex)
|
||||
: m_findUsages(findUsages), m_astPath(astPath), m_tokenIndex(tokenIndex)
|
||||
{
|
||||
}
|
||||
|
||||
Usage::Type getUsageType() const
|
||||
Usage::Tags getTags() const
|
||||
{
|
||||
if (m_astPath.size() < 2 || !m_astPath.last()->asSimpleName())
|
||||
return Usage::Type::Other;
|
||||
return {};
|
||||
|
||||
for (auto it = m_astPath.rbegin() + 1; it != m_astPath.rend(); ++it) {
|
||||
if ((*it)->asExpressionStatement())
|
||||
return Usage::Type::Read;
|
||||
return Usage::Tag::Read;
|
||||
if ((*it)->asSwitchStatement())
|
||||
return Usage::Type::Read;
|
||||
return Usage::Tag::Read;
|
||||
if ((*it)->asCaseStatement())
|
||||
return Usage::Type::Read;
|
||||
return Usage::Tag::Read;
|
||||
if ((*it)->asIfStatement())
|
||||
return Usage::Type::Read;
|
||||
return Usage::Tag::Read;
|
||||
if ((*it)->asLambdaCapture())
|
||||
return Usage::Type::Other;
|
||||
return {};
|
||||
if ((*it)->asTypenameTypeParameter())
|
||||
return Usage::Type::Declaration;
|
||||
return Usage::Tag::Declaration;
|
||||
if ((*it)->asNewExpression())
|
||||
return Usage::Type::Other;
|
||||
return {};
|
||||
if (ClassSpecifierAST *classSpec = (*it)->asClassSpecifier()) {
|
||||
if (classSpec->name == *(it - 1))
|
||||
return Usage::Type::Declaration;
|
||||
return Usage::Tag::Declaration;
|
||||
continue;
|
||||
}
|
||||
if (const auto memInitAst = (*it)->asMemInitializer()) {
|
||||
if (memInitAst->name == *(it - 1))
|
||||
return Usage::Type::Write;
|
||||
return Usage::Type::Read;
|
||||
return Usage::Tag::Write;
|
||||
return Usage::Tag::Read;
|
||||
}
|
||||
if ((*it)->asCall())
|
||||
return checkPotentialWrite(getUsageTypeForCall(it), it + 1);
|
||||
return checkPotentialWrite(getTagsForCall(it), it + 1);
|
||||
if ((*it)->asDeleteExpression())
|
||||
return Usage::Type::Write;
|
||||
return Usage::Tag::Write;
|
||||
if (const auto binExpr = (*it)->asBinaryExpression()) {
|
||||
if (binExpr->left_expression == *(it - 1) && isAssignment(binExpr->binary_op_token))
|
||||
return checkPotentialWrite(Usage::Type::Write, it + 1);
|
||||
return checkPotentialWrite(Usage::Tag::Write, it + 1);
|
||||
const std::optional<LookupItem> item = getTypeOfExpr(binExpr->left_expression,
|
||||
it + 1);
|
||||
if (!item)
|
||||
return Usage::Type::Other;
|
||||
return checkPotentialWrite(getUsageTypeFromLhsAndRhs(
|
||||
return {};
|
||||
return checkPotentialWrite(getTagsFromLhsAndRhs(
|
||||
item->type(), binExpr->right_expression, it),
|
||||
it + 1);
|
||||
}
|
||||
if (const auto unaryOp = (*it)->asUnaryExpression()) {
|
||||
switch (m_findUsages->tokenKind(unaryOp->unary_op_token)) {
|
||||
case T_PLUS_PLUS: case T_MINUS_MINUS:
|
||||
return checkPotentialWrite(Usage::Type::Write, it + 1);
|
||||
return checkPotentialWrite(Usage::Tag::Write, it + 1);
|
||||
case T_AMPER: case T_STAR:
|
||||
continue;
|
||||
default:
|
||||
return Usage::Type::Read;
|
||||
return Usage::Tag::Read;
|
||||
}
|
||||
}
|
||||
if (const auto sizeofExpr = (*it)->asSizeofExpression()) {
|
||||
if (containsToken(sizeofExpr->expression))
|
||||
return Usage::Type::Read;
|
||||
return Usage::Type::Other;
|
||||
return Usage::Tag::Read;
|
||||
return {};
|
||||
}
|
||||
if (const auto arrayExpr = (*it)->asArrayAccess()) {
|
||||
if (containsToken(arrayExpr->expression))
|
||||
return Usage::Type::Read;
|
||||
return Usage::Tag::Read;
|
||||
continue;
|
||||
}
|
||||
if (const auto postIncrDecrOp = (*it)->asPostIncrDecr())
|
||||
return checkPotentialWrite(Usage::Type::Write, it + 1);
|
||||
return checkPotentialWrite(Usage::Tag::Write, it + 1);
|
||||
if (const auto declaratorId = (*it)->asDeclaratorId()) {
|
||||
// We don't want to classify constructors and destructors as declarations
|
||||
// when listing class usages.
|
||||
if (m_findUsages->_declSymbol->asClass())
|
||||
return Usage::Type::Other;
|
||||
return {};
|
||||
continue;
|
||||
}
|
||||
if (const auto declarator = (*it)->asDeclarator()) {
|
||||
@@ -231,36 +231,36 @@ public:
|
||||
&& (!declarator->postfix_declarator_list
|
||||
|| !declarator->postfix_declarator_list->value
|
||||
|| !declarator->postfix_declarator_list->value->asFunctionDeclarator())) {
|
||||
return Usage::Type::Initialization;
|
||||
return {Usage::Tag::Declaration, Usage::Tag::Write};
|
||||
}
|
||||
return Usage::Type::Declaration;
|
||||
return Usage::Tag::Declaration;
|
||||
}
|
||||
if (const auto decl = (*(it + 1))->asSimpleDeclaration()) {
|
||||
if (decl->symbols && decl->symbols->value) {
|
||||
return checkPotentialWrite(
|
||||
getUsageTypeFromLhsAndRhs(decl->symbols->value->type(),
|
||||
getTagsFromLhsAndRhs(decl->symbols->value->type(),
|
||||
declarator->initializer, it + 1),
|
||||
it + 1);
|
||||
}
|
||||
}
|
||||
return Usage::Type::Other;
|
||||
return {};
|
||||
}
|
||||
if (const auto retStmt = (*it)->asReturnStatement()) {
|
||||
for (auto funcIt = it + 1; funcIt != m_astPath.rend(); ++funcIt) {
|
||||
if (FunctionDefinitionAST * const funcAst = (*funcIt)->asFunctionDefinition()) {
|
||||
if (funcAst->symbol) {
|
||||
return checkPotentialWrite(
|
||||
getUsageTypeFromLhsAndRhs(funcAst->symbol->type(),
|
||||
getTagsFromLhsAndRhs(funcAst->symbol->type(),
|
||||
retStmt->expression, funcIt),
|
||||
funcIt + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Usage::Type::Other;
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
return Usage::Type::Other;
|
||||
return {};
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -286,27 +286,27 @@ private:
|
||||
// This is called for the type of the LHS of an (initialization) assignment.
|
||||
// We consider the RHS to be writable through the LHS if the LHS is a pointer
|
||||
// that is non-const at any element level, or if it is a a non-const reference.
|
||||
static Usage::Type getUsageTypeFromDataType(FullySpecifiedType type)
|
||||
static Usage::Tags getTagsFromDataType(FullySpecifiedType type)
|
||||
{
|
||||
if (type.isAuto())
|
||||
return Usage::Type::Other;
|
||||
return {};
|
||||
if (const auto refType = type->asReferenceType())
|
||||
return refType->elementType().isConst() ? Usage::Type::Read : Usage::Type::WritableRef;
|
||||
return refType->elementType().isConst() ? Usage::Tag::Read : Usage::Tag::WritableRef;
|
||||
while (type->asPointerType()) {
|
||||
type = type->asPointerType()->elementType();
|
||||
if (!type.isConst())
|
||||
return Usage::Type::WritableRef;
|
||||
return Usage::Tag::WritableRef;
|
||||
}
|
||||
return Usage::Type::Read;
|
||||
return Usage::Tag::Read;
|
||||
}
|
||||
|
||||
// If we found a potential write access inside a lambda, we have to check whether the variable
|
||||
// was captured by value. If so, it's not really a write access.
|
||||
// FIXME: The parser does not record whether the capture was by reference.
|
||||
Usage::Type checkPotentialWrite(Usage::Type usageType, Iterator startIt) const
|
||||
Usage::Tags checkPotentialWrite(Usage::Tags tags, Iterator startIt) const
|
||||
{
|
||||
if (usageType != Usage::Type::Write && usageType != Usage::Type::WritableRef)
|
||||
return usageType;
|
||||
if (tags != Usage::Tag::Write && tags != Usage::Tag::WritableRef)
|
||||
return tags;
|
||||
for (auto it = startIt; it != m_astPath.rend(); ++it) {
|
||||
if ((*it)->firstToken() > m_tokenIndex)
|
||||
break;
|
||||
@@ -324,10 +324,10 @@ private:
|
||||
capList->value->identifier->name)) {
|
||||
continue;
|
||||
}
|
||||
return capList->value->amper_token ? usageType : Usage::Type::Read;
|
||||
return capList->value->amper_token ? tags : Usage::Tag::Read;
|
||||
}
|
||||
}
|
||||
return usageType;
|
||||
return tags;
|
||||
}
|
||||
|
||||
const QList<LookupItem> getTypesOfExpr(ExpressionAST *expr, Iterator scopeSearchPos) const
|
||||
@@ -356,21 +356,21 @@ private:
|
||||
return std::optional<LookupItem>(items.first());
|
||||
}
|
||||
|
||||
Usage::Type getUsageTypeFromLhsAndRhs(const FullySpecifiedType &lhsType, ExpressionAST *rhs,
|
||||
Usage::Tags getTagsFromLhsAndRhs(const FullySpecifiedType &lhsType, ExpressionAST *rhs,
|
||||
Iterator scopeSearchPos) const
|
||||
{
|
||||
const Usage::Type usageType = getUsageTypeFromDataType(lhsType);
|
||||
if (usageType != Usage::Type::Other)
|
||||
return usageType;
|
||||
const Usage::Tags tags = getTagsFromDataType(lhsType);
|
||||
if (tags.toInt())
|
||||
return tags;
|
||||
|
||||
// If the lhs has type auto, we use the RHS type.
|
||||
const std::optional<LookupItem> item = getTypeOfExpr(rhs, scopeSearchPos);
|
||||
if (!item)
|
||||
return Usage::Type::Other;
|
||||
return getUsageTypeFromDataType(item->type());
|
||||
return {};
|
||||
return getTagsFromDataType(item->type());
|
||||
}
|
||||
|
||||
Usage::Type getUsageTypeForCall(Iterator callIt) const
|
||||
Usage::Tags getTagsForCall(Iterator callIt) const
|
||||
{
|
||||
CallAST * const call = (*callIt)->asCall();
|
||||
|
||||
@@ -383,11 +383,11 @@ private:
|
||||
if (!memberAccess || !memberAccess->member_name || !memberAccess->member_name->name)
|
||||
continue;
|
||||
if (memberAccess->member_name == *(it - 1))
|
||||
return Usage::Type::Other;
|
||||
return {};
|
||||
const std::optional<LookupItem> item = getTypeOfExpr(memberAccess->base_expression,
|
||||
it);
|
||||
if (!item)
|
||||
return Usage::Type::Other;
|
||||
return {};
|
||||
FullySpecifiedType baseExprType = item->type();
|
||||
if (const auto refType = baseExprType->asReferenceType())
|
||||
baseExprType = refType->elementType();
|
||||
@@ -406,21 +406,21 @@ private:
|
||||
}
|
||||
}
|
||||
if (!klass)
|
||||
return Usage::Type::Other;
|
||||
return {};
|
||||
items = context.lookup(memberAccess->member_name->name, klass);
|
||||
if (items.isEmpty())
|
||||
return Usage::Type::Other;
|
||||
return {};
|
||||
for (const LookupItem &item : std::as_const(items)) {
|
||||
if (item.type()->asFunctionType()) {
|
||||
if (item.type().isConst())
|
||||
return Usage::Type::Read;
|
||||
return Usage::Tag::Read;
|
||||
if (item.type().isStatic())
|
||||
return Usage::Type::Other;
|
||||
return Usage::Type::WritableRef;
|
||||
return {};
|
||||
return Usage::Tag::WritableRef;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Usage::Type::Other;
|
||||
return {};
|
||||
}
|
||||
|
||||
// Check whether our symbol is passed as an argument to the function.
|
||||
@@ -433,27 +433,27 @@ private:
|
||||
match = argList->value == *(callIt - 1);
|
||||
}
|
||||
if (!match)
|
||||
return Usage::Type::Other;
|
||||
return {};
|
||||
|
||||
// If we find more than one overload with a matching number of arguments,
|
||||
// and they have conflicting usage types, then we give up and report Type::Other.
|
||||
// We could do better by trying to match the types manually and finding out
|
||||
// which overload is the right one, but that would be an inordinate amount
|
||||
// of effort and we'd still have no guarantee that the result is correct.
|
||||
Usage::Type currentType = Usage::Type::Other;
|
||||
Usage::Tags currentTags;
|
||||
for (const LookupItem &item : getTypesOfExpr(call->base_expression, callIt + 1)) {
|
||||
Function * const func = item.type()->asFunctionType();
|
||||
if (!func || func->argumentCount() <= argPos)
|
||||
continue;
|
||||
const Usage::Type newType = getUsageTypeFromLhsAndRhs(
|
||||
const Usage::Tags newTags = getTagsFromLhsAndRhs(
|
||||
func->argumentAt(argPos)->type(), (*(callIt - 1))->asExpression(), callIt);
|
||||
if (newType != Usage::Type::Other && newType != currentType) {
|
||||
if (currentType != Usage::Type::Other)
|
||||
return Usage::Type::Other;
|
||||
currentType = newType;
|
||||
if (newTags.toInt() && newTags != currentTags) {
|
||||
if (currentTags.toInt())
|
||||
return {};
|
||||
currentTags = newTags;
|
||||
}
|
||||
}
|
||||
return currentType;
|
||||
return currentTags;
|
||||
}
|
||||
|
||||
FindUsages * const m_findUsages;
|
||||
@@ -461,11 +461,11 @@ private:
|
||||
const int m_tokenIndex;
|
||||
};
|
||||
|
||||
Usage::Type FindUsages::getType(int line, int column, int tokenIndex)
|
||||
Usage::Tags FindUsages::getTags(int line, int column, int tokenIndex)
|
||||
{
|
||||
if (!_categorize)
|
||||
return Usage::Type::Other;
|
||||
return GetUsageType(this, ASTPath(_doc)(line, column), tokenIndex).getUsageType();
|
||||
return {};
|
||||
return GetUsageTags(this, ASTPath(_doc)(line, column), tokenIndex).getTags();
|
||||
}
|
||||
|
||||
QString FindUsages::matchingLine(const Token &tk) const
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -286,7 +286,7 @@ void ClangdFindReferences::Private::reportAllSearchResultsAndFinish()
|
||||
finishSearch();
|
||||
}
|
||||
|
||||
static Usage::Type getUsageType(const ClangdAstPath &path);
|
||||
static Usage::Tags getUsageType(const ClangdAstPath &path);
|
||||
|
||||
void ClangdFindReferences::Private::addSearchResultsForFile(const FilePath &file,
|
||||
const ReferencesFileData &fileData)
|
||||
@@ -296,11 +296,11 @@ void ClangdFindReferences::Private::addSearchResultsForFile(const FilePath &file
|
||||
for (const auto &rangeWithText : fileData.rangesAndLineText) {
|
||||
const Range &range = rangeWithText.first;
|
||||
const ClangdAstPath astPath = getAstPath(fileData.ast, range);
|
||||
const Usage::Type usageType = fileData.ast.isValid() ? getUsageType(astPath)
|
||||
: Usage::Type::Other;
|
||||
const Usage::Tags usageType = fileData.ast.isValid() ? getUsageType(astPath)
|
||||
: Usage::Tags();
|
||||
|
||||
SearchResultItem item;
|
||||
item.setUserData(int(usageType));
|
||||
item.setUserData(usageType.toInt());
|
||||
item.setStyle(CppEditor::colorStyleForUsageType(usageType));
|
||||
item.setFilePath(file);
|
||||
item.setMainRange(SymbolSupport::convertRange(range));
|
||||
@@ -349,7 +349,7 @@ std::optional<QString> ClangdFindReferences::Private::getContainingFunctionName(
|
||||
return containingFuncNode->detail();
|
||||
}
|
||||
|
||||
static Usage::Type getUsageType(const ClangdAstPath &path)
|
||||
static Usage::Tags getUsageType(const ClangdAstPath &path)
|
||||
{
|
||||
bool potentialWrite = false;
|
||||
bool isFunction = false;
|
||||
@@ -357,24 +357,24 @@ static Usage::Type getUsageType(const ClangdAstPath &path)
|
||||
const auto isPotentialWrite = [&] { return potentialWrite && !isFunction; };
|
||||
for (auto pathIt = path.rbegin(); pathIt != path.rend(); ++pathIt) {
|
||||
if (pathIt->arcanaContains("non_odr_use_unevaluated"))
|
||||
return Usage::Type::Other;
|
||||
return {};
|
||||
if (pathIt->kind() == "CXXDelete")
|
||||
return Usage::Type::Write;
|
||||
return Usage::Tag::Write;
|
||||
if (pathIt->kind() == "CXXNew")
|
||||
return Usage::Type::Other;
|
||||
return {};
|
||||
if (pathIt->kind() == "Switch" || pathIt->kind() == "If")
|
||||
return Usage::Type::Read;
|
||||
return Usage::Tag::Read;
|
||||
if (pathIt->kind() == "Call")
|
||||
return isFunction ? Usage::Type::Other
|
||||
: potentialWrite ? Usage::Type::WritableRef : Usage::Type::Read;
|
||||
return isFunction ? Usage::Tags()
|
||||
: potentialWrite ? Usage::Tag::WritableRef : Usage::Tag::Read;
|
||||
if (pathIt->kind() == "CXXMemberCall") {
|
||||
const auto children = pathIt->children();
|
||||
if (children && children->size() == 1
|
||||
&& children->first() == path.last()
|
||||
&& children->first().arcanaContains("bound member function")) {
|
||||
return Usage::Type::Other;
|
||||
return {};
|
||||
}
|
||||
return isPotentialWrite() ? Usage::Type::WritableRef : Usage::Type::Read;
|
||||
return isPotentialWrite() ? Usage::Tag::WritableRef : Usage::Tag::Read;
|
||||
}
|
||||
if ((pathIt->kind() == "DeclRef" || pathIt->kind() == "Member")
|
||||
&& pathIt->arcanaContains("lvalue")) {
|
||||
@@ -385,25 +385,25 @@ static Usage::Type getUsageType(const ClangdAstPath &path)
|
||||
}
|
||||
if (pathIt->role() == "declaration") {
|
||||
if (symbolIsDataType)
|
||||
return Usage::Type::Other;
|
||||
return {};
|
||||
if (pathIt->arcanaContains("cinit")) {
|
||||
if (pathIt == path.rbegin())
|
||||
return Usage::Type::Initialization;
|
||||
return {Usage::Tag::Declaration, Usage::Tag::Write};
|
||||
if (pathIt->childContainsRange(0, path.last().range()))
|
||||
return Usage::Type::Initialization;
|
||||
return {Usage::Tag::Declaration, Usage::Tag::Write};
|
||||
if (isFunction)
|
||||
return Usage::Type::Read;
|
||||
return Usage::Tag::Read;
|
||||
if (!pathIt->hasConstType())
|
||||
return Usage::Type::WritableRef;
|
||||
return Usage::Type::Read;
|
||||
return Usage::Tag::WritableRef;
|
||||
return Usage::Tag::Read;
|
||||
}
|
||||
return Usage::Type::Declaration;
|
||||
return Usage::Tag::Declaration;
|
||||
}
|
||||
if (pathIt->kind() == "MemberInitializer")
|
||||
return pathIt == path.rbegin() ? Usage::Type::Write : Usage::Type::Read;
|
||||
return pathIt == path.rbegin() ? Usage::Tag::Write : Usage::Tag::Read;
|
||||
if (pathIt->kind() == "UnaryOperator"
|
||||
&& (pathIt->detailIs("++") || pathIt->detailIs("--"))) {
|
||||
return Usage::Type::Write;
|
||||
return Usage::Tag::Write;
|
||||
}
|
||||
|
||||
// LLVM uses BinaryOperator only for built-in types; for classes, CXXOperatorCall
|
||||
@@ -413,29 +413,29 @@ static Usage::Type getUsageType(const ClangdAstPath &path)
|
||||
const bool isOpCall = pathIt->kind() == "CXXOperatorCall";
|
||||
if (isBinaryOp || isOpCall) {
|
||||
if (isOpCall && symbolIsDataType) // Constructor invocation.
|
||||
return Usage::Type::Other;
|
||||
return {};
|
||||
|
||||
const QString op = pathIt->operatorString();
|
||||
if (op.endsWith("=") && op != "==") { // Assignment.
|
||||
const int lhsIndex = isBinaryOp ? 0 : 1;
|
||||
if (pathIt->childContainsRange(lhsIndex, path.last().range()))
|
||||
return Usage::Type::Write;
|
||||
return isPotentialWrite() ? Usage::Type::WritableRef : Usage::Type::Read;
|
||||
return Usage::Tag::Write;
|
||||
return isPotentialWrite() ? Usage::Tag::WritableRef : Usage::Tag::Read;
|
||||
}
|
||||
return Usage::Type::Read;
|
||||
return Usage::Tag::Read;
|
||||
}
|
||||
|
||||
if (pathIt->kind() == "ImplicitCast") {
|
||||
if (pathIt->detailIs("FunctionToPointerDecay"))
|
||||
return Usage::Type::Other;
|
||||
return {};
|
||||
if (pathIt->hasConstType())
|
||||
return Usage::Type::Read;
|
||||
return Usage::Tag::Read;
|
||||
potentialWrite = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return Usage::Type::Other;
|
||||
return {};
|
||||
}
|
||||
|
||||
class ClangdFindLocalReferences::Private
|
||||
|
||||
@@ -62,6 +62,8 @@ namespace ClangCodeModel {
|
||||
namespace Internal {
|
||||
namespace Tests {
|
||||
|
||||
const Usage::Tags Initialization{Usage::Tag::Declaration, Usage::Tag::Write};
|
||||
|
||||
static QString qrcPath(const QByteArray &relativeFilePath)
|
||||
{
|
||||
return QLatin1String(":/unittests/ClangCodeModel/") + QString::fromUtf8(relativeFilePath);
|
||||
@@ -187,89 +189,89 @@ void ClangdTestFindReferences::test_data()
|
||||
using ItemList = QList<SearchResultItem>;
|
||||
QTest::addColumn<ItemList>("expectedResults");
|
||||
|
||||
static const auto makeItem = [](int line, int column, Usage::Type type) {
|
||||
static const auto makeItem = [](int line, int column, Usage::Tags tags) {
|
||||
SearchResultItem item;
|
||||
item.setMainRange(line, column, 0);
|
||||
item.setUserData(int(type));
|
||||
item.setUserData(tags.toInt());
|
||||
return item;
|
||||
};
|
||||
|
||||
QTest::newRow("struct member") << "defs.h" << 55 << ItemList{
|
||||
makeItem(2, 17, Usage::Type::Read), makeItem(3, 15, Usage::Type::Declaration),
|
||||
makeItem(6, 17, Usage::Type::WritableRef), makeItem(8, 11, Usage::Type::WritableRef),
|
||||
makeItem(9, 13, Usage::Type::WritableRef), makeItem(10, 12, Usage::Type::WritableRef),
|
||||
makeItem(11, 13, Usage::Type::WritableRef), makeItem(12, 14, Usage::Type::WritableRef),
|
||||
makeItem(13, 26, Usage::Type::WritableRef), makeItem(14, 23, Usage::Type::Read),
|
||||
makeItem(15, 14, Usage::Type::Read), makeItem(16, 24, Usage::Type::WritableRef),
|
||||
makeItem(17, 15, Usage::Type::WritableRef), makeItem(18, 22, Usage::Type::Read),
|
||||
makeItem(19, 12, Usage::Type::WritableRef), makeItem(20, 12, Usage::Type::Read),
|
||||
makeItem(21, 13, Usage::Type::WritableRef), makeItem(22, 13, Usage::Type::Read),
|
||||
makeItem(23, 12, Usage::Type::Read), makeItem(42, 20, Usage::Type::Read),
|
||||
makeItem(44, 15, Usage::Type::Read), makeItem(47, 15, Usage::Type::Write),
|
||||
makeItem(50, 11, Usage::Type::Read), makeItem(51, 11, Usage::Type::Write),
|
||||
makeItem(52, 9, Usage::Type::Write), makeItem(53, 7, Usage::Type::Write),
|
||||
makeItem(56, 7, Usage::Type::Write), makeItem(56, 25, Usage::Type::Other),
|
||||
makeItem(58, 13, Usage::Type::Read), makeItem(58, 25, Usage::Type::Read),
|
||||
makeItem(59, 7, Usage::Type::Write), makeItem(59, 24, Usage::Type::Read)};
|
||||
makeItem(2, 17, Usage::Tag::Read), makeItem(3, 15, Usage::Tag::Declaration),
|
||||
makeItem(6, 17, Usage::Tag::WritableRef), makeItem(8, 11, Usage::Tag::WritableRef),
|
||||
makeItem(9, 13, Usage::Tag::WritableRef), makeItem(10, 12, Usage::Tag::WritableRef),
|
||||
makeItem(11, 13, Usage::Tag::WritableRef), makeItem(12, 14, Usage::Tag::WritableRef),
|
||||
makeItem(13, 26, Usage::Tag::WritableRef), makeItem(14, 23, Usage::Tag::Read),
|
||||
makeItem(15, 14, Usage::Tag::Read), makeItem(16, 24, Usage::Tag::WritableRef),
|
||||
makeItem(17, 15, Usage::Tag::WritableRef), makeItem(18, 22, Usage::Tag::Read),
|
||||
makeItem(19, 12, Usage::Tag::WritableRef), makeItem(20, 12, Usage::Tag::Read),
|
||||
makeItem(21, 13, Usage::Tag::WritableRef), makeItem(22, 13, Usage::Tag::Read),
|
||||
makeItem(23, 12, Usage::Tag::Read), makeItem(42, 20, Usage::Tag::Read),
|
||||
makeItem(44, 15, Usage::Tag::Read), makeItem(47, 15, Usage::Tag::Write),
|
||||
makeItem(50, 11, Usage::Tag::Read), makeItem(51, 11, Usage::Tag::Write),
|
||||
makeItem(52, 9, Usage::Tag::Write), makeItem(53, 7, Usage::Tag::Write),
|
||||
makeItem(56, 7, Usage::Tag::Write), makeItem(56, 25, Usage::Tags()),
|
||||
makeItem(58, 13, Usage::Tag::Read), makeItem(58, 25, Usage::Tag::Read),
|
||||
makeItem(59, 7, Usage::Tag::Write), makeItem(59, 24, Usage::Tag::Read)};
|
||||
QTest::newRow("constructor member initialization") << "defs.h" << 68 << ItemList{
|
||||
makeItem(2, 10, Usage::Type::Write), makeItem(4, 8, Usage::Type::Declaration)};
|
||||
makeItem(2, 10, Usage::Tag::Write), makeItem(4, 8, Usage::Tag::Declaration)};
|
||||
QTest::newRow("direct member initialization") << "defs.h" << 101 << ItemList{
|
||||
makeItem(5, 21, Usage::Type::Initialization), makeItem(45, 16, Usage::Type::Read)};
|
||||
makeItem(5, 21, Initialization), makeItem(45, 16, Usage::Tag::Read)};
|
||||
|
||||
ItemList pureVirtualRefs{makeItem(17, 17, Usage::Type::Declaration),
|
||||
makeItem(21, 9, Usage::Type::Declaration)};
|
||||
ItemList pureVirtualRefs{makeItem(17, 17, Usage::Tag::Declaration),
|
||||
makeItem(21, 9, Usage::Tag::Declaration)};
|
||||
QTest::newRow("pure virtual declaration") << "defs.h" << 420 << pureVirtualRefs;
|
||||
|
||||
QTest::newRow("pointer variable") << "main.cpp" << 52 << ItemList{
|
||||
makeItem(6, 10, Usage::Type::Initialization), makeItem(8, 4, Usage::Type::Write),
|
||||
makeItem(10, 4, Usage::Type::Write), makeItem(24, 5, Usage::Type::Write),
|
||||
makeItem(25, 11, Usage::Type::WritableRef), makeItem(26, 11, Usage::Type::Read),
|
||||
makeItem(27, 10, Usage::Type::WritableRef), makeItem(28, 10, Usage::Type::Read),
|
||||
makeItem(29, 11, Usage::Type::Read), makeItem(30, 15, Usage::Type::WritableRef),
|
||||
makeItem(31, 22, Usage::Type::Read)};
|
||||
makeItem(6, 10, Initialization), makeItem(8, 4, Usage::Tag::Write),
|
||||
makeItem(10, 4, Usage::Tag::Write), makeItem(24, 5, Usage::Tag::Write),
|
||||
makeItem(25, 11, Usage::Tag::WritableRef), makeItem(26, 11, Usage::Tag::Read),
|
||||
makeItem(27, 10, Usage::Tag::WritableRef), makeItem(28, 10, Usage::Tag::Read),
|
||||
makeItem(29, 11, Usage::Tag::Read), makeItem(30, 15, Usage::Tag::WritableRef),
|
||||
makeItem(31, 22, Usage::Tag::Read)};
|
||||
QTest::newRow("struct variable") << "main.cpp" << 39 << ItemList{
|
||||
makeItem(5, 7, Usage::Type::Declaration), makeItem(6, 15, Usage::Type::WritableRef),
|
||||
makeItem(8, 9, Usage::Type::WritableRef), makeItem(9, 11, Usage::Type::WritableRef),
|
||||
makeItem(11, 4, Usage::Type::Write), makeItem(11, 11, Usage::Type::WritableRef),
|
||||
makeItem(12, 12, Usage::Type::WritableRef), makeItem(13, 6, Usage::Type::Write),
|
||||
makeItem(14, 21, Usage::Type::Read), makeItem(15, 4, Usage::Type::Write),
|
||||
makeItem(15, 12, Usage::Type::Read), makeItem(16, 22, Usage::Type::WritableRef),
|
||||
makeItem(17, 13, Usage::Type::WritableRef), makeItem(18, 20, Usage::Type::Read),
|
||||
makeItem(19, 10, Usage::Type::WritableRef), makeItem(20, 10, Usage::Type::Read),
|
||||
makeItem(21, 11, Usage::Type::WritableRef), makeItem(22, 11, Usage::Type::Read),
|
||||
makeItem(23, 10, Usage::Type::Read), makeItem(32, 4, Usage::Type::Write),
|
||||
makeItem(33, 23, Usage::Type::WritableRef), makeItem(34, 23, Usage::Type::Read),
|
||||
makeItem(35, 15, Usage::Type::WritableRef), makeItem(36, 22, Usage::Type::WritableRef),
|
||||
makeItem(37, 4, Usage::Type::Read), makeItem(38, 4, Usage::Type::WritableRef),
|
||||
makeItem(39, 6, Usage::Type::WritableRef), makeItem(40, 4, Usage::Type::Read),
|
||||
makeItem(41, 4, Usage::Type::WritableRef), makeItem(42, 4, Usage::Type::Read),
|
||||
makeItem(42, 18, Usage::Type::Read), makeItem(43, 11, Usage::Type::Write),
|
||||
makeItem(54, 4, Usage::Type::Other), makeItem(55, 4, Usage::Type::Other)};
|
||||
makeItem(5, 7, Usage::Tag::Declaration), makeItem(6, 15, Usage::Tag::WritableRef),
|
||||
makeItem(8, 9, Usage::Tag::WritableRef), makeItem(9, 11, Usage::Tag::WritableRef),
|
||||
makeItem(11, 4, Usage::Tag::Write), makeItem(11, 11, Usage::Tag::WritableRef),
|
||||
makeItem(12, 12, Usage::Tag::WritableRef), makeItem(13, 6, Usage::Tag::Write),
|
||||
makeItem(14, 21, Usage::Tag::Read), makeItem(15, 4, Usage::Tag::Write),
|
||||
makeItem(15, 12, Usage::Tag::Read), makeItem(16, 22, Usage::Tag::WritableRef),
|
||||
makeItem(17, 13, Usage::Tag::WritableRef), makeItem(18, 20, Usage::Tag::Read),
|
||||
makeItem(19, 10, Usage::Tag::WritableRef), makeItem(20, 10, Usage::Tag::Read),
|
||||
makeItem(21, 11, Usage::Tag::WritableRef), makeItem(22, 11, Usage::Tag::Read),
|
||||
makeItem(23, 10, Usage::Tag::Read), makeItem(32, 4, Usage::Tag::Write),
|
||||
makeItem(33, 23, Usage::Tag::WritableRef), makeItem(34, 23, Usage::Tag::Read),
|
||||
makeItem(35, 15, Usage::Tag::WritableRef), makeItem(36, 22, Usage::Tag::WritableRef),
|
||||
makeItem(37, 4, Usage::Tag::Read), makeItem(38, 4, Usage::Tag::WritableRef),
|
||||
makeItem(39, 6, Usage::Tag::WritableRef), makeItem(40, 4, Usage::Tag::Read),
|
||||
makeItem(41, 4, Usage::Tag::WritableRef), makeItem(42, 4, Usage::Tag::Read),
|
||||
makeItem(42, 18, Usage::Tag::Read), makeItem(43, 11, Usage::Tag::Write),
|
||||
makeItem(54, 4, Usage::Tags()), makeItem(55, 4, Usage::Tags())};
|
||||
|
||||
// Some of these are conceptually questionable, as S is a type and thus we cannot "read from"
|
||||
// or "write to" it. But it probably matches the intuitive user expectation.
|
||||
QTest::newRow("struct type") << "defs.h" << 7 << ItemList{
|
||||
makeItem(1, 7, Usage::Type::Declaration), makeItem(2, 4, Usage::Type::Declaration),
|
||||
makeItem(20, 19, Usage::Type::Other), makeItem(10, 9, Usage::Type::WritableRef),
|
||||
makeItem(12, 4, Usage::Type::Write), makeItem(44, 12, Usage::Type::Read),
|
||||
makeItem(45, 13, Usage::Type::Read), makeItem(47, 12, Usage::Type::Write),
|
||||
makeItem(50, 8, Usage::Type::Read), makeItem(51, 8, Usage::Type::Write),
|
||||
makeItem(52, 6, Usage::Type::Write), makeItem(53, 4, Usage::Type::Write),
|
||||
makeItem(56, 4, Usage::Type::Write), makeItem(56, 22, Usage::Type::Other),
|
||||
makeItem(58, 10, Usage::Type::Read), makeItem(58, 22, Usage::Type::Read),
|
||||
makeItem(59, 4, Usage::Type::Write), makeItem(59, 21, Usage::Type::Read)};
|
||||
makeItem(1, 7, Usage::Tag::Declaration), makeItem(2, 4, Usage::Tag::Declaration),
|
||||
makeItem(20, 19, Usage::Tags()), makeItem(10, 9, Usage::Tag::WritableRef),
|
||||
makeItem(12, 4, Usage::Tag::Write), makeItem(44, 12, Usage::Tag::Read),
|
||||
makeItem(45, 13, Usage::Tag::Read), makeItem(47, 12, Usage::Tag::Write),
|
||||
makeItem(50, 8, Usage::Tag::Read), makeItem(51, 8, Usage::Tag::Write),
|
||||
makeItem(52, 6, Usage::Tag::Write), makeItem(53, 4, Usage::Tag::Write),
|
||||
makeItem(56, 4, Usage::Tag::Write), makeItem(56, 22, Usage::Tags()),
|
||||
makeItem(58, 10, Usage::Tag::Read), makeItem(58, 22, Usage::Tag::Read),
|
||||
makeItem(59, 4, Usage::Tag::Write), makeItem(59, 21, Usage::Tag::Read)};
|
||||
|
||||
QTest::newRow("subclass") << "defs.h" << 450 << ItemList{
|
||||
makeItem(20, 7, Usage::Type::Declaration), makeItem(5, 4, Usage::Type::Other),
|
||||
makeItem(13, 21, Usage::Type::Other), makeItem(32, 8, Usage::Type::Other)};
|
||||
makeItem(20, 7, Usage::Tag::Declaration), makeItem(5, 4, Usage::Tags()),
|
||||
makeItem(13, 21, Usage::Tags()), makeItem(32, 8, Usage::Tags())};
|
||||
QTest::newRow("array variable") << "main.cpp" << 1134 << ItemList{
|
||||
makeItem(57, 8, Usage::Type::Declaration), makeItem(58, 4, Usage::Type::Write),
|
||||
makeItem(59, 15, Usage::Type::Read)};
|
||||
makeItem(57, 8, Usage::Tag::Declaration), makeItem(58, 4, Usage::Tag::Write),
|
||||
makeItem(59, 15, Usage::Tag::Read)};
|
||||
QTest::newRow("free function") << "defs.h" << 510 << ItemList{
|
||||
makeItem(24, 5, Usage::Type::Declaration), makeItem(19, 4, Usage::Type::Other),
|
||||
makeItem(25, 4, Usage::Type::Other), makeItem(60, 26, Usage::Type::Read)};
|
||||
makeItem(24, 5, Usage::Tag::Declaration), makeItem(19, 4, Usage::Tags()),
|
||||
makeItem(25, 4, Usage::Tags()), makeItem(60, 26, Usage::Tag::Read)};
|
||||
QTest::newRow("member function") << "defs.h" << 192 << ItemList{
|
||||
makeItem(9, 12, Usage::Type::Declaration), makeItem(40, 8, Usage::Type::Other)};
|
||||
makeItem(9, 12, Usage::Tag::Declaration), makeItem(40, 8, Usage::Tags())};
|
||||
}
|
||||
|
||||
// The main point here is to test our access type categorization.
|
||||
|
||||
@@ -41,20 +41,13 @@ using namespace std::placeholders;
|
||||
|
||||
namespace CppEditor {
|
||||
|
||||
SearchResultColor::Style colorStyleForUsageType(CPlusPlus::Usage::Type type)
|
||||
SearchResultColor::Style colorStyleForUsageType(CPlusPlus::Usage::Tags tags)
|
||||
{
|
||||
switch (type) {
|
||||
case CPlusPlus::Usage::Type::Read:
|
||||
if (tags.testFlag(CPlusPlus::Usage::Tag::Read))
|
||||
return SearchResultColor::Style::Alt1;
|
||||
case CPlusPlus::Usage::Type::Initialization:
|
||||
case CPlusPlus::Usage::Type::Write:
|
||||
case CPlusPlus::Usage::Type::WritableRef:
|
||||
if (tags.testAnyFlags({CPlusPlus::Usage::Tag::Write, CPlusPlus::Usage::Tag::WritableRef}))
|
||||
return SearchResultColor::Style::Alt2;
|
||||
case CPlusPlus::Usage::Type::Declaration:
|
||||
case CPlusPlus::Usage::Type::Other:
|
||||
return SearchResultColor::Style::Default;
|
||||
}
|
||||
return SearchResultColor::Style::Default; // For dumb compilers.
|
||||
return SearchResultColor::Style::Default;
|
||||
}
|
||||
|
||||
QWidget *CppSearchResultFilter::createWidget()
|
||||
@@ -87,19 +80,14 @@ QWidget *CppSearchResultFilter::createWidget()
|
||||
|
||||
bool CppSearchResultFilter::matches(const SearchResultItem &item) const
|
||||
{
|
||||
switch (static_cast<CPlusPlus::Usage::Type>(item.userData().toInt())) {
|
||||
case CPlusPlus::Usage::Type::Read:
|
||||
const auto usageTags = CPlusPlus::Usage::Tags::fromInt(item.userData().toInt());
|
||||
if (usageTags.testFlag(CPlusPlus::Usage::Tag::Read))
|
||||
return m_showReads;
|
||||
case CPlusPlus::Usage::Type::Write:
|
||||
case CPlusPlus::Usage::Type::WritableRef:
|
||||
case CPlusPlus::Usage::Type::Initialization:
|
||||
if (usageTags.testAnyFlags({CPlusPlus::Usage::Tag::Write, CPlusPlus::Usage::Tag::WritableRef}))
|
||||
return m_showWrites;
|
||||
case CPlusPlus::Usage::Type::Declaration:
|
||||
if (usageTags.testFlag(CPlusPlus::Usage::Tag::Declaration))
|
||||
return m_showDecls;
|
||||
case CPlusPlus::Usage::Type::Other:
|
||||
return m_showOther;
|
||||
}
|
||||
return false;
|
||||
return m_showOther;
|
||||
}
|
||||
|
||||
void CppSearchResultFilter::setValue(bool &member, bool value)
|
||||
@@ -582,9 +570,9 @@ static void displayResults(SearchResult *search,
|
||||
item.setFilePath(result.path);
|
||||
item.setMainRange(result.line, result.col, result.len);
|
||||
item.setLineText(result.lineText);
|
||||
item.setUserData(int(result.type));
|
||||
item.setUserData(result.tags.toInt());
|
||||
item.setContainingFunctionName(result.containingFunction);
|
||||
item.setStyle(colorStyleForUsageType(result.type));
|
||||
item.setStyle(colorStyleForUsageType(result.tags));
|
||||
item.setUseTextEditorFont(true);
|
||||
if (search->supportsReplace())
|
||||
item.setSelectForReplacement(SessionManager::projectForFile(result.path));
|
||||
@@ -678,7 +666,7 @@ restart_search:
|
||||
unsigned column;
|
||||
const QString &lineSource = matchingLine(use.bytesBegin(), source, &column);
|
||||
usages.append(CPlusPlus::Usage(fileName, lineSource, {},
|
||||
CPlusPlus::Usage::Type::Other, use.beginLine(),
|
||||
{}, use.beginLine(),
|
||||
column, useMacro.nameToQString().size()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace CppEditor {
|
||||
class CppModelManager;
|
||||
|
||||
Core::SearchResultColor::Style CPPEDITOR_EXPORT
|
||||
colorStyleForUsageType(CPlusPlus::Usage::Type type);
|
||||
colorStyleForUsageType(CPlusPlus::Usage::Tags tags);
|
||||
|
||||
class CPPEDITOR_EXPORT CppSearchResultFilter : public Core::SearchResultFilter
|
||||
{
|
||||
|
||||
@@ -47,6 +47,8 @@ private:
|
||||
const char *_name;
|
||||
};
|
||||
|
||||
const Usage::Tags Initialization{Usage::Tag::Declaration, Usage::Tag::Write};
|
||||
|
||||
class tst_FindUsages: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -158,8 +160,8 @@ void tst_FindUsages::inlineMethod()
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(arg);
|
||||
QCOMPARE(findUsages.usages().size(), 2);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).type, Usage::Type::Read);
|
||||
QCOMPARE(findUsages.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).tags, Usage::Tag::Read);
|
||||
QCOMPARE(findUsages.references().size(), 2);
|
||||
}
|
||||
|
||||
@@ -193,9 +195,9 @@ void tst_FindUsages::lambdaCaptureByValue()
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(d);
|
||||
QCOMPARE(findUsages.usages().size(), 3);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).type, Usage::Type::Other);
|
||||
QCOMPARE(findUsages.usages().at(2).type, Usage::Type::Read);
|
||||
QCOMPARE(findUsages.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).tags, Usage::Tags());
|
||||
QCOMPARE(findUsages.usages().at(2).tags, Usage::Tag::Read);
|
||||
}
|
||||
|
||||
void tst_FindUsages::lambdaCaptureByReference()
|
||||
@@ -228,10 +230,10 @@ void tst_FindUsages::lambdaCaptureByReference()
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(d);
|
||||
QCOMPARE(findUsages.usages().size(), 3);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).type, Usage::Type::Other);
|
||||
QCOMPARE(findUsages.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).tags, Usage::Tags());
|
||||
QEXPECT_FAIL(nullptr, "parser does not record capture type", Continue);
|
||||
QCOMPARE(findUsages.usages().at(2).type, Usage::Type::Write);
|
||||
QCOMPARE(findUsages.usages().at(2).tags, Usage::Tag::Write);
|
||||
}
|
||||
|
||||
void tst_FindUsages::shadowedNames_1()
|
||||
@@ -262,8 +264,8 @@ void tst_FindUsages::shadowedNames_1()
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(d);
|
||||
QCOMPARE(findUsages.usages().size(), 2);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).type, Usage::Type::Other);
|
||||
QCOMPARE(findUsages.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).tags, Usage::Tags());
|
||||
}
|
||||
|
||||
void tst_FindUsages::shadowedNames_2()
|
||||
@@ -297,9 +299,9 @@ void tst_FindUsages::shadowedNames_2()
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(d);
|
||||
QCOMPARE(findUsages.usages().size(), 3);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).type, Usage::Type::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(2).type, Usage::Type::Other);
|
||||
QCOMPARE(findUsages.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(2).tags, Usage::Tags());
|
||||
}
|
||||
|
||||
void tst_FindUsages::staticVariables()
|
||||
@@ -346,11 +348,11 @@ void tst_FindUsages::staticVariables()
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(d);
|
||||
QCOMPARE(findUsages.usages().size(), 5);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).type, Usage::Type::Initialization);
|
||||
QCOMPARE(findUsages.usages().at(2).type, Usage::Type::Write);
|
||||
QCOMPARE(findUsages.usages().at(3).type, Usage::Type::Write);
|
||||
QCOMPARE(findUsages.usages().at(4).type, Usage::Type::Write);
|
||||
QCOMPARE(findUsages.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).tags, Initialization);
|
||||
QCOMPARE(findUsages.usages().at(2).tags, Usage::Tag::Write);
|
||||
QCOMPARE(findUsages.usages().at(3).tags, Usage::Tag::Write);
|
||||
QCOMPARE(findUsages.usages().at(4).tags, Usage::Tag::Write);
|
||||
}
|
||||
|
||||
void tst_FindUsages::structuredBinding()
|
||||
@@ -380,13 +382,13 @@ void tst_FindUsages::structuredBinding()
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(d1);
|
||||
QCOMPARE(findUsages.usages().size(), 2);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Initialization);
|
||||
QCOMPARE(findUsages.usages().at(1).type, Usage::Type::Read);
|
||||
QCOMPARE(findUsages.usages().at(0).tags, Initialization);
|
||||
QCOMPARE(findUsages.usages().at(1).tags, Usage::Tag::Read);
|
||||
|
||||
findUsages(d2);
|
||||
QCOMPARE(findUsages.usages().size(), 2);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Initialization);
|
||||
QCOMPARE(findUsages.usages().at(1).type, Usage::Type::Read);
|
||||
QCOMPARE(findUsages.usages().at(0).tags, Initialization);
|
||||
QCOMPARE(findUsages.usages().at(1).tags, Usage::Tag::Read);
|
||||
}
|
||||
|
||||
void tst_FindUsages::functionNameFoundInArguments()
|
||||
@@ -419,15 +421,15 @@ void foo2(int b=bar()){} // 3rd result
|
||||
|
||||
QCOMPARE(find.usages().size(), 3);
|
||||
|
||||
QCOMPARE(find.usages()[0].type, Usage::Type::Declaration);
|
||||
QCOMPARE(find.usages()[0].tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(find.usages()[0].line, 1);
|
||||
QCOMPARE(find.usages()[0].col, 5);
|
||||
|
||||
QCOMPARE(find.usages()[1].type, Usage::Type::Other);
|
||||
QCOMPARE(find.usages()[1].tags, Usage::Tags());
|
||||
QCOMPARE(find.usages()[1].line, 4);
|
||||
QCOMPARE(find.usages()[1].col, 16);
|
||||
|
||||
QCOMPARE(find.usages()[2].type, Usage::Type::Other);
|
||||
QCOMPARE(find.usages()[2].tags, Usage::Tags());
|
||||
QCOMPARE(find.usages()[2].line, 5);
|
||||
QCOMPARE(find.usages()[2].col, 16);
|
||||
}
|
||||
@@ -486,22 +488,22 @@ struct Struct{
|
||||
find(memberFunctionFoo);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
|
||||
QCOMPARE(find.usages()[0].type, Usage::Type::Declaration);
|
||||
QCOMPARE(find.usages()[0].tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(find.usages()[0].line, 3);
|
||||
QCOMPARE(find.usages()[0].col, 15);
|
||||
|
||||
QCOMPARE(find.usages()[1].type, Usage::Type::Other);
|
||||
QCOMPARE(find.usages()[1].tags, Usage::Tags());
|
||||
QCOMPARE(find.usages()[1].line, 5);
|
||||
QCOMPARE(find.usages()[1].col, 24);
|
||||
|
||||
find(variableFoo);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
|
||||
QCOMPARE(find.usages()[0].type, Usage::Type::Initialization);
|
||||
QCOMPARE(find.usages()[0].tags, Initialization);
|
||||
QCOMPARE(find.usages()[0].line, 5);
|
||||
QCOMPARE(find.usages()[0].col, 12);
|
||||
|
||||
QCOMPARE(find.usages()[1].type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages()[1].tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages()[1].line, 6);
|
||||
QCOMPARE(find.usages()[1].col, 22);
|
||||
}
|
||||
@@ -558,13 +560,13 @@ int main() {
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
find(sv);
|
||||
QCOMPARE(find.usages().size(), 7);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(find.usages().at(1).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(2).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(3).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(4).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(5).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(6).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(find.usages().at(1).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(2).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(3).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(4).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(5).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(6).tags, Usage::Tag::Read);
|
||||
}
|
||||
|
||||
void tst_FindUsages::templateConstructorVsCallOperator()
|
||||
@@ -617,13 +619,13 @@ int main()
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
find(sv);
|
||||
QCOMPARE(find.usages().size(), 7);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(find.usages().at(1).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(2).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(3).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(4).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(5).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(6).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(find.usages().at(1).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(2).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(3).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(4).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(5).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(6).tags, Usage::Tag::Read);
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -720,8 +722,8 @@ void tst_FindUsages::qproperty_1()
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(setX_method);
|
||||
QCOMPARE(findUsages.usages().size(), 2);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Other);
|
||||
QCOMPARE(findUsages.usages().at(1).type, Usage::Type::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(0).tags, Usage::Tags());
|
||||
QCOMPARE(findUsages.usages().at(1).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(findUsages.references().size(), 2);
|
||||
}
|
||||
|
||||
@@ -766,8 +768,8 @@ void tst_FindUsages::instantiateTemplateWithNestedClass()
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(barDeclaration);
|
||||
QCOMPARE(findUsages.usages().size(), 2);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).type, Usage::Type::Read);
|
||||
QCOMPARE(findUsages.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).tags, Usage::Tag::Read);
|
||||
}
|
||||
|
||||
void tst_FindUsages::operatorAsteriskOfNestedClassOfTemplateClass_QTCREATORBUG9006()
|
||||
@@ -813,8 +815,8 @@ void tst_FindUsages::operatorAsteriskOfNestedClassOfTemplateClass_QTCREATORBUG90
|
||||
findUsages(fooDeclaration);
|
||||
|
||||
QCOMPARE(findUsages.usages().size(), 2);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).type, Usage::Type::Read);
|
||||
QCOMPARE(findUsages.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).tags, Usage::Tag::Read);
|
||||
}
|
||||
|
||||
void tst_FindUsages::anonymousClass_QTCREATORBUG8963()
|
||||
@@ -858,8 +860,8 @@ void tst_FindUsages::anonymousClass_QTCREATORBUG8963()
|
||||
findUsages(isNotIntDeclaration);
|
||||
|
||||
QCOMPARE(findUsages.usages().size(), 2);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).type, Usage::Type::Read);
|
||||
QCOMPARE(findUsages.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).tags, Usage::Tag::Read);
|
||||
}
|
||||
|
||||
void tst_FindUsages::anonymousClass_QTCREATORBUG11859()
|
||||
@@ -901,12 +903,12 @@ void tst_FindUsages::anonymousClass_QTCREATORBUG11859()
|
||||
findUsages(fooAsStruct);
|
||||
QCOMPARE(findUsages.references().size(), 1);
|
||||
QCOMPARE(findUsages.usages().size(), 1);
|
||||
QCOMPARE(findUsages.usages().first().type, Usage::Type::Declaration);
|
||||
QCOMPARE(findUsages.usages().first().tags, Usage::Tag::Declaration);
|
||||
|
||||
findUsages(fooAsMemberOfAnonymousStruct);
|
||||
QCOMPARE(findUsages.references().size(), 2);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).type, Usage::Type::Read);
|
||||
QCOMPARE(findUsages.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).tags, Usage::Tag::Read);
|
||||
}
|
||||
|
||||
void tst_FindUsages::using_insideGlobalNamespace()
|
||||
@@ -947,9 +949,9 @@ void tst_FindUsages::using_insideGlobalNamespace()
|
||||
findUsages(structSymbol);
|
||||
|
||||
QCOMPARE(findUsages.usages().size(), 3);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).type, Usage::Type::Other);
|
||||
QCOMPARE(findUsages.usages().at(2).type, Usage::Type::Other);
|
||||
QCOMPARE(findUsages.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).tags, Usage::Tags());
|
||||
QCOMPARE(findUsages.usages().at(2).tags, Usage::Tags());
|
||||
}
|
||||
|
||||
void tst_FindUsages::using_insideNamespace()
|
||||
@@ -993,9 +995,9 @@ void tst_FindUsages::using_insideNamespace()
|
||||
findUsages(structSymbol);
|
||||
|
||||
QCOMPARE(findUsages.usages().size(), 3);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).type, Usage::Type::Other);
|
||||
QCOMPARE(findUsages.usages().at(2).type, Usage::Type::Other);
|
||||
QCOMPARE(findUsages.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).tags, Usage::Tags());
|
||||
QCOMPARE(findUsages.usages().at(2).tags, Usage::Tags());
|
||||
}
|
||||
|
||||
void tst_FindUsages::using_insideFunction()
|
||||
@@ -1036,9 +1038,9 @@ void tst_FindUsages::using_insideFunction()
|
||||
findUsages(structSymbol);
|
||||
|
||||
QCOMPARE(findUsages.usages().size(), 3);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).type, Usage::Type::Other);
|
||||
QCOMPARE(findUsages.usages().at(2).type, Usage::Type::Other);
|
||||
QCOMPARE(findUsages.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).tags, Usage::Tags());
|
||||
QCOMPARE(findUsages.usages().at(2).tags, Usage::Tags());
|
||||
}
|
||||
|
||||
void tst_FindUsages::operatorArrowOfNestedClassOfTemplateClass_QTCREATORBUG9005()
|
||||
@@ -1083,8 +1085,8 @@ void tst_FindUsages::operatorArrowOfNestedClassOfTemplateClass_QTCREATORBUG9005(
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(fooDeclaration);
|
||||
QCOMPARE(findUsages.usages().size(), 2);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).type, Usage::Type::Read);
|
||||
QCOMPARE(findUsages.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).tags, Usage::Tag::Read);
|
||||
}
|
||||
|
||||
void tst_FindUsages::templateClassParameters()
|
||||
@@ -1120,11 +1122,11 @@ void tst_FindUsages::templateClassParameters()
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(templArgument);
|
||||
QCOMPARE(findUsages.usages().size(), 5);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).type, Usage::Type::Other);
|
||||
QCOMPARE(findUsages.usages().at(2).type, Usage::Type::Other);
|
||||
QCOMPARE(findUsages.usages().at(3).type, Usage::Type::Other);
|
||||
QCOMPARE(findUsages.usages().at(4).type, Usage::Type::Other);
|
||||
QCOMPARE(findUsages.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).tags, Usage::Tags());
|
||||
QCOMPARE(findUsages.usages().at(2).tags, Usage::Tags());
|
||||
QCOMPARE(findUsages.usages().at(3).tags, Usage::Tags());
|
||||
QCOMPARE(findUsages.usages().at(4).tags, Usage::Tags());
|
||||
}
|
||||
|
||||
void tst_FindUsages::templateClass_className()
|
||||
@@ -1166,13 +1168,13 @@ void tst_FindUsages::templateClass_className()
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(classTS);
|
||||
QCOMPARE(findUsages.usages().size(), 7);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).type, Usage::Type::Other);
|
||||
QCOMPARE(findUsages.usages().at(2).type, Usage::Type::Other);
|
||||
QCOMPARE(findUsages.usages().at(3).type, Usage::Type::Other);
|
||||
QCOMPARE(findUsages.usages().at(4).type, Usage::Type::Other);
|
||||
QCOMPARE(findUsages.usages().at(5).type, Usage::Type::Other);
|
||||
QCOMPARE(findUsages.usages().at(6).type, Usage::Type::Other);
|
||||
QCOMPARE(findUsages.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).tags, Usage::Tags());
|
||||
QCOMPARE(findUsages.usages().at(2).tags, Usage::Tags());
|
||||
QCOMPARE(findUsages.usages().at(3).tags, Usage::Tags());
|
||||
QCOMPARE(findUsages.usages().at(4).tags, Usage::Tags());
|
||||
QCOMPARE(findUsages.usages().at(5).tags, Usage::Tags());
|
||||
QCOMPARE(findUsages.usages().at(6).tags, Usage::Tags());
|
||||
}
|
||||
|
||||
void tst_FindUsages::templateFunctionParameters()
|
||||
@@ -1206,10 +1208,10 @@ void tst_FindUsages::templateFunctionParameters()
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(templArgument);
|
||||
QCOMPARE(findUsages.usages().size(), 4);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).type, Usage::Type::Other);
|
||||
QCOMPARE(findUsages.usages().at(2).type, Usage::Type::Other);
|
||||
QCOMPARE(findUsages.usages().at(3).type, Usage::Type::Other);
|
||||
QCOMPARE(findUsages.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).tags, Usage::Tags());
|
||||
QCOMPARE(findUsages.usages().at(2).tags, Usage::Tags());
|
||||
QCOMPARE(findUsages.usages().at(3).tags, Usage::Tags());
|
||||
}
|
||||
|
||||
void tst_FindUsages::templatedFunction_QTCREATORBUG9749()
|
||||
@@ -1240,8 +1242,8 @@ void tst_FindUsages::templatedFunction_QTCREATORBUG9749()
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(func);
|
||||
QCOMPARE(findUsages.usages().size(), 2);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).type, Usage::Type::Other);
|
||||
QCOMPARE(findUsages.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).tags, Usage::Tags());
|
||||
}
|
||||
|
||||
void tst_FindUsages::templateInNamespaceTypeOutside()
|
||||
@@ -1279,8 +1281,8 @@ int func()
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(v);
|
||||
QCOMPARE(findUsages.usages().size(), 2);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).type, Usage::Type::Read);
|
||||
QCOMPARE(findUsages.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).tags, Usage::Tag::Read);
|
||||
}
|
||||
|
||||
void tst_FindUsages::usingInDifferentNamespace_QTCREATORBUG7978()
|
||||
@@ -1320,9 +1322,9 @@ void tst_FindUsages::usingInDifferentNamespace_QTCREATORBUG7978()
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(templateClass);
|
||||
QCOMPARE(findUsages.usages().size(), 3);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).type, Usage::Type::Other);
|
||||
QCOMPARE(findUsages.usages().at(2).type, Usage::Type::Other);
|
||||
QCOMPARE(findUsages.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).tags, Usage::Tags());
|
||||
QCOMPARE(findUsages.usages().at(2).tags, Usage::Tags());
|
||||
}
|
||||
|
||||
void tst_FindUsages::unicodeIdentifier()
|
||||
@@ -1350,8 +1352,8 @@ void tst_FindUsages::unicodeIdentifier()
|
||||
findUsages(declaration);
|
||||
const QList<Usage> usages = findUsages.usages();
|
||||
QCOMPARE(usages.size(), 2);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).type, Usage::Type::Write);
|
||||
QCOMPARE(findUsages.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(findUsages.usages().at(1).tags, Usage::Tag::Write);
|
||||
QCOMPARE(usages.at(0).len, 7);
|
||||
QCOMPARE(usages.at(1).len, 7);
|
||||
}
|
||||
@@ -1381,10 +1383,10 @@ void tst_FindUsages::inAlignas()
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
find(c);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
QCOMPARE(find.usages()[0].type, Usage::Type::Declaration);
|
||||
QCOMPARE(find.usages()[0].tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(find.usages()[0].line, 1);
|
||||
QCOMPARE(find.usages()[0].col, 7);
|
||||
QCOMPARE(find.usages()[1].type, Usage::Type::Other);
|
||||
QCOMPARE(find.usages()[1].tags, Usage::Tags());
|
||||
QCOMPARE(find.usages()[1].line, 2);
|
||||
QCOMPARE(find.usages()[1].col, 15);
|
||||
}
|
||||
@@ -1424,10 +1426,10 @@ void tst_FindUsages::memberAccessAsTemplate()
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
find(c);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
QCOMPARE(find.usages()[0].type, Usage::Type::Declaration);
|
||||
QCOMPARE(find.usages()[0].tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(find.usages()[0].line, 1);
|
||||
QCOMPARE(find.usages()[0].col, 7);
|
||||
QCOMPARE(find.usages()[1].type, Usage::Type::Other);
|
||||
QCOMPARE(find.usages()[1].tags, Usage::Tags());
|
||||
QCOMPARE(find.usages()[1].line, 11);
|
||||
QCOMPARE(find.usages()[1].col, 24);
|
||||
}
|
||||
@@ -1445,10 +1447,10 @@ void tst_FindUsages::memberAccessAsTemplate()
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
find(f);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
QCOMPARE(find.usages()[0].type, Usage::Type::Declaration);
|
||||
QCOMPARE(find.usages()[0].tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(find.usages()[0].line, 4);
|
||||
QCOMPARE(find.usages()[0].col, 7);
|
||||
QCOMPARE(find.usages()[1].type, Usage::Type::Other);
|
||||
QCOMPARE(find.usages()[1].tags, Usage::Tags());
|
||||
QCOMPARE(find.usages()[1].line, 11);
|
||||
QCOMPARE(find.usages()[1].col, 11);
|
||||
}
|
||||
@@ -1488,10 +1490,10 @@ void tst_FindUsages::variadicFunctionTemplate()
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
find(v);
|
||||
QCOMPARE(find.usages().size(), 4);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(find.usages().at(1).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(2).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(3).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(find.usages().at(1).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(2).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(3).tags, Usage::Tag::Read);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1539,13 +1541,13 @@ void tst_FindUsages::typeTemplateParameterWithDefault()
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
find(xv);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(find.usages().at(1).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(find.usages().at(1).tags, Usage::Tag::Read);
|
||||
find(sv);
|
||||
QCOMPARE(find.usages().size(), 3);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(find.usages().at(1).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(2).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(find.usages().at(1).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(2).tags, Usage::Tag::Read);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1583,8 +1585,8 @@ void tst_FindUsages::resolveOrder_for_templateFunction_vs_function()
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
find(xv);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(find.usages().at(1).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(find.usages().at(1).tags, Usage::Tag::Read);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1625,9 +1627,9 @@ void tst_FindUsages::templateArrowOperator_with_defaultType()
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
find(sv);
|
||||
QCOMPARE(find.usages().size(), 3);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(find.usages().at(1).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(2).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(find.usages().at(1).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(2).tags, Usage::Tag::Read);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1707,23 +1709,23 @@ void tst_FindUsages::templateSpecialization_with_IntArgument()
|
||||
find(sv[1]);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
|
||||
QCOMPARE(find.usages()[0].type, Usage::Type::Initialization);
|
||||
QCOMPARE(find.usages()[0].tags, Initialization);
|
||||
QCOMPARE(find.usages()[0].line, 2);
|
||||
QCOMPARE(find.usages()[0].col, 15);
|
||||
QCOMPARE(find.usages()[1].type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages()[1].tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages()[1].line, 13);
|
||||
QCOMPARE(find.usages()[1].col, 9);
|
||||
|
||||
find(sv[2]);
|
||||
QCOMPARE(find.usages().size(), 3);
|
||||
|
||||
QCOMPARE(find.usages()[0].type, Usage::Type::Initialization);
|
||||
QCOMPARE(find.usages()[0].tags, Initialization);
|
||||
QCOMPARE(find.usages()[0].line, 3);
|
||||
QCOMPARE(find.usages()[0].col, 15);
|
||||
QCOMPARE(find.usages()[1].type, Usage::Type::Write);
|
||||
QCOMPARE(find.usages()[1].tags, Usage::Tag::Write);
|
||||
QCOMPARE(find.usages()[1].line, 14);
|
||||
QCOMPARE(find.usages()[1].col, 9);
|
||||
QCOMPARE(find.usages()[2].type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages()[2].tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages()[2].line, 14);
|
||||
QCOMPARE(find.usages()[2].col, 22);
|
||||
}
|
||||
@@ -1786,20 +1788,20 @@ void tst_FindUsages::templateSpecialization_with_BoolArgument()
|
||||
find(sv[0]);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
|
||||
QCOMPARE(find.usages()[0].type, Usage::Type::Initialization);
|
||||
QCOMPARE(find.usages()[0].tags, Initialization);
|
||||
QCOMPARE(find.usages()[0].line, 1);
|
||||
QCOMPARE(find.usages()[0].col, 15);
|
||||
QCOMPARE(find.usages()[1].type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages()[1].tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages()[1].line, 9);
|
||||
QCOMPARE(find.usages()[1].col, 9);
|
||||
|
||||
find(sv[1]);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
|
||||
QCOMPARE(find.usages()[0].type, Usage::Type::Initialization);
|
||||
QCOMPARE(find.usages()[0].tags, Initialization);
|
||||
QCOMPARE(find.usages()[0].line, 2);
|
||||
QCOMPARE(find.usages()[0].col, 15);
|
||||
QCOMPARE(find.usages()[1].type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages()[1].tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages()[1].line, 10);
|
||||
QCOMPARE(find.usages()[1].col, 9);
|
||||
}
|
||||
@@ -1862,20 +1864,20 @@ void tst_FindUsages::templatePartialSpecialization()
|
||||
find(sv[0]);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
|
||||
QCOMPARE(find.usages()[0].type, Usage::Type::Initialization);
|
||||
QCOMPARE(find.usages()[0].tags, Initialization);
|
||||
QCOMPARE(find.usages()[0].line, 1);
|
||||
QCOMPARE(find.usages()[0].col, 15);
|
||||
QCOMPARE(find.usages()[1].type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages()[1].tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages()[1].line, 9);
|
||||
QCOMPARE(find.usages()[1].col, 10);
|
||||
|
||||
find(sv[1]);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
|
||||
QCOMPARE(find.usages()[0].type, Usage::Type::Initialization);
|
||||
QCOMPARE(find.usages()[0].tags, Initialization);
|
||||
QCOMPARE(find.usages()[0].line, 2);
|
||||
QCOMPARE(find.usages()[0].col, 15);
|
||||
QCOMPARE(find.usages()[1].type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages()[1].tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages()[1].line, 10);
|
||||
QCOMPARE(find.usages()[1].col, 10);
|
||||
}
|
||||
@@ -1931,18 +1933,18 @@ int main()
|
||||
|
||||
find(sv[0]);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Initialization);
|
||||
QCOMPARE(find.usages().at(1).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(0).tags, Initialization);
|
||||
QCOMPARE(find.usages().at(1).tags, Usage::Tag::Read);
|
||||
|
||||
find(sv[1]);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Initialization);
|
||||
QCOMPARE(find.usages().at(1).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(0).tags, Initialization);
|
||||
QCOMPARE(find.usages().at(1).tags, Usage::Tag::Read);
|
||||
|
||||
find(sv[2]);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Initialization);
|
||||
QCOMPARE(find.usages().at(1).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(0).tags, Initialization);
|
||||
QCOMPARE(find.usages().at(1).tags, Usage::Tag::Read);
|
||||
}
|
||||
|
||||
void tst_FindUsages::template_SFINAE_1()
|
||||
@@ -1981,8 +1983,8 @@ int main(){
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
find(sv);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Initialization);
|
||||
QCOMPARE(find.usages().at(1).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(0).tags, Initialization);
|
||||
QCOMPARE(find.usages().at(1).tags, Usage::Tag::Read);
|
||||
}
|
||||
|
||||
void tst_FindUsages::variableTemplateInExpression()
|
||||
@@ -2026,8 +2028,8 @@ int main(){
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
find(sv);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(find.usages().at(1).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(find.usages().at(1).tags, Usage::Tag::Read);
|
||||
}
|
||||
|
||||
void tst_FindUsages::variadicMacros()
|
||||
@@ -2066,8 +2068,8 @@ int main(){}
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
find(sv);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(find.usages().at(1).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(find.usages().at(1).tags, Usage::Tag::Read);
|
||||
}
|
||||
|
||||
void tst_FindUsages::writableRefs()
|
||||
@@ -2179,37 +2181,37 @@ int main()
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
find(sv);
|
||||
QCOMPARE(find.usages().size(), 31);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(1).type, Usage::Type::Declaration);
|
||||
QCOMPARE(find.usages().at(2).type, Usage::Type::WritableRef);
|
||||
QCOMPARE(find.usages().at(3).type, Usage::Type::WritableRef);
|
||||
QCOMPARE(find.usages().at(4).type, Usage::Type::WritableRef);
|
||||
QCOMPARE(find.usages().at(5).type, Usage::Type::WritableRef);
|
||||
QCOMPARE(find.usages().at(6).type, Usage::Type::WritableRef);
|
||||
QCOMPARE(find.usages().at(7).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(8).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(9).type, Usage::Type::WritableRef);
|
||||
QCOMPARE(find.usages().at(10).type, Usage::Type::WritableRef);
|
||||
QCOMPARE(find.usages().at(11).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(12).type, Usage::Type::WritableRef);
|
||||
QCOMPARE(find.usages().at(13).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(14).type, Usage::Type::WritableRef);
|
||||
QCOMPARE(find.usages().at(15).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(16).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(17).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(18).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(19).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(20).type, Usage::Type::Write);
|
||||
QCOMPARE(find.usages().at(21).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(22).type, Usage::Type::Write);
|
||||
QCOMPARE(find.usages().at(23).type, Usage::Type::Write);
|
||||
QCOMPARE(find.usages().at(24).type, Usage::Type::Write);
|
||||
QCOMPARE(find.usages().at(25).type, Usage::Type::Write);
|
||||
QCOMPARE(find.usages().at(26).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(27).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(28).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(29).type, Usage::Type::Write);
|
||||
QCOMPARE(find.usages().at(30).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(0).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(1).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(find.usages().at(2).tags, Usage::Tag::WritableRef);
|
||||
QCOMPARE(find.usages().at(3).tags, Usage::Tag::WritableRef);
|
||||
QCOMPARE(find.usages().at(4).tags, Usage::Tag::WritableRef);
|
||||
QCOMPARE(find.usages().at(5).tags, Usage::Tag::WritableRef);
|
||||
QCOMPARE(find.usages().at(6).tags, Usage::Tag::WritableRef);
|
||||
QCOMPARE(find.usages().at(7).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(8).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(9).tags, Usage::Tag::WritableRef);
|
||||
QCOMPARE(find.usages().at(10).tags, Usage::Tag::WritableRef);
|
||||
QCOMPARE(find.usages().at(11).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(12).tags, Usage::Tag::WritableRef);
|
||||
QCOMPARE(find.usages().at(13).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(14).tags, Usage::Tag::WritableRef);
|
||||
QCOMPARE(find.usages().at(15).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(16).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(17).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(18).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(19).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(20).tags, Usage::Tag::Write);
|
||||
QCOMPARE(find.usages().at(21).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(22).tags, Usage::Tag::Write);
|
||||
QCOMPARE(find.usages().at(23).tags, Usage::Tag::Write);
|
||||
QCOMPARE(find.usages().at(24).tags, Usage::Tag::Write);
|
||||
QCOMPARE(find.usages().at(25).tags, Usage::Tag::Write);
|
||||
QCOMPARE(find.usages().at(26).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(27).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(28).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(29).tags, Usage::Tag::Write);
|
||||
QCOMPARE(find.usages().at(30).tags, Usage::Tag::Read);
|
||||
|
||||
Declaration * const sv2 = structS->memberAt(2)->asDeclaration();
|
||||
QVERIFY(sv2);
|
||||
@@ -2218,8 +2220,8 @@ int main()
|
||||
// Member initialization in constructor
|
||||
find(sv2);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Write);
|
||||
QCOMPARE(find.usages().at(1).type, Usage::Type::Declaration);
|
||||
QCOMPARE(find.usages().at(0).tags, Usage::Tag::Write);
|
||||
QCOMPARE(find.usages().at(1).tags, Usage::Tag::Declaration);
|
||||
|
||||
// Make sure that pure virtual declaration is not mistaken for an assignment.
|
||||
Declaration * const pureVirtual = structS->memberAt(11)->asDeclaration();
|
||||
@@ -2227,13 +2229,13 @@ int main()
|
||||
QCOMPARE(pureVirtual->name()->identifier()->chars(), "pureVirtual");
|
||||
find(pureVirtual);
|
||||
QCOMPARE(find.usages().size(), 1);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(find.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
Function * const pureVirtual2 = structS->memberAt(12)->asFunction();
|
||||
QVERIFY(pureVirtual2);
|
||||
QCOMPARE(pureVirtual2->name()->identifier()->chars(), "pureVirtual2");
|
||||
find(pureVirtual2);
|
||||
QCOMPARE(find.usages().size(), 1);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(find.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
|
||||
Function * const main = doc->globalSymbolAt(6)->asFunction();
|
||||
QVERIFY(main);
|
||||
@@ -2248,16 +2250,16 @@ int main()
|
||||
QCOMPARE(p->name()->identifier()->chars(), "p");
|
||||
find(p);
|
||||
QCOMPARE(find.usages().size(), 10);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Initialization);
|
||||
QCOMPARE(find.usages().at(1).type, Usage::Type::Write);
|
||||
QCOMPARE(find.usages().at(2).type, Usage::Type::Write);
|
||||
QCOMPARE(find.usages().at(3).type, Usage::Type::WritableRef);
|
||||
QCOMPARE(find.usages().at(4).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(5).type, Usage::Type::WritableRef);
|
||||
QCOMPARE(find.usages().at(6).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(7).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(8).type, Usage::Type::WritableRef);
|
||||
QCOMPARE(find.usages().at(9).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(0).tags, Initialization);
|
||||
QCOMPARE(find.usages().at(1).tags, Usage::Tag::Write);
|
||||
QCOMPARE(find.usages().at(2).tags, Usage::Tag::Write);
|
||||
QCOMPARE(find.usages().at(3).tags, Usage::Tag::WritableRef);
|
||||
QCOMPARE(find.usages().at(4).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(5).tags, Usage::Tag::WritableRef);
|
||||
QCOMPARE(find.usages().at(6).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(7).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(8).tags, Usage::Tag::WritableRef);
|
||||
QCOMPARE(find.usages().at(9).tags, Usage::Tag::Read);
|
||||
|
||||
// Access to struct variable via its members
|
||||
Declaration * const varS = block->memberAt(0)->asDeclaration();
|
||||
@@ -2265,70 +2267,70 @@ int main()
|
||||
QCOMPARE(varS->name()->identifier()->chars(), "s");
|
||||
find(varS);
|
||||
QCOMPARE(find.usages().size(), 33);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(find.usages().at(1).type, Usage::Type::WritableRef);
|
||||
QCOMPARE(find.usages().at(2).type, Usage::Type::WritableRef);
|
||||
QCOMPARE(find.usages().at(3).type, Usage::Type::WritableRef);
|
||||
QCOMPARE(find.usages().at(4).type, Usage::Type::Write);
|
||||
QCOMPARE(find.usages().at(5).type, Usage::Type::WritableRef);
|
||||
QCOMPARE(find.usages().at(6).type, Usage::Type::Write);
|
||||
QCOMPARE(find.usages().at(7).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(8).type, Usage::Type::Write);
|
||||
QCOMPARE(find.usages().at(9).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(10).type, Usage::Type::WritableRef);
|
||||
QCOMPARE(find.usages().at(11).type, Usage::Type::WritableRef);
|
||||
QCOMPARE(find.usages().at(12).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(13).type, Usage::Type::WritableRef);
|
||||
QCOMPARE(find.usages().at(14).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(15).type, Usage::Type::WritableRef);
|
||||
QCOMPARE(find.usages().at(16).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(17).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(find.usages().at(1).tags, Usage::Tag::WritableRef);
|
||||
QCOMPARE(find.usages().at(2).tags, Usage::Tag::WritableRef);
|
||||
QCOMPARE(find.usages().at(3).tags, Usage::Tag::WritableRef);
|
||||
QCOMPARE(find.usages().at(4).tags, Usage::Tag::Write);
|
||||
QCOMPARE(find.usages().at(5).tags, Usage::Tag::WritableRef);
|
||||
QCOMPARE(find.usages().at(6).tags, Usage::Tag::Write);
|
||||
QCOMPARE(find.usages().at(7).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(8).tags, Usage::Tag::Write);
|
||||
QCOMPARE(find.usages().at(9).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(10).tags, Usage::Tag::WritableRef);
|
||||
QCOMPARE(find.usages().at(11).tags, Usage::Tag::WritableRef);
|
||||
QCOMPARE(find.usages().at(12).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(13).tags, Usage::Tag::WritableRef);
|
||||
QCOMPARE(find.usages().at(14).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(15).tags, Usage::Tag::WritableRef);
|
||||
QCOMPARE(find.usages().at(16).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(17).tags, Usage::Tag::Read);
|
||||
|
||||
// Direct access to struct variable
|
||||
QCOMPARE(find.usages().at(18).type, Usage::Type::Write);
|
||||
QCOMPARE(find.usages().at(19).type, Usage::Type::WritableRef);
|
||||
QCOMPARE(find.usages().at(18).tags, Usage::Tag::Write);
|
||||
QCOMPARE(find.usages().at(19).tags, Usage::Tag::WritableRef);
|
||||
QEXPECT_FAIL(nullptr, "parser does not record const qualifier for auto types", Continue);
|
||||
QCOMPARE(find.usages().at(20).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(20).tags, Usage::Tag::Read);
|
||||
QEXPECT_FAIL(nullptr, "parser does not record reference qualifier for auto types", Continue);
|
||||
QCOMPARE(find.usages().at(21).type, Usage::Type::WritableRef);
|
||||
QCOMPARE(find.usages().at(21).tags, Usage::Tag::WritableRef);
|
||||
QEXPECT_FAIL(nullptr, "parser does not record const qualifier for auto types", Continue);
|
||||
QCOMPARE(find.usages().at(22).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(22).tags, Usage::Tag::Read);
|
||||
|
||||
// Member function calls.
|
||||
QCOMPARE(find.usages().at(23).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(24).type, Usage::Type::WritableRef);
|
||||
QCOMPARE(find.usages().at(25).type, Usage::Type::WritableRef);
|
||||
QCOMPARE(find.usages().at(26).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(27).type, Usage::Type::WritableRef);
|
||||
QCOMPARE(find.usages().at(28).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(29).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(31).type, Usage::Type::Other);
|
||||
QCOMPARE(find.usages().at(32).type, Usage::Type::Other);
|
||||
QCOMPARE(find.usages().at(23).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(24).tags, Usage::Tag::WritableRef);
|
||||
QCOMPARE(find.usages().at(25).tags, Usage::Tag::WritableRef);
|
||||
QCOMPARE(find.usages().at(26).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(27).tags, Usage::Tag::WritableRef);
|
||||
QCOMPARE(find.usages().at(28).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(29).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(31).tags, Usage::Tags());
|
||||
QCOMPARE(find.usages().at(32).tags, Usage::Tags());
|
||||
|
||||
// Usages of struct type
|
||||
find(structS);
|
||||
QCOMPARE(find.usages().size(), 18);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(find.usages().at(1).type, Usage::Type::Other);
|
||||
QCOMPARE(find.usages().at(2).type, Usage::Type::Other);
|
||||
QCOMPARE(find.usages().at(3).type, Usage::Type::Other);
|
||||
QCOMPARE(find.usages().at(4).type, Usage::Type::Other);
|
||||
QCOMPARE(find.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(find.usages().at(1).tags, Usage::Tags());
|
||||
QCOMPARE(find.usages().at(2).tags, Usage::Tags());
|
||||
QCOMPARE(find.usages().at(3).tags, Usage::Tags());
|
||||
QCOMPARE(find.usages().at(4).tags, Usage::Tags());
|
||||
|
||||
// These are conceptually questionable, as S is a type and thus we cannot "read from"
|
||||
// or "write to" it. But it possibly matches the intuitive user expectation.
|
||||
QCOMPARE(find.usages().at(5).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(6).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(7).type, Usage::Type::Write);
|
||||
QCOMPARE(find.usages().at(8).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(9).type, Usage::Type::Write);
|
||||
QCOMPARE(find.usages().at(10).type, Usage::Type::Write);
|
||||
QCOMPARE(find.usages().at(11).type, Usage::Type::Write);
|
||||
QCOMPARE(find.usages().at(12).type, Usage::Type::Write);
|
||||
QCOMPARE(find.usages().at(13).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(14).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(15).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(16).type, Usage::Type::Write);
|
||||
QCOMPARE(find.usages().at(17).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(5).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(6).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(7).tags, Usage::Tag::Write);
|
||||
QCOMPARE(find.usages().at(8).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(9).tags, Usage::Tag::Write);
|
||||
QCOMPARE(find.usages().at(10).tags, Usage::Tag::Write);
|
||||
QCOMPARE(find.usages().at(11).tags, Usage::Tag::Write);
|
||||
QCOMPARE(find.usages().at(12).tags, Usage::Tag::Write);
|
||||
QCOMPARE(find.usages().at(13).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(14).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(15).tags, Usage::Tag::Read);
|
||||
QCOMPARE(find.usages().at(16).tags, Usage::Tag::Write);
|
||||
QCOMPARE(find.usages().at(17).tags, Usage::Tag::Read);
|
||||
|
||||
// Arrays.
|
||||
Declaration * const array = block->memberAt(17)->asDeclaration();
|
||||
@@ -2336,9 +2338,9 @@ int main()
|
||||
QCOMPARE(array->name()->identifier()->chars(), "array");
|
||||
find(array);
|
||||
QCOMPARE(find.usages().size(), 3);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Declaration);
|
||||
QCOMPARE(find.usages().at(1).type, Usage::Type::Write);
|
||||
QCOMPARE(find.usages().at(2).type, Usage::Type::Read);
|
||||
QCOMPARE(find.usages().at(0).tags, Usage::Tag::Declaration);
|
||||
QCOMPARE(find.usages().at(1).tags, Usage::Tag::Write);
|
||||
QCOMPARE(find.usages().at(2).tags, Usage::Tag::Read);
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(tst_FindUsages)
|
||||
|
||||
Reference in New Issue
Block a user