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

Method RangeFormat

CodeFormatLib/src/LuaCodeFormat.cpp:102–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100}
101
102Result<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
136Result<std::vector<LuaTypeFormat::Result>>
137LuaCodeFormat::TypeFormat(const std::string &uri, std::size_t line, std::size_t character, std::string &&text,

Callers 1

range_formatFunction · 0.45

Calls 8

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

Tested by

no test coverage detected