forked from qt-creator/qt-creator
CPlusPlus: Properly categorize usages in if statements
Change-Id: I5f6e5fa14ea51cd9e61a9e2e96c110ca618be429 Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
@@ -334,6 +334,8 @@ Usage::Type FindUsages::getType(int line, int column, int tokenIndex)
|
||||
return Usage::Type::Read;
|
||||
if ((*it)->asCaseStatement())
|
||||
return Usage::Type::Read;
|
||||
if ((*it)->asIfStatement())
|
||||
return Usage::Type::Read;
|
||||
if ((*it)->asLambdaCapture() || (*it)->asNamedTypeSpecifier()
|
||||
|| (*it)->asElaboratedTypeSpecifier()) {
|
||||
return Usage::Type::Other;
|
||||
|
@@ -2084,6 +2084,8 @@ int main()
|
||||
switch (S::value = 5) {
|
||||
default: break;
|
||||
}
|
||||
if (S::value) {}
|
||||
if (S::value = 0) {}
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -2109,7 +2111,7 @@ int main()
|
||||
// Access to struct member
|
||||
FindUsages find(src, doc, snapshot);
|
||||
find(sv);
|
||||
QCOMPARE(find.usages().size(), 21);
|
||||
QCOMPARE(find.usages().size(), 23);
|
||||
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);
|
||||
@@ -2131,6 +2133,8 @@ int main()
|
||||
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);
|
||||
|
||||
Declaration * const sv2 = structS->memberAt(2)->asDeclaration();
|
||||
QVERIFY(sv2);
|
||||
@@ -2147,7 +2151,7 @@ int main()
|
||||
QCOMPARE(main->memberCount(), 1);
|
||||
Block * const block = main->memberAt(0)->asBlock();
|
||||
QVERIFY(block);
|
||||
QCOMPARE(block->memberCount(), 15);
|
||||
QCOMPARE(block->memberCount(), 17);
|
||||
|
||||
// Access to pointer
|
||||
Declaration * const p = block->memberAt(1)->asDeclaration();
|
||||
@@ -2213,7 +2217,7 @@ int main()
|
||||
|
||||
// Usages of struct type
|
||||
find(structS);
|
||||
QCOMPARE(find.usages().size(), 8);
|
||||
QCOMPARE(find.usages().size(), 10);
|
||||
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);
|
||||
@@ -2225,6 +2229,8 @@ int main()
|
||||
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);
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(tst_FindUsages)
|
||||
|
Reference in New Issue
Block a user