diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-09-16 15:27:08 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-09-16 19:18:16 +0000 |
commit | 5aaffdee4cc4821fd9a827954efcf5776a8842cc (patch) | |
tree | d23a92e9fbf5ddf8a7f68d27ba00e3c90c437d40 | |
parent | 083aa667808317bd869a56907650f96c0c78067b (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.py | 2 | ||||
-rw-r--r-- | tools/snippets_translate/tests/test_converter.py | 2 |
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(): |