| 50 | } // unnamed namespace |
| 51 | |
| 52 | ScriptAppJob::ScriptAppJob(ExecuteScriptPlugin* parent, KDevelop::ILaunchConfiguration* cfg) |
| 53 | : OutputJob(parent) |
| 54 | , proc(nullptr) |
| 55 | , lineMaker(nullptr) |
| 56 | { |
| 57 | qCDebug(PLUGIN_EXECUTESCRIPT) << "creating script app job"; |
| 58 | setCapabilities(Killable); |
| 59 | |
| 60 | auto* iface = KDevelop::ICore::self()->pluginController()->pluginForExtension(QStringLiteral("org.kdevelop.IExecuteScriptPlugin"))->extension<IExecuteScriptPlugin>(); |
| 61 | Q_ASSERT(iface); |
| 62 | |
| 63 | QString err; |
| 64 | const auto detectError = [&err, this](int errorCode) { |
| 65 | if (err.isEmpty()) { |
| 66 | return false; |
| 67 | } |
| 68 | setError(errorCode); |
| 69 | setErrorText(err); |
| 70 | return true; |
| 71 | }; |
| 72 | |
| 73 | const auto interpreter = iface->interpreter(cfg, err); |
| 74 | if (detectError(-2)) { |
| 75 | return; |
| 76 | } |
| 77 | |
| 78 | QUrl script; |
| 79 | if( !iface->runCurrentFile( cfg ) ) |
| 80 | { |
| 81 | script = iface->script( cfg, err ); |
| 82 | if (detectError(-3)) { |
| 83 | return; |
| 84 | } |
| 85 | } else { |
| 86 | KDevelop::IDocument* document = KDevelop::ICore::self()->documentController()->activeDocument(); |
| 87 | if( !document ) |
| 88 | { |
| 89 | setError( -1 ); |
| 90 | setErrorText( i18n( "There is no active document to launch." ) ); |
| 91 | return; |
| 92 | } |
| 93 | script = ICore::self()->runtimeController()->currentRuntime()->pathInRuntime(KDevelop::Path(document->url())).toUrl(); |
| 94 | } |
| 95 | const auto scriptPath = script.toLocalFile(); |
| 96 | |
| 97 | QString remoteHost = iface->remoteHost( cfg, err ); |
| 98 | if (detectError(-4)) { |
| 99 | return; |
| 100 | } |
| 101 | |
| 102 | QStringList arguments = iface->arguments( cfg, err ); |
| 103 | if (detectError(-5)) { |
| 104 | return; |
| 105 | } |
| 106 | |
| 107 | auto currentFilterMode = static_cast<KDevelop::OutputModel::OutputFilterStrategy>( iface->outputFilterModeId( cfg ) ); |
| 108 | |
| 109 | proc = new KProcess(this); |
nothing calls this directly
no test coverage detected