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

Method executeScriptFromContextMenu

plugins/externalscript/externalscriptplugin.cpp:326–346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

324}
325
326void ExternalScriptPlugin::executeScriptFromContextMenu() const
327{
328 auto* action = qobject_cast<QAction*>(sender());
329 Q_ASSERT(action);
330
331 auto* item = action->data().value<ExternalScriptItem*>();
332 Q_ASSERT(item);
333
334 for (const QUrl& url : m_urls) {
335 // An empty URL here probably means that the user triggered an external script action from an untitled
336 // document's context menu. In this case EditorContext::url() returns an untitled KTextEditor::Document's
337 // URL, which is empty. An empty QUrl is relative, so attempting to open an empty URL makes the assertion
338 // !inputUrl.isRelative() in DocumentControllerPrivate::openDocumentInternal() fail.
339 // Therefore, do not attempt to open a document for an empty URL. In the discussed scenario the untitled
340 // document is already open and active. Thus the triggered external script action can work correctly.
341 if (!url.isEmpty()) {
342 KDevelop::ICore::self()->documentController()->openDocument(url);
343 }
344 execute(item, url);
345 }
346}
347
348void ExternalScriptPlugin::rowsInserted(const QModelIndex& /*parent*/, int start, int end)
349{

Callers

nothing calls this directly

Calls 5

executeFunction · 0.85
documentControllerMethod · 0.80
dataMethod · 0.45
isEmptyMethod · 0.45
openDocumentMethod · 0.45

Tested by

no test coverage detected