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

Method testVariableScope

plugins/clang/tests/test_codecompletion.cpp:1367–1388  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1365}
1366
1367void TestCodeCompletion::testVariableScope()
1368{
1369 TestFile file(QStringLiteral("int var; \nvoid test(int var) {int tmp =\n }"), QStringLiteral("cpp"));
1370 QVERIFY(file.parseAndWait(TopDUContext::AllDeclarationsContextsUsesAndAST));
1371 DUChainReadLocker lock;
1372 auto top = file.topContext();
1373 QVERIFY(top);
1374 const ParseSessionData::Ptr sessionData(dynamic_cast<ParseSessionData*>(top->ast().data()));
1375 QVERIFY(sessionData);
1376
1377 lock.unlock();
1378
1379 const auto context = createContext(top, sessionData, {2, 0});
1380 context->setFilters(NoMacroOrBuiltin);
1381 lock.lock();
1382 const auto tester = ClangCodeCompletionItemTester(context);
1383
1384 QCOMPARE(tester.items.size(), 3);
1385 auto item = tester.findItem(QStringLiteral("var"));
1386 VERIFY(item);
1387 QCOMPARE(item->declaration()->range().start, CursorInRevision(1, 14));
1388}
1389
1390struct HintItem
1391{

Callers

nothing calls this directly

Calls 13

createContextFunction · 0.85
parseAndWaitMethod · 0.80
CursorInRevisionClass · 0.50
topContextMethod · 0.45
dataMethod · 0.45
astMethod · 0.45
unlockMethod · 0.45
setFiltersMethod · 0.45
lockMethod · 0.45
sizeMethod · 0.45
findItemMethod · 0.45
rangeMethod · 0.45

Tested by

no test coverage detected