Commit 880ab207 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlJS: Fix rewriter for signal parameters



Task-number: QTCREATORBUG-7931

I had to fix a bug in the QmlJsParser.
The source location for the
propertyTypeToken was not initialized in all cases.

I also updated qmljs.g.

Change-Id: Idd0880f70578867cf5f97666aede654e00cfc744
Reviewed-by: default avatarJoerg Bornemann <joerg.bornemann@digia.com>
Reviewed-by: default avatarChristian Kamm <kamm@incasoftware.de>
parent 366a9316
......@@ -399,6 +399,7 @@ Parser::Parser(Engine *engine):
state_stack(0),
location_stack(0),
string_stack(0),
program(0),
first_token(0),
last_token(0)
{
......@@ -821,6 +822,7 @@ UiParameterList: UiParameterList T_COMMA UiPropertyType JsIdentifier ;
/.
case $rule_number: {
AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, stringRef(3), stringRef(4));
node->propertyTypeToken = loc(3);
node->commaToken = loc(2);
node->identifierToken = loc(4);
sym(1).Node = node;
......@@ -2885,7 +2887,7 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ;
yylloc.startColumn += yylloc.length;
yylloc.length = 0;
//const QString msg = qApp->translate("QmlParser", "Missing `;'");
//const QString msg = qApp->translate("QQmlParser", "Missing `;'");
//diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, yylloc, msg));
first_token = &token_buffer[0];
......@@ -2915,9 +2917,9 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ;
QString msg;
int token = token_buffer[0].token;
if (token < 0 || token >= TERMINAL_COUNT)
msg = qApp->translate("QmlParser", "Syntax error");
msg = qApp->translate("QQmlParser", "Syntax error");
else
msg = qApp->translate("QmlParser", "Unexpected token `%1'").arg(QLatin1String(spell[token]));
msg = qApp->translate("QQmlParser", "Unexpected token `%1'").arg(QLatin1String(spell[token]));
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
action = errorState;
......@@ -2945,7 +2947,7 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ;
for (int *tk = tokens; *tk != EOF_SYMBOL; ++tk) {
int a = t_action(errorState, *tk);
if (a > 0 && t_action(a, yytoken)) {
const QString msg = qApp->translate("QmlParser", "Expected token `%1'").arg(QLatin1String(spell[*tk]));
const QString msg = qApp->translate("QQmlParser", "Expected token `%1'").arg(QLatin1String(spell[*tk]));
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
yytoken = *tk;
......@@ -2969,7 +2971,7 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ;
int a = t_action(errorState, tk);
if (a > 0 && t_action(a, yytoken)) {
const QString msg = qApp->translate("QmlParser", "Expected token `%1'").arg(QLatin1String(spell[tk]));
const QString msg = qApp->translate("QQmlParser", "Expected token `%1'").arg(QLatin1String(spell[tk]));
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
yytoken = tk;
......@@ -2982,7 +2984,7 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ;
}
}
const QString msg = qApp->translate("QmlParser", "Syntax error");
const QString msg = qApp->translate("QQmlParser", "Syntax error");
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
}
......
......@@ -825,6 +825,13 @@ void UiObjectInitializer::accept0(Visitor *visitor)
visitor->endVisit(this);
}
void UiParameterList::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
}
visitor->endVisit(this);
}
void UiObjectBinding::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
......
......@@ -2390,7 +2390,7 @@ public:
previous->next = this;
}
virtual void accept0(Visitor *) {}
virtual void accept0(Visitor *);
virtual SourceLocation firstSourceLocation() const
{ return propertyTypeToken; }
......
......@@ -156,6 +156,7 @@ class UiProgram;
class UiImportList;
class UiImport;
class UiPublicMember;
class UiParameterList;
class UiObjectDefinition;
class UiObjectInitializer;
class UiObjectBinding;
......
......@@ -68,6 +68,7 @@ public:
virtual bool visit(UiObjectBinding *) { return true; }
virtual bool visit(UiScriptBinding *) { return true; }
virtual bool visit(UiArrayBinding *) { return true; }
virtual bool visit(UiParameterList *) { return true; }
virtual bool visit(UiObjectMemberList *) { return true; }
virtual bool visit(UiArrayMemberList *) { return true; }
virtual bool visit(UiQualifiedId *) { return true; }
......@@ -82,6 +83,7 @@ public:
virtual void endVisit(UiObjectBinding *) {}
virtual void endVisit(UiScriptBinding *) {}
virtual void endVisit(UiArrayBinding *) {}
virtual void endVisit(UiParameterList *) {}
virtual void endVisit(UiObjectMemberList *) {}
virtual void endVisit(UiArrayMemberList *) {}
virtual void endVisit(UiQualifiedId *) {}
......
......@@ -387,6 +387,7 @@ case 47: {
case 48: {
AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, stringRef(3), stringRef(4));
node->propertyTypeToken = loc(3);
node->commaToken = loc(2);
node->identifierToken = loc(4);
sym(1).Node = node;
......
......@@ -544,6 +544,18 @@ protected:
return false;
}
virtual bool visit(UiParameterList *list)
{
for (UiParameterList *it = list; it; it = it->next) {
out(it->propertyTypeToken);
out(" ");
out(it->identifierToken);
if (it->next)
out(", ", it->commaToken);
}
return false;
}
virtual bool visit(UiPublicMember *ast)
{
if (ast->type == UiPublicMember::Property) {
......@@ -570,7 +582,11 @@ protected:
} else { // signal
out("signal ");
out(ast->identifierToken);
accept(ast->parameters);
if (ast->parameters) {
out("(");
accept(ast->parameters);
out(")");
}
}
return false;
}
......
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