| 453 | } |
| 454 | |
| 455 | void TestDUChain::testReparse() |
| 456 | { |
| 457 | TestFile file(QStringLiteral("int main() { int i = 42; return i; }"), QStringLiteral("cpp")); |
| 458 | file.parse(TopDUContext::AllDeclarationsContextsAndUses); |
| 459 | |
| 460 | DeclarationPointer mainDecl; |
| 461 | DeclarationPointer iDecl; |
| 462 | for (int i = 0; i < 3; ++i) { |
| 463 | QVERIFY(file.waitForParsed(500)); |
| 464 | DUChainReadLocker lock; |
| 465 | QVERIFY(file.topContext()); |
| 466 | QCOMPARE(file.topContext()->childContexts().size(), 1); |
| 467 | QCOMPARE(file.topContext()->localDeclarations().size(), 1); |
| 468 | DUContext *exprContext = file.topContext()->childContexts().first()->childContexts().first(); |
| 469 | QCOMPARE(exprContext->localDeclarations().size(), 1); |
| 470 | |
| 471 | if (i) { |
| 472 | QVERIFY(mainDecl); |
| 473 | QCOMPARE(mainDecl.data(), file.topContext()->localDeclarations().first()); |
| 474 | |
| 475 | QVERIFY(iDecl); |
| 476 | QCOMPARE(iDecl.data(), exprContext->localDeclarations().first()); |
| 477 | } |
| 478 | mainDecl = file.topContext()->localDeclarations().first(); |
| 479 | iDecl = exprContext->localDeclarations().first(); |
| 480 | |
| 481 | QVERIFY(mainDecl->uses().isEmpty()); |
| 482 | QCOMPARE(iDecl->uses().size(), 1); |
| 483 | QCOMPARE(iDecl->uses().begin()->size(), 1); |
| 484 | |
| 485 | if (i == 1) { |
| 486 | file.setFileContents(QStringLiteral("int main()\n{\nfloat i = 13; return i - 5;\n}\n")); |
| 487 | } |
| 488 | |
| 489 | file.parse(TopDUContext::AllDeclarationsContextsAndUses | TopDUContext::ForceUpdateRecursive); |
| 490 | } |
| 491 | } |
| 492 | |
| 493 | void TestDUChain::testReparseError() |
| 494 | { |
nothing calls this directly
no test coverage detected