aboutsummaryrefslogtreecommitdiffstats
path: root/tools/snippets_translate/converter.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/snippets_translate/converter.py')
-rw-r--r--tools/snippets_translate/converter.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/tools/snippets_translate/converter.py b/tools/snippets_translate/converter.py
index 784e4e45f..d45bf277f 100644
--- a/tools/snippets_translate/converter.py
+++ b/tools/snippets_translate/converter.py
@@ -45,6 +45,9 @@ QUALIFIERS = {"public:", "protected:", "private:", "public slots:",
"protected slots:", "private slots:", "signals:"}
+FUNCTION_QUALIFIERS = ["virtual ", " override", "inline ", " noexcept"]
+
+
switch_var = None
switch_branch = 0
@@ -60,7 +63,8 @@ def snippet_translate(x):
## General Rules
# Remove ';' at the end of the lines
- if x.endswith(";"):
+ has_semicolon = x.endswith(";")
+ if has_semicolon:
x = x[:-1]
# Remove lines with only '{' or '}'
@@ -260,7 +264,8 @@ def snippet_translate(x):
# At the end we skip methods with the form:
# QStringView Message::body()
# to threat them as methods.
- if (VAR1_PATTERN.search(xs)
+ if (has_semicolon and VAR1_PATTERN.search(xs)
+ and not ([f for f in FUNCTION_QUALIFIERS if f in x])
and xs.split()[0] not in ("def", "return", "and", "or")
and not VAR2_PATTERN.search(xs)
and ("{" not in x and "}" not in x)):