diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/haskell/haskellconstants.h | 1 | ||||
-rw-r--r-- | plugins/haskell/haskelleditorwidget.cpp | 25 | ||||
-rw-r--r-- | plugins/haskell/haskelleditorwidget.h | 3 | ||||
-rw-r--r-- | plugins/haskell/haskellhoverhandler.cpp | 19 | ||||
-rw-r--r-- | plugins/haskell/optionspage.cpp | 3 |
5 files changed, 48 insertions, 3 deletions
diff --git a/plugins/haskell/haskellconstants.h b/plugins/haskell/haskellconstants.h index 1ec7113..f4c1bea 100644 --- a/plugins/haskell/haskellconstants.h +++ b/plugins/haskell/haskellconstants.h @@ -34,6 +34,7 @@ const char C_HASKELL_PROJECT_MIMETYPE[] = "text/x-haskell-project"; const char C_HASKELL_RUNCONFIG_ID_PREFIX[] = "Haskell.Run."; const char C_HASKELL_PROJECT_ID[] = "Haskell.Project"; const char C_HASKELL_EXECUTABLE_KEY[] = "Haskell.Executable"; +const char OPTIONS_GENERAL[] = "Haskell.A.General"; } // namespace Haskell } // namespace Constants diff --git a/plugins/haskell/haskelleditorwidget.cpp b/plugins/haskell/haskelleditorwidget.cpp index 8d052a9..6454d82 100644 --- a/plugins/haskell/haskelleditorwidget.cpp +++ b/plugins/haskell/haskelleditorwidget.cpp @@ -25,11 +25,16 @@ #include "haskelleditorwidget.h" +#include "haskellconstants.h" #include "haskelltokenizer.h" +#include <coreplugin/icore.h> +#include <coreplugin/infobar.h> +#include <texteditor/textdocument.h> #include <utils/textutils.h> #include <QTextBlock> +#include <QTimer> using namespace TextEditor; @@ -63,6 +68,26 @@ Utils::optional<Token> HaskellEditorWidget::symbolAt(QTextDocument *doc, int pos return Utils::nullopt; } +void HaskellEditorWidget::showFailedToStartStackError(const QString &stackExecutable, + TextEditorWidget *widget) +{ + static const char id[] = "Haskell.FailedToStartStack"; + Core::IDocument *document = widget->textDocument(); + if (!document->infoBar()->containsInfo(id)) { + Core::InfoBarEntry info( + id, + tr("Failed to start Haskell Stack \"%1\". Make sure you have stack installed and configured in the options.") + .arg(stackExecutable)); + info.setCustomButtonInfo(Core::ICore::msgShowOptionsDialog(), [document] { + QTimer::singleShot(0, Core::ICore::instance(), [document] { + document->infoBar()->removeInfo(id); + Core::ICore::showOptionsDialog(Constants::OPTIONS_GENERAL); + }); + }); + document->infoBar()->addInfo(info); + } +} + Utils::Link HaskellEditorWidget::findLinkAt(const QTextCursor &cursor, bool resolveTarget, bool inNextSplit) { diff --git a/plugins/haskell/haskelleditorwidget.h b/plugins/haskell/haskelleditorwidget.h index 819e040..2421fc3 100644 --- a/plugins/haskell/haskelleditorwidget.h +++ b/plugins/haskell/haskelleditorwidget.h @@ -43,6 +43,9 @@ public: static Utils::optional<Token> symbolAt(QTextDocument *doc, int position, int *line, int *column); + static void showFailedToStartStackError(const QString &stackExecutable, + TextEditor::TextEditorWidget *widget); + protected: Utils::Link findLinkAt(const QTextCursor &cursor, bool resolveTarget = true, bool inNextSplit = false) override; 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); diff --git a/plugins/haskell/optionspage.cpp b/plugins/haskell/optionspage.cpp index 88a5792..04cab79 100644 --- a/plugins/haskell/optionspage.cpp +++ b/plugins/haskell/optionspage.cpp @@ -25,6 +25,7 @@ #include "optionspage.h" +#include "haskellconstants.h" #include "haskellmanager.h" #include <QGroupBox> @@ -38,7 +39,7 @@ namespace Internal { OptionsPage::OptionsPage() { - setId("A.General"); + setId(Constants::OPTIONS_GENERAL); setDisplayName(tr("General")); setCategory("J.Z.Haskell"); setDisplayCategory(tr("Haskell")); |