public override void IndentLines(ITextEditor editor, int beginLine, int endLine)
 {
     //DocumentAccessor acc = new DocumentAccessor(editor.Document, beginLine, endLine);
     //CSharpIndentationStrategy indentStrategy = new CSharpIndentationStrategy();
     //indentStrategy.IndentationString = editor.Options.IndentationString;
     //indentStrategy.Indent(acc, true);
     SharpLua.Visitors.NonModifiedAstBeautifier b = null;
     try
     {
         Lexer l = new Lexer();
         Parser p = new Parser(l.Lex(editor.Document.Text));
         SharpLua.Ast.Chunk c = p.Parse();
         b = new SharpLua.Visitors.NonModifiedAstBeautifier();
         //SharpLua.Visitors.ExactReconstruction b = new SharpLua.Visitors.ExactReconstruction();
         b.options.Tab = editor.Options.IndentationString;
         b.options.TabsToSpaces = editor.Options.ConvertTabsToSpaces;
         int off = editor.Caret.Offset;
         //editor.Document.Text = b.Reconstruct(c);
         editor.Document.Text = b.Beautify(c);
         editor.Caret.Offset = off >= editor.Document.TextLength ? 0 : off;
     }
     catch (LuaSourceException ex)
     {
         LoggingService.Warn("Error parsing document: " + System.IO.Path.GetFileName(ex.GenerateMessage(editor.FileName)));
     }
     catch (System.Exception ex)
     {
         LoggingService.Error("Error formatting document:", ex);
         MessageBox.Show(b.index.ToString() + " "+ b.tok.Count);
         MessageBox.Show("Error formatting Lua script: " + ex.ToString() + "\r\n\r\nPlease report this to the SharpLua GitHub page so it can get fixed");
     }
 }
 public override void IndentLines(ITextEditor editor, int beginLine, int endLine)
 {
     //DocumentAccessor acc = new DocumentAccessor(editor.Document, beginLine, endLine);
     //CSharpIndentationStrategy indentStrategy = new CSharpIndentationStrategy();
     //indentStrategy.IndentationString = editor.Options.IndentationString;
     //indentStrategy.Indent(acc, true);
     SharpLua.Visitors.NonModifiedAstBeautifier b = null;
     try
     {
         Lexer              l = new Lexer();
         Parser             p = new Parser(l.Lex(editor.Document.Text));
         SharpLua.Ast.Chunk c = p.Parse();
         b = new SharpLua.Visitors.NonModifiedAstBeautifier();
         //SharpLua.Visitors.ExactReconstruction b = new SharpLua.Visitors.ExactReconstruction();
         b.options.Tab          = editor.Options.IndentationString;
         b.options.TabsToSpaces = editor.Options.ConvertTabsToSpaces;
         int off = editor.Caret.Offset;
         //editor.Document.Text = b.Reconstruct(c);
         editor.Document.Text = b.Beautify(c);
         editor.Caret.Offset  = off >= editor.Document.TextLength ? 0 : off;
     }
     catch (LuaSourceException ex)
     {
         LoggingService.Warn("Error parsing document: " + System.IO.Path.GetFileName(ex.GenerateMessage(editor.FileName)));
     }
     catch (System.Exception ex)
     {
         LoggingService.Error("Error formatting document:", ex);
         MessageBox.Show(b.index.ToString() + " " + b.tok.Count);
         MessageBox.Show("Error formatting Lua script: " + ex.ToString() + "\r\n\r\nPlease report this to the SharpLua GitHub page so it can get fixed");
     }
 }