diff --git a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp
index ad5cb4350de0b664249ba8fdcf63b5a0c382f6a7..d0e34e06ff5129ebabfafcd4649827ccae8ca716 100644
--- a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp
@@ -33,56 +33,68 @@
 #include "cmakeprojectconstants.h"
 #include "cmakeproject.h"
 
-#include <coreplugin/icore.h>
-#include <coreplugin/infobar.h>
 #include <coreplugin/actionmanager/actioncontainer.h>
+#include <coreplugin/actionmanager/actioncontainer.h>
+#include <coreplugin/actionmanager/actionmanager.h>
 #include <coreplugin/actionmanager/actionmanager.h>
+#include <coreplugin/editormanager/editormanager.h>
+#include <coreplugin/icore.h>
+#include <coreplugin/icore.h>
+#include <coreplugin/infobar.h>
 #include <coreplugin/mimedatabase.h>
+
 #include <extensionsystem/pluginmanager.h>
+
 #include <projectexplorer/projectexplorer.h>
 #include <projectexplorer/session.h>
+
+#include <texteditor/highlighterutils.h>
 #include <texteditor/texteditoractionhandler.h>
 #include <texteditor/texteditorconstants.h>
-#include <texteditor/highlighterutils.h>
+
+#include <utils/qtcassert.h>
 
 #include <QFileInfo>
-#include <QSharedPointer>
 #include <QTextBlock>
 
