Commit 08b9323f authored by Christian Kamm's avatar Christian Kamm
Browse files

Fix completion and checking for Script elements. Update Qml type xml.

* The "Script" type is now implicitly available without imports.
* No errors for bindings inside a Connections element.

Reviewed-by: Roberto Raggi
parent 93dbb3a5
......@@ -170,7 +170,7 @@ ObjectValue *Bind::bindObject(UiQualifiedId *qualifiedTypeNameId, UiObjectInitia
// Script blocks all contribute to the same scope
parentObjectValue = switchObjectValue(_functionEnvironment);
processScript(qualifiedTypeNameId, initializer);
return switchObjectValue(parentObjectValue);
switchObjectValue(parentObjectValue);
}
// normal component instance
......
......@@ -150,6 +150,11 @@ void Link::populateImportedTypes(Interpreter::ObjectValue *typeEnv, Document::Pt
if (! (doc->qmlProgram() && doc->qmlProgram()->imports))
return;
// Add the implicitly available Script type
const ObjectValue *scriptValue = engine()->metaTypeSystem().staticTypeForImport("Script");
if (scriptValue)
typeEnv->setProperty("Script", scriptValue);
QFileInfo fileInfo(doc->fileName());
const QString absolutePath = fileInfo.absolutePath();
......
......@@ -73,12 +73,14 @@ void ScopeBuilder::setQmlScopeObject(Node *node)
return; // Probably syntax errors, where we're working with a "recovered" AST.
}
// check if the object has a Qt.ListElement ancestor
// check if the object has a Qt.ListElement or Qt.Connections ancestor
// ### allow only signal bindings for Connections
const ObjectValue *prototype = scopeObject->prototype(_context);
while (prototype) {
if (const QmlObjectValue *qmlMetaObject = dynamic_cast<const QmlObjectValue *>(prototype)) {
if (qmlMetaObject->className() == QLatin1String("ListElement")
&& qmlMetaObject->packageName() == QLatin1String("Qt")) {
if ((qmlMetaObject->className() == QLatin1String("ListElement")
|| qmlMetaObject->className() == QLatin1String("Connections")
) && qmlMetaObject->packageName() == QLatin1String("Qt")) {
scopeChain.qmlScopeObjects.clear();
break;
}
......
......@@ -209,6 +209,36 @@ void dump(const QMetaObject *meta, QXmlStreamWriter *xml)
xml->writeEndElement();
}
void writeScriptElement(QXmlStreamWriter *xml)
{
xml->writeStartElement("type");
{
QXmlStreamAttributes attributes;
attributes.append(QXmlStreamAttribute("name", "Script"));
xml->writeAttributes(attributes);
}
xml->writeStartElement("property");
{
QXmlStreamAttributes attributes;
attributes.append(QXmlStreamAttribute("name", "script"));
attributes.append(QXmlStreamAttribute("type", "string"));
xml->writeAttributes(attributes);
}
xml->writeEndElement();
xml->writeStartElement("property");
{
QXmlStreamAttributes attributes;
attributes.append(QXmlStreamAttribute("name", "source"));
attributes.append(QXmlStreamAttribute("type", "QUrl"));
xml->writeAttributes(attributes);
}
xml->writeEndElement();
xml->writeEndElement();
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
......@@ -252,6 +282,8 @@ int main(int argc, char *argv[])
foreach (const QMetaObject *meta, metas) {
dump(meta, &xml);
}
writeScriptElement(&xml);
xml.writeEndElement();
xml.writeEndDocument();
......
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