private void FormatByDaxEditor() { int lineCont = _source.GetLineCount(); for (int line = 0; line < lineCont; line++) { int lineEnd = 0; TokenInfo[] lineInfos = _source.GetColorizer().GetLineInfo(_source.GetTextLines(), line, _colorState); if (lineInfos != null) { for (int i = 0; i < lineInfos.Length; i++) { // Store it for future usage TokenInfo tokenInfo = lineInfos[i]; var te = new TokenEdit() { TokenInfo = tokenInfo }; te.TextSpan = new TextSpan() { iStartLine = line, iStartIndex = tokenInfo.StartIndex, iEndLine = line, iEndIndex = tokenInfo.EndIndex + 1 }; lineEnd = tokenInfo.EndIndex + 1; te.OriginalText = _source.GetText(te.TextSpan); if (te.TokenInfo.Token == (int)Tokens.LEX_ERROR) { te = ReplaceInvalidChars(te); } _tokenEdits.AddLast(te); } } // Insert token for EOL var tokenInfoEOL = new TokenInfo() { Type = TokenType.WhiteSpace }; var teEOL = new TokenEdit() { TokenInfo = tokenInfoEOL }; teEOL.TextSpan = new TextSpan() { iStartLine = line, iStartIndex = lineEnd, iEndLine = line + 1, iEndIndex = 0 }; teEOL.OriginalText = Environment.NewLine; _tokenEdits.AddLast(teEOL); } NormilizeWhitespaces(); InsertEol(); CheckHeadAndTail(); ApplyEdits(); }