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

Method findUrl

kdevplatform/shell/ktexteditorpluginintegration.cpp:422–444  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

420}
421
422KTextEditor::Document *Application::findUrl(const QUrl &url) const
423{
424 if (url.isEmpty()) {
425 // Return the first found document with an empty URL.
426 // Perform a linear search across all open documents. Cannot just look a document
427 // up by an empty URL, because each IDocument has a unique nonempty URL.
428 const auto documents = Core::self()->documentControllerInternal()->openDocuments();
429 const auto it = std::find_if(documents.cbegin(), documents.cend(), [](const IDocument* document) {
430 return DocumentController::isEmptyDocumentUrl(document->url());
431 });
432 return it == documents.cend() ? nullptr : (*it)->textDocument();
433 }
434
435 const auto resolvedUrl = resolvedToLocalFile(url);
436 if (!canPointToFile(resolvedUrl)) {
437 return nullptr; // a document cannot have a non-file URL
438 }
439
440 // ensure that a local-file URL has canonical path so that DocumentController::documentForUrl() finds the document
441 const auto* const doc =
442 Core::self()->documentControllerInternal()->documentForUrl(urlWithCanonicalizedPathIfLocalFile(resolvedUrl));
443 return doc ? doc->textDocument() : nullptr;
444}
445
446bool Application::quit() const
447{

Callers

nothing calls this directly

Calls 9

resolvedToLocalFileFunction · 0.85
canPointToFileFunction · 0.85
openDocumentsMethod · 0.80
documentForUrlMethod · 0.80
isEmptyMethod · 0.45
urlMethod · 0.45
textDocumentMethod · 0.45

Tested by

no test coverage detected