ClangFormat: Update script for generating clangformatchecks

Updated for clang-format-16

Task-number: QTCREATORBUG-29434
Change-Id: Ib7fe12c19a6e3616760c146b623b150fb1df2c22
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Artem Sokolovskii
2023-08-01 16:11:44 +02:00
parent 2e72860179
commit f63c4857b8

View File

@@ -70,8 +70,6 @@ def full_source_content(source_code, layout_code):
#include <QPushButton>
#include <QWidget>
using namespace Utils;
using namespace ClangFormat;
ClangFormatChecks::ClangFormatChecks(QWidget *parent)
@@ -105,8 +103,8 @@ def combobox_source(name, values, offset):
def combobox_source_bool(name, offset):
return combobox_source(name, ["Default", "true", "false"], offset)
def combobox_layout(name, offset):
layout = " new QLabel(\"" + offset + name + "\"), m_" + name + ", br,\n"
def combobox_layout(name, field_name, offset):
layout = " new QLabel(\"" + offset + field_name + "\"), m_" + name + ", br,\n"
return layout
# String UI
@@ -121,11 +119,10 @@ def string_source(name, offset):
source += " m_" + name + "->setObjectName(\"" + name + "\");\n"
source += " m_set" + name + " = new QPushButton(\"Set\", this);\n\n"
source += " m_set" + name + "->setObjectName(\"set" + name + "\");\n"
# source += "m_" + name + "->setObjectName(\"" + offset + name + "\");\n\n"
return source
def string_layout(name, offset):
layout = " new QLabel(\"" + offset + name + "\"), Row {m_" + name + ", m_set" + name + "}, br,\n"
def string_layout(name, field_name, offset):
layout = " new QLabel(\"" + offset + field_name + "\"), Row {m_" + name + ", m_set" + name + "}, br,\n"
return layout
# Vector UI
@@ -144,8 +141,8 @@ def vector_source(name, offset):
# source += "m_" + name + "->setObjectName(\"" + offset + name + "\");\n\n"
return source
def vector_layout(name, offset):
layout = " new QLabel(\"" + offset + name + "\"), Row {m_" + name + ", m_set" + name + "}, br,\n"
def vector_layout(name, field_name, offset):
layout = " new QLabel(\"" + offset + field_name + "\"), Row {m_" + name + ", m_set" + name + "}, br,\n"
return layout
# Struct Layout
@@ -160,7 +157,7 @@ def in_list(list, type):
return element;
return
def create_private_variables(variables, enums, structs, offset = ""):
def create_private_variables(variables, enums, structs, offset = "", parent_name = ""):
header = ""
source = ""
layout = ""
@@ -169,7 +166,7 @@ def create_private_variables(variables, enums, structs, offset = ""):
if offset == "":
header += combobox_header("BasedOnStyle")
source += combobox_source("BasedOnStyle", ["LLVM", "Google", "Chromium", "Mozilla", "WebKit", "Microsoft", "GNU"], offset)
layout += combobox_layout("BasedOnStyle", offset)
layout += combobox_layout("BasedOnStyle", "BasedOnStyle", offset)
for variable in variables:
if "doxygen" in variable.keys():
@@ -177,31 +174,32 @@ def create_private_variables(variables, enums, structs, offset = ""):
continue;
type = variable["type"]
name = variable["name"]
field_name = variable["name"]
variable_name = parent_name + variable["name"]
enum = in_list(enums, type)
struct = in_list(structs, type)
if enum:
header += combobox_header(name)
source += combobox_source(name, [value["name"].split("_")[1] for value in enum["values"]], offset)
layout += combobox_layout(name, offset)
header += combobox_header(variable_name)
source += combobox_source(variable_name, [value["name"].split("_")[1] for value in enum["values"]], offset)
layout += combobox_layout(variable_name, field_name, offset)
elif struct:
layout += struct_layout(name, offset)
header_tmp, source_tmp, layout_tmp = create_private_variables(struct["properties"]["public"], enums, structs, " ")
layout += struct_layout(variable_name, offset)
header_tmp, source_tmp, layout_tmp = create_private_variables(struct["properties"]["public"], enums, structs, " ", variable_name)
header += header_tmp
source += source_tmp
layout += layout_tmp
elif "std::string" == type or "unsigned" == type or "int" == type:
header += string_header(name)
source += string_source(name, offset)
layout += string_layout(name, offset)
elif "std::vector<std::string >" == type:
header += vector_header(name)
source += vector_source(name, offset)
layout += vector_layout(name, offset)
header += string_header(variable_name)
source += string_source(variable_name, offset)
layout += string_layout(variable_name, field_name, offset)
elif "std::vector<std::string>" == type:
header += vector_header(variable_name)
source += vector_source(variable_name, offset)
layout += vector_layout(variable_name, field_name, offset)
elif "bool" == type:
header += combobox_header(name)
source += combobox_source_bool(name, offset)
layout += combobox_layout(name, offset);
header += combobox_header(variable_name)
source += combobox_source_bool(variable_name, offset)
layout += combobox_layout(variable_name, field_name, offset);
return header, source, layout