1- #include " CodeService/LuaTypeFormat.h"
1+ #include " CodeService/TypeFormat/ LuaTypeFormat.h"
22#include < algorithm>
33#include " LuaParser/LuaTokenTypeDetail.h"
44#include " CodeService/FormatElement/SerializeContext.h"
@@ -27,9 +27,11 @@ int FindTokenIndexBeforePosition(std::vector<LuaToken>& tokens, int offset)
2727 return static_cast <int >(pos - tokens.begin ()) - 1 ;
2828}
2929
30- LuaTypeFormat::LuaTypeFormat (std::shared_ptr<LuaParser> luaParser, LuaCodeStyleOptions& options)
30+ LuaTypeFormat::LuaTypeFormat (std::shared_ptr<LuaParser> luaParser, LuaCodeStyleOptions& options,
31+ LuaTypeFormatOptions& typeOptions)
3132 : _parser(luaParser),
3233 _options(options),
34+ _typeOptions(typeOptions),
3335 _hasResult(false )
3436{
3537}
@@ -84,6 +86,11 @@ void LuaTypeFormat::AnalysisReturn(int line, int character)
8486
8587void LuaTypeFormat::CompleteMissToken (int line, int character, LuaError& luaError)
8688{
89+ if (!_typeOptions.auto_complete_end )
90+ {
91+ return ;
92+ }
93+
8794 LuaCodeStyleOptions temp = _options;
8895 temp.insert_final_newline = true ;
8996 switch (luaError.MissToken )
@@ -190,6 +197,11 @@ void LuaTypeFormat::CompleteMissToken(int line, int character, LuaError& luaErro
190197
191198void LuaTypeFormat::FormatLine (int line)
192199{
200+ if (!_typeOptions.format_line )
201+ {
202+ return ;
203+ }
204+
193205 LuaCodeStyleOptions temp = _options;
194206 temp.insert_final_newline = true ;
195207 temp.remove_expression_list_finish_comma = false ;
@@ -213,7 +225,7 @@ void LuaTypeFormat::FormatLine(int line)
213225 break ;
214226 }
215227 }
216- if (!formatText.empty () && formatText.back () != ' \n ' )
228+ if (!formatText.empty () && formatText.back () != ' \n ' )
217229 {
218230 formatText.push_back (' \n ' );
219231 }
0 commit comments