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

Function executeIncludePathCompletion

plugins/clang/tests/test_codecompletion.cpp:303–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

301using IncludeTester = CodeCompletionItemTester<IncludePathCompletionContext>;
302
303QExplicitlySharedDataPointer<IncludePathCompletionContext> executeIncludePathCompletion(TestFile* file, const KTextEditor::Cursor& position)
304{
305 if (!file->parseAndWait(TopDUContext::AllDeclarationsContextsUsesAndAST)) {
306 QTest::qFail("Failed to parse source file.", __FILE__, __LINE__);
307 return {};
308 }
309
310 DUChainReadLocker lock;
311 auto top = file->topContext();
312 if (!top) {
313 QTest::qFail("Failed to parse source file.", __FILE__, __LINE__);
314 return {};
315 }
316 const ParseSessionData::Ptr sessionData(dynamic_cast<ParseSessionData*>(top->ast().data()));
317 if (!sessionData) {
318 QTest::qFail("Failed to acquire parse session data.", __FILE__, __LINE__);
319 return {};
320 }
321
322 DUContextPointer topPtr(top);
323
324 lock.unlock();
325
326 auto text = file->fileContents();
327 int textLength = -1;
328 if (position.isValid()) {
329 textLength = 0;
330 for (int i = 0; i < position.line(); ++i) {
331 textLength = text.indexOf('\n', textLength) + 1;
332 }
333 textLength += position.column();
334 }
335 auto context = new IncludePathCompletionContext(topPtr, sessionData, file->url().toUrl(), position, text.mid(0, textLength));
336 return QExplicitlySharedDataPointer<IncludePathCompletionContext>{context};
337}
338
339constexpr const char* definesAndIncludesConfigName = "CustomDefinesAndIncludes";
340

Callers 2

Calls 13

parseAndWaitMethod · 0.80
fileContentsMethod · 0.80
midMethod · 0.80
topContextMethod · 0.45
dataMethod · 0.45
astMethod · 0.45
unlockMethod · 0.45
isValidMethod · 0.45
lineMethod · 0.45
indexOfMethod · 0.45
columnMethod · 0.45
toUrlMethod · 0.45

Tested by

no test coverage detected