diff --git a/src/plugins/qmldesigner/designercore/model/basetexteditmodifier.cpp b/src/plugins/qmldesigner/designercore/model/basetexteditmodifier.cpp index 256c21217c1..6b3b179df97 100644 --- a/src/plugins/qmldesigner/designercore/model/basetexteditmodifier.cpp +++ b/src/plugins/qmldesigner/designercore/model/basetexteditmodifier.cpp @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -71,7 +72,8 @@ bool BaseTextEditModifier::renameId(const QString &oldId, const QString &newId) { if (QmlJSEditor::QmlJSTextEditorWidget *qmljse = qobject_cast(plainTextEdit())) { Utils::ChangeSet changeSet; - foreach (const QmlJS::AST::SourceLocation &loc, qmljse->semanticInfo().idLocations.value(oldId)) { + foreach (const QmlJS::AST::SourceLocation &loc, + qmljse->qmlJsEditorDocument()->semanticInfo().idLocations.value(oldId)) { changeSet.replace(loc.begin(), loc.end(), newId); } QTextCursor tc = qmljse->textCursor(); diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index 91b59d24da0..7b830fe2e51 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -166,31 +166,6 @@ QmlJSTextEditorWidget::~QmlJSTextEditorWidget() { } -SemanticInfo QmlJSTextEditorWidget::semanticInfo() const -{ - return m_qmlJsEditorDocument->semanticInfo(); -} - -int QmlJSTextEditorWidget::editorRevision() const -{ - return document()->revision(); -} - -QVector QmlJSTextEditorWidget::diagnosticRanges() const -{ - return m_qmlJsEditorDocument->diagnosticRanges(); -} - -bool QmlJSTextEditorWidget::isSemanticInfoOutdated() const -{ - return m_qmlJsEditorDocument->isSemanticInfoOutdated(); -} - -QmlOutlineModel *QmlJSTextEditorWidget::outlineModel() const -{ - return m_qmlJsEditorDocument->outlineModel(); -} - QModelIndex QmlJSTextEditorWidget::outlineModelIndex() { if (!m_outlineModelIndex.isValid()) { @@ -299,7 +274,7 @@ void QmlJSTextEditorWidget::updateOutlineIndexNow() if (!m_qmlJsEditorDocument->outlineModel()->document()) return; - if (m_qmlJsEditorDocument->outlineModel()->document()->editorRevision() != editorRevision()) { + if (m_qmlJsEditorDocument->outlineModel()->document()->editorRevision() != document()->revision()) { m_updateOutlineIndexTimer->start(); return; } @@ -832,6 +807,11 @@ void QmlJSTextEditorWidget::unCommentSelection() Utils::unCommentSelection(this); } +QmlJSEditorDocument *QmlJSTextEditorWidget::qmlJsEditorDocument() const +{ + return m_qmlJsEditorDocument; +} + void QmlJSTextEditorWidget::semanticInfoUpdated(const SemanticInfo &semanticInfo) { if (isVisible()) { diff --git a/src/plugins/qmljseditor/qmljseditor.h b/src/plugins/qmljseditor/qmljseditor.h index 4b280550003..eac388b066f 100644 --- a/src/plugins/qmljseditor/qmljseditor.h +++ b/src/plugins/qmljseditor/qmljseditor.h @@ -66,10 +66,10 @@ namespace AST { */ namespace QmlJSEditor { class QmlJSEditor; +class QmlJSEditorDocument; class FindReferences; namespace Internal { -class QmlJSEditorDocument; class QmlOutlineModel; } // namespace Internal @@ -84,12 +84,7 @@ public: virtual void unCommentSelection(); - // redirecting to document - QmlJSTools::SemanticInfo semanticInfo() const; - bool isSemanticInfoOutdated() const; - int editorRevision() const; - QVector diagnosticRanges() const; - Internal::QmlOutlineModel *outlineModel() const; + QmlJSEditorDocument *qmlJsEditorDocument() const; QModelIndex outlineModelIndex(); @@ -145,7 +140,7 @@ private: QModelIndex indexForPosition(unsigned cursorPosition, const QModelIndex &rootIndex = QModelIndex()) const; bool hideContextPane(); - Internal::QmlJSEditorDocument *m_qmlJsEditorDocument; + QmlJSEditorDocument *m_qmlJsEditorDocument; QTimer *m_updateUsesTimer; // to wait for multiple text cursor position changes QTimer *m_updateOutlineIndexTimer; QTimer *m_contextPaneTimer; diff --git a/src/plugins/qmljseditor/qmljseditordocument.cpp b/src/plugins/qmljseditor/qmljseditordocument.cpp index 7e36ae94bb5..4456c98cde7 100644 --- a/src/plugins/qmljseditor/qmljseditordocument.cpp +++ b/src/plugins/qmljseditor/qmljseditordocument.cpp @@ -530,13 +530,15 @@ void QmlJSEditorDocumentPrivate::updateOutlineModel() m_outlineModel->update(m_semanticInfo); } +} // Internal + QmlJSEditorDocument::QmlJSEditorDocument() - : m_d(new QmlJSEditorDocumentPrivate(this)) + : m_d(new Internal::QmlJSEditorDocumentPrivate(this)) { connect(this, SIGNAL(tabSettingsChanged()), m_d, SLOT(invalidateFormatterCache())); setSyntaxHighlighter(new Highlighter(document())); - setIndenter(new Indenter); + setIndenter(new Internal::Indenter); } QmlJSEditorDocument::~QmlJSEditorDocument() @@ -559,7 +561,7 @@ QVector QmlJSEditorDocument::diagnosticRanges() const return m_d->m_diagnosticRanges; } -QmlOutlineModel *QmlJSEditorDocument::outlineModel() const +Internal::QmlOutlineModel *QmlJSEditorDocument::outlineModel() const { return m_d->m_outlineModel; } @@ -593,5 +595,4 @@ void QmlJSEditorDocument::triggerPendingUpdates() } } -} // Internal } // QmlJSEditor diff --git a/src/plugins/qmljseditor/qmljseditordocument.h b/src/plugins/qmljseditor/qmljseditordocument.h index 01870542aea..cc3884dba7a 100644 --- a/src/plugins/qmljseditor/qmljseditordocument.h +++ b/src/plugins/qmljseditor/qmljseditordocument.h @@ -30,6 +30,8 @@ #ifndef QMLJSEDITORDOCUMENT_H #define QMLJSEDITORDOCUMENT_H +#include "qmljseditor_global.h" + #include #include #include @@ -37,12 +39,13 @@ #include namespace QmlJSEditor { -namespace Internal { +namespace Internal { class QmlJSEditorDocumentPrivate; class QmlOutlineModel; +} // Internal -class QmlJSEditorDocument : public TextEditor::BaseTextDocument +class QMLJSEDITOR_EXPORT QmlJSEditorDocument : public TextEditor::BaseTextDocument { Q_OBJECT public: @@ -65,10 +68,9 @@ protected: private: friend class QmlJSEditorDocumentPrivate; // sending signals - QmlJSEditorDocumentPrivate *m_d; + Internal::QmlJSEditorDocumentPrivate *m_d; }; -} // Internal } // QmlJSEditor #endif // QMLJSEDITORDOCUMENT_H diff --git a/src/plugins/qmljseditor/qmljseditordocument_p.h b/src/plugins/qmljseditor/qmljseditordocument_p.h index d99b0ece27b..a934d3d76a2 100644 --- a/src/plugins/qmljseditor/qmljseditordocument_p.h +++ b/src/plugins/qmljseditor/qmljseditordocument_p.h @@ -38,9 +38,11 @@ #include namespace QmlJSEditor { -namespace Internal { class QmlJSEditorDocument; + +namespace Internal { + class QmlOutlineModel; class SemanticHighlighter; class SemanticInfoUpdater; diff --git a/src/plugins/qmljseditor/qmljseditorplugin.h b/src/plugins/qmljseditor/qmljseditorplugin.h index 469b500b8d1..36e599327ff 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.h +++ b/src/plugins/qmljseditor/qmljseditorplugin.h @@ -60,10 +60,10 @@ namespace QmlJS { namespace QmlJSEditor { class QmlFileWizard; +class QmlJSEditorDocument; namespace Internal { -class QmlJSEditorDocument; class QmlJSEditorFactory; class QmlJSPreviewRunner; class QmlJSQuickFixAssistProvider; diff --git a/src/plugins/qmljseditor/qmljshoverhandler.cpp b/src/plugins/qmljseditor/qmljshoverhandler.cpp index fe731ab8a34..b632de221ed 100644 --- a/src/plugins/qmljseditor/qmljshoverhandler.cpp +++ b/src/plugins/qmljseditor/qmljshoverhandler.cpp @@ -29,6 +29,7 @@ #include "qmljshoverhandler.h" #include "qmljseditor.h" +#include "qmljseditordocument.h" #include "qmljseditoreditable.h" #include "qmlexpressionundercursor.h" @@ -194,8 +195,8 @@ void HoverHandler::identifyMatch(TextEditor::ITextEditor *editor, int pos) if (!qmlEditor) return; - const QmlJSTools::SemanticInfo &semanticInfo = qmlEditor->semanticInfo(); - if (! semanticInfo.isValid() || qmlEditor->isSemanticInfoOutdated()) + const QmlJSTools::SemanticInfo &semanticInfo = qmlEditor->qmlJsEditorDocument()->semanticInfo(); + if (!semanticInfo.isValid() || qmlEditor->qmlJsEditorDocument()->isSemanticInfoOutdated()) return; QList rangePath = semanticInfo.rangePath(pos); @@ -266,7 +267,8 @@ bool HoverHandler::matchDiagnosticMessage(QmlJSTextEditorWidget *qmlEditor, int return true; } } - foreach (const QTextLayout::FormatRange &range, qmlEditor->diagnosticRanges()) { + foreach (const QTextLayout::FormatRange &range, + qmlEditor->qmlJsEditorDocument()->diagnosticRanges()) { if (pos >= range.start && pos < range.start+range.length) { setToolTip(range.format.toolTip()); return true; diff --git a/src/plugins/qmljseditor/qmljsoutline.cpp b/src/plugins/qmljseditor/qmljsoutline.cpp index 442d6220830..e42a617d78b 100644 --- a/src/plugins/qmljseditor/qmljsoutline.cpp +++ b/src/plugins/qmljseditor/qmljsoutline.cpp @@ -124,7 +124,7 @@ void QmlJSOutlineWidget::setEditor(QmlJSTextEditorWidget *editor) { m_editor = editor; - m_filterModel->setSourceModel(m_editor->outlineModel()); + m_filterModel->setSourceModel(m_editor->qmlJsEditorDocument()->outlineModel()); modelUpdated(); connect(m_treeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), @@ -135,7 +135,7 @@ void QmlJSOutlineWidget::setEditor(QmlJSTextEditorWidget *editor) connect(m_editor, SIGNAL(outlineModelIndexChanged(QModelIndex)), this, SLOT(updateSelectionInTree(QModelIndex))); - connect(m_editor->outlineModel(), SIGNAL(updated()), + connect(m_editor->qmlJsEditorDocument()->outlineModel(), SIGNAL(updated()), this, SLOT(modelUpdated())); } @@ -207,7 +207,8 @@ void QmlJSOutlineWidget::updateSelectionInText(const QItemSelection &selection) void QmlJSOutlineWidget::updateTextCursor(const QModelIndex &index) { QModelIndex sourceIndex = m_filterModel->mapToSource(index); - AST::SourceLocation location = m_editor->outlineModel()->sourceLocation(sourceIndex); + AST::SourceLocation location + = m_editor->qmlJsEditorDocument()->outlineModel()->sourceLocation(sourceIndex); if (!location.isValid()) return; diff --git a/src/plugins/qmljseditor/qmljsquickfixassist.cpp b/src/plugins/qmljseditor/qmljsquickfixassist.cpp index 1bccc679235..c7ddeaf8f0d 100644 --- a/src/plugins/qmljseditor/qmljsquickfixassist.cpp +++ b/src/plugins/qmljseditor/qmljsquickfixassist.cpp @@ -29,6 +29,7 @@ #include "qmljsquickfixassist.h" #include "qmljseditorconstants.h" +#include "qmljseditordocument.h" //temp #include "qmljsquickfix.h" @@ -50,7 +51,7 @@ QmlJSQuickFixAssistInterface::QmlJSQuickFixAssistInterface(QmlJSTextEditorWidget : DefaultAssistInterface(editor->document(), editor->position(), editor->baseTextDocument()->filePath(), reason) , m_editor(editor) - , m_semanticInfo(editor->semanticInfo()) + , m_semanticInfo(editor->qmlJsEditorDocument()->semanticInfo()) , m_currentFile(QmlJSRefactoringChanges::file(m_editor, m_semanticInfo.document)) {} diff --git a/src/plugins/qmljseditor/qmljssemantichighlighter.h b/src/plugins/qmljseditor/qmljssemantichighlighter.h index d871403f935..cd316a95c94 100644 --- a/src/plugins/qmljseditor/qmljssemantichighlighter.h +++ b/src/plugins/qmljseditor/qmljssemantichighlighter.h @@ -52,10 +52,10 @@ class SemanticInfo; namespace QmlJSEditor { -namespace Internal { - class QmlJSEditorDocument; +namespace Internal { + class SemanticHighlighter : public QObject { Q_OBJECT