Commit ac4afcaa authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner.rewriter: exposing lookupContext and document

We need this for the new AST based meta info system
parent 4ce19d4b
......@@ -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);
......
......@@ -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())
......
......@@ -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);
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment