diff options
author | hjk <hjk121@nokiamail.com> | 2014-08-20 01:47:42 +0200 |
---|---|---|
committer | hjk <hjk121@nokiamail.com> | 2014-08-21 08:40:56 +0200 |
commit | 3ac0668d5cea314da2e611342ce96ce7ee411141 (patch) | |
tree | 53cf4b9238fb47c4e0225685a4d932b8de630752 | |
parent | ba5124052456601e0942a3c4ac48bfe1623c58f0 (diff) | |
download | qt-creator-3ac0668d5cea314da2e611342ce96ce7ee411141.tar.gz |
QmlJSEditor: General editor related code consolidation
Merge editor files, sort #includes, namespaces.
This does not yet use the new editor construction scheme.
Change-Id: Idb1171389858c4470d7a4ec9441fb25e6d157400
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
-rw-r--r-- | src/plugins/qmljseditor/qmljseditor.cpp | 138 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljseditor.h | 38 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljseditor.pro | 4 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljseditor.qbs | 4 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljseditoreditable.cpp | 71 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljseditoreditable.h | 57 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljseditorfactory.cpp | 72 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljseditorfactory.h | 51 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljseditorplugin.cpp | 6 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljseditorplugin.h | 7 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljshoverhandler.cpp | 1 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljsoutline.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmltaskmanager.cpp | 53 |
13 files changed, 150 insertions, 354 deletions
diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index 411dcb2220..7db8d22877 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -30,14 +30,13 @@ #include "qmljseditor.h" #include "qmljsautocompleter.h" -#include "qmljseditoreditable.h" +#include "qmljscompletionassist.h" #include "qmljseditorconstants.h" #include "qmljseditordocument.h" #include "qmljseditorplugin.h" -#include "qmloutlinemodel.h" #include "qmljsfindreferences.h" -#include "qmljscompletionassist.h" #include "qmljsquickfixassist.h" +#include "qmloutlinemodel.h" #include <qmljs/qmljsbind.h> #include <qmljs/qmljsevaluate.h> @@ -46,15 +45,22 @@ #include <qmljs/qmljsutils.h> #include <qmljstools/qmljstoolsconstants.h> +#include <qmldesigner/qmldesignerconstants.h> +#include <projectexplorer/projectexplorerconstants.h> -#include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/actioncontainer.h> -#include <coreplugin/id.h> +#include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/command.h> +#include <coreplugin/coreconstants.h> +#include <coreplugin/designmode.h> #include <coreplugin/editormanager/editormanager.h> #include <coreplugin/icore.h> +#include <coreplugin/id.h> #include <coreplugin/mimedatabase.h> +#include <coreplugin/modemanager.h> + #include <extensionsystem/pluginmanager.h> + #include <texteditor/basetextdocument.h> #include <texteditor/fontsettings.h> #include <texteditor/tabsettings.h> @@ -63,25 +69,23 @@ #include <texteditor/refactoroverlay.h> #include <texteditor/codeassist/genericproposal.h> #include <texteditor/codeassist/basicproposalitemlistmodel.h> -#include <qmldesigner/qmldesignerconstants.h> -#include <projectexplorer/projectexplorerconstants.h> +#include <texteditor/texteditoractionhandler.h> + #include <utils/changeset.h> #include <utils/uncommentselection.h> #include <utils/qtcassert.h> #include <utils/annotateditemdelegate.h> +#include <QComboBox> +#include <QCoreApplication> #include <QFileInfo> -#include <QSignalMapper> -#include <QTimer> +#include <QHeaderView> +#include <QMenu> #include <QPointer> #include <QScopedPointer> +#include <QSignalMapper> #include <QTextCodec> - -#include <QMenu> -#include <QComboBox> -#include <QHeaderView> -#include <QInputDialog> -#include <QToolBar> +#include <QTimer> #include <QTreeView> enum { @@ -93,11 +97,16 @@ using namespace Core; using namespace QmlJS; using namespace QmlJS::AST; using namespace QmlJSTools; +using namespace TextEditor; namespace QmlJSEditor { namespace Internal { -QmlJSTextEditorWidget::QmlJSTextEditorWidget(TextEditor::BaseTextDocumentPtr doc) +// +// QmlJSEditorWidget +// + +QmlJSTextEditorWidget::QmlJSTextEditorWidget(BaseTextDocumentPtr doc) { setTextDocument(doc); setAutoCompleter(new AutoCompleter); @@ -175,7 +184,7 @@ IEditor *QmlJSEditor::duplicate() bool QmlJSEditor::open(QString *errorString, const QString &fileName, const QString &realFileName) { - bool b = TextEditor::BaseTextEditor::open(errorString, fileName, realFileName); + bool b = BaseTextEditor::open(errorString, fileName, realFileName); textDocument()->setMimeType(MimeDatabase::findByFile(QFileInfo(fileName)).type()); return b; } @@ -288,10 +297,10 @@ namespace QmlJSEditor { namespace Internal { template <class T> -static QList<TextEditor::RefactorMarker> removeMarkersOfType(const QList<TextEditor::RefactorMarker> &markers) +static QList<RefactorMarker> removeMarkersOfType(const QList<RefactorMarker> &markers) { - QList<TextEditor::RefactorMarker> result; - foreach (const TextEditor::RefactorMarker &marker, markers) { + QList<RefactorMarker> result; + foreach (const RefactorMarker &marker, markers) { if (!marker.data.canConvert<T>()) result += marker; } @@ -311,14 +320,14 @@ void QmlJSTextEditorWidget::updateContextPane() if (m_contextPane->isAvailable(editor(), info.document, newNode) && !m_contextPane->widget()->isVisible()) { - QList<TextEditor::RefactorMarker> markers = removeMarkersOfType<QtQuickToolbarMarker>(refactorMarkers()); + QList<RefactorMarker> markers = removeMarkersOfType<QtQuickToolbarMarker>(refactorMarkers()); if (UiObjectMember *m = newNode->uiObjectMemberCast()) { const int start = qualifiedTypeNameId(m)->identifierToken.begin(); for (UiQualifiedId *q = qualifiedTypeNameId(m); q; q = q->next) { if (! q->next) { const int end = q->identifierToken.end(); if (position() >= start && position() <= end) { - TextEditor::RefactorMarker marker; + RefactorMarker marker; QTextCursor tc(document()); tc.setPosition(end); marker.cursor = tc; @@ -496,7 +505,7 @@ void QmlJSTextEditorWidget::setSelectedElements() void QmlJSTextEditorWidget::applyFontSettings() { - TextEditor::BaseTextEditorWidget::applyFontSettings(); + BaseTextEditorWidget::applyFontSettings(); if (!m_qmlJsEditorDocument->isSemanticInfoOutdated()) updateUses(); } @@ -527,7 +536,7 @@ bool QmlJSTextEditorWidget::isClosingBrace(const QList<Token> &tokens) const return false; } -TextEditor::BaseTextEditor *QmlJSTextEditorWidget::createEditor() +BaseTextEditor *QmlJSTextEditorWidget::createEditor() { return new QmlJSEditor; } @@ -566,12 +575,12 @@ void QmlJSTextEditorWidget::createToolBar() connect(this, SIGNAL(cursorPositionChanged()), m_updateOutlineIndexTimer, SLOT(start())); - insertExtraToolBarWidget(TextEditor::BaseTextEditorWidget::Left, m_outlineCombo); + insertExtraToolBarWidget(BaseTextEditorWidget::Left, m_outlineCombo); } -TextEditor::BaseTextEditorWidget::Link QmlJSTextEditorWidget::findLinkAt(const QTextCursor &cursor, - bool /*resolveTarget*/, - bool /*inNextSplit*/) +BaseTextEditorWidget::Link QmlJSTextEditorWidget::findLinkAt(const QTextCursor &cursor, + bool /*resolveTarget*/, + bool /*inNextSplit*/) { const SemanticInfo semanticInfo = m_qmlJsEditorDocument->semanticInfo(); if (! semanticInfo.isValid()) @@ -678,7 +687,7 @@ void QmlJSTextEditorWidget::showContextPane() void QmlJSTextEditorWidget::performQuickFix(int index) { - TextEditor::QuickFixOperation::Ptr op = m_quickFixes.at(index); + QuickFixOperation::Ptr op = m_quickFixes.at(index); op->perform(); } @@ -691,20 +700,16 @@ void QmlJSTextEditorWidget::contextMenuEvent(QContextMenuEvent *e) QSignalMapper mapper; connect(&mapper, SIGNAL(mapped(int)), this, SLOT(performQuickFix(int))); if (!m_qmlJsEditorDocument->isSemanticInfoOutdated()) { - TextEditor::IAssistInterface *interface = - createAssistInterface(TextEditor::QuickFix, TextEditor::ExplicitlyInvoked); + IAssistInterface *interface = createAssistInterface(QuickFix, ExplicitlyInvoked); if (interface) { - QScopedPointer<TextEditor::IAssistProcessor> processor( + QScopedPointer<IAssistProcessor> processor( QmlJSEditorPlugin::instance()->quickFixAssistProvider()->createProcessor()); - QScopedPointer<TextEditor::IAssistProposal> proposal(processor->perform(interface)); + QScopedPointer<IAssistProposal> proposal(processor->perform(interface)); if (!proposal.isNull()) { - TextEditor::BasicProposalItemListModel *model = - static_cast<TextEditor::BasicProposalItemListModel *>(proposal->model()); + BasicProposalItemListModel *model = static_cast<BasicProposalItemListModel *>(proposal->model()); for (int index = 0; index < model->size(); ++index) { - TextEditor::BasicProposalItem *item = - static_cast<TextEditor::BasicProposalItem *>(model->proposalItem(index)); - TextEditor::QuickFixOperation::Ptr op = - item->data().value<TextEditor::QuickFixOperation::Ptr>(); + BasicProposalItem *item = static_cast<BasicProposalItem *>(model->proposalItem(index)); + QuickFixOperation::Ptr op = item->data().value<QuickFixOperation::Ptr>(); m_quickFixes.append(op); QAction *action = refactoringMenu->addAction(op->description()); mapper.setMapping(action, index); @@ -809,7 +814,7 @@ void QmlJSTextEditorWidget::semanticInfoUpdated(const SemanticInfo &semanticInfo updateUses(); } -void QmlJSTextEditorWidget::onRefactorMarkerClicked(const TextEditor::RefactorMarker &marker) +void QmlJSTextEditorWidget::onRefactorMarkerClicked(const RefactorMarker &marker) { if (marker.data.canConvert<QtQuickToolbarMarker>()) showContextPane(); @@ -847,7 +852,7 @@ bool QmlJSTextEditorWidget::hideContextPane() return b; } -TextEditor::IAssistInterface *QmlJSTextEditorWidget::createAssistInterface( +IAssistInterface *QmlJSTextEditorWidget::createAssistInterface( TextEditor::AssistKind assistKind, TextEditor::AssistReason reason) const { @@ -879,5 +884,56 @@ QString QmlJSTextEditorWidget::foldReplacementText(const QTextBlock &block) cons return TextEditor::BaseTextEditorWidget::foldReplacementText(block); } + +// +// QmlJSEditor +// + +QmlJSEditor::QmlJSEditor() +{ + addContext(Constants::C_QMLJSEDITOR_ID); + addContext(ProjectExplorer::Constants::LANG_QMLJS); + setDuplicateSupported(true); + setCommentStyle(Utils::CommentDefinition::CppStyle); + setCompletionAssistProvider(ExtensionSystem::PluginManager::getObject<Internal::QmlJSCompletionAssistProvider>()); +} + +bool QmlJSEditor::isDesignModePreferred() const +{ + // stay in design mode if we are there + IMode *mode = ModeManager::currentMode(); + return mode && mode->id() == Core::Constants::MODE_DESIGN; +} + + +// +// QmlJSEditorFactory +// + +QmlJSEditorFactory::QmlJSEditorFactory() +{ + setId(Constants::C_QMLJSEDITOR_ID); + setDisplayName(qApp->translate("OpenWith::Editors", Constants::C_QMLJSEDITOR_DISPLAY_NAME)); + + addMimeType(QmlJSTools::Constants::QML_MIMETYPE); + addMimeType(QmlJSTools::Constants::QMLPROJECT_MIMETYPE); + addMimeType(QmlJSTools::Constants::QBS_MIMETYPE); + addMimeType(QmlJSTools::Constants::QMLTYPES_MIMETYPE); + addMimeType(QmlJSTools::Constants::JS_MIMETYPE); + addMimeType(QmlJSTools::Constants::JSON_MIMETYPE); + new TextEditorActionHandler(this, Constants::C_QMLJSEDITOR_ID, + TextEditorActionHandler::Format + | TextEditorActionHandler::UnCommentSelection + | TextEditorActionHandler::UnCollapseAll + | TextEditorActionHandler::FollowSymbolUnderCursor); + +} + +IEditor *QmlJSEditorFactory::createEditor() +{ + QmlJSTextEditorWidget *rc = new QmlJSTextEditorWidget(BaseTextDocumentPtr(new QmlJSEditorDocument)); + return rc->editor(); +} + } // namespace Internal } // namespace QmlJSEditor diff --git a/src/plugins/qmljseditor/qmljseditor.h b/src/plugins/qmljseditor/qmljseditor.h index 9226b067e3..c55c66292f 100644 --- a/src/plugins/qmljseditor/qmljseditor.h +++ b/src/plugins/qmljseditor/qmljseditor.h @@ -34,41 +34,32 @@ #include <qmljs/qmljsscanner.h> #include <qmljstools/qmljssemanticinfo.h> +#include <coreplugin/editormanager/ieditorfactory.h> #include <texteditor/basetexteditor.h> #include <texteditor/quickfix.h> #include <texteditor/texteditorconstants.h> +#include <utils/uncommentselection.h> -#include <QSharedPointer> #include <QModelIndex> -#include <QTextLayout> -#include <QVector> QT_BEGIN_NAMESPACE class QComboBox; class QTimer; QT_END_NAMESPACE -namespace Core { class ICore; } - namespace QmlJS { class ModelManagerInterface; class IContextPane; - class LookupContext; namespace AST { class UiObjectMember; } } -/*! - The top-level namespace of the QmlJSEditor plug-in. - */ namespace QmlJSEditor { + class QmlJSEditorDocument; class FindReferences; namespace Internal { -class QmlJSEditor; -class QmlOutlineModel; - class QmlJSTextEditorWidget : public TextEditor::BaseTextEditorWidget { Q_OBJECT @@ -147,6 +138,29 @@ private: FindReferences *m_findReferences; }; + +class QmlJSEditor : public TextEditor::BaseTextEditor +{ + Q_OBJECT + +public: + QmlJSEditor(); + + Core::IEditor *duplicate(); + bool open(QString *errorString, const QString &fileName, const QString &realFileName); + bool isDesignModePreferred() const; +}; + +class QmlJSEditorFactory : public Core::IEditorFactory +{ + Q_OBJECT + +public: + QmlJSEditorFactory(); + + Core::IEditor *createEditor(); +}; + } // namespace Internal } // namespace QmlJSEditor diff --git a/src/plugins/qmljseditor/qmljseditor.pro b/src/plugins/qmljseditor/qmljseditor.pro index c09ce621e7..755941488b 100644 --- a/src/plugins/qmljseditor/qmljseditor.pro +++ b/src/plugins/qmljseditor/qmljseditor.pro @@ -8,7 +8,6 @@ HEADERS += \ qmljseditor.h \ qmljseditor_global.h \ qmljseditorconstants.h \ - qmljseditorfactory.h \ qmljseditorplugin.h \ qmlexpressionundercursor.h \ qmlfilewizard.h \ @@ -24,7 +23,6 @@ HEADERS += \ quicktoolbar.h \ qmljscomponentnamedialog.h \ qmljsfindreferences.h \ - qmljseditoreditable.h \ qmljsautocompleter.h \ jsfilewizard.h \ qmljssnippetprovider.h \ @@ -40,7 +38,6 @@ HEADERS += \ SOURCES += \ qmljseditor.cpp \ - qmljseditorfactory.cpp \ qmljseditorplugin.cpp \ qmlexpressionundercursor.cpp \ qmlfilewizard.cpp \ @@ -57,7 +54,6 @@ SOURCES += \ quicktoolbar.cpp \ qmljscomponentnamedialog.cpp \ qmljsfindreferences.cpp \ - qmljseditoreditable.cpp \ qmljsautocompleter.cpp \ jsfilewizard.cpp \ qmljssnippetprovider.cpp \ diff --git a/src/plugins/qmljseditor/qmljseditor.qbs b/src/plugins/qmljseditor/qmljseditor.qbs index 6bde46b85a..f021b4e444 100644 --- a/src/plugins/qmljseditor/qmljseditor.qbs +++ b/src/plugins/qmljseditor/qmljseditor.qbs @@ -41,10 +41,6 @@ QtcPlugin { "qmljseditordocument.cpp", "qmljseditordocument.h", "qmljseditordocument_p.h", - "qmljseditoreditable.cpp", - "qmljseditoreditable.h", - "qmljseditorfactory.cpp", - "qmljseditorfactory.h", "qmljseditorplugin.cpp", "qmljseditorplugin.h", "qmljsfindreferences.cpp", diff --git a/src/plugins/qmljseditor/qmljseditoreditable.cpp b/src/plugins/qmljseditor/qmljseditoreditable.cpp deleted file mode 100644 index dfec522d26..0000000000 --- a/src/plugins/qmljseditor/qmljseditoreditable.cpp +++ /dev/null @@ -1,71 +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 "qmljseditoreditable.h" -#include "qmljseditor.h" -#include "qmljseditorconstants.h" -#include "qmljscompletionassist.h" -#include "qmljsautocompleter.h" - -#include <qmljstools/qmljstoolsconstants.h> -#include <texteditor/texteditorconstants.h> -#include <projectexplorer/projectexplorerconstants.h> - -#include <coreplugin/mimedatabase.h> -#include <coreplugin/icore.h> -#include <coreplugin/designmode.h> -#include <coreplugin/modemanager.h> -#include <coreplugin/coreconstants.h> - -#include <extensionsystem/pluginmanager.h> - -namespace QmlJSEditor { -namespace Internal { - -QmlJSEditor::QmlJSEditor() -{ - m_context.add(Constants::C_QMLJSEDITOR_ID); - m_context.add(TextEditor::Constants::C_TEXTEDITOR); - m_context.add(ProjectExplorer::Constants::LANG_QMLJS); - setDuplicateSupported(true); - setCommentStyle(Utils::CommentDefinition::CppStyle); - setCompletionAssistProvider(ExtensionSystem::PluginManager::getObject<Internal::QmlJSCompletionAssistProvider>()); -} - -bool QmlJSEditor::isDesignModePreferred() const -{ - // stay in design mode if we are there - Core::IMode *mode = Core::ModeManager::currentMode(); - if (mode && mode->id() == Core::Constants::MODE_DESIGN) - return true; - return false; -} - -} // namespace Internal -} // namespace QmlJSEditor diff --git a/src/plugins/qmljseditor/qmljseditoreditable.h b/src/plugins/qmljseditor/qmljseditoreditable.h deleted file mode 100644 index f8e108db78..0000000000 --- a/src/plugins/qmljseditor/qmljseditoreditable.h +++ /dev/null @@ -1,57 +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 QMLJSEDITOREDITABLE_H -#define QMLJSEDITOREDITABLE_H - -#include "qmljseditor_global.h" -#include <utils/uncommentselection.h> -#include <texteditor/basetexteditor.h> - -namespace QmlJSEditor { -namespace Internal { - -class QmlJSTextEditorWidget; - -class QmlJSEditor : public TextEditor::BaseTextEditor -{ - Q_OBJECT - -public: - QmlJSEditor(); - - Core::IEditor *duplicate(); - bool open(QString *errorString, const QString &fileName, const QString &realFileName); - bool isDesignModePreferred() const; -}; - -} // namespace Internal -} // namespace QmlJSEditor - -#endif // QMLJSEDITOREDITABLE_H diff --git a/src/plugins/qmljseditor/qmljseditorfactory.cpp b/src/plugins/qmljseditor/qmljseditorfactory.cpp deleted file mode 100644 index d781686ae1..0000000000 --- a/src/plugins/qmljseditor/qmljseditorfactory.cpp +++ /dev/null @@ -1,72 +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 "qmljseditorfactory.h" -#include "qmljseditordocument.h" -#include "qmljseditoreditable.h" -#include "qmljseditor.h" -#include "qmljseditorconstants.h" -#include "qmljseditorplugin.h" - -#include <qmljstools/qmljstoolsconstants.h> -#include <texteditor/texteditoractionhandler.h> - -#include <QCoreApplication> - -namespace QmlJSEditor { -namespace Internal { - -QmlJSEditorFactory::QmlJSEditorFactory(QObject *parent) - : Core::IEditorFactory(parent) -{ - setId(Constants::C_QMLJSEDITOR_ID); - setDisplayName(qApp->translate("OpenWith::Editors", Constants::C_QMLJSEDITOR_DISPLAY_NAME)); - - addMimeType(QmlJSTools::Constants::QML_MIMETYPE); - addMimeType(QmlJSTools::Constants::QMLPROJECT_MIMETYPE); - addMimeType(QmlJSTools::Constants::QBS_MIMETYPE); - addMimeType(QmlJSTools::Constants::QMLTYPES_MIMETYPE); - addMimeType(QmlJSTools::Constants::JS_MIMETYPE); - addMimeType(QmlJSTools::Constants::JSON_MIMETYPE); - new TextEditor::TextEditorActionHandler(this, Constants::C_QMLJSEDITOR_ID, - TextEditor::TextEditorActionHandler::Format - | TextEditor::TextEditorActionHandler::UnCommentSelection - | TextEditor::TextEditorActionHandler::UnCollapseAll - | TextEditor::TextEditorActionHandler::FollowSymbolUnderCursor); - -} - -Core::IEditor *QmlJSEditorFactory::createEditor() -{ - QmlJSTextEditorWidget *rc = new QmlJSTextEditorWidget(TextEditor::BaseTextDocumentPtr(new QmlJSEditorDocument)); - return rc->editor(); -} - -} // namespace Internal -} // namespace QmlJSEditor diff --git a/src/plugins/qmljseditor/qmljseditorfactory.h b/src/plugins/qmljseditor/qmljseditorfactory.h deleted file mode 100644 index e8e047cd9b..0000000000 --- a/src/plugins/qmljseditor/qmljseditorfactory.h +++ /dev/null @@ -1,51 +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 QMLJSEDITORFACTORY_H -#define QMLJSEDITORFACTORY_H - -#include <coreplugin/editormanager/ieditorfactory.h> - -namespace QmlJSEditor { -namespace Internal { - -class QmlJSEditorFactory : public Core::IEditorFactory -{ - Q_OBJECT - -public: - QmlJSEditorFactory(QObject *parent); - - Core::IEditor *createEditor(); -}; - -} // namespace Internal -} // namespace QmlJSEditor - -#endif // QMLJSEDITORFACTORY_H diff --git a/src/plugins/qmljseditor/qmljseditorplugin.cpp b/src/plugins/qmljseditor/qmljseditorplugin.cpp index af934da57d..5fe464a804 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.cpp +++ b/src/plugins/qmljseditor/qmljseditorplugin.cpp @@ -32,7 +32,6 @@ #include "qmljseditor.h" #include "qmljseditorconstants.h" #include "qmljseditordocument.h" -#include "qmljseditorfactory.h" #include "qmljshoverhandler.h" #include "qmlfilewizard.h" #include "jsfilewizard.h" @@ -93,7 +92,6 @@ QmlJSEditorPlugin *QmlJSEditorPlugin::m_instance = 0; QmlJSEditorPlugin::QmlJSEditorPlugin() : m_modelManager(0), - m_editor(0), m_quickFixAssistProvider(0), m_reformatFileAction(0), m_currentDocument(0), @@ -106,7 +104,6 @@ QmlJSEditorPlugin::QmlJSEditorPlugin() : QmlJSEditorPlugin::~QmlJSEditorPlugin() { - removeObject(m_editor); m_instance = 0; } @@ -142,8 +139,7 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e Core::Context context(Constants::C_QMLJSEDITOR_ID); - m_editor = new QmlJSEditorFactory(this); - addObject(m_editor); + addAutoReleasedObject(new QmlJSEditorFactory); IWizardFactory *wizard = new QmlFileWizard; wizard->setWizardKind(Core::IWizardFactory::FileWizard); diff --git a/src/plugins/qmljseditor/qmljseditorplugin.h b/src/plugins/qmljseditor/qmljseditorplugin.h index aac9959e89..3604350291 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.h +++ b/src/plugins/qmljseditor/qmljseditorplugin.h @@ -43,23 +43,17 @@ namespace Utils { class JsonSchemaManager; } namespace Core { class Command; class ActionContainer; -class ActionManager; class IEditor; } -namespace TextEditor { class BaseTextEditor; } - namespace QmlJS { class ModelManagerInterface; } namespace QmlJSEditor { -class QmlFileWizard; class QmlJSEditorDocument; namespace Internal { -class QmlJSEditorFactory; -class QmlJSPreviewRunner; class QmlJSQuickFixAssistProvider; class QmlTaskManager; @@ -102,7 +96,6 @@ private: static QmlJSEditorPlugin *m_instance; QmlJS::ModelManagerInterface *m_modelManager; - QmlJSEditorFactory *m_editor; QmlJSQuickFixAssistProvider *m_quickFixAssistProvider; QmlTaskManager *m_qmlTaskManager; diff --git a/src/plugins/qmljseditor/qmljshoverhandler.cpp b/src/plugins/qmljseditor/qmljshoverhandler.cpp index 90333eea2d..504377681a 100644 --- a/src/plugins/qmljseditor/qmljshoverhandler.cpp +++ b/src/plugins/qmljseditor/qmljshoverhandler.cpp @@ -30,7 +30,6 @@ #include "qmljshoverhandler.h" #include "qmljseditor.h" #include "qmljseditordocument.h" -#include "qmljseditoreditable.h" #include "qmlexpressionundercursor.h" #include <coreplugin/editormanager/ieditor.h> diff --git a/src/plugins/qmljseditor/qmljsoutline.cpp b/src/plugins/qmljseditor/qmljsoutline.cpp index 77f233eaba..d736d6698a 100644 --- a/src/plugins/qmljseditor/qmljsoutline.cpp +++ b/src/plugins/qmljseditor/qmljsoutline.cpp @@ -29,7 +29,7 @@ #include "qmljsoutline.h" #include "qmloutlinemodel.h" -#include "qmljseditoreditable.h" +#include "qmljseditor.h" #include "qmljsoutlinetreeview.h" #include <coreplugin/find/itemviewfind.h> diff --git a/src/plugins/qmljseditor/qmltaskmanager.cpp b/src/plugins/qmljseditor/qmltaskmanager.cpp index dbc50b59d3..1678beab21 100644 --- a/src/plugins/qmljseditor/qmltaskmanager.cpp +++ b/src/plugins/qmljseditor/qmltaskmanager.cpp @@ -28,6 +28,7 @@ ****************************************************************************/ #include "qmltaskmanager.h" +#include "qmljseditor.h" #include "qmljseditorconstants.h" #include <coreplugin/idocument.h> @@ -35,16 +36,17 @@ #include <projectexplorer/taskhub.h> #include <qmljs/qmljsmodelmanagerinterface.h> #include <qmljs/qmljscontext.h> +#include <qmljs/qmljsconstants.h> #include <qmljs/qmljslink.h> #include <qmljs/qmljscheck.h> -#include <qmljseditor/qmljseditor.h> -#include <qmljseditor/qmljseditoreditable.h> +#include <utils/runextensions.h> #include <QDebug> #include <QtConcurrentRun> -#include <utils/runextensions.h> +using namespace ProjectExplorer; using namespace QmlJS; +using namespace Utils; namespace QmlJSEditor { namespace Internal { @@ -65,23 +67,18 @@ QmlTaskManager::QmlTaskManager(QObject *parent) : SLOT(updateMessagesNow())); } -static QList<ProjectExplorer::Task> convertToTasks(const QList<DiagnosticMessage> &messages, const Utils::FileName &fileName, Core::Id category) +static QList<Task> convertToTasks(const QList<DiagnosticMessage> &messages, const FileName &fileName, Core::Id category) { - QList<ProjectExplorer::Task> result; + QList<Task> result; foreach (const DiagnosticMessage &msg, messages) { - ProjectExplorer::Task::TaskType type - = msg.isError() ? ProjectExplorer::Task::Error - : ProjectExplorer::Task::Warning; - - ProjectExplorer::Task task(type, msg.message, fileName, msg.loc.startLine, - category); - + Task::TaskType type = msg.isError() ? Task::Error : Task::Warning; + Task task(type, msg.message, fileName, msg.loc.startLine, category); result += task; } return result; } -static QList<ProjectExplorer::Task> convertToTasks(const QList<StaticAnalysis::Message> &messages, const Utils::FileName &fileName, Core::Id category) +static QList<Task> convertToTasks(const QList<StaticAnalysis::Message> &messages, const FileName &fileName, Core::Id category) { QList<DiagnosticMessage> diagnostics; foreach (const StaticAnalysis::Message &msg, messages) @@ -111,18 +108,18 @@ void QmlTaskManager::collectMessages( result.fileName = fileName; if (document->language().isFullySupportedLanguage()) { result.tasks = convertToTasks(document->diagnosticMessages(), - Utils::FileName::fromString(fileName), - Core::Id(Constants::TASK_CATEGORY_QML)); + FileName::fromString(fileName), + Constants::TASK_CATEGORY_QML); if (updateSemantic) { result.tasks += convertToTasks(linkMessages.value(fileName), - Utils::FileName::fromString(fileName), - Core::Id(Constants::TASK_CATEGORY_QML_ANALYSIS)); + FileName::fromString(fileName), + Constants::TASK_CATEGORY_QML_ANALYSIS); Check checker(document, context); result.tasks += convertToTasks(checker(), - Utils::FileName::fromString(fileName), - Core::Id(Constants::TASK_CATEGORY_QML_ANALYSIS)); + FileName::fromString(fileName), + Constants::TASK_CATEGORY_QML_ANALYSIS); } } @@ -175,7 +172,7 @@ void QmlTaskManager::displayResults(int begin, int end) { for (int i = begin; i < end; ++i) { FileErrorMessages result = m_messageCollector.resultAt(i); - foreach (const ProjectExplorer::Task &task, result.tasks) { + foreach (const Task &task, result.tasks) { insertTask(task); } } @@ -187,29 +184,29 @@ void QmlTaskManager::displayAllResults() m_updatingSemantic = false; } -void QmlTaskManager::insertTask(const ProjectExplorer::Task &task) +void QmlTaskManager::insertTask(const Task &task) { - QList<ProjectExplorer::Task> tasks = m_docsWithTasks.value(task.file.toString()); + QList<Task> tasks = m_docsWithTasks.value(task.file.toString()); tasks.append(task); m_docsWithTasks.insert(task.file.toString(), tasks); - ProjectExplorer::TaskHub::addTask(task); + TaskHub::addTask(task); } void QmlTaskManager::removeTasksForFile(const QString &fileName) { if (m_docsWithTasks.contains(fileName)) { - const QList<ProjectExplorer::Task> tasks = m_docsWithTasks.value(fileName); - foreach (const ProjectExplorer::Task &task, tasks) - ProjectExplorer::TaskHub::removeTask(task); + const QList<Task> tasks = m_docsWithTasks.value(fileName); + foreach (const Task &task, tasks) + TaskHub::removeTask(task); m_docsWithTasks.remove(fileName); } } void QmlTaskManager::removeAllTasks(bool clearSemantic) { - ProjectExplorer::TaskHub::clearTasks(Constants::TASK_CATEGORY_QML); + TaskHub::clearTasks(Constants::TASK_CATEGORY_QML); if (clearSemantic) - ProjectExplorer::TaskHub::clearTasks(Constants::TASK_CATEGORY_QML_ANALYSIS); + TaskHub::clearTasks(Constants::TASK_CATEGORY_QML_ANALYSIS); m_docsWithTasks.clear(); } |