-using namespace CMakeProjectManager;
-using namespace CMakeProjectManager::Internal;
+using namespace Core;
+using namespace TextEditor;
+using namespace CMakeProjectManager::Constants;
+
+namespace CMakeProjectManager {
+namespace Internal {
 
 //
-// ProFileEditorEditable
+// CMakeEditor
 //
 
 CMakeEditor::CMakeEditor()
 {
-    setContext(Core::Context(CMakeProjectManager::Constants::C_CMAKEEDITOR,
-              TextEditor::Constants::C_TEXTEDITOR));
+    addContext(Constants::C_CMAKEEDITOR);
     setDuplicateSupported(true);
     setCommentStyle(Utils::CommentDefinition::HashStyle);
     setCompletionAssistProvider(ExtensionSystem::PluginManager::getObject<CMakeFileCompletionAssistProvider>());
-}
-
-Core::IEditor *CMakeEditor::duplicate()
-{
-    CMakeEditorWidget *ret = new CMakeEditorWidget;
-    ret->setTextDocument(editorWidget()->textDocumentPtr());
-    return ret->editor();
+    setEditorCreator([]() { return new CMakeEditor; });
+    setWidgetCreator([]() { return new CMakeEditorWidget; });
+
+    setDocumentCreator([this]() -> BaseTextDocument * {
+        auto doc = new CMakeDocument;
+        connect(doc, &IDocument::changed, this, &CMakeEditor::markAsChanged);
+        return doc;
+    });
 }
 
 void CMakeEditor::markAsChanged()
 {
     if (!document()->isModified())
         return;
-    Core::InfoBar *infoBar = document()->infoBar();
-    Core::Id infoRunCmake("CMakeEditor.RunCMake");
+    InfoBar *infoBar = document()->infoBar();
+    Id infoRunCmake("CMakeEditor.RunCMake");
     if (!infoBar->canInfoBeAdded(infoRunCmake))
         return;
-    Core::InfoBarEntry info(infoRunCmake,
-                            tr("Changes to cmake files are shown in the project tree after building."),
-                            Core::InfoBarEntry::GlobalSuppressionEnabled);
+    InfoBarEntry info(infoRunCmake,
+                      tr("Changes to cmake files are shown in the project tree after building."),
+                      InfoBarEntry::GlobalSuppressionEnabled);
     info.setCustomButtonInfo(tr("Build now"), this, SLOT(build()));
     infoBar->addInfo(info);
 }
@@ -103,7 +115,7 @@ void CMakeEditor::build()
 QString CMakeEditor::contextHelpId() const
 {
     int pos = position();
-    TextEditor::BaseTextDocument *doc = const_cast<CMakeEditor*>(this)->textDocument();
+    BaseTextDocument *doc = const_cast<CMakeEditor*>(this)->textDocument();
 
     QChar chr;
     do {
@@ -143,7 +155,7 @@ QString CMakeEditor::contextHelpId() const
 }
 
 //
-// CMakeEditor
+// CMakeEditorWidget
 //
 
 CMakeEditorWidget::CMakeEditorWidget()
@@ -151,11 +163,9 @@ CMakeEditorWidget::CMakeEditorWidget()
     setCodeFoldingSupported(true);
 }
 
-TextEditor::BaseTextEditor *CMakeEditorWidget::createEditor()
+BaseTextEditor *CMakeEditorWidget::createEditor()
 {
-    auto editor = new CMakeEditor;
-    connect(textDocument(), &Core::IDocument::changed, editor, &CMakeEditor::markAsChanged);
-    return editor;
+    QTC_ASSERT("should not happen anymore" && false, return 0);
 }
 
 void CMakeEditorWidget::contextMenuEvent(QContextMenuEvent *e)
@@ -165,14 +175,12 @@ void CMakeEditorWidget::contextMenuEvent(QContextMenuEvent *e)
 
 static bool isValidFileNameChar(const QChar &c)
 {
-    if (c.isLetterOrNumber()
+    return c.isLetterOrNumber()
             || c == QLatin1Char('.')
             || c == QLatin1Char('_')
             || c == QLatin1Char('-')
             || c == QLatin1Char('/')
-            || c == QLatin1Char('\\'))
-        return true;
-    return false;
+            || c == QLatin1Char('\\');
 }
 
 CMakeEditorWidget::Link CMakeEditorWidget::findLinkAt(const QTextCursor &cursor,
@@ -239,17 +247,16 @@ CMakeEditorWidget::Link CMakeEditorWidget::findLinkAt(const QTextCursor &cursor,
     return link;
 }
 
-
 //
 // CMakeDocument
 //
+
 CMakeDocument::CMakeDocument()
-    : TextEditor::BaseTextDocument()
 {
-    setId(CMakeProjectManager::Constants::CMAKE_EDITOR_ID);
-    setMimeType(QLatin1String(CMakeProjectManager::Constants::CMAKEMIMETYPE));
+    setId(Constants::CMAKE_EDITOR_ID);
+    setMimeType(QLatin1String(Constants::CMAKEMIMETYPE));
 
-    Core::MimeType mimeType = Core::MimeDatabase::findByType(QLatin1String(Constants::CMAKEMIMETYPE));
+    MimeType mimeType = MimeDatabase::findByType(QLatin1String(Constants::CMAKEMIMETYPE));
     setSyntaxHighlighter(TextEditor::createGenericSyntaxHighlighter(mimeType));
 }
 
@@ -264,3 +271,32 @@ QString CMakeDocument::suggestedFileName() const
     QFileInfo fi(filePath());
     return fi.fileName();
 }
+
+//
+// CMakeEditorFactory
+//
+
+CMakeEditorFactory::CMakeEditorFactory()
+{
+    setId(Constants::CMAKE_EDITOR_ID);
+    setDisplayName(tr(Constants::CMAKE_EDITOR_DISPLAY_NAME));
+    addMimeType(Constants::CMAKEMIMETYPE);
+    addMimeType(Constants::CMAKEPROJECTMIMETYPE);
+
+    new TextEditorActionHandler(this, Constants::C_CMAKEEDITOR,
+            TextEditorActionHandler::UnCommentSelection
+            | TextEditorActionHandler::JumpToFileUnderCursor);
+
+    ActionContainer *contextMenu = ActionManager::createMenu(Constants::M_CONTEXT);
+    contextMenu->addAction(ActionManager::command(TextEditor::Constants::JUMP_TO_FILE_UNDER_CURSOR));
+    contextMenu->addSeparator(Context(C_CMAKEEDITOR));
+    contextMenu->addAction(ActionManager::command(TextEditor::Constants::UN_COMMENT_SELECTION));
+}
+
+IEditor *CMakeEditorFactory::createEditor()
+{
+    return new CMakeEditor;
+}
+
+} // namespace Internal
+} // namespace CMakeProjectManager
diff --git a/src/plugins/cmakeprojectmanager/cmakeeditor.h b/src/plugins/cmakeprojectmanager/cmakeeditor.h
index ffe82b418d2e933f82936a43261fa841830268b1..5d97257ac4fc0571898836adb2a5b1fcb020428f 100644
--- a/src/plugins/cmakeprojectmanager/cmakeeditor.h
+++ b/src/plugins/cmakeprojectmanager/cmakeeditor.h
@@ -33,17 +33,12 @@
 #include <texteditor/basetextdocument.h>
 #include <texteditor/basetexteditor.h>
 #include <texteditor/codeassist/completionassistprovider.h>
