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

Method applyReloadModeAndReload

kdevplatform/debugger/tests/test_breakpointmodel.cpp:234–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232}
233
234TestBreakpointModel::ReloadMode TestBreakpointModel::applyReloadModeAndReload(const QUrl& url, IDocument* doc,
235 Breakpoint* b1)
236{
237 QFETCH(const ReloadMode, reloadMode);
238 if (reloadMode != ReloadMode::Clean) {
239 const auto* const textDoc = doc->textDocument();
240 QString text;
241 if (reloadMode == ReloadMode::DirtyBreakpointLine) {
242 // Modify text on a breakpoint's line to prevent KTextEditor from restoring the breakpoint's mark when
243 // the document is reloaded. KDevelop must ensure the breakpoint mark is restored in this case too.
244 text = textDoc->text({{0, 0}, {b1->line(), 0}});
245 text += textDoc->text({{b1->line(), 4}, textDoc->documentEnd()});
246 } else {
247 // Remove several lines from the end of the document's file.
248 // This must not affect breakpoints above the removed lines.
249 text = textDoc->text({{0, 0}, {textDoc->lines() - 3, 0}});
250 }
251
252 overwriteExistingFile(url, text);
253 RETURN_IF_TEST_FAILED(reloadMode);
254 }
255
256 doc->reload();
257 return reloadMode;
258}
259
260TestBreakpointModel::TestBreakpointModel(QObject* parent)
261 : QObject(parent)

Callers

nothing calls this directly

Calls 6

overwriteExistingFileFunction · 0.85
textDocumentMethod · 0.45
textMethod · 0.45
lineMethod · 0.45
linesMethod · 0.45
reloadMethod · 0.45

Tested by

no test coverage detected