diff options
| author | Eike Ziller <eike.ziller@qt.io> | 2017-12-23 11:20:52 +0100 |
|---|---|---|
| committer | Eike Ziller <eike.ziller@qt.io> | 2018-01-06 11:08:02 +0000 |
| commit | a76efd4cac4592a9534717051c3bba801767d8b2 (patch) | |
| tree | b92854693ecce180abc84f73946f14fbcdbe1e61 /plugins/haskell/haskellhoverhandler.cpp | |
| parent | f73e91128adeaca803e53b0f7af79075bf6ee4b1 (diff) | |
Show error in editor if stack cannot be run
With the option to open the configuration page.
Change-Id: I4895e27648d5e161fd0c9b617723f7fdd6853248
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'plugins/haskell/haskellhoverhandler.cpp')
| -rw-r--r-- | plugins/haskell/haskellhoverhandler.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/plugins/haskell/haskellhoverhandler.cpp b/plugins/haskell/haskellhoverhandler.cpp index bb8472b..ffad6a9 100644 --- a/plugins/haskell/haskellhoverhandler.cpp +++ b/plugins/haskell/haskellhoverhandler.cpp @@ -86,7 +86,19 @@ void HaskellHoverHandler::identifyMatch(TextEditor::TextEditorWidget *editorWidg } } -static void tryShowToolTip(const QPointer<QWidget> &widget, const QPoint &point, +static void showError(const QPointer<TextEditor::TextEditorWidget> &widget, + const Error &typeError, const Error &infoError) +{ + if (typeError.type == Error::Type::FailedToStartStack + || infoError.type == Error::Type::FailedToStartStack) { + const QString stackExecutable = typeError.type == Error::Type::FailedToStartStack + ? typeError.details + : infoError.details; + HaskellEditorWidget::showFailedToStartStackError(stackExecutable, widget); + } +} + +static void tryShowToolTip(const QPointer<TextEditor::TextEditorWidget> &widget, const QPoint &point, QFuture<QStringOrError> typeFuture, QFuture<SymbolInfoOrError> symbolFuture) { @@ -94,6 +106,9 @@ static void tryShowToolTip(const QPointer<QWidget> &widget, const QPoint &point, && symbolFuture.isResultReadyAt(0) && typeFuture.isResultReadyAt(0)) { const QStringOrError typeOrError = typeFuture.result(); const SymbolInfoOrError infoOrError = symbolFuture.result(); + if (const Error *typeError = Utils::get_if<Error>(&typeOrError)) + if (const Error *infoError = Utils::get_if<Error>(&infoOrError)) + showError(widget, *typeError, *infoError); const QString *type = Utils::get_if<QString>(&typeOrError); const SymbolInfo *info = Utils::get_if<SymbolInfo>(&infoOrError); const QString typeString = !type || type->isEmpty() @@ -115,7 +130,7 @@ void HaskellHoverHandler::operateTooltip(TextEditor::TextEditorWidget *editorWid } Utils::ToolTip::show(point, HaskellManager::trLookingUp(m_name), editorWidget); - QPointer<QWidget> widget = editorWidget; + QPointer<TextEditor::TextEditorWidget> widget = editorWidget; std::shared_ptr<AsyncGhcMod> ghcmod; auto doc = qobject_cast<HaskellDocument *>(editorWidget->textDocument()); QTC_ASSERT(doc, return); |
