| 100 | } |
| 101 | |
| 102 | Result<std::string> LuaCodeFormat::RangeFormat(const std::string &uri, FormatRange &range, |
| 103 | std::string &&text, |
| 104 | ConfigMap &configMap) { |
| 105 | auto file = std::make_shared<LuaSource>(std::move(text)); |
| 106 | LuaLexer luaLexer(file); |
| 107 | if (_supportNonStandardSymbol) { |
| 108 | luaLexer.SupportNonStandardSymbol(); |
| 109 | } |
| 110 | if (_supportCLikeComments) { |
| 111 | luaLexer.SupportCLikeComments(); |
| 112 | } |
| 113 | |
| 114 | luaLexer.Parse(); |
| 115 | |
| 116 | LuaParser p(file, std::move(luaLexer.GetTokens())); |
| 117 | p.Parse(); |
| 118 | |
| 119 | if (p.HasError()) { |
| 120 | return ResultType::Err; |
| 121 | } |
| 122 | |
| 123 | LuaSyntaxTree t; |
| 124 | t.BuildTree(p); |
| 125 | |
| 126 | LuaStyle style = GetStyle(uri); |
| 127 | CalculateTempStyle(style, configMap); |
| 128 | |
| 129 | RangeFormatBuilder f(style, range); |
| 130 | |
| 131 | auto formattedText = f.GetFormatResult(t); |
| 132 | range = f.GetReplaceRange(); |
| 133 | return formattedText; |
| 134 | } |
| 135 | |
| 136 | Result<std::vector<LuaTypeFormat::Result>> |
| 137 | LuaCodeFormat::TypeFormat(const std::string &uri, std::size_t line, std::size_t character, std::string &&text, |
no test coverage detected