aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Ziller <git@eikeziller.de>2017-04-24 16:42:24 +0200
committerEike Ziller <git@eikeziller.de>2017-10-01 20:11:08 +0200
commit2f69373309cfe88084c5777baeff6bb46eecd071 (patch)
tree8d812f1e02821826aa2b8aec9b910a8df8d3b280
parentb682f2b32716b6f3a60ee9b422041a358a36e86c (diff)
Provide snippet group
-rw-r--r--plugins/haskell/haskell.pro18
-rw-r--r--plugins/haskell/haskellcompletionassist.cpp44
-rw-r--r--plugins/haskell/haskellcompletionassist.h45
-rw-r--r--plugins/haskell/haskellconstants.h3
-rw-r--r--plugins/haskell/haskelleditorfactory.cpp11
-rw-r--r--plugins/haskell/haskellplugin.cpp5
6 files changed, 114 insertions, 12 deletions
diff --git a/plugins/haskell/haskell.pro b/plugins/haskell/haskell.pro
index f6aabb2..9c557b1 100644
--- a/plugins/haskell/haskell.pro
+++ b/plugins/haskell/haskell.pro
@@ -2,13 +2,17 @@ DEFINES += HASKELL_LIBRARY
# Haskell files
-SOURCES += haskellplugin.cpp \
- haskelleditorfactory.cpp
-
-HEADERS += haskellplugin.h \
- haskell_global.h \
- haskellconstants.h \
- haskelleditorfactory.h
+SOURCES += \
+ haskellcompletionassist.cpp \
+ haskelleditorfactory.cpp \
+ haskellplugin.cpp
+
+HEADERS += \
+ haskell_global.h \
+ haskellcompletionassist.h \
+ haskellconstants.h \
+ haskelleditorfactory.h \
+ haskellplugin.h
## uncomment to build plugin into user config directory
## <localappdata>/plugins/<ideversion>
diff --git a/plugins/haskell/haskellcompletionassist.cpp b/plugins/haskell/haskellcompletionassist.cpp
new file mode 100644
index 0000000..aa053f5
--- /dev/null
+++ b/plugins/haskell/haskellcompletionassist.cpp
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#include "haskellcompletionassist.h"
+
+#include "haskellconstants.h"
+
+#include <coreplugin/id.h>
+#include <texteditor/codeassist/keywordscompletionassist.h>
+
+namespace Haskell {
+namespace Internal {
+
+TextEditor::IAssistProcessor *HaskellCompletionAssistProvider::createProcessor() const
+{
+ auto processor = new TextEditor::KeywordsCompletionAssistProcessor(TextEditor::Keywords());
+ processor->setSnippetGroup(Constants::C_HASKELLSNIPPETSGROUP_ID);
+ return processor;
+}
+
+} // namespace Internal
+} // namespace Haskell
diff --git a/plugins/haskell/haskellcompletionassist.h b/plugins/haskell/haskellcompletionassist.h
new file mode 100644
index 0000000..9b3f0ca
--- /dev/null
+++ b/plugins/haskell/haskellcompletionassist.h
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#ifndef HASKELLCOMPLETIONASSIST_H
+#define HASKELLCOMPLETIONASSIST_H
+
+#include <texteditor/codeassist/completionassistprovider.h>
+
+namespace Haskell {
+namespace Internal {
+
+class HaskellCompletionAssistProvider : public TextEditor::CompletionAssistProvider
+{
+ Q_OBJECT
+
+public:
+ TextEditor::IAssistProcessor *createProcessor() const override;
+};
+
+} // namespace Internal
+} // namespace Haskell
+
+#endif // HASKELLCOMPLETIONASSIST_H
diff --git a/plugins/haskell/haskellconstants.h b/plugins/haskell/haskellconstants.h
index 05b5c91..55be670 100644
--- a/plugins/haskell/haskellconstants.h
+++ b/plugins/haskell/haskellconstants.h
@@ -28,5 +28,8 @@
namespace Haskell {
namespace Constants {
+const char C_HASKELLEDITOR_ID[] = "Haskell.HaskellEditor";
+const char C_HASKELLSNIPPETSGROUP_ID[] = "Haskell";
+
} // namespace Haskell
} // namespace Constants
diff --git a/plugins/haskell/haskelleditorfactory.cpp b/plugins/haskell/haskelleditorfactory.cpp
index 704f7f4..220e52e 100644
--- a/plugins/haskell/haskelleditorfactory.cpp
+++ b/plugins/haskell/haskelleditorfactory.cpp
@@ -25,27 +25,28 @@
#include "haskelleditorfactory.h"
+#include "haskellcompletionassist.h"
+#include "haskellconstants.h"
+
#include <texteditor/textdocument.h>
#include <texteditor/texteditoractionhandler.h>
#include <QCoreApplication>
-const char C_HASKELLEDITOR_ID[] = "Haskell.HaskellEditor";
-
namespace Haskell {
namespace Internal {
HaskellEditorFactory::HaskellEditorFactory()
{
- setId(C_HASKELLEDITOR_ID);
+ setId(Constants::C_HASKELLEDITOR_ID);
setDisplayName(QCoreApplication::translate("OpenWith::Editors", "Haskell Editor"));
addMimeType("text/x-haskell");
setEditorActionHandlers(TextEditor::TextEditorActionHandler::UnCommentSelection);
-
- setDocumentCreator([] { return new TextEditor::TextDocument(C_HASKELLEDITOR_ID); });
+ setDocumentCreator([] { return new TextEditor::TextDocument(Constants::C_HASKELLEDITOR_ID); });
setCommentDefinition(Utils::CommentDefinition("--", "{-", "-}"));
setParenthesesMatchingEnabled(true);
setMarksVisible(true);
+ setCompletionAssistProvider(new HaskellCompletionAssistProvider);
}
} // Internal
diff --git a/plugins/haskell/haskellplugin.cpp b/plugins/haskell/haskellplugin.cpp
index 8df9961..fd6827f 100644
--- a/plugins/haskell/haskellplugin.cpp
+++ b/plugins/haskell/haskellplugin.cpp
@@ -27,6 +27,8 @@
#include "haskellconstants.h"
#include "haskelleditorfactory.h"
+#include <texteditor/snippets/snippetprovider.h>
+
namespace Haskell {
namespace Internal {
@@ -55,6 +57,9 @@ bool HaskellPlugin::initialize(const QStringList &arguments, QString *errorStrin
addAutoReleasedObject(new HaskellEditorFactory);
+ TextEditor::SnippetProvider::registerGroup(Constants::C_HASKELLSNIPPETSGROUP_ID,
+ tr("Haskell", "SnippetProvider"));
+
return true;
}