aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/haskell/haskellplugin.cpp
blob: 6da003c1a5021cb97c32fb56ba290cab282e0891 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright (c) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#include "haskellbuildconfiguration.h"
#include "haskellconstants.h"
#include "haskelleditorfactory.h"
#include "haskellmanager.h"
#include "haskellproject.h"
#include "haskellrunconfiguration.h"
#include "haskelltr.h"
#include "stackbuildstep.h"

#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/icore.h>

#include <extensionsystem/iplugin.h>

#include <projectexplorer/jsonwizard/jsonwizardfactory.h>
#include <projectexplorer/projectmanager.h>
#include <projectexplorer/runcontrol.h>

#include <texteditor/snippets/snippetprovider.h>

#include <QAction>

namespace Haskell::Internal {

static void registerGhciAction(QObject *guard)
{
    QAction *action = new QAction(Tr::tr("Run GHCi"), guard);
    Core::ActionManager::registerAction(action, Constants::A_RUN_GHCI);
    QObject::connect(action, &QAction::triggered, guard, [] {
        if (Core::IDocument *doc = Core::EditorManager::currentDocument())
            HaskellManager::openGhci(doc->filePath());
    });
}

class HaskellPlugin final : public ExtensionSystem::IPlugin
{
    Q_OBJECT
    Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Haskell.json")

public:
    void initialize() final
    {
        setupHaskellStackBuildStep();
        setupHaskellBuildConfiguration();

        setupHaskellRunSupport();

        setupHaskellEditor();

        ProjectExplorer::ProjectManager::registerProjectType<HaskellProject>(
            Constants::C_HASKELL_PROJECT_MIMETYPE);
        TextEditor::SnippetProvider::registerGroup(Constants::C_HASKELLSNIPPETSGROUP_ID,
                                                   Tr::tr("Haskell", "SnippetProvider"));

        registerGhciAction(this);

        ProjectExplorer::JsonWizardFactory::addWizardPath(":/haskell/share/wizards/");
    }
};

} // Haskell::Internal

#include "haskellplugin.moc"