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

Method Reformat

CodeFormatLib/src/LuaCodeFormat.cpp:72–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72Result<std::string> LuaCodeFormat::Reformat(const std::string &uri, std::string &&text, ConfigMap &configMap) {
73 auto file = std::make_shared<LuaSource>(std::move(text));
74 LuaLexer luaLexer(file);
75 if (_supportNonStandardSymbol) {
76 luaLexer.SupportNonStandardSymbol();
77 }
78 if (_supportCLikeComments) {
79 luaLexer.SupportCLikeComments();
80 }
81
82 luaLexer.Parse();
83
84 LuaParser p(file, std::move(luaLexer.GetTokens()));
85 p.Parse();
86
87 if (p.HasError()) {
88 return ResultType::Err;
89 }
90
91 LuaSyntaxTree t;
92 t.BuildTree(p);
93
94 LuaStyle style = GetStyle(uri);
95 CalculateTempStyle(style, configMap);
96
97 FormatBuilder f(style);
98
99 return f.GetFormatResult(t);
100}
101
102Result<std::string> LuaCodeFormat::RangeFormat(const std::string &uri, FormatRange &range,
103 std::string &&text,

Callers 1

formatFunction · 0.45

Calls 7

GetTokensMethod · 0.80
BuildTreeMethod · 0.80
SupportCLikeCommentsMethod · 0.45
ParseMethod · 0.45
HasErrorMethod · 0.45
GetFormatResultMethod · 0.45

Tested by

no test coverage detected