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

Method Diagnostic

CodeFormatCLib/src/CodeFormat.cpp:180–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

178}
179
180Result<std::vector<LuaDiagnosticInfo>> CodeFormat::Diagnostic(const std::string &uri, std::string &&text) {
181 auto file = std::make_shared<LuaSource>(std::move(text));
182 LuaLexer luaLexer(file);
183 if (_supportNonStandardSymbol) {
184 luaLexer.SupportNonStandardSymbol();
185 }
186 if (_supportCLikeComments) {
187 luaLexer.SupportCLikeComments();
188 }
189
190 luaLexer.Parse();
191
192 LuaParser p(file, std::move(luaLexer.GetTokens()));
193 p.Parse();
194
195 if (p.HasError()) {
196 return ResultType::Err;
197 }
198
199 LuaSyntaxTree t;
200 t.BuildTree(p);
201
202 LuaStyle style = GetStyle(uri);
203
204 DiagnosticBuilder diagnosticBuilder(style, _diagnosticStyle);
205 diagnosticBuilder.CodeStyleCheck(t);
206 return MakeDiagnosticInfo(diagnosticBuilder.GetDiagnosticResults(t), file);
207}
208
209LuaStyle &CodeFormat::GetStyle(const std::string &uri) {
210 std::shared_ptr<LuaEditorConfig> editorConfig = nullptr;

Callers 1

CheckCodeStyleFunction · 0.45

Calls 8

GetTokensMethod · 0.80
BuildTreeMethod · 0.80
CodeStyleCheckMethod · 0.80
GetDiagnosticResultsMethod · 0.80
SupportCLikeCommentsMethod · 0.45
ParseMethod · 0.45
HasErrorMethod · 0.45

Tested by

no test coverage detected