| 178 | } |
| 179 | |
| 180 | Result<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 | |
| 209 | LuaStyle &CodeFormat::GetStyle(const std::string &uri) { |
| 210 | std::shared_ptr<LuaEditorConfig> editorConfig = nullptr; |
no test coverage detected