-#include <utils/uncommentselection.h>
-
-
-namespace TextEditor { class FontSettings; }
+#include <coreplugin/editormanager/ieditorfactory.h>
 
 namespace CMakeProjectManager {
 namespace Internal {
 
 class CMakeEditorWidget;
-class CMakeHighlighter;
-class CMakeManager;
 
 class CMakeEditor : public TextEditor::BaseTextEditor
 {
@@ -52,7 +47,6 @@ class CMakeEditor : public TextEditor::BaseTextEditor
 public:
     CMakeEditor();
 
-    Core::IEditor *duplicate();
     QString contextHelpId() const;
 
     friend class CMakeEditorWidget;
@@ -69,11 +63,9 @@ class CMakeEditorWidget : public TextEditor::BaseTextEditorWidget
 public:
     CMakeEditorWidget();
 
+private:
     bool save(const QString &fileName = QString());
-
     Link findLinkAt(const QTextCursor &cursor, bool resolveTarget = true, bool inNextSplit = false);
-
-protected:
     TextEditor::BaseTextEditor *createEditor();
     void contextMenuEvent(QContextMenuEvent *e);
 };
@@ -84,10 +76,20 @@ class CMakeDocument : public TextEditor::BaseTextDocument
 
 public:
     CMakeDocument();
+
     QString defaultPath() const;
     QString suggestedFileName() const;
 };
 
+class CMakeEditorFactory : public Core::IEditorFactory
+{
+    Q_OBJECT
+
+public:
+    CMakeEditorFactory();
+    Core::IEditor *createEditor();
+};
+
 } // namespace Internal
 } // namespace CMakeProjectManager
 
diff --git a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp
deleted file mode 100644
index 3174dc1fd1771aa0071982f46a984e6c5bb413cd..0000000000000000000000000000000000000000
--- a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia.  For licensing terms and
-** conditions see http://qt.digia.com/licensing.  For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file.  Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights.  These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#include "cmakeeditorfactory.h"
-#include "cmakeprojectconstants.h"
-#include "cmakeeditor.h"
-
-#include <coreplugin/icore.h>
-#include <coreplugin/actionmanager/actioncontainer.h>
-#include <coreplugin/actionmanager/actionmanager.h>
-#include <coreplugin/editormanager/editormanager.h>
-#include <texteditor/texteditoractionhandler.h>
-#include <texteditor/texteditorconstants.h>
-
-using namespace CMakeProjectManager;
-using namespace CMakeProjectManager::Internal;
-
-CMakeEditorFactory::CMakeEditorFactory(CMakeManager *manager)
-    : m_manager(manager)
-{
-    using namespace Core;
-    using namespace TextEditor;
-
-    setId(CMakeProjectManager::Constants::CMAKE_EDITOR_ID);
-    setDisplayName(tr(CMakeProjectManager::Constants::CMAKE_EDITOR_DISPLAY_NAME));
-    addMimeType(CMakeProjectManager::Constants::CMAKEMIMETYPE);
-    addMimeType(CMakeProjectManager::Constants::CMAKEPROJECTMIMETYPE);
-
-    new TextEditorActionHandler(this, Constants::C_CMAKEEDITOR,
-            TextEditorActionHandler::UnCommentSelection
-            | TextEditorActionHandler::JumpToFileUnderCursor);
-
-    ActionContainer *contextMenu = Core::ActionManager::createMenu(Constants::M_CONTEXT);
-    Command *cmd;
-    Context cmakeEditorContext = Context(Constants::C_CMAKEEDITOR);
-
-    cmd = Core::ActionManager::command(TextEditor::Constants::JUMP_TO_FILE_UNDER_CURSOR);
-    contextMenu->addAction(cmd);
-
-    contextMenu->addSeparator(cmakeEditorContext);
-
-    cmd = Core::ActionManager::command(TextEditor::Constants::UN_COMMENT_SELECTION);
-    contextMenu->addAction(cmd);
-}
-
-Core::IEditor *CMakeEditorFactory::createEditor()
-{
-    CMakeEditorWidget *widget = new CMakeEditorWidget;
-    widget->setTextDocument(TextEditor::BaseTextDocumentPtr(new CMakeDocument));
-    return widget->editor();
-}
diff --git a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.h b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.h
deleted file mode 100644
index 4d6b4fae956a6ed6b6806d420d50514098a0b7c6..0000000000000000000000000000000000000000
--- a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia.  For licensing terms and
-** conditions see http://qt.digia.com/licensing.  For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file.  Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights.  These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#ifndef CMAKEEDITORFACTORY_H
-#define CMAKEEDITORFACTORY_H
-
-#include "cmakeprojectmanager.h"
-
-#include <coreplugin/editormanager/ieditorfactory.h>
-
-namespace CMakeProjectManager {
-namespace Internal {
-
-class CMakeEditorFactory : public Core::IEditorFactory
-{
-    Q_OBJECT
-
-public:
-    CMakeEditorFactory(CMakeManager *parent);
-    Core::IEditor *createEditor();
-
-private:
-    const QStringList m_mimeTypes;
-    CMakeManager *m_manager;
-};
-
-} // namespace Internal
-} // namespace CMakeProjectManager
-
-#endif // CMAKEEDITORFACTORY_H
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro
index f33e1a0a6bf9ea3f6afa7d04e1acb6784b63e48c..4f3eff9da540d58d13f481afb5baf59ab426207f 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro
@@ -10,7 +10,6 @@ HEADERS = cmakebuildinfo.h \
     cmakerunconfiguration.h \
     cmakeopenprojectwizard.h \
     cmakebuildconfiguration.h \
