forked from qt-creator/qt-creator
QmlJS: Remove LookupContext.
Use Context or ScopeChain instead. Change-Id: I2489477eac08774ba41710ee81876aab11b5af24 Reviewed-on: http://codereview.qt.nokia.com/1699 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
This commit is contained in:
@@ -49,7 +49,6 @@
|
||||
#include <qmljs/qmljsinterpreter.h>
|
||||
#include <qmljs/qmljscontext.h>
|
||||
#include <qmljs/qmljsscopechain.h>
|
||||
#include <qmljs/qmljslookupcontext.h>
|
||||
#include <qmljs/qmljsscanner.h>
|
||||
#include <qmljs/qmljsbind.h>
|
||||
#include <qmljs/qmljscompletioncontextfinder.h>
|
||||
@@ -421,9 +420,8 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const IAssistInterface
|
||||
isQmlFile = true;
|
||||
|
||||
const QList<AST::Node *> path = semanticInfo.rangePath(m_interface->position());
|
||||
LookupContext::Ptr lookupContext = semanticInfo.lookupContext(path);
|
||||
const Interpreter::ContextPtr &context = lookupContext->context();
|
||||
const Interpreter::ScopeChain &scopeChain = lookupContext->scopeChain();
|
||||
const Interpreter::ContextPtr &context = semanticInfo.context;
|
||||
const Interpreter::ScopeChain &scopeChain = semanticInfo.scopeChain(path);
|
||||
|
||||
// Search for the operator that triggered the completion.
|
||||
QChar completionOperator;
|
||||
@@ -615,9 +613,9 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const IAssistInterface
|
||||
|
||||
if (expression != 0 && ! isLiteral(expression)) {
|
||||
// Evaluate the expression under cursor.
|
||||
Interpreter::ValueOwner *interp = lookupContext->valueOwner();
|
||||
Interpreter::ValueOwner *interp = context->valueOwner();
|
||||
const Interpreter::Value *value =
|
||||
interp->convertToObject(lookupContext->evaluate(expression));
|
||||
interp->convertToObject(scopeChain.evaluate(expression));
|
||||
//qDebug() << "type:" << interp->typeId(value);
|
||||
|
||||
if (value && completionOperator == QLatin1Char('.')) { // member completion
|
||||
|
||||
@@ -46,8 +46,8 @@
|
||||
#include <qmljs/qmljsevaluate.h>
|
||||
#include <qmljs/qmljsdocument.h>
|
||||
#include <qmljs/qmljsicontextpane.h>
|
||||
#include <qmljs/qmljslookupcontext.h>
|
||||
#include <qmljs/qmljsmodelmanagerinterface.h>
|
||||
#include <qmljs/qmljsscopebuilder.h>
|
||||
#include <qmljs/parser/qmljsastvisitor_p.h>
|
||||
#include <qmljs/parser/qmljsast_p.h>
|
||||
#include <qmljs/parser/qmljsengine_p.h>
|
||||
@@ -547,14 +547,17 @@ QList<AST::Node *> SemanticInfo::rangePath(int cursorPosition) const
|
||||
return path;
|
||||
}
|
||||
|
||||
LookupContext::Ptr SemanticInfo::lookupContext(const QList<QmlJS::AST::Node *> &path) const
|
||||
Interpreter::ScopeChain SemanticInfo::scopeChain(const QList<QmlJS::AST::Node *> &path) const
|
||||
{
|
||||
Q_ASSERT(! m_context.isNull());
|
||||
Q_ASSERT(m_rootScopeChain);
|
||||
|
||||
if (m_context.isNull())
|
||||
return LookupContext::create(document, snapshot, path);
|
||||
if (path.isEmpty())
|
||||
return *m_rootScopeChain;
|
||||
|
||||
return LookupContext::create(document, m_context, path);
|
||||
Interpreter::ScopeChain scope = *m_rootScopeChain;
|
||||
ScopeBuilder builder(&scope);
|
||||
builder.push(path);
|
||||
return scope;
|
||||
}
|
||||
|
||||
static bool importContainsCursor(UiImport *importAst, unsigned cursorPosition)
|
||||
@@ -602,7 +605,7 @@ AST::Node *SemanticInfo::nodeUnderCursor(int pos) const
|
||||
|
||||
bool SemanticInfo::isValid() const
|
||||
{
|
||||
if (document && m_context)
|
||||
if (document && context && m_rootScopeChain)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -924,7 +927,7 @@ void QmlJSTextEditorWidget::updateCursorPositionNow()
|
||||
Node *oldNode = m_semanticInfo.declaringMemberNoProperties(m_oldCursorPosition);
|
||||
Node *newNode = m_semanticInfo.declaringMemberNoProperties(position());
|
||||
if (oldNode != newNode && m_oldCursorPosition != -1)
|
||||
m_contextPane->apply(editor(), semanticInfo().document, LookupContext::Ptr(),newNode, false);
|
||||
m_contextPane->apply(editor(), semanticInfo().document, 0, newNode, false);
|
||||
if (m_contextPane->isAvailable(editor(), semanticInfo().document, newNode) &&
|
||||
!m_contextPane->widget()->isVisible()) {
|
||||
QList<TextEditor::RefactorMarker> markers;
|
||||
@@ -1009,19 +1012,17 @@ class SelectedElement: protected Visitor
|
||||
unsigned m_cursorPositionStart;
|
||||
unsigned m_cursorPositionEnd;
|
||||
QList<UiObjectMember *> m_selectedMembers;
|
||||
LookupContext::Ptr m_lookupContext;
|
||||
|
||||
public:
|
||||
SelectedElement()
|
||||
: m_cursorPositionStart(0), m_cursorPositionEnd(0) {}
|
||||
|
||||
QList<UiObjectMember *> operator()(LookupContext::Ptr lookupContext, unsigned startPosition, unsigned endPosition)
|
||||
QList<UiObjectMember *> operator()(const Document::Ptr &doc, unsigned startPosition, unsigned endPosition)
|
||||
{
|
||||
m_lookupContext = lookupContext;
|
||||
m_cursorPositionStart = startPosition;
|
||||
m_cursorPositionEnd = endPosition;
|
||||
m_selectedMembers.clear();
|
||||
Node::accept(lookupContext->document()->qmlProgram(), this);
|
||||
Node::accept(doc->qmlProgram(), this);
|
||||
return m_selectedMembers;
|
||||
}
|
||||
|
||||
@@ -1135,7 +1136,7 @@ void QmlJSTextEditorWidget::setSelectedElements()
|
||||
|
||||
if (m_semanticInfo.isValid()) {
|
||||
SelectedElement selectedMembers;
|
||||
QList<UiObjectMember *> members = selectedMembers(m_semanticInfo.lookupContext(),
|
||||
QList<UiObjectMember *> members = selectedMembers(m_semanticInfo.document,
|
||||
startPos, endPos);
|
||||
if (!members.isEmpty()) {
|
||||
foreach(UiObjectMember *m, members) {
|
||||
@@ -1259,8 +1260,8 @@ TextEditor::BaseTextEditorWidget::Link QmlJSTextEditorWidget::findLinkAt(const Q
|
||||
return Link();
|
||||
}
|
||||
|
||||
LookupContext::Ptr lookupContext = semanticInfo.lookupContext(semanticInfo.rangePath(cursorPosition));
|
||||
Evaluate evaluator(&lookupContext->scopeChain());
|
||||
const Interpreter::ScopeChain scopeChain = semanticInfo.scopeChain(semanticInfo.rangePath(cursorPosition));
|
||||
Evaluate evaluator(&scopeChain);
|
||||
const Interpreter::Value *value = evaluator.reference(node);
|
||||
|
||||
QString fileName;
|
||||
@@ -1316,7 +1317,10 @@ void QmlJSTextEditorWidget::showContextPane()
|
||||
{
|
||||
if (m_contextPane && m_semanticInfo.isValid()) {
|
||||
Node *newNode = m_semanticInfo.declaringMemberNoProperties(position());
|
||||
m_contextPane->apply(editor(), m_semanticInfo.document, m_semanticInfo.lookupContext(), newNode, false, true);
|
||||
Interpreter::ScopeChain scopeChain = m_semanticInfo.scopeChain(m_semanticInfo.rangePath(position()));
|
||||
m_contextPane->apply(editor(), m_semanticInfo.document,
|
||||
&scopeChain,
|
||||
newNode, false, true);
|
||||
m_oldCursorPosition = position();
|
||||
QList<TextEditor::RefactorMarker> markers;
|
||||
setRefactorMarkers(markers);
|
||||
@@ -1412,10 +1416,7 @@ void QmlJSTextEditorWidget::wheelEvent(QWheelEvent *event)
|
||||
BaseTextEditorWidget::wheelEvent(event);
|
||||
|
||||
if (visible) {
|
||||
LookupContext::Ptr lookupContext;
|
||||
if (m_semanticInfo.isValid())
|
||||
lookupContext = m_semanticInfo.lookupContext();
|
||||
m_contextPane->apply(editor(), semanticInfo().document, QmlJS::LookupContext::Ptr(), m_semanticInfo.declaringMemberNoProperties(m_oldCursorPosition), false, true);
|
||||
m_contextPane->apply(editor(), semanticInfo().document, 0, m_semanticInfo.declaringMemberNoProperties(m_oldCursorPosition), false, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1486,7 +1487,7 @@ void QmlJSTextEditorWidget::updateSemanticInfo(const SemanticInfo &semanticInfo)
|
||||
if (m_contextPane) {
|
||||
Node *newNode = m_semanticInfo.declaringMemberNoProperties(position());
|
||||
if (newNode) {
|
||||
m_contextPane->apply(editor(), semanticInfo.document, LookupContext::Ptr(), newNode, true);
|
||||
m_contextPane->apply(editor(), semanticInfo.document, 0, newNode, true);
|
||||
m_cursorPositionTimer->start(); //update text marker
|
||||
}
|
||||
}
|
||||
@@ -1539,7 +1540,7 @@ bool QmlJSTextEditorWidget::hideContextPane()
|
||||
{
|
||||
bool b = (m_contextPane) && m_contextPane->widget()->isVisible();
|
||||
if (b) {
|
||||
m_contextPane->apply(editor(), semanticInfo().document, LookupContext::Ptr(), 0, false);
|
||||
m_contextPane->apply(editor(), semanticInfo().document, 0, 0, false);
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
#include <qmljs/qmljsdocument.h>
|
||||
#include <qmljs/qmljsscanner.h>
|
||||
#include <qmljs/qmljscontext.h>
|
||||
#include <qmljs/qmljsscopechain.h>
|
||||
#include <texteditor/basetexteditor.h>
|
||||
#include <texteditor/quickfix.h>
|
||||
|
||||
@@ -117,12 +117,13 @@ public:
|
||||
// Returns the list of nodes that enclose the given position.
|
||||
QList<QmlJS::AST::Node *> rangePath(int cursorPosition) const;
|
||||
|
||||
// Returns a context for the given path
|
||||
QSharedPointer<QmlJS::LookupContext> lookupContext(const QList<QmlJS::AST::Node *> &path = QList<QmlJS::AST::Node *>()) const;
|
||||
// Returns a scopeChain for the given path
|
||||
QmlJS::Interpreter::ScopeChain scopeChain(const QList<QmlJS::AST::Node *> &path = QList<QmlJS::AST::Node *>()) const;
|
||||
|
||||
public: // attributes
|
||||
QmlJS::Document::Ptr document;
|
||||
QmlJS::Snapshot snapshot;
|
||||
QmlJS::Interpreter::ContextPtr context;
|
||||
QList<Range> ranges;
|
||||
QHash<QString, QList<QmlJS::AST::SourceLocation> > idLocations;
|
||||
QList<Declaration> declarations;
|
||||
@@ -131,7 +132,7 @@ public: // attributes
|
||||
QList<QmlJS::DiagnosticMessage> semanticMessages;
|
||||
|
||||
private:
|
||||
QmlJS::Interpreter::ContextPtr m_context;
|
||||
QSharedPointer<const QmlJS::Interpreter::ScopeChain> m_rootScopeChain;
|
||||
|
||||
friend class Internal::SemanticHighlighter;
|
||||
};
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
#include <QtCore/QFutureWatcher>
|
||||
#include <utils/filesearch.h>
|
||||
#include <qmljs/qmljsdocument.h>
|
||||
#include <qmljs/qmljslookupcontext.h>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QTimer)
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include <coreplugin/helpmanager.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <qmljs/qmljscontext.h>
|
||||
#include <qmljs/qmljsscopechain.h>
|
||||
#include <qmljs/qmljsinterpreter.h>
|
||||
#include <qmljs/parser/qmljsast_p.h>
|
||||
#include <qmljs/parser/qmljsastfwd_p.h>
|
||||
@@ -54,6 +55,7 @@
|
||||
|
||||
using namespace Core;
|
||||
using namespace QmlJS;
|
||||
using namespace QmlJS::Interpreter;
|
||||
using namespace QmlJSEditor;
|
||||
using namespace QmlJSEditor::Internal;
|
||||
|
||||
@@ -123,20 +125,20 @@ void HoverHandler::identifyMatch(TextEditor::ITextEditor *editor, int pos)
|
||||
QList<AST::Node *> astPath = semanticInfo.rangePath(pos);
|
||||
|
||||
const Document::Ptr qmlDocument = semanticInfo.document;
|
||||
LookupContext::Ptr lookupContext = semanticInfo.lookupContext(astPath);
|
||||
ScopeChain scopeChain = semanticInfo.scopeChain(astPath);
|
||||
|
||||
AST::Node *node = semanticInfo.nodeUnderCursor(pos);
|
||||
if (astPath.isEmpty()) {
|
||||
if (AST::UiImport *import = AST::cast<AST::UiImport *>(node))
|
||||
handleImport(lookupContext, import);
|
||||
handleImport(scopeChain, import);
|
||||
return;
|
||||
}
|
||||
if (matchColorItem(lookupContext, qmlDocument, astPath, pos))
|
||||
if (matchColorItem(scopeChain, qmlDocument, astPath, pos))
|
||||
return;
|
||||
|
||||
handleOrdinaryMatch(lookupContext, node);
|
||||
handleOrdinaryMatch(scopeChain, node);
|
||||
|
||||
TextEditor::HelpItem helpItem = qmlHelpItem(lookupContext, node);
|
||||
TextEditor::HelpItem helpItem = qmlHelpItem(scopeChain, node);
|
||||
if (!helpItem.helpId().isEmpty())
|
||||
setLastHelpItemIdentified(helpItem);
|
||||
}
|
||||
@@ -153,7 +155,7 @@ bool HoverHandler::matchDiagnosticMessage(QmlJSEditor::QmlJSTextEditorWidget *qm
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HoverHandler::matchColorItem(const LookupContext::Ptr &lookupContext,
|
||||
bool HoverHandler::matchColorItem(const ScopeChain &scopeChain,
|
||||
const Document::Ptr &qmlDocument,
|
||||
const QList<AST::Node *> &astPath,
|
||||
unsigned pos)
|
||||
@@ -176,7 +178,7 @@ bool HoverHandler::matchColorItem(const LookupContext::Ptr &lookupContext,
|
||||
const Interpreter::Value *value = 0;
|
||||
if (const AST::UiScriptBinding *binding = AST::cast<const AST::UiScriptBinding *>(member)) {
|
||||
if (binding->qualifiedId && posIsInSource(pos, binding->statement)) {
|
||||
value = lookupContext->evaluate(binding->qualifiedId);
|
||||
value = scopeChain.evaluate(binding->qualifiedId);
|
||||
if (value && value->asColorValue()) {
|
||||
color = textAt(qmlDocument,
|
||||
binding->statement->firstSourceLocation(),
|
||||
@@ -186,9 +188,9 @@ bool HoverHandler::matchColorItem(const LookupContext::Ptr &lookupContext,
|
||||
} else if (const AST::UiPublicMember *publicMember =
|
||||
AST::cast<const AST::UiPublicMember *>(member)) {
|
||||
if (publicMember->name && posIsInSource(pos, publicMember->statement)) {
|
||||
value = lookupContext->scopeChain().lookup(publicMember->name->asString());
|
||||
value = scopeChain.lookup(publicMember->name->asString());
|
||||
if (const Interpreter::Reference *ref = value->asReference())
|
||||
value = lookupContext->context()->lookupReference(ref);
|
||||
value = scopeChain.context()->lookupReference(ref);
|
||||
color = textAt(qmlDocument,
|
||||
publicMember->statement->firstSourceLocation(),
|
||||
publicMember->statement->lastSourceLocation());
|
||||
@@ -209,18 +211,18 @@ bool HoverHandler::matchColorItem(const LookupContext::Ptr &lookupContext,
|
||||
return false;
|
||||
}
|
||||
|
||||
void HoverHandler::handleOrdinaryMatch(const LookupContext::Ptr &lookupContext, AST::Node *node)
|
||||
void HoverHandler::handleOrdinaryMatch(const ScopeChain &scopeChain, AST::Node *node)
|
||||
{
|
||||
if (node && !(AST::cast<AST::StringLiteral *>(node) != 0 ||
|
||||
AST::cast<AST::NumericLiteral *>(node) != 0)) {
|
||||
const Interpreter::Value *value = lookupContext->evaluate(node);
|
||||
prettyPrintTooltip(value, lookupContext->context());
|
||||
const Interpreter::Value *value = scopeChain.evaluate(node);
|
||||
prettyPrintTooltip(value, scopeChain.context());
|
||||
}
|
||||
}
|
||||
|
||||
void HoverHandler::handleImport(const LookupContext::Ptr &lookupContext, AST::UiImport *node)
|
||||
void HoverHandler::handleImport(const ScopeChain &scopeChain, AST::UiImport *node)
|
||||
{
|
||||
const Interpreter::Imports *imports = lookupContext->context()->imports(lookupContext->document().data());
|
||||
const Interpreter::Imports *imports = scopeChain.context()->imports(scopeChain.document().data());
|
||||
if (!imports)
|
||||
return;
|
||||
|
||||
@@ -229,7 +231,7 @@ void HoverHandler::handleImport(const LookupContext::Ptr &lookupContext, AST::Ui
|
||||
if (import.info.type() == Interpreter::ImportInfo::LibraryImport
|
||||
&& !import.libraryPath.isEmpty()) {
|
||||
QString msg = tr("Library at %1").arg(import.libraryPath);
|
||||
const LibraryInfo &libraryInfo = lookupContext->snapshot().libraryInfo(import.libraryPath);
|
||||
const LibraryInfo &libraryInfo = scopeChain.context()->snapshot().libraryInfo(import.libraryPath);
|
||||
if (libraryInfo.pluginTypeInfoStatus() == LibraryInfo::DumpDone) {
|
||||
msg += QLatin1Char('\n');
|
||||
msg += tr("Dumped plugins successfully.");
|
||||
@@ -298,7 +300,7 @@ void HoverHandler::prettyPrintTooltip(const QmlJS::Interpreter::Value *value,
|
||||
}
|
||||
|
||||
// if node refers to a property, its name and defining object are returned - otherwise zero
|
||||
static const Interpreter::ObjectValue *isMember(const LookupContext::Ptr &lookupContext,
|
||||
static const Interpreter::ObjectValue *isMember(const ScopeChain &scopeChain,
|
||||
AST::Node *node, QString *name)
|
||||
{
|
||||
const Interpreter::ObjectValue *owningObject = 0;
|
||||
@@ -306,22 +308,22 @@ static const Interpreter::ObjectValue *isMember(const LookupContext::Ptr &lookup
|
||||
if (!identExp->name)
|
||||
return 0;
|
||||
*name = identExp->name->asString();
|
||||
lookupContext->scopeChain().lookup(*name, &owningObject);
|
||||
scopeChain.lookup(*name, &owningObject);
|
||||
} else if (AST::FieldMemberExpression *fme = AST::cast<AST::FieldMemberExpression *>(node)) {
|
||||
if (!fme->base || !fme->name)
|
||||
return 0;
|
||||
*name = fme->name->asString();
|
||||
const Interpreter::Value *base = lookupContext->evaluate(fme->base);
|
||||
const Interpreter::Value *base = scopeChain.evaluate(fme->base);
|
||||
if (!base)
|
||||
return 0;
|
||||
owningObject = base->asObjectValue();
|
||||
if (owningObject)
|
||||
owningObject->lookupMember(*name, lookupContext->context(), &owningObject);
|
||||
owningObject->lookupMember(*name, scopeChain.context(), &owningObject);
|
||||
} else if (AST::UiQualifiedId *qid = AST::cast<AST::UiQualifiedId *>(node)) {
|
||||
if (!qid->name)
|
||||
return 0;
|
||||
*name = qid->name->asString();
|
||||
const Interpreter::Value *value = lookupContext->scopeChain().lookup(*name, &owningObject);
|
||||
const Interpreter::Value *value = scopeChain.lookup(*name, &owningObject);
|
||||
for (AST::UiQualifiedId *it = qid->next; it; it = it->next) {
|
||||
if (!value)
|
||||
return 0;
|
||||
@@ -329,17 +331,17 @@ static const Interpreter::ObjectValue *isMember(const LookupContext::Ptr &lookup
|
||||
if (!next || !it->name)
|
||||
return 0;
|
||||
*name = it->name->asString();
|
||||
value = next->lookupMember(*name, lookupContext->context(), &owningObject);
|
||||
value = next->lookupMember(*name, scopeChain.context(), &owningObject);
|
||||
}
|
||||
}
|
||||
return owningObject;
|
||||
}
|
||||
|
||||
TextEditor::HelpItem HoverHandler::qmlHelpItem(const LookupContext::Ptr &lookupContext,
|
||||
TextEditor::HelpItem HoverHandler::qmlHelpItem(const ScopeChain &scopeChain,
|
||||
AST::Node *node) const
|
||||
{
|
||||
QString name;
|
||||
if (const Interpreter::ObjectValue *scope = isMember(lookupContext, node, &name)) {
|
||||
if (const Interpreter::ObjectValue *scope = isMember(scopeChain, node, &name)) {
|
||||
// maybe it's a type?
|
||||
if (!name.isEmpty() && name.at(0).isUpper()) {
|
||||
const QString maybeHelpId(QLatin1String("QML.") + name);
|
||||
@@ -349,8 +351,8 @@ TextEditor::HelpItem HoverHandler::qmlHelpItem(const LookupContext::Ptr &lookupC
|
||||
|
||||
// otherwise, it's probably a property
|
||||
const Interpreter::ObjectValue *lastScope;
|
||||
scope->lookupMember(name, lookupContext->context(), &lastScope);
|
||||
Interpreter::PrototypeIterator iter(scope, lookupContext->context());
|
||||
scope->lookupMember(name, scopeChain.context(), &lastScope);
|
||||
Interpreter::PrototypeIterator iter(scope, scopeChain.context());
|
||||
while (iter.hasNext()) {
|
||||
const Interpreter::ObjectValue *cur = iter.next();
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
#define QMLJSHOVERHANDLER_H
|
||||
|
||||
#include <qmljs/qmljsmodelmanagerinterface.h>
|
||||
#include <qmljs/qmljslookupcontext.h>
|
||||
#include <texteditor/basehoverhandler.h>
|
||||
|
||||
#include <QtGui/QColor>
|
||||
@@ -51,6 +50,15 @@ namespace TextEditor {
|
||||
class ITextEditor;
|
||||
}
|
||||
|
||||
namespace QmlJS {
|
||||
namespace Interpreter {
|
||||
class ScopeChain;
|
||||
class Context;
|
||||
typedef QSharedPointer<const Context> ContextPtr;
|
||||
class Value;
|
||||
}
|
||||
}
|
||||
|
||||
namespace QmlJSEditor {
|
||||
class QmlJSTextEditorWidget;
|
||||
|
||||
@@ -70,19 +78,19 @@ private:
|
||||
virtual void operateTooltip(TextEditor::ITextEditor *editor, const QPoint &point);
|
||||
|
||||
bool matchDiagnosticMessage(QmlJSEditor::QmlJSTextEditorWidget *qmlEditor, int pos);
|
||||
bool matchColorItem(const QmlJS::LookupContext::Ptr &lookupContext,
|
||||
bool matchColorItem(const QmlJS::Interpreter::ScopeChain &lookupContext,
|
||||
const QmlJS::Document::Ptr &qmlDocument,
|
||||
const QList<QmlJS::AST::Node *> &astPath,
|
||||
unsigned pos);
|
||||
void handleOrdinaryMatch(const QmlJS::LookupContext::Ptr &lookupContext,
|
||||
void handleOrdinaryMatch(const QmlJS::Interpreter::ScopeChain &lookupContext,
|
||||
QmlJS::AST::Node *node);
|
||||
void handleImport(const QmlJS::LookupContext::Ptr &lookupContext,
|
||||
void handleImport(const QmlJS::Interpreter::ScopeChain &lookupContext,
|
||||
QmlJS::AST::UiImport *node);
|
||||
|
||||
void prettyPrintTooltip(const QmlJS::Interpreter::Value *value,
|
||||
const QmlJS::Interpreter::ContextPtr &context);
|
||||
|
||||
TextEditor::HelpItem qmlHelpItem(const QmlJS::LookupContext::Ptr &lookupContext,
|
||||
TextEditor::HelpItem qmlHelpItem(const QmlJS::Interpreter::ScopeChain &lookupContext,
|
||||
QmlJS::AST::Node *node) const;
|
||||
|
||||
QmlJS::ModelManagerInterface *m_modelManager;
|
||||
|
||||
@@ -135,10 +135,12 @@ SemanticInfo SemanticHighlighter::semanticInfo(const SemanticHighlighterSource &
|
||||
QmlJS::ModelManagerInterface *modelManager = QmlJS::ModelManagerInterface::instance();
|
||||
|
||||
QmlJS::Link link(snapshot, modelManager->importPaths(), modelManager->builtins(doc));
|
||||
QmlJS::Interpreter::ContextPtr ctx = link(doc, &semanticInfo.semanticMessages);
|
||||
semanticInfo.m_context = QSharedPointer<const QmlJS::Interpreter::Context>(ctx);
|
||||
semanticInfo.context = link(doc, &semanticInfo.semanticMessages);
|
||||
|
||||
QmlJS::Check checker(doc, ctx);
|
||||
QmlJS::Interpreter::ScopeChain *scopeChain = new QmlJS::Interpreter::ScopeChain(doc, semanticInfo.context);
|
||||
semanticInfo.m_rootScopeChain = QSharedPointer<const QmlJS::Interpreter::ScopeChain>(scopeChain);
|
||||
|
||||
QmlJS::Check checker(doc, semanticInfo.context);
|
||||
semanticInfo.semanticMessages.append(checker());
|
||||
|
||||
return semanticInfo;
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
#include <qmljs/parser/qmljsastvisitor_p.h>
|
||||
#include <qmljs/qmljscontext.h>
|
||||
#include <qmljs/qmljslookupcontext.h>
|
||||
#include <qmljs/qmljsscopechain.h>
|
||||
#include <qmljs/qmljsmodelmanagerinterface.h>
|
||||
#include <qmljs/qmljsrewriter.h>
|
||||
#include <qmljstools/qmljsrefactoringchanges.h>
|
||||
@@ -72,10 +72,10 @@ QVariant QmlOutlineItem::data(int role) const
|
||||
return QVariant();
|
||||
|
||||
QList<AST::Node *> astPath = m_outlineModel->m_semanticInfo.rangePath(location.begin());
|
||||
LookupContext::Ptr lookupContext = m_outlineModel->m_semanticInfo.lookupContext(astPath);
|
||||
const Interpreter::Value *value = lookupContext->evaluate(uiQualifiedId);
|
||||
Interpreter::ScopeChain scopeChain = m_outlineModel->m_semanticInfo.scopeChain(astPath);
|
||||
const Interpreter::Value *value = scopeChain.evaluate(uiQualifiedId);
|
||||
|
||||
return prettyPrint(value, lookupContext->context());
|
||||
return prettyPrint(value, scopeChain.context());
|
||||
}
|
||||
|
||||
if (role == Qt::DecorationRole) {
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
#include <utils/changeset.h>
|
||||
#include <qmljs/qmljsdocument.h>
|
||||
#include <qmljs/qmljsicons.h>
|
||||
#include <qmljs/qmljslookupcontext.h>
|
||||
|
||||
#include <QtGui/QStandardItemModel>
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
#include <qmljs/qmljspropertyreader.h>
|
||||
#include <qmljs/qmljsrewriter.h>
|
||||
#include <qmljs/qmljsindenter.h>
|
||||
#include <qmljs/qmljslookupcontext.h>
|
||||
#include <qmljs/qmljscontext.h>
|
||||
#include <qmljs/qmljsbind.h>
|
||||
#include <qmljs/qmljsscopebuilder.h>
|
||||
@@ -65,7 +64,7 @@ static inline QString textAt(const Document* doc,
|
||||
return doc->source().mid(from.offset, to.end() - from.begin());
|
||||
}
|
||||
|
||||
static inline const Interpreter::ObjectValue * getPropertyChangesTarget(Node *node, LookupContext::Ptr lookupContext)
|
||||
static inline const Interpreter::ObjectValue * getPropertyChangesTarget(Node *node, const Interpreter::ScopeChain &scopeChain)
|
||||
{
|
||||
UiObjectInitializer *initializer = 0;
|
||||
if (UiObjectDefinition *definition = cast<UiObjectDefinition *>(node))
|
||||
@@ -78,7 +77,7 @@ static inline const Interpreter::ObjectValue * getPropertyChangesTarget(Node *no
|
||||
if (scriptBinding->qualifiedId
|
||||
&& scriptBinding->qualifiedId->name->asString() == QLatin1String("target")
|
||||
&& ! scriptBinding->qualifiedId->next) {
|
||||
Evaluate evaluator(&lookupContext->scopeChain());
|
||||
Evaluate evaluator(&scopeChain);
|
||||
const Interpreter::Value *targetValue = evaluator(scriptBinding->statement);
|
||||
if (const Interpreter::ObjectValue *targetObject = Interpreter::value_cast<const Interpreter::ObjectValue *>(targetValue)) {
|
||||
return targetObject;
|
||||
@@ -132,7 +131,7 @@ QuickToolBar::~QuickToolBar()
|
||||
m_widget.clear();
|
||||
}
|
||||
|
||||
void QuickToolBar::apply(TextEditor::BaseTextEditor *editor, Document::Ptr document, LookupContext::Ptr lookupContext, AST::Node *node, bool update, bool force)
|
||||
void QuickToolBar::apply(TextEditor::BaseTextEditor *editor, Document::Ptr document, const Interpreter::ScopeChain *scopeChain, AST::Node *node, bool update, bool force)
|
||||
{
|
||||
if (!QuickToolBarSettings::get().enableContextPane && !force && !update) {
|
||||
contextWidget()->hide();
|
||||
@@ -151,20 +150,20 @@ void QuickToolBar::apply(TextEditor::BaseTextEditor *editor, Document::Ptr docum
|
||||
|
||||
bool isPropertyChanges = false;
|
||||
|
||||
if (!lookupContext.isNull() && scopeObject) {
|
||||
if (scopeChain && scopeObject) {
|
||||
m_prototypes.clear();
|
||||
foreach (const Interpreter::ObjectValue *object,
|
||||
Interpreter::PrototypeIterator(scopeObject, lookupContext->context()).all()) {
|
||||
Interpreter::PrototypeIterator(scopeObject, scopeChain->context()).all()) {
|
||||
m_prototypes.append(object->className());
|
||||
}
|
||||
|
||||
if (m_prototypes.contains("PropertyChanges")) {
|
||||
isPropertyChanges = true;
|
||||
const Interpreter::ObjectValue *targetObject = getPropertyChangesTarget(node, lookupContext);
|
||||
const Interpreter::ObjectValue *targetObject = getPropertyChangesTarget(node, *scopeChain);
|
||||
m_prototypes.clear();
|
||||
if (targetObject) {
|
||||
foreach (const Interpreter::ObjectValue *object,
|
||||
Interpreter::PrototypeIterator(targetObject, lookupContext->context()).all()) {
|
||||
Interpreter::PrototypeIterator(targetObject, scopeChain->context()).all()) {
|
||||
m_prototypes.append(object->className());
|
||||
}
|
||||
}
|
||||
@@ -196,7 +195,7 @@ void QuickToolBar::apply(TextEditor::BaseTextEditor *editor, Document::Ptr docum
|
||||
end = objectBinding->lastSourceLocation().end();
|
||||
}
|
||||
|
||||
if (lookupContext.isNull()) {
|
||||
if (!scopeChain) {
|
||||
if (name != m_oldType)
|
||||
m_prototypes.clear();
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class QuickToolBar : public QmlJS::IContextPane
|
||||
public:
|
||||
QuickToolBar(QObject *parent = 0);
|
||||
~QuickToolBar();
|
||||
void apply(TextEditor::BaseTextEditor *editor, QmlJS::Document::Ptr document, QmlJS::LookupContext::Ptr lookupContext, QmlJS::AST::Node *node, bool update, bool force = false);
|
||||
void apply(TextEditor::BaseTextEditor *editor, QmlJS::Document::Ptr document, const QmlJS::Interpreter::ScopeChain *scopeChain, QmlJS::AST::Node *node, bool update, bool force = false);
|
||||
bool isAvailable(TextEditor::BaseTextEditor *editor, QmlJS::Document::Ptr document, QmlJS::AST::Node *node);
|
||||
void setProperty(const QString &propertyName, const QVariant &value);
|
||||
void removeProperty(const QString &propertyName);
|
||||
|
||||
Reference in New Issue
Block a user