| 276 | } |
| 277 | |
| 278 | void ExternalScriptJob::processFinished(int exitCode, QProcess::ExitStatus status) |
| 279 | { |
| 280 | m_lineMaker->flushBuffers(); |
| 281 | |
| 282 | if (exitCode == 0 && status == QProcess::NormalExit) { |
| 283 | if (m_outputMode != ExternalScriptItem::OutputNone) { |
| 284 | if (!m_stdout.isEmpty()) { |
| 285 | QString output = m_stdout.join(QLatin1Char('\n')); |
| 286 | switch (m_outputMode) { |
| 287 | case ExternalScriptItem::OutputNone: |
| 288 | // do nothing; |
| 289 | break; |
| 290 | case ExternalScriptItem::OutputCreateNewFile: |
| 291 | KDevelop::ICore::self()->documentController()->openDocumentFromText(output); |
| 292 | break; |
| 293 | case ExternalScriptItem::OutputInsertAtCursor: |
| 294 | m_document->insertText(m_cursorPosition, output); |
| 295 | break; |
| 296 | case ExternalScriptItem::OutputReplaceSelectionOrInsertAtCursor: |
| 297 | if (m_selectionRange.isValid()) { |
| 298 | m_document->replaceText(m_selectionRange, output); |
| 299 | } else { |
| 300 | m_document->insertText(m_cursorPosition, output); |
| 301 | } |
| 302 | break; |
| 303 | case ExternalScriptItem::OutputReplaceSelectionOrDocument: |
| 304 | if (m_selectionRange.isValid()) { |
| 305 | m_document->replaceText(m_selectionRange, output); |
| 306 | } else { |
| 307 | m_document->setText(output); |
| 308 | } |
| 309 | break; |
| 310 | case ExternalScriptItem::OutputReplaceDocument: |
| 311 | m_document->setText(output); |
| 312 | break; |
| 313 | } |
| 314 | } |
| 315 | } |
| 316 | if (m_errorMode != ExternalScriptItem::ErrorNone && m_errorMode != ExternalScriptItem::ErrorMergeOutput) { |
| 317 | QString output = m_stderr.join(QLatin1Char('\n')); |
| 318 | |
| 319 | if (!output.isEmpty()) { |
| 320 | switch (m_errorMode) { |
| 321 | case ExternalScriptItem::ErrorNone: |
| 322 | case ExternalScriptItem::ErrorMergeOutput: |
| 323 | // do nothing; |
| 324 | break; |
| 325 | case ExternalScriptItem::ErrorCreateNewFile: |
| 326 | KDevelop::ICore::self()->documentController()->openDocumentFromText(output); |
| 327 | break; |
| 328 | case ExternalScriptItem::ErrorInsertAtCursor: |
| 329 | m_document->insertText(m_cursorPosition, output); |
| 330 | break; |
| 331 | case ExternalScriptItem::ErrorReplaceSelectionOrInsertAtCursor: |
| 332 | if (m_selectionRange.isValid()) { |
| 333 | m_document->replaceText(m_selectionRange, output); |
| 334 | } else { |
| 335 | m_document->insertText(m_cursorPosition, output); |
nothing calls this directly
no test coverage detected