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

Method documentUrlChanged

kdevplatform/debugger/breakpoint/breakpointmodel.cpp:186–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184}
185
186void BreakpointModel::documentUrlChanged(KDevelop::IDocument* document, const QUrl& previousUrl)
187{
188 Q_D(BreakpointModel);
189
190 // Ignore non-text documents.
191 if (!document->textDocument()) {
192 return;
193 }
194
195 // We rely on previousUrl being an IDocument::url(), which is unique and never empty.
196 // An empty previousUrl is unacceptable, because a breakpoint's empty URL
197 // value means "none" and must not be replaced in the loop below.
198 Q_ASSERT(!previousUrl.isEmpty());
199
200 std::vector<Breakpoint*> updatedBreakpoints;
201 const auto destinationUrl = document->url();
202 for (auto* const breakpoint : std::as_const(d->breakpoints)) {
203 // Ignore unsuitable breakpoints.
204 if (breakpoint->kind() != Breakpoint::CodeBreakpoint || breakpoint->url() != previousUrl) {
205 continue;
206 }
207 // Update the breakpoint to use the (renamed to) destinationUrl.
208 breakpoint->assignUrl(destinationUrl);
209 updatedBreakpoints.push_back(breakpoint);
210 }
211
212 // The loop above silently reassigns URLs to restore consistency between the Breakpoint URLs and moving cursors.
213 // Notify the world about the URL changes in this separate loop to avoid possible inconsistency issues.
214 for (auto* const breakpoint : updatedBreakpoints) {
215 reportChange(breakpoint, Breakpoint::LocationColumn);
216 }
217}
218
219void BreakpointModel::removeBreakpointMarks(KTextEditor::Document& document)
220{

Callers

nothing calls this directly

Calls 6

assignUrlMethod · 0.80
textDocumentMethod · 0.45
isEmptyMethod · 0.45
urlMethod · 0.45
kindMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected