From ac4afcaab3f105181b5e8ecff7fba30ea778dc3e Mon Sep 17 00:00:00 2001 From: Thomas Hartmann <Thomas.Hartmann@nokia.com> Date: Wed, 1 Dec 2010 13:21:22 +0100 Subject: [PATCH] QmlDesigner.rewriter: exposing lookupContext and document We need this for the new AST based meta info system --- .../qmldesigner/designercore/include/rewriterview.h | 6 ++++++ .../qmldesigner/designercore/model/rewriterview.cpp | 10 ++++++++++ .../designercore/model/texttomodelmerger.cpp | 8 ++++++++ .../qmldesigner/designercore/model/texttomodelmerger.h | 10 ++++++++++ 4 files changed, 34 insertions(+) diff --git a/src/plugins/qmldesigner/designercore/include/rewriterview.h b/src/plugins/qmldesigner/designercore/include/rewriterview.h index eebc9d3740..0665fd9ce4 100644 --- a/src/plugins/qmldesigner/designercore/include/rewriterview.h +++ b/src/plugins/qmldesigner/designercore/include/rewriterview.h @@ -44,7 +44,10 @@ #include <QScopedPointer> namespace QmlJS { + class DiagnosticMessage; +class LookupContext; +class Document; } @@ -166,6 +169,9 @@ public: bool renameId(const QString& oldId, const QString& newId); + QmlJS::LookupContext *lookupContext() const; + QmlJS::Document *document() const; + signals: void errorsChanged(const QList<RewriterView::Error> &errors); diff --git a/src/plugins/qmldesigner/designercore/model/rewriterview.cpp b/src/plugins/qmldesigner/designercore/model/rewriterview.cpp index d2163114da..07d7669b13 100644 --- a/src/plugins/qmldesigner/designercore/model/rewriterview.cpp +++ b/src/plugins/qmldesigner/designercore/model/rewriterview.cpp @@ -567,6 +567,16 @@ bool RewriterView::renameId(const QString& oldId, const QString& newId) return false; } +QmlJS::LookupContext *RewriterView::lookupContext() const +{ + return textToModelMerger()->lookupContext(); +} + +QmlJS::Document *RewriterView::document() const +{ + return textToModelMerger()->document(); +} + void RewriterView::qmlTextChanged() { if (inErrorState()) diff --git a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp index c65bd962d9..69d0d75e36 100644 --- a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp +++ b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp @@ -225,6 +225,7 @@ public: : m_snapshot(snapshot) , m_doc(doc) , m_context(new Interpreter::Context) + , m_lookupContext(LookupContext::create(doc, snapshot, QList<AST::Node*>())) , m_link(m_context, doc, snapshot, importPaths) , m_scopeBuilder(m_context, doc, snapshot) { @@ -478,10 +479,15 @@ public: return QVariant(); } + + LookupContext::Ptr lookupContext() const + { return m_lookupContext; } + private: Snapshot m_snapshot; Document::Ptr m_doc; Interpreter::Context *m_context; + LookupContext::Ptr m_lookupContext; Link m_link; ScopeBuilder m_scopeBuilder; }; @@ -581,6 +587,8 @@ bool TextToModelMerger::load(const QString &data, DifferenceHandler &differenceH snapshot.insert(doc); ReadingContext ctxt(snapshot, doc, importPaths); + m_lookupContext = ctxt.lookupContext(); + m_document = doc; setupImports(doc, differenceHandler); diff --git a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.h b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.h index 1c0050a471..9d233ae4c7 100644 --- a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.h +++ b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.h @@ -35,7 +35,9 @@ #include "nodelistproperty.h" #include "modelnode.h" +#include <qmljs/qmljslookupcontext.h> #include <qmljs/qmljsdocument.h> +#include <qmljs/qmljslookupcontext.h> #include <QtCore/QStringList> @@ -63,6 +65,12 @@ public: RewriterView *view() const { return m_rewriterView; } + QmlJS::LookupContext *lookupContext() const + { return m_lookupContext.data(); } + + QmlJS::Document *document() const + { return m_document.data(); } + protected: void setActive(bool active); @@ -122,6 +130,8 @@ private: private: RewriterView *m_rewriterView; bool m_isActive; + QmlJS::LookupContext::Ptr m_lookupContext; + QmlJS::Document::Ptr m_document; }; class DifferenceHandler -- GitLab