-    cmakeeditorfactory.h \
     cmakeeditor.h \
     cmakelocatorfilter.h \
     cmakefilecompletionassist.h \
@@ -27,7 +26,6 @@ SOURCES = cmakeproject.cpp \
     cmakerunconfiguration.cpp \
     cmakeopenprojectwizard.cpp \
     cmakebuildconfiguration.cpp \
-    cmakeeditorfactory.cpp \
     cmakeeditor.cpp \
     cmakelocatorfilter.cpp \
     cmakefilecompletionassist.cpp \
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs
index 6b7d625c21d6c5c18c4fc0fbb561eb6bcb1e63f3..fc8eabc50bccf8decab989004dfb3484fcd82f18 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs
@@ -25,8 +25,6 @@ QtcPlugin {
         "cmakebuildinfo.h",
         "cmakeeditor.cpp",
         "cmakeeditor.h",
-        "cmakeeditorfactory.cpp",
-        "cmakeeditorfactory.h",
         "cmakefilecompletionassist.cpp",
         "cmakefilecompletionassist.h",
         "cmakelocatorfilter.cpp",
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp
index 626fa8a0fc75bc54b40dc121dd9ddb0128012cd8..573dd98ed2f634bacd2c8e03ca39e6163a223492 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp
@@ -28,10 +28,11 @@
 ****************************************************************************/
 
 #include "cmakeprojectplugin.h"
+
+#include "cmakeeditor.h"
 #include "cmakeprojectmanager.h"
 #include "cmakebuildconfiguration.h"
 #include "cmakerunconfiguration.h"
-#include "cmakeeditorfactory.h"
 #include "makestep.h"
 #include "cmakeprojectconstants.h"
 #include "cmakelocatorfilter.h"
@@ -39,7 +40,6 @@
 
 #include <coreplugin/featureprovider.h>
 #include <coreplugin/mimedatabase.h>
-#include <texteditor/texteditoractionhandler.h>
 
 #include <QtPlugin>
 #include <QDebug>
@@ -61,13 +61,12 @@ bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString *
         return false;
     CMakeSettingsPage *cmp = new CMakeSettingsPage();
     addAutoReleasedObject(cmp);
-    CMakeManager *manager = new CMakeManager(cmp);
-    addAutoReleasedObject(manager);
+    addAutoReleasedObject(new CMakeManager(cmp));
     addAutoReleasedObject(new MakeStepFactory);
     addAutoReleasedObject(new CMakeRunConfigurationFactory);
     addAutoReleasedObject(new CMakeBuildConfigurationFactory);
 
-    addAutoReleasedObject(new CMakeEditorFactory(manager));
+    addAutoReleasedObject(new CMakeEditorFactory);
     addAutoReleasedObject(new CMakeLocatorFilter);
     addAutoReleasedObject(new CMakeFileCompletionAssistProvider(cmp));