MCPcopy Create free account
hub / github.com/KDE/kdevelop / testReparse

Method testReparse

plugins/clang/tests/test_duchain.cpp:455–491  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

453}
454
455void 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
493void TestDUChain::testReparseError()
494{

Callers

nothing calls this directly

Calls 12

waitForParsedMethod · 0.80
childContextsMethod · 0.80
localDeclarationsMethod · 0.80
parseMethod · 0.45
topContextMethod · 0.45
sizeMethod · 0.45
firstMethod · 0.45
dataMethod · 0.45
isEmptyMethod · 0.45
usesMethod · 0.45
beginMethod · 0.45
setFileContentsMethod · 0.45

Tested by

no test coverage detected