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

Method TypeFormat

CodeFormatLib/src/LuaCodeFormat.cpp:136–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134}
135
136Result<std::vector<LuaTypeFormat::Result>>
137LuaCodeFormat::TypeFormat(const std::string &uri, std::size_t line, std::size_t character, std::string &&text,
138 ConfigMap &configMap, ConfigMap &stringTypeOptions) {
139 auto file = std::make_shared<LuaSource>(std::move(text));
140 LuaLexer luaLexer(file);
141 if (_supportNonStandardSymbol) {
142 luaLexer.SupportNonStandardSymbol();
143 }
144 if (_supportCLikeComments) {
145 luaLexer.SupportCLikeComments();
146 }
147
148 luaLexer.Parse();
149
150 LuaParser p(file, std::move(luaLexer.GetTokens()));
151 p.Parse();
152
153 if (p.HasError()) {
154 return ResultType::Err;
155 }
156
157 LuaSyntaxTree t;
158 t.BuildTree(p);
159
160 LuaStyle style = GetStyle(uri);
161 CalculateTempStyle(style, configMap);
162
163 LuaTypeFormatFeatures typeFormatOptions = LuaTypeFormatFeatures::From(stringTypeOptions);
164
165 LuaTypeFormat tf(typeFormatOptions);
166 tf.Analyze("\n", line, character, t, style);
167 return tf.GetResult();
168}
169
170Result<std::vector<LuaDiagnosticInfo>> LuaCodeFormat::Diagnostic(const std::string &uri, std::string &&text) {
171 auto file = std::make_shared<LuaSource>(std::move(text));

Callers 1

type_formatFunction · 0.45

Calls 8

GetTokensMethod · 0.80
BuildTreeMethod · 0.80
GetResultMethod · 0.80
SupportCLikeCommentsMethod · 0.45
ParseMethod · 0.45
HasErrorMethod · 0.45
AnalyzeMethod · 0.45

Tested by

no test coverage detected