forked from qt-creator/qt-creator
QmlJSEditor: Remove functions from widget that delegate to document
Instead access document directly. Needs to export document. Change-Id: I8fa86832982d2793ea951e88a5b6e3925b7cd281 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
This commit is contained in:
@@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include <qmljs/qmljsmodelmanagerinterface.h>
|
#include <qmljs/qmljsmodelmanagerinterface.h>
|
||||||
#include <qmljseditor/qmljseditor.h>
|
#include <qmljseditor/qmljseditor.h>
|
||||||
|
#include <qmljseditor/qmljseditordocument.h>
|
||||||
#include <texteditor/tabsettings.h>
|
#include <texteditor/tabsettings.h>
|
||||||
#include <utils/changeset.h>
|
#include <utils/changeset.h>
|
||||||
|
|
||||||
@@ -71,7 +72,8 @@ bool BaseTextEditModifier::renameId(const QString &oldId, const QString &newId)
|
|||||||
{
|
{
|
||||||
if (QmlJSEditor::QmlJSTextEditorWidget *qmljse = qobject_cast<QmlJSEditor::QmlJSTextEditorWidget*>(plainTextEdit())) {
|
if (QmlJSEditor::QmlJSTextEditorWidget *qmljse = qobject_cast<QmlJSEditor::QmlJSTextEditorWidget*>(plainTextEdit())) {
|
||||||
Utils::ChangeSet changeSet;
|
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);
|
changeSet.replace(loc.begin(), loc.end(), newId);
|
||||||
}
|
}
|
||||||
QTextCursor tc = qmljse->textCursor();
|
QTextCursor tc = qmljse->textCursor();
|
||||||
|
|||||||
@@ -166,31 +166,6 @@ QmlJSTextEditorWidget::~QmlJSTextEditorWidget()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SemanticInfo QmlJSTextEditorWidget::semanticInfo() const
|
|
||||||
{
|
|
||||||
return m_qmlJsEditorDocument->semanticInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
int QmlJSTextEditorWidget::editorRevision() const
|
|
||||||
{
|
|
||||||
return document()->revision();
|
|
||||||
}
|
|
||||||
|
|
||||||
QVector<QTextLayout::FormatRange> 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()
|
QModelIndex QmlJSTextEditorWidget::outlineModelIndex()
|
||||||
{
|
{
|
||||||
if (!m_outlineModelIndex.isValid()) {
|
if (!m_outlineModelIndex.isValid()) {
|
||||||
@@ -299,7 +274,7 @@ void QmlJSTextEditorWidget::updateOutlineIndexNow()
|
|||||||
if (!m_qmlJsEditorDocument->outlineModel()->document())
|
if (!m_qmlJsEditorDocument->outlineModel()->document())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_qmlJsEditorDocument->outlineModel()->document()->editorRevision() != editorRevision()) {
|
if (m_qmlJsEditorDocument->outlineModel()->document()->editorRevision() != document()->revision()) {
|
||||||
m_updateOutlineIndexTimer->start();
|
m_updateOutlineIndexTimer->start();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -832,6 +807,11 @@ void QmlJSTextEditorWidget::unCommentSelection()
|
|||||||
Utils::unCommentSelection(this);
|
Utils::unCommentSelection(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QmlJSEditorDocument *QmlJSTextEditorWidget::qmlJsEditorDocument() const
|
||||||
|
{
|
||||||
|
return m_qmlJsEditorDocument;
|
||||||
|
}
|
||||||
|
|
||||||
void QmlJSTextEditorWidget::semanticInfoUpdated(const SemanticInfo &semanticInfo)
|
void QmlJSTextEditorWidget::semanticInfoUpdated(const SemanticInfo &semanticInfo)
|
||||||
{
|
{
|
||||||
if (isVisible()) {
|
if (isVisible()) {
|
||||||
|
|||||||
@@ -66,10 +66,10 @@ namespace AST {
|
|||||||
*/
|
*/
|
||||||
namespace QmlJSEditor {
|
namespace QmlJSEditor {
|
||||||
class QmlJSEditor;
|
class QmlJSEditor;
|
||||||
|
class QmlJSEditorDocument;
|
||||||
class FindReferences;
|
class FindReferences;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
class QmlJSEditorDocument;
|
|
||||||
class QmlOutlineModel;
|
class QmlOutlineModel;
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|
||||||
@@ -84,12 +84,7 @@ public:
|
|||||||
|
|
||||||
virtual void unCommentSelection();
|
virtual void unCommentSelection();
|
||||||
|
|
||||||
// redirecting to document
|
QmlJSEditorDocument *qmlJsEditorDocument() const;
|
||||||
QmlJSTools::SemanticInfo semanticInfo() const;
|
|
||||||
bool isSemanticInfoOutdated() const;
|
|
||||||
int editorRevision() const;
|
|
||||||
QVector<QTextLayout::FormatRange> diagnosticRanges() const;
|
|
||||||
Internal::QmlOutlineModel *outlineModel() const;
|
|
||||||
|
|
||||||
QModelIndex outlineModelIndex();
|
QModelIndex outlineModelIndex();
|
||||||
|
|
||||||
@@ -145,7 +140,7 @@ private:
|
|||||||
QModelIndex indexForPosition(unsigned cursorPosition, const QModelIndex &rootIndex = QModelIndex()) const;
|
QModelIndex indexForPosition(unsigned cursorPosition, const QModelIndex &rootIndex = QModelIndex()) const;
|
||||||
bool hideContextPane();
|
bool hideContextPane();
|
||||||
|
|
||||||
Internal::QmlJSEditorDocument *m_qmlJsEditorDocument;
|
QmlJSEditorDocument *m_qmlJsEditorDocument;
|
||||||
QTimer *m_updateUsesTimer; // to wait for multiple text cursor position changes
|
QTimer *m_updateUsesTimer; // to wait for multiple text cursor position changes
|
||||||
QTimer *m_updateOutlineIndexTimer;
|
QTimer *m_updateOutlineIndexTimer;
|
||||||
QTimer *m_contextPaneTimer;
|
QTimer *m_contextPaneTimer;
|
||||||
|
|||||||
@@ -530,13 +530,15 @@ void QmlJSEditorDocumentPrivate::updateOutlineModel()
|
|||||||
m_outlineModel->update(m_semanticInfo);
|
m_outlineModel->update(m_semanticInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // Internal
|
||||||
|
|
||||||
QmlJSEditorDocument::QmlJSEditorDocument()
|
QmlJSEditorDocument::QmlJSEditorDocument()
|
||||||
: m_d(new QmlJSEditorDocumentPrivate(this))
|
: m_d(new Internal::QmlJSEditorDocumentPrivate(this))
|
||||||
{
|
{
|
||||||
connect(this, SIGNAL(tabSettingsChanged()),
|
connect(this, SIGNAL(tabSettingsChanged()),
|
||||||
m_d, SLOT(invalidateFormatterCache()));
|
m_d, SLOT(invalidateFormatterCache()));
|
||||||
setSyntaxHighlighter(new Highlighter(document()));
|
setSyntaxHighlighter(new Highlighter(document()));
|
||||||
setIndenter(new Indenter);
|
setIndenter(new Internal::Indenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlJSEditorDocument::~QmlJSEditorDocument()
|
QmlJSEditorDocument::~QmlJSEditorDocument()
|
||||||
@@ -559,7 +561,7 @@ QVector<QTextLayout::FormatRange> QmlJSEditorDocument::diagnosticRanges() const
|
|||||||
return m_d->m_diagnosticRanges;
|
return m_d->m_diagnosticRanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlOutlineModel *QmlJSEditorDocument::outlineModel() const
|
Internal::QmlOutlineModel *QmlJSEditorDocument::outlineModel() const
|
||||||
{
|
{
|
||||||
return m_d->m_outlineModel;
|
return m_d->m_outlineModel;
|
||||||
}
|
}
|
||||||
@@ -593,5 +595,4 @@ void QmlJSEditorDocument::triggerPendingUpdates()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Internal
|
|
||||||
} // QmlJSEditor
|
} // QmlJSEditor
|
||||||
|
|||||||
@@ -30,6 +30,8 @@
|
|||||||
#ifndef QMLJSEDITORDOCUMENT_H
|
#ifndef QMLJSEDITORDOCUMENT_H
|
||||||
#define QMLJSEDITORDOCUMENT_H
|
#define QMLJSEDITORDOCUMENT_H
|
||||||
|
|
||||||
|
#include "qmljseditor_global.h"
|
||||||
|
|
||||||
#include <qmljs/qmljsdocument.h>
|
#include <qmljs/qmljsdocument.h>
|
||||||
#include <qmljstools/qmljssemanticinfo.h>
|
#include <qmljstools/qmljssemanticinfo.h>
|
||||||
#include <texteditor/basetextdocument.h>
|
#include <texteditor/basetextdocument.h>
|
||||||
@@ -37,12 +39,13 @@
|
|||||||
#include <QTextLayout>
|
#include <QTextLayout>
|
||||||
|
|
||||||
namespace QmlJSEditor {
|
namespace QmlJSEditor {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
class QmlJSEditorDocumentPrivate;
|
class QmlJSEditorDocumentPrivate;
|
||||||
class QmlOutlineModel;
|
class QmlOutlineModel;
|
||||||
|
} // Internal
|
||||||
|
|
||||||
class QmlJSEditorDocument : public TextEditor::BaseTextDocument
|
class QMLJSEDITOR_EXPORT QmlJSEditorDocument : public TextEditor::BaseTextDocument
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@@ -65,10 +68,9 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
friend class QmlJSEditorDocumentPrivate; // sending signals
|
friend class QmlJSEditorDocumentPrivate; // sending signals
|
||||||
QmlJSEditorDocumentPrivate *m_d;
|
Internal::QmlJSEditorDocumentPrivate *m_d;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Internal
|
|
||||||
} // QmlJSEditor
|
} // QmlJSEditor
|
||||||
|
|
||||||
#endif // QMLJSEDITORDOCUMENT_H
|
#endif // QMLJSEDITORDOCUMENT_H
|
||||||
|
|||||||
@@ -38,9 +38,11 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
namespace QmlJSEditor {
|
namespace QmlJSEditor {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class QmlJSEditorDocument;
|
class QmlJSEditorDocument;
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
class QmlOutlineModel;
|
class QmlOutlineModel;
|
||||||
class SemanticHighlighter;
|
class SemanticHighlighter;
|
||||||
class SemanticInfoUpdater;
|
class SemanticInfoUpdater;
|
||||||
|
|||||||
@@ -60,10 +60,10 @@ namespace QmlJS {
|
|||||||
namespace QmlJSEditor {
|
namespace QmlJSEditor {
|
||||||
|
|
||||||
class QmlFileWizard;
|
class QmlFileWizard;
|
||||||
|
class QmlJSEditorDocument;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class QmlJSEditorDocument;
|
|
||||||
class QmlJSEditorFactory;
|
class QmlJSEditorFactory;
|
||||||
class QmlJSPreviewRunner;
|
class QmlJSPreviewRunner;
|
||||||
class QmlJSQuickFixAssistProvider;
|
class QmlJSQuickFixAssistProvider;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include "qmljshoverhandler.h"
|
#include "qmljshoverhandler.h"
|
||||||
#include "qmljseditor.h"
|
#include "qmljseditor.h"
|
||||||
|
#include "qmljseditordocument.h"
|
||||||
#include "qmljseditoreditable.h"
|
#include "qmljseditoreditable.h"
|
||||||
#include "qmlexpressionundercursor.h"
|
#include "qmlexpressionundercursor.h"
|
||||||
|
|
||||||
@@ -194,8 +195,8 @@ void HoverHandler::identifyMatch(TextEditor::ITextEditor *editor, int pos)
|
|||||||
if (!qmlEditor)
|
if (!qmlEditor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const QmlJSTools::SemanticInfo &semanticInfo = qmlEditor->semanticInfo();
|
const QmlJSTools::SemanticInfo &semanticInfo = qmlEditor->qmlJsEditorDocument()->semanticInfo();
|
||||||
if (! semanticInfo.isValid() || qmlEditor->isSemanticInfoOutdated())
|
if (!semanticInfo.isValid() || qmlEditor->qmlJsEditorDocument()->isSemanticInfoOutdated())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QList<AST::Node *> rangePath = semanticInfo.rangePath(pos);
|
QList<AST::Node *> rangePath = semanticInfo.rangePath(pos);
|
||||||
@@ -266,7 +267,8 @@ bool HoverHandler::matchDiagnosticMessage(QmlJSTextEditorWidget *qmlEditor, int
|
|||||||
return true;
|
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) {
|
if (pos >= range.start && pos < range.start+range.length) {
|
||||||
setToolTip(range.format.toolTip());
|
setToolTip(range.format.toolTip());
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ void QmlJSOutlineWidget::setEditor(QmlJSTextEditorWidget *editor)
|
|||||||
{
|
{
|
||||||
m_editor = editor;
|
m_editor = editor;
|
||||||
|
|
||||||
m_filterModel->setSourceModel(m_editor->outlineModel());
|
m_filterModel->setSourceModel(m_editor->qmlJsEditorDocument()->outlineModel());
|
||||||
modelUpdated();
|
modelUpdated();
|
||||||
|
|
||||||
connect(m_treeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
|
connect(m_treeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
|
||||||
@@ -135,7 +135,7 @@ void QmlJSOutlineWidget::setEditor(QmlJSTextEditorWidget *editor)
|
|||||||
|
|
||||||
connect(m_editor, SIGNAL(outlineModelIndexChanged(QModelIndex)),
|
connect(m_editor, SIGNAL(outlineModelIndexChanged(QModelIndex)),
|
||||||
this, SLOT(updateSelectionInTree(QModelIndex)));
|
this, SLOT(updateSelectionInTree(QModelIndex)));
|
||||||
connect(m_editor->outlineModel(), SIGNAL(updated()),
|
connect(m_editor->qmlJsEditorDocument()->outlineModel(), SIGNAL(updated()),
|
||||||
this, SLOT(modelUpdated()));
|
this, SLOT(modelUpdated()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,7 +207,8 @@ void QmlJSOutlineWidget::updateSelectionInText(const QItemSelection &selection)
|
|||||||
void QmlJSOutlineWidget::updateTextCursor(const QModelIndex &index)
|
void QmlJSOutlineWidget::updateTextCursor(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
QModelIndex sourceIndex = m_filterModel->mapToSource(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())
|
if (!location.isValid())
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include "qmljsquickfixassist.h"
|
#include "qmljsquickfixassist.h"
|
||||||
#include "qmljseditorconstants.h"
|
#include "qmljseditorconstants.h"
|
||||||
|
#include "qmljseditordocument.h"
|
||||||
|
|
||||||
//temp
|
//temp
|
||||||
#include "qmljsquickfix.h"
|
#include "qmljsquickfix.h"
|
||||||
@@ -50,7 +51,7 @@ QmlJSQuickFixAssistInterface::QmlJSQuickFixAssistInterface(QmlJSTextEditorWidget
|
|||||||
: DefaultAssistInterface(editor->document(), editor->position(),
|
: DefaultAssistInterface(editor->document(), editor->position(),
|
||||||
editor->baseTextDocument()->filePath(), reason)
|
editor->baseTextDocument()->filePath(), reason)
|
||||||
, m_editor(editor)
|
, m_editor(editor)
|
||||||
, m_semanticInfo(editor->semanticInfo())
|
, m_semanticInfo(editor->qmlJsEditorDocument()->semanticInfo())
|
||||||
, m_currentFile(QmlJSRefactoringChanges::file(m_editor, m_semanticInfo.document))
|
, m_currentFile(QmlJSRefactoringChanges::file(m_editor, m_semanticInfo.document))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|||||||
@@ -52,10 +52,10 @@ class SemanticInfo;
|
|||||||
|
|
||||||
namespace QmlJSEditor {
|
namespace QmlJSEditor {
|
||||||
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class QmlJSEditorDocument;
|
class QmlJSEditorDocument;
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
class SemanticHighlighter : public QObject
|
class SemanticHighlighter : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|||||||
Reference in New Issue
Block a user