aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2022-09-16 15:27:08 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-09-16 19:18:16 +0000
commit5aaffdee4cc4821fd9a827954efcf5776a8842cc (patch)
treed23a92e9fbf5ddf8a7f68d27ba00e3c90c437d40
parent083aa667808317bd869a56907650f96c0c78067b (diff)
snippets_translate: Handle "new" without parentheses
Change-Id: Ic50c175fab1f362c4c15e12f78e5ec440784e20c Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> (cherry picked from commit 37dcc13a8389f2f9a76376538b48007a39cf7147) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--tools/snippets_translate/converter.py2
-rw-r--r--tools/snippets_translate/tests/test_converter.py2
2 files changed, 3 insertions, 1 deletions
diff --git a/tools/snippets_translate/converter.py b/tools/snippets_translate/converter.py
index 92c89bdf6..a0650b3af 100644
--- a/tools/snippets_translate/converter.py
+++ b/tools/snippets_translate/converter.py
@@ -128,6 +128,8 @@ def snippet_translate(x):
# that include the string 'new'
if "new " in x:
x = x.replace("new ", "")
+ if not x.endswith(")"): # "new Foo" -> "new Foo()"
+ x += "()"
# Handle 'const'
# Some variables/functions have the word 'const' so we explicitly
diff --git a/tools/snippets_translate/tests/test_converter.py b/tools/snippets_translate/tests/test_converter.py
index d47ab9ef2..28436e846 100644
--- a/tools/snippets_translate/tests/test_converter.py
+++ b/tools/snippets_translate/tests/test_converter.py
@@ -100,7 +100,7 @@ def test_else():
def test_new():
assert st("a = new Something(...);") == "a = Something(...)"
- assert st("a = new Something") == "a = Something"
+ assert st("a = new Something") == "a = Something()"
def test_semicolon():