forked from qt-creator/qt-creator
QmlDesigner: Do not allow keywords as properties in annotations
Otherwise we get a syntax error. Change-Id: Id69be9ef0426dae64c461f21dda14eca340f720d Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
committed by
Tim Jenssen
parent
4d04eecc5e
commit
4f55b9a0fa
@@ -483,6 +483,42 @@ static QString replaceIllegalPropertyNameChars(const QString &str)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool idIsQmlKeyWord(const QString& id)
|
||||||
|
{
|
||||||
|
static const QSet<QString> keywords = {
|
||||||
|
"as",
|
||||||
|
"break",
|
||||||
|
"case",
|
||||||
|
"catch",
|
||||||
|
"continue",
|
||||||
|
"debugger",
|
||||||
|
"default",
|
||||||
|
"delete",
|
||||||
|
"do",
|
||||||
|
"else",
|
||||||
|
"finally",
|
||||||
|
"for",
|
||||||
|
"function",
|
||||||
|
"if",
|
||||||
|
"import",
|
||||||
|
"in",
|
||||||
|
"instanceof",
|
||||||
|
"new",
|
||||||
|
"return",
|
||||||
|
"switch",
|
||||||
|
"this",
|
||||||
|
"throw",
|
||||||
|
"try",
|
||||||
|
"typeof",
|
||||||
|
"var",
|
||||||
|
"void",
|
||||||
|
"while",
|
||||||
|
"with"
|
||||||
|
};
|
||||||
|
|
||||||
|
return keywords.contains(id);
|
||||||
|
}
|
||||||
|
|
||||||
QString RewriterView::auxiliaryDataAsQML() const
|
QString RewriterView::auxiliaryDataAsQML() const
|
||||||
{
|
{
|
||||||
bool hasAuxData = false;
|
bool hasAuxData = false;
|
||||||
@@ -523,6 +559,9 @@ QString RewriterView::auxiliaryDataAsQML() const
|
|||||||
if (key.endsWith("@Internal"))
|
if (key.endsWith("@Internal"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (idIsQmlKeyWord(key))
|
||||||
|
continue;
|
||||||
|
|
||||||
const QVariant value = data.value(key.toUtf8());
|
const QVariant value = data.value(key.toUtf8());
|
||||||
QString strValue = value.toString();
|
QString strValue = value.toString();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user