forked from qt-creator/qt-creator
Cleanup.
This commit is contained in:
@@ -95,6 +95,21 @@ ObjectValue *Bind::scopeChainAt(Document::Ptr currentDocument, const Snapshot &s
|
|||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Bind::toString(UiQualifiedId *qualifiedId, QChar delimiter)
|
||||||
|
{
|
||||||
|
QString result;
|
||||||
|
|
||||||
|
for (UiQualifiedId *iter = qualifiedId; iter; iter = iter->next) {
|
||||||
|
if (iter != qualifiedId)
|
||||||
|
result += delimiter;
|
||||||
|
|
||||||
|
if (iter->name)
|
||||||
|
result += iter->name->asString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void Bind::accept(Node *node)
|
void Bind::accept(Node *node)
|
||||||
{
|
{
|
||||||
Node::accept(node, this);
|
Node::accept(node, this);
|
||||||
@@ -110,21 +125,6 @@ bool Bind::visit(UiImportList *)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString serialize(UiQualifiedId *qualifiedId, QChar delimiter)
|
|
||||||
{
|
|
||||||
QString result;
|
|
||||||
|
|
||||||
for (UiQualifiedId *iter = qualifiedId; iter; iter = iter->next) {
|
|
||||||
if (iter != qualifiedId)
|
|
||||||
result += delimiter;
|
|
||||||
|
|
||||||
if (iter->name)
|
|
||||||
result += iter->name->asString();
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
import Qt 4.6
|
import Qt 4.6
|
||||||
import Qt 4.6 as Xxx
|
import Qt 4.6 as Xxx
|
||||||
@@ -161,7 +161,7 @@ bool Bind::visit(UiImport *ast)
|
|||||||
|
|
||||||
// else try the metaobject system
|
// else try the metaobject system
|
||||||
if (ast->importUri) {
|
if (ast->importUri) {
|
||||||
const QString package = serialize(ast->importUri, '/');
|
const QString package = toString(ast->importUri, '/');
|
||||||
int majorVersion = -1; // ### TODO: Check these magic version numbers
|
int majorVersion = -1; // ### TODO: Check these magic version numbers
|
||||||
int minorVersion = -1; // ### TODO: Check these magic version numbers
|
int minorVersion = -1; // ### TODO: Check these magic version numbers
|
||||||
|
|
||||||
@@ -208,9 +208,7 @@ ObjectValue *Bind::bindObject(UiQualifiedId *qualifiedTypeNameId, UiObjectInitia
|
|||||||
{
|
{
|
||||||
ObjectValue *parentObjectValue;
|
ObjectValue *parentObjectValue;
|
||||||
|
|
||||||
if (qualifiedTypeNameId && !qualifiedTypeNameId->next
|
if (toString(qualifiedTypeNameId) == QLatin1String("Script")) {
|
||||||
&& qualifiedTypeNameId->name->asString() == QLatin1String("Script")
|
|
||||||
) {
|
|
||||||
// Script blocks all contribute to the same scope
|
// Script blocks all contribute to the same scope
|
||||||
parentObjectValue = switchObjectValue(_functionEnvironment);
|
parentObjectValue = switchObjectValue(_functionEnvironment);
|
||||||
} else { // normal component instance
|
} else { // normal component instance
|
||||||
@@ -253,11 +251,12 @@ bool Bind::visit(UiObjectInitializer *)
|
|||||||
|
|
||||||
bool Bind::visit(UiScriptBinding *ast)
|
bool Bind::visit(UiScriptBinding *ast)
|
||||||
{
|
{
|
||||||
if (!(ast->qualifiedId->next) && ast->qualifiedId->name->asString() == "id")
|
if (toString(ast->qualifiedId) == QLatin1String("id")) {
|
||||||
if (ExpressionStatement *e = cast<ExpressionStatement*>(ast->statement))
|
if (ExpressionStatement *e = cast<ExpressionStatement*>(ast->statement))
|
||||||
if (IdentifierExpression *i = cast<IdentifierExpression*>(e->expression))
|
if (IdentifierExpression *i = cast<IdentifierExpression*>(e->expression))
|
||||||
if (i->name)
|
if (i->name)
|
||||||
_idEnvironment->setProperty(i->name->asString(), _currentObjectValue);
|
_idEnvironment->setProperty(i->name->asString(), _currentObjectValue);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,10 @@ public:
|
|||||||
AST::UiObjectMember *currentObject);
|
AST::UiObjectMember *currentObject);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
using AST::Visitor::visit;
|
||||||
|
|
||||||
|
QString toString(AST::UiQualifiedId *qualifiedId, QChar delimiter = QChar('.'));
|
||||||
|
|
||||||
void accept(AST::Node *node);
|
void accept(AST::Node *node);
|
||||||
|
|
||||||
// Ui
|
// Ui
|
||||||
|
|||||||
Reference in New Issue
Block a user