private void SetMode(string mode) { var prev = new BeautifierFlags("BLOCK"); if (Flags != null) { FlagStore.Add(Flags); prev = Flags; } Flags = new BeautifierFlags(mode); if (FlagStore.Count == 1) { Flags.IndentationLevel = 0; } else { Flags.IndentationLevel = prev.IndentationLevel; if (prev.VarLine && prev.VarLineReindented) { Flags.IndentationLevel = Flags.IndentationLevel + 1; } } Flags.PreviousMode = prev.Mode; }
private void BlankState() { // internal flags Flags = new BeautifierFlags("BLOCK"); FlagStore = new List <BeautifierFlags>(); WantedNewline = false; JustAddedNewline = false; DoBlockJustClosed = false; if (Opts.IndentWithTabs) { IndentString = "\t"; } else { IndentString = new string(Opts.IndentChar, (int)Opts.IndentSize); } PreindentString = ""; LastWord = ""; // last TK_WORD seen LastType = "TK_START_EXPR"; // last token type LastText = ""; // last token text LastLastText = ""; // pre-last token text Input = null; Output = new List <string>(); // formatted javascript gets built here Whitespace = new[] { '\n', '\r', '\t', ' ' }; Wordchar = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$"; Digits = "0123456789"; Punct = "+ - * / % & ++ -- = += -= *= /= %= == === != !== > < => >= <= >> << >>> >>>= >>= <<= && &= | || ! !! , : ? ^ ^= |= :: <?= <? ?> <%= <% %>" .Split(' '); // Words which always should start on a new line LineStarters = "continue,try,throw,return,var,if,switch,case,default,for,while,break,function".Split(','); SetMode("BLOCK"); ParserPos = 0; }
private void SetMode(string mode) { BeautifierFlags prev = new BeautifierFlags("BLOCK"); if (this.Flags != null) { this.FlagStore.Add(this.Flags); prev = this.Flags; } this.Flags = new BeautifierFlags(mode); if (this.FlagStore.Count == 1) this.Flags.IndentationLevel = 0; else { this.Flags.IndentationLevel = prev.IndentationLevel; if (prev.VarLine && prev.VarLineReindented) this.Flags.IndentationLevel = this.Flags.IndentationLevel + 1; } this.Flags.PreviousMode = prev.Mode; }