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

Method execute

plugins/clang/codecompletion/context.cpp:362–394  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

360 }
361
362 void execute(KTextEditor::View* view, const KTextEditor::Range& word) override
363 {
364 auto* const document = view->document();
365
366 DocumentChangeSet changes;
367 KTextEditor::Cursor rangeStart = word.start();
368
369 // try and replace leading typed text that match the proposed implementation
370 const QString leading = document->line(word.end().line()).left(word.end().column());
371 const QString leadingNoSpace = removeWhitespace(leading);
372 if (!leadingNoSpace.isEmpty() && (removeWhitespace(m_display).startsWith(leadingNoSpace)
373 || removeWhitespace(m_replacement).startsWith(leadingNoSpace))) {
374 const int removeSize = leading.end() - std::find_if_not(leading.begin(), leading.end(),
375 [](QChar c){ return c.isSpace(); });
376 rangeStart = {word.end().line(), word.end().column() - removeSize};
377 }
378
379 DocumentChange change(IndexedString(view->document()->url()),
380 KTextEditor::Range(rangeStart, word.end()),
381 QString(),
382 m_replacement);
383 change.m_ignoreOldText = true;
384 changes.addChange(change);
385 changes.applyAllChanges();
386
387 // Place cursor after the opening brace
388 // arbitrarily chose 4, as it would accommodate the template and return types on their own line
389 const auto searchRange = KTextEditor::Range(rangeStart, rangeStart.line() + 4, 0);
390 const auto results = view->document()->searchText(searchRange, QStringLiteral("{"));
391 if (!results.isEmpty()) {
392 view->setCursorPosition(results.first().end());
393 }
394 }
395};
396
397class ArgumentHintItem : public DeclarationItem

Callers

nothing calls this directly

Calls 15

removeWhitespaceFunction · 0.85
addChangeMethod · 0.80
applyAllChangesMethod · 0.80
IndexedStringClass · 0.50
RangeClass · 0.50
QStringClass · 0.50
documentMethod · 0.45
startMethod · 0.45
lineMethod · 0.45
endMethod · 0.45
columnMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected