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 <qmljseditor/qmljseditor.h>
|
||||
#include <qmljseditor/qmljseditordocument.h>
|
||||
#include <texteditor/tabsettings.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())) {
|
||||
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();
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
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()) {
|
||||
|
||||
@@ -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<QTextLayout::FormatRange> 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;
|
||||
|
||||
@@ -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<QTextLayout::FormatRange> 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
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#ifndef QMLJSEDITORDOCUMENT_H
|
||||
#define QMLJSEDITORDOCUMENT_H
|
||||
|
||||
#include "qmljseditor_global.h"
|
||||
|
||||
#include <qmljs/qmljsdocument.h>
|
||||
#include <qmljstools/qmljssemanticinfo.h>
|
||||
#include <texteditor/basetextdocument.h>
|
||||
@@ -37,12 +39,13 @@
|
||||
#include <QTextLayout>
|
||||
|
||||
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
|
||||
|
||||
@@ -38,9 +38,11 @@
|
||||
#include <QTimer>
|
||||
|
||||
namespace QmlJSEditor {
|
||||
namespace Internal {
|
||||
|
||||
class QmlJSEditorDocument;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class QmlOutlineModel;
|
||||
class SemanticHighlighter;
|
||||
class SemanticInfoUpdater;
|
||||
|
||||
@@ -60,10 +60,10 @@ namespace QmlJS {
|
||||
namespace QmlJSEditor {
|
||||
|
||||
class QmlFileWizard;
|
||||
class QmlJSEditorDocument;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class QmlJSEditorDocument;
|
||||
class QmlJSEditorFactory;
|
||||
class QmlJSPreviewRunner;
|
||||
class QmlJSQuickFixAssistProvider;
|
||||
|
||||
@@ -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<AST::Node *> 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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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))
|
||||
{}
|
||||
|
||||
|
||||
@@ -52,10 +52,10 @@ class SemanticInfo;
|
||||
|
||||
namespace QmlJSEditor {
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class QmlJSEditorDocument;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class SemanticHighlighter : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Reference in New Issue
Block a user