QmlJS: Remove Interpreter namespace.

The distinction between QmlJS and QmlJS::Interpreter has always been
weak and the extra namespace just added an unnecessary complication.

Change-Id: I4db8ef4bd91b5f6bf610a9d23fdbf55bd60250fc
Reviewed-on: http://codereview.qt.nokia.com/2743
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
This commit is contained in:
Christian Kamm
2011-08-08 12:47:49 +02:00
parent ff092f79b3
commit 0e54183d4d
42 changed files with 308 additions and 344 deletions

View File

@@ -79,18 +79,18 @@ enum CompletionOrder {
TypeOrder = -30
};
class EnumerateProperties: private Interpreter::MemberProcessor
class EnumerateProperties: private MemberProcessor
{
QSet<const Interpreter::ObjectValue *> _processed;
QHash<QString, const Interpreter::Value *> _properties;
QSet<const ObjectValue *> _processed;
QHash<QString, const Value *> _properties;
bool _globalCompletion;
bool _enumerateGeneratedSlots;
bool _enumerateSlots;
const Interpreter::ScopeChain *_scopeChain;
const Interpreter::ObjectValue *_currentObject;
const ScopeChain *_scopeChain;
const ObjectValue *_currentObject;
public:
EnumerateProperties(const Interpreter::ScopeChain *scopeChain)
EnumerateProperties(const ScopeChain *scopeChain)
: _globalCompletion(false),
_enumerateGeneratedSlots(false),
_enumerateSlots(true),
@@ -114,61 +114,61 @@ public:
_enumerateSlots = enumerate;
}
QHash<QString, const Interpreter::Value *> operator ()(const Interpreter::Value *value)
QHash<QString, const Value *> operator ()(const Value *value)
{
_processed.clear();
_properties.clear();
_currentObject = Interpreter::value_cast<const Interpreter::ObjectValue *>(value);
_currentObject = value_cast<const ObjectValue *>(value);
enumerateProperties(value);
return _properties;
}
QHash<QString, const Interpreter::Value *> operator ()()
QHash<QString, const Value *> operator ()()
{
_processed.clear();
_properties.clear();
_currentObject = 0;
foreach (const Interpreter::ObjectValue *scope, _scopeChain->all())
foreach (const ObjectValue *scope, _scopeChain->all())
enumerateProperties(scope);
return _properties;
}
private:
void insertProperty(const QString &name, const Interpreter::Value *value)
void insertProperty(const QString &name, const Value *value)
{
_properties.insert(name, value);
}
virtual bool processProperty(const QString &name, const Interpreter::Value *value)
virtual bool processProperty(const QString &name, const Value *value)
{
insertProperty(name, value);
return true;
}
virtual bool processEnumerator(const QString &name, const Interpreter::Value *value)
virtual bool processEnumerator(const QString &name, const Value *value)
{
if (! _globalCompletion)
insertProperty(name, value);
return true;
}
virtual bool processSignal(const QString &, const Interpreter::Value *)
virtual bool processSignal(const QString &, const Value *)
{
return true;
}
virtual bool processSlot(const QString &name, const Interpreter::Value *value)
virtual bool processSlot(const QString &name, const Value *value)
{
if (_enumerateSlots)
insertProperty(name, value);
return true;
}
virtual bool processGeneratedSlot(const QString &name, const Interpreter::Value *value)
virtual bool processGeneratedSlot(const QString &name, const Value *value)
{
if (_enumerateGeneratedSlots || (_currentObject && _currentObject->className().endsWith(QLatin1String("Keys")))) {
// ### FIXME: add support for attached properties.
@@ -177,16 +177,16 @@ private:
return true;
}
void enumerateProperties(const Interpreter::Value *value)
void enumerateProperties(const Value *value)
{
if (! value)
return;
else if (const Interpreter::ObjectValue *object = value->asObjectValue()) {
else if (const ObjectValue *object = value->asObjectValue()) {
enumerateProperties(object);
}
}
void enumerateProperties(const Interpreter::ObjectValue *object)
void enumerateProperties(const ObjectValue *object)
{
if (! object || _processed.contains(object))
return;
@@ -198,16 +198,16 @@ private:
}
};
const Interpreter::Value *getPropertyValue(const Interpreter::ObjectValue *object,
const Value *getPropertyValue(const ObjectValue *object,
const QStringList &propertyNames,
const Interpreter::ContextPtr &context)
const ContextPtr &context)
{
if (propertyNames.isEmpty() || !object)
return 0;
const Interpreter::Value *value = object;
const Value *value = object;
foreach (const QString &name, propertyNames) {
if (const Interpreter::ObjectValue *objectValue = value->asObjectValue()) {
if (const ObjectValue *objectValue = value->asObjectValue()) {
value = objectValue->lookupMember(name, context);
if (!value)
return 0;
@@ -420,8 +420,8 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const IAssistInterface
isQmlFile = true;
const QList<AST::Node *> path = semanticInfo.rangePath(m_interface->position());
const Interpreter::ContextPtr &context = semanticInfo.context;
const Interpreter::ScopeChain &scopeChain = semanticInfo.scopeChain(path);
const ContextPtr &context = semanticInfo.context;
const ScopeChain &scopeChain = semanticInfo.scopeChain(path);
// Search for the operator that triggered the completion.
QChar completionOperator;
@@ -432,7 +432,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const IAssistInterface
startPositionCursor.setPosition(m_startPosition);
CompletionContextFinder contextFinder(startPositionCursor);
const Interpreter::ObjectValue *qmlScopeType = 0;
const ObjectValue *qmlScopeType = 0;
if (contextFinder.isInQmlContext()) {
// find the enclosing qml object
// ### this should use semanticInfo.declaringMember instead, but that may also return functions
@@ -450,15 +450,15 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const IAssistInterface
AST::UiObjectDefinition *objDef = AST::cast<AST::UiObjectDefinition *>(path[i]);
if (!objDef || !document->bind()->isGroupedPropertyBinding(objDef))
break;
const Interpreter::ObjectValue *newScopeType = qmlScopeType;
const ObjectValue *newScopeType = qmlScopeType;
for (AST::UiQualifiedId *it = objDef->qualifiedTypeNameId; it; it = it->next) {
if (!newScopeType || !it->name) {
newScopeType = 0;
break;
}
const Interpreter::Value *v = newScopeType->lookupMember(it->name->asString(), context);
const Value *v = newScopeType->lookupMember(it->name->asString(), context);
v = context->lookupReference(v);
newScopeType = Interpreter::value_cast<const Interpreter::ObjectValue *>(v);
newScopeType = value_cast<const ObjectValue *>(v);
}
if (!newScopeType)
break;
@@ -490,7 +490,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const IAssistInterface
return 0;
}
const Interpreter::Value *value =
const Value *value =
getPropertyValue(qmlScopeType, contextFinder.bindingPropertyName(), context);
if (!value) {
// do nothing
@@ -550,10 +550,10 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const IAssistInterface
doQmlKeywordCompletion = false;
// complete enum values for enum properties
const Interpreter::Value *value =
const Value *value =
getPropertyValue(qmlScopeType, contextFinder.bindingPropertyName(), context);
if (const Interpreter::QmlEnumValue *enumValue =
dynamic_cast<const Interpreter::QmlEnumValue *>(value)) {
if (const QmlEnumValue *enumValue =
dynamic_cast<const QmlEnumValue *>(value)) {
foreach (const QString &key, enumValue->keys())
addCompletion(key, m_interface->symbolIcon(),
EnumValueOrder, QString("\"%1\"").arg(key));
@@ -564,7 +564,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const IAssistInterface
doQmlTypeCompletion = true;
if (doQmlTypeCompletion) {
if (const Interpreter::ObjectValue *qmlTypes = scopeChain.qmlTypes()) {
if (const ObjectValue *qmlTypes = scopeChain.qmlTypes()) {
EnumerateProperties enumerateProperties(&scopeChain);
addCompletions(enumerateProperties(qmlTypes), m_interface->symbolIcon(), TypeOrder);
}
@@ -613,8 +613,8 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const IAssistInterface
if (expression != 0 && ! isLiteral(expression)) {
// Evaluate the expression under cursor.
Interpreter::ValueOwner *interp = context->valueOwner();
const Interpreter::Value *value =
ValueOwner *interp = context->valueOwner();
const Value *value =
interp->convertToObject(scopeChain.evaluate(expression));
//qDebug() << "type:" << interp->typeId(value);
@@ -632,7 +632,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const IAssistInterface
&& completionOperator == QLatin1Char('(')
&& m_startPosition == m_interface->position()) {
// function completion
if (const Interpreter::FunctionValue *f = value->asFunctionValue()) {
if (const FunctionValue *f = value->asFunctionValue()) {
QString functionName = expressionUnderCursor.text();
int indexOfDot = functionName.lastIndexOf(QLatin1Char('.'));
if (indexOfDot != -1)
@@ -767,12 +767,12 @@ bool QmlJSCompletionAssistProcessor::completeUrl(const QString &relativeBasePath
}
void QmlJSCompletionAssistProcessor::addCompletionsPropertyLhs(const QHash<QString,
const QmlJS::Interpreter::Value *> &newCompletions,
const QmlJS::Value *> &newCompletions,
const QIcon &icon,
int order,
bool afterOn)
{
QHashIterator<QString, const Interpreter::Value *> it(newCompletions);
QHashIterator<QString, const Value *> it(newCompletions);
while (it.hasNext()) {
it.next();
@@ -782,8 +782,8 @@ void QmlJSCompletionAssistProcessor::addCompletionsPropertyLhs(const QHash<QStri
postfix = QLatin1String(": ");
if (afterOn)
postfix = QLatin1String(" {");
if (const Interpreter::QmlObjectValue *qmlValue =
dynamic_cast<const Interpreter::QmlObjectValue *>(it.value())) {
if (const QmlObjectValue *qmlValue =
dynamic_cast<const QmlObjectValue *>(it.value())) {
// to distinguish "anchors." from "gradient:" we check if the right hand side
// type is instantiatable or is the prototype of an instantiatable object
if (qmlValue->hasChildInPackage())
@@ -815,11 +815,11 @@ void QmlJSCompletionAssistProcessor::addCompletion(const QString &text,
}
void QmlJSCompletionAssistProcessor::addCompletions(const QHash<QString,
const QmlJS::Interpreter::Value *> &newCompletions,
const QmlJS::Value *> &newCompletions,
const QIcon &icon,
int order)
{
QHashIterator<QString, const Interpreter::Value *> it(newCompletions);
QHashIterator<QString, const Value *> it(newCompletions);
while (it.hasNext()) {
it.next();
addCompletion(it.key(), icon, order);

View File

@@ -48,10 +48,8 @@
#include <QtGui/QIcon>
namespace QmlJS {
namespace Interpreter {
class Value;
}
}
namespace QmlJSEditor {
namespace Internal {
@@ -115,12 +113,12 @@ private:
const QIcon &icon,
int order,
const QVariant &data = QVariant());
void addCompletions(const QHash<QString, const QmlJS::Interpreter::Value *> &newCompletions,
void addCompletions(const QHash<QString, const QmlJS::Value *> &newCompletions,
const QIcon &icon,
int order);
void addCompletions(const QStringList &newCompletions, const QIcon &icon, int order);
void addCompletionsPropertyLhs(const QHash<QString,
const QmlJS::Interpreter::Value *> &newCompletions,
const QmlJS::Value *> &newCompletions,
const QIcon &icon,
int order,
bool afterOn);

View File

@@ -547,14 +547,14 @@ QList<AST::Node *> SemanticInfo::rangePath(int cursorPosition) const
return path;
}
Interpreter::ScopeChain SemanticInfo::scopeChain(const QList<QmlJS::AST::Node *> &path) const
ScopeChain SemanticInfo::scopeChain(const QList<QmlJS::AST::Node *> &path) const
{
Q_ASSERT(m_rootScopeChain);
if (path.isEmpty())
return *m_rootScopeChain;
Interpreter::ScopeChain scope = *m_rootScopeChain;
ScopeChain scope = *m_rootScopeChain;
ScopeBuilder builder(&scope);
builder.push(path);
return scope;
@@ -573,7 +573,7 @@ AST::Node *SemanticInfo::nodeUnderCursor(int pos) const
const unsigned cursorPosition = pos;
foreach (const Interpreter::ImportInfo &import, document->bind()->imports()) {
foreach (const ImportInfo &import, document->bind()->imports()) {
if (importContainsCursor(import.ast(), cursorPosition))
return import.ast();
}
@@ -1249,8 +1249,8 @@ TextEditor::BaseTextEditorWidget::Link QmlJSTextEditorWidget::findLinkAt(const Q
if (AST::UiImport *importAst = cast<AST::UiImport *>(node)) {
// if it's a file import, link to the file
foreach (const Interpreter::ImportInfo &import, semanticInfo.document->bind()->imports()) {
if (import.ast() == importAst && import.type() == Interpreter::ImportInfo::FileImport) {
foreach (const ImportInfo &import, semanticInfo.document->bind()->imports()) {
if (import.ast() == importAst && import.type() == ImportInfo::FileImport) {
BaseTextEditorWidget::Link link(import.name());
link.begin = importAst->firstSourceLocation().begin();
link.end = importAst->lastSourceLocation().end();
@@ -1260,9 +1260,9 @@ TextEditor::BaseTextEditorWidget::Link QmlJSTextEditorWidget::findLinkAt(const Q
return Link();
}
const Interpreter::ScopeChain scopeChain = semanticInfo.scopeChain(semanticInfo.rangePath(cursorPosition));
const ScopeChain scopeChain = semanticInfo.scopeChain(semanticInfo.rangePath(cursorPosition));
Evaluate evaluator(&scopeChain);
const Interpreter::Value *value = evaluator.reference(node);
const Value *value = evaluator.reference(node);
QString fileName;
int line = 0, column = 0;
@@ -1317,7 +1317,7 @@ void QmlJSTextEditorWidget::showContextPane()
{
if (m_contextPane && m_semanticInfo.isValid()) {
Node *newNode = m_semanticInfo.declaringMemberNoProperties(position());
Interpreter::ScopeChain scopeChain = m_semanticInfo.scopeChain(m_semanticInfo.rangePath(position()));
ScopeChain scopeChain = m_semanticInfo.scopeChain(m_semanticInfo.rangePath(position()));
m_contextPane->apply(editor(), m_semanticInfo.document,
&scopeChain,
newNode, false, true);

View File

@@ -118,12 +118,12 @@ public:
QList<QmlJS::AST::Node *> rangePath(int cursorPosition) const;
// Returns a scopeChain for the given path
QmlJS::Interpreter::ScopeChain scopeChain(const QList<QmlJS::AST::Node *> &path = QList<QmlJS::AST::Node *>()) const;
QmlJS::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;
QmlJS::ContextPtr context;
QList<Range> ranges;
QHash<QString, QList<QmlJS::AST::SourceLocation> > idLocations;
QList<Declaration> declarations;
@@ -132,7 +132,7 @@ public: // attributes
QList<QmlJS::DiagnosticMessage> semanticMessages;
private:
QSharedPointer<const QmlJS::Interpreter::ScopeChain> m_rootScopeChain;
QSharedPointer<const QmlJS::ScopeChain> m_rootScopeChain;
friend class Internal::SemanticHighlighter;
};

View File

@@ -65,7 +65,6 @@
#include <functional>
using namespace QmlJS;
using namespace QmlJS::Interpreter;
using namespace QmlJS::AST;
using namespace QmlJSEditor;

View File

@@ -55,7 +55,6 @@
using namespace Core;
using namespace QmlJS;
using namespace QmlJS::Interpreter;
using namespace QmlJSEditor;
using namespace QmlJSEditor::Internal;
@@ -175,7 +174,7 @@ bool HoverHandler::matchColorItem(const ScopeChain &scopeChain,
return false;
QString color;
const Interpreter::Value *value = 0;
const Value *value = 0;
if (const AST::UiScriptBinding *binding = AST::cast<const AST::UiScriptBinding *>(member)) {
if (binding->qualifiedId && posIsInSource(pos, binding->statement)) {
value = scopeChain.evaluate(binding->qualifiedId);
@@ -189,7 +188,7 @@ bool HoverHandler::matchColorItem(const ScopeChain &scopeChain,
AST::cast<const AST::UiPublicMember *>(member)) {
if (publicMember->name && posIsInSource(pos, publicMember->statement)) {
value = scopeChain.lookup(publicMember->name->asString());
if (const Interpreter::Reference *ref = value->asReference())
if (const Reference *ref = value->asReference())
value = scopeChain.context()->lookupReference(ref);
color = textAt(qmlDocument,
publicMember->statement->firstSourceLocation(),
@@ -215,20 +214,20 @@ void HoverHandler::handleOrdinaryMatch(const ScopeChain &scopeChain, AST::Node *
{
if (node && !(AST::cast<AST::StringLiteral *>(node) != 0 ||
AST::cast<AST::NumericLiteral *>(node) != 0)) {
const Interpreter::Value *value = scopeChain.evaluate(node);
const Value *value = scopeChain.evaluate(node);
prettyPrintTooltip(value, scopeChain.context());
}
}
void HoverHandler::handleImport(const ScopeChain &scopeChain, AST::UiImport *node)
{
const Interpreter::Imports *imports = scopeChain.context()->imports(scopeChain.document().data());
const Imports *imports = scopeChain.context()->imports(scopeChain.document().data());
if (!imports)
return;
foreach (const Interpreter::Import &import, imports->all()) {
foreach (const Import &import, imports->all()) {
if (import.info.ast() == node) {
if (import.info.type() == Interpreter::ImportInfo::LibraryImport
if (import.info.type() == ImportInfo::LibraryImport
&& !import.libraryPath.isEmpty()) {
QString msg = tr("Library at %1").arg(import.libraryPath);
const LibraryInfo &libraryInfo = scopeChain.context()->snapshot().libraryInfo(import.libraryPath);
@@ -270,16 +269,16 @@ void HoverHandler::operateTooltip(TextEditor::ITextEditor *editor, const QPoint
}
}
void HoverHandler::prettyPrintTooltip(const QmlJS::Interpreter::Value *value,
const QmlJS::Interpreter::ContextPtr &context)
void HoverHandler::prettyPrintTooltip(const QmlJS::Value *value,
const QmlJS::ContextPtr &context)
{
if (! value)
return;
if (const Interpreter::ObjectValue *objectValue = value->asObjectValue()) {
Interpreter::PrototypeIterator iter(objectValue, context);
if (const ObjectValue *objectValue = value->asObjectValue()) {
PrototypeIterator iter(objectValue, context);
while (iter.hasNext()) {
const Interpreter::ObjectValue *prototype = iter.next();
const ObjectValue *prototype = iter.next();
const QString className = prototype->className();
if (! className.isEmpty()) {
@@ -287,8 +286,8 @@ void HoverHandler::prettyPrintTooltip(const QmlJS::Interpreter::Value *value,
break;
}
}
} else if (const Interpreter::QmlEnumValue *enumValue =
dynamic_cast<const Interpreter::QmlEnumValue *>(value)) {
} else if (const QmlEnumValue *enumValue =
dynamic_cast<const QmlEnumValue *>(value)) {
setToolTip(enumValue->name());
}
@@ -300,10 +299,10 @@ 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 ScopeChain &scopeChain,
static const ObjectValue *isMember(const ScopeChain &scopeChain,
AST::Node *node, QString *name)
{
const Interpreter::ObjectValue *owningObject = 0;
const ObjectValue *owningObject = 0;
if (AST::IdentifierExpression *identExp = AST::cast<AST::IdentifierExpression *>(node)) {
if (!identExp->name)
return 0;
@@ -313,7 +312,7 @@ static const Interpreter::ObjectValue *isMember(const ScopeChain &scopeChain,
if (!fme->base || !fme->name)
return 0;
*name = fme->name->asString();
const Interpreter::Value *base = scopeChain.evaluate(fme->base);
const Value *base = scopeChain.evaluate(fme->base);
if (!base)
return 0;
owningObject = base->asObjectValue();
@@ -323,11 +322,11 @@ static const Interpreter::ObjectValue *isMember(const ScopeChain &scopeChain,
if (!qid->name)
return 0;
*name = qid->name->asString();
const Interpreter::Value *value = scopeChain.lookup(*name, &owningObject);
const Value *value = scopeChain.lookup(*name, &owningObject);
for (AST::UiQualifiedId *it = qid->next; it; it = it->next) {
if (!value)
return 0;
const Interpreter::ObjectValue *next = value->asObjectValue();
const ObjectValue *next = value->asObjectValue();
if (!next || !it->name)
return 0;
*name = it->name->asString();
@@ -341,7 +340,7 @@ TextEditor::HelpItem HoverHandler::qmlHelpItem(const ScopeChain &scopeChain,
AST::Node *node) const
{
QString name;
if (const Interpreter::ObjectValue *scope = isMember(scopeChain, node, &name)) {
if (const ObjectValue *scope = isMember(scopeChain, node, &name)) {
// maybe it's a type?
if (!name.isEmpty() && name.at(0).isUpper()) {
const QString maybeHelpId(QLatin1String("QML.") + name);
@@ -350,11 +349,11 @@ TextEditor::HelpItem HoverHandler::qmlHelpItem(const ScopeChain &scopeChain,
}
// otherwise, it's probably a property
const Interpreter::ObjectValue *lastScope;
const ObjectValue *lastScope;
scope->lookupMember(name, scopeChain.context(), &lastScope);
Interpreter::PrototypeIterator iter(scope, scopeChain.context());
PrototypeIterator iter(scope, scopeChain.context());
while (iter.hasNext()) {
const Interpreter::ObjectValue *cur = iter.next();
const ObjectValue *cur = iter.next();
const QString className = cur->className();
if (!className.isEmpty()) {

View File

@@ -51,13 +51,11 @@ class ITextEditor;
}
namespace QmlJS {
namespace Interpreter {
class ScopeChain;
class Context;
typedef QSharedPointer<const Context> ContextPtr;
class Value;
}
}
namespace QmlJSEditor {
class QmlJSTextEditorWidget;
@@ -78,19 +76,19 @@ private:
virtual void operateTooltip(TextEditor::ITextEditor *editor, const QPoint &point);
bool matchDiagnosticMessage(QmlJSEditor::QmlJSTextEditorWidget *qmlEditor, int pos);
bool matchColorItem(const QmlJS::Interpreter::ScopeChain &lookupContext,
bool matchColorItem(const QmlJS::ScopeChain &lookupContext,
const QmlJS::Document::Ptr &qmlDocument,
const QList<QmlJS::AST::Node *> &astPath,
unsigned pos);
void handleOrdinaryMatch(const QmlJS::Interpreter::ScopeChain &lookupContext,
void handleOrdinaryMatch(const QmlJS::ScopeChain &lookupContext,
QmlJS::AST::Node *node);
void handleImport(const QmlJS::Interpreter::ScopeChain &lookupContext,
void handleImport(const QmlJS::ScopeChain &lookupContext,
QmlJS::AST::UiImport *node);
void prettyPrintTooltip(const QmlJS::Interpreter::Value *value,
const QmlJS::Interpreter::ContextPtr &context);
void prettyPrintTooltip(const QmlJS::Value *value,
const QmlJS::ContextPtr &context);
TextEditor::HelpItem qmlHelpItem(const QmlJS::Interpreter::ScopeChain &lookupContext,
TextEditor::HelpItem qmlHelpItem(const QmlJS::ScopeChain &lookupContext,
QmlJS::AST::Node *node) const;
QmlJS::ModelManagerInterface *m_modelManager;

View File

@@ -137,8 +137,8 @@ SemanticInfo SemanticHighlighter::semanticInfo(const SemanticHighlighterSource &
QmlJS::Link link(snapshot, modelManager->importPaths(), modelManager->builtins(doc));
semanticInfo.context = link(doc, &semanticInfo.semanticMessages);
QmlJS::Interpreter::ScopeChain *scopeChain = new QmlJS::Interpreter::ScopeChain(doc, semanticInfo.context);
semanticInfo.m_rootScopeChain = QSharedPointer<const QmlJS::Interpreter::ScopeChain>(scopeChain);
QmlJS::ScopeChain *scopeChain = new QmlJS::ScopeChain(doc, semanticInfo.context);
semanticInfo.m_rootScopeChain = QSharedPointer<const QmlJS::ScopeChain>(scopeChain);
QmlJS::Check checker(doc, semanticInfo.context);
semanticInfo.semanticMessages.append(checker());

View File

@@ -72,8 +72,8 @@ QVariant QmlOutlineItem::data(int role) const
return QVariant();
QList<AST::Node *> astPath = m_outlineModel->m_semanticInfo.rangePath(location.begin());
Interpreter::ScopeChain scopeChain = m_outlineModel->m_semanticInfo.scopeChain(astPath);
const Interpreter::Value *value = scopeChain.evaluate(uiQualifiedId);
ScopeChain scopeChain = m_outlineModel->m_semanticInfo.scopeChain(astPath);
const Value *value = scopeChain.evaluate(uiQualifiedId);
return prettyPrint(value, scopeChain.context());
}
@@ -99,12 +99,12 @@ void QmlOutlineItem::setItemData(const QMap<int, QVariant> &roles)
}
}
QString QmlOutlineItem::prettyPrint(const Interpreter::Value *value, const Interpreter::ContextPtr &context) const
QString QmlOutlineItem::prettyPrint(const Value *value, const ContextPtr &context) const
{
if (! value)
return QString();
if (const Interpreter::ObjectValue *objectValue = value->asObjectValue()) {
if (const ObjectValue *objectValue = value->asObjectValue()) {
const QString className = objectValue->className();
if (!className.isEmpty()) {
return className;

View File

@@ -41,11 +41,9 @@
#include <QtGui/QStandardItemModel>
namespace QmlJS {
namespace Interpreter {
class Value;
class Context;
}
}
namespace QmlJSEditor {
namespace Internal {
@@ -64,7 +62,7 @@ public:
void setItemData(const QMap<int, QVariant> &roles);
private:
QString prettyPrint(const QmlJS::Interpreter::Value *value, const QmlJS::Interpreter::ContextPtr &context) const;
QString prettyPrint(const QmlJS::Value *value, const QmlJS::ContextPtr &context) const;
QmlOutlineModel *m_outlineModel;
};

View File

@@ -73,7 +73,7 @@ void QmlTaskManager::collectMessages(QFutureInterface<FileErrorMessages> &future
Snapshot snapshot, QStringList files, QStringList /*importPaths*/)
{
// ### link and check error messages are disabled for now: too many false-positives!
//Interpreter::Context ctx(snapshot);
//Context ctx(snapshot);
//QHash<QString, QList<DiagnosticMessage> > linkMessages;
//Link link(&ctx, snapshot, importPaths);
//link(&linkMessages);

View File

@@ -64,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, const Interpreter::ScopeChain &scopeChain)
static inline const ObjectValue * getPropertyChangesTarget(Node *node, const ScopeChain &scopeChain)
{
UiObjectInitializer *initializer = 0;
if (UiObjectDefinition *definition = cast<UiObjectDefinition *>(node))
@@ -78,8 +78,8 @@ static inline const Interpreter::ObjectValue * getPropertyChangesTarget(Node *no
&& scriptBinding->qualifiedId->name->asString() == QLatin1String("target")
&& ! scriptBinding->qualifiedId->next) {
Evaluate evaluator(&scopeChain);
const Interpreter::Value *targetValue = evaluator(scriptBinding->statement);
if (const Interpreter::ObjectValue *targetObject = Interpreter::value_cast<const Interpreter::ObjectValue *>(targetValue)) {
const Value *targetValue = evaluator(scriptBinding->statement);
if (const ObjectValue *targetObject = value_cast<const ObjectValue *>(targetValue)) {
return targetObject;
} else {
return 0;
@@ -131,7 +131,7 @@ QuickToolBar::~QuickToolBar()
m_widget.clear();
}
void QuickToolBar::apply(TextEditor::BaseTextEditor *editor, Document::Ptr document, const Interpreter::ScopeChain *scopeChain, AST::Node *node, bool update, bool force)
void QuickToolBar::apply(TextEditor::BaseTextEditor *editor, Document::Ptr document, const ScopeChain *scopeChain, AST::Node *node, bool update, bool force)
{
if (!QuickToolBarSettings::get().enableContextPane && !force && !update) {
contextWidget()->hide();
@@ -146,24 +146,24 @@ void QuickToolBar::apply(TextEditor::BaseTextEditor *editor, Document::Ptr docum
m_blockWriting = true;
const Interpreter::ObjectValue *scopeObject = document->bind()->findQmlObject(node);
const ObjectValue *scopeObject = document->bind()->findQmlObject(node);
bool isPropertyChanges = false;
if (scopeChain && scopeObject) {
m_prototypes.clear();
foreach (const Interpreter::ObjectValue *object,
Interpreter::PrototypeIterator(scopeObject, scopeChain->context()).all()) {
foreach (const ObjectValue *object,
PrototypeIterator(scopeObject, scopeChain->context()).all()) {
m_prototypes.append(object->className());
}
if (m_prototypes.contains("PropertyChanges")) {
isPropertyChanges = true;
const Interpreter::ObjectValue *targetObject = getPropertyChangesTarget(node, *scopeChain);
const ObjectValue *targetObject = getPropertyChangesTarget(node, *scopeChain);
m_prototypes.clear();
if (targetObject) {
foreach (const Interpreter::ObjectValue *object,
Interpreter::PrototypeIterator(targetObject, scopeChain->context()).all()) {
foreach (const ObjectValue *object,
PrototypeIterator(targetObject, scopeChain->context()).all()) {
m_prototypes.append(object->className());
}
}

View File

@@ -52,7 +52,7 @@ class QuickToolBar : public QmlJS::IContextPane
public:
QuickToolBar(QObject *parent = 0);
~QuickToolBar();
void apply(TextEditor::BaseTextEditor *editor, QmlJS::Document::Ptr document, const QmlJS::Interpreter::ScopeChain *scopeChain, QmlJS::AST::Node *node, bool update, bool force = false);
void apply(TextEditor::BaseTextEditor *editor, QmlJS::Document::Ptr document, const QmlJS::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);