MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / ParseTree

Method ParseTree

CodeFormatCore/src/Config/LuaDiagnosticStyle.cpp:89–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89void LuaDiagnosticStyle::ParseTree(InfoTree &tree) {
90 auto root = tree.GetRoot();
91
92 BOOL_OPTION(code_style_check);
93
94 BOOL_OPTION(name_style_check);
95
96 BOOL_OPTION(spell_check);
97
98 std::vector<std::pair<std::vector<NameStyleRule> &, std::string>> name_styles = {
99 {local_name_style, "local_name_style" },
100 {function_param_name_style, "function_param_name_style" },
101 {function_name_style, "function_name_style" },
102 {local_function_name_style, "local_function_name_style" },
103 {table_field_name_style, "table_field_name_style" },
104 {global_variable_name_style, "global_variable_name_style"},
105 {module_name_style, "module_name_style" },
106 {require_module_name_style, "require_module_name_style" },
107 {class_name_style, "class_name_style" },
108 {const_variable_name_style, "const_variable_name_style" },
109 {module_local_name_style, "module_local_name_style" }
110 };
111 for (auto &pair: name_styles) {
112 if (auto n = root.GetValue(pair.second); !n.IsNull()) {
113 pair.first.clear();
114 if (n.IsArray()) {
115 for (auto c: n.AsArray()) {
116 pair.first.push_back(MakeNameStyle(c));
117 }
118 } else {
119 pair.first.push_back(MakeNameStyle(n));
120 }
121 }
122 }
123 // module_local_name_style should fallback on local_name_style if not defined
124 if (root.GetValue("module_local_name_style").IsNull() && !root.GetValue("local_name_style").IsNull()) {
125 auto moduleLocalNameStyle = std::find_if(name_styles.begin(), name_styles.end(), [&](const std::pair<std::vector<NameStyleRule> &, std::string> &pair) {
126 return pair.second == "module_local_name_style";
127 });
128 auto localNameStyle = std::find_if(name_styles.begin(), name_styles.end(), [&](const std::pair<std::vector<NameStyleRule> &, std::string> &pair) {
129 return pair.second == "local_name_style";
130 });
131
132 // overwrite the namestyle of module_local_name_style with the namestyle of local_name_style
133 if (moduleLocalNameStyle != name_styles.end() && localNameStyle != name_styles.end()) {
134 moduleLocalNameStyle->first = localNameStyle->first;
135 }
136 }
137}

Callers 3

UpdateDiagnosticStyleMethod · 0.80
UpdateDiagnosticStyleMethod · 0.80
UpdateClientConfigMethod · 0.80

Calls 10

MakeNameStyleFunction · 0.85
GetRootMethod · 0.80
GetValueMethod · 0.80
IsArrayMethod · 0.80
AsArrayMethod · 0.80
IsNullMethod · 0.45
clearMethod · 0.45
push_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected