Skip to content
Snippets Groups Projects
Commit 669b9c45 authored by Christian Kamm's avatar Christian Kamm
Browse files

Add signals defined in Qml and their generated slots to the code model.

parent b6460f92
No related branches found
No related tags found
No related merge requests found
......@@ -2000,9 +2000,12 @@ ASTObjectValue::ASTObjectValue(UiQualifiedId *typeName,
for (UiObjectMemberList *it = _initializer->members; it; it = it->next) {
UiObjectMember *member = it->member;
if (UiPublicMember *def = cast<UiPublicMember *>(member)) {
if (def->name && def->memberType) {
if (def->type == UiPublicMember::Property && def->name && def->memberType) {
ASTPropertyReference *ref = new ASTPropertyReference(def, _doc, engine);
_properties.append(ref);
} else if (def->type == UiPublicMember::Signal && def->name) {
ASTSignalReference *ref = new ASTSignalReference(def, _doc, engine);
_signals.append(ref);
}
}
}
......@@ -2025,6 +2028,11 @@ void ASTObjectValue::processMembers(MemberProcessor *processor) const
{
foreach (ASTPropertyReference *ref, _properties)
processor->processProperty(ref->ast()->name->asString(), ref);
foreach (ASTSignalReference *ref, _signals) {
// ### These two should get different values?
processor->processSignal(ref->ast()->name->asString(), ref);
processor->processGeneratedSlot(ref->slotName(), ref);
}
ObjectValue::processMembers(processor);
}
......@@ -2143,3 +2151,29 @@ const Value *ASTPropertyReference::value(Context *context) const
return engine()->undefinedValue();
}
ASTSignalReference::ASTSignalReference(UiPublicMember *ast, const QmlJS::Document *doc, Engine *engine)
: Reference(engine), _ast(ast), _doc(doc)
{
const QString signalName = ast->name->asString();
_slotName = QLatin1String("on");
_slotName += signalName.at(0).toUpper();
_slotName += signalName.midRef(1);
}
ASTSignalReference::~ASTSignalReference()
{
}
bool ASTSignalReference::getSourceLocation(QString *fileName, int *line, int *column) const
{
*fileName = _doc->fileName();
*line = _ast->identifierToken.startLine;
*column = _ast->identifierToken.startColumn;
return true;
}
const Value *ASTSignalReference::value(Context *context) const
{
return engine()->undefinedValue();
}
......@@ -696,12 +696,30 @@ public:
virtual const Value *value(Context *context) const;
};
class QMLJS_EXPORT ASTSignalReference: public Reference
{
AST::UiPublicMember *_ast;
const Document *_doc;
QString _slotName;
public:
ASTSignalReference(AST::UiPublicMember *ast, const Document *doc, Engine *engine);
virtual ~ASTSignalReference();
AST::UiPublicMember *ast() const { return _ast; }
QString slotName() const { return _slotName; }
virtual bool getSourceLocation(QString *fileName, int *line, int *column) const;
virtual const Value *value(Context *context) const;
};
class QMLJS_EXPORT ASTObjectValue: public ObjectValue
{
AST::UiQualifiedId *_typeName;
AST::UiObjectInitializer *_initializer;
const Document *_doc;
QList<ASTPropertyReference *> _properties;
QList<ASTSignalReference *> _signals;
public:
ASTObjectValue(AST::UiQualifiedId *typeName,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment