示例#1
0
        private static void KillTrailingNewline(TokenRewriteStream tokens, int index)
        {
            IList <IToken> all   = tokens.GetTokens();
            IToken         tok   = all[index];
            IToken         after = all[index + 1];
            string         ws    = after.Text;

            if (ws.StartsWith("\n"))
            {
                //Console.Out.WriteLine( "killing WS after action" );
                if (ws.Length > 1)
                {
                    int space = ws.IndexOf(' ');
                    int tab   = ws.IndexOf('\t');
                    if (ws.StartsWith("\n") && space >= 0 || tab >= 0)
                    {
                        return; // do nothing if \n + indent
                    }
                    // otherwise kill all \n
                    ws = ws.Replace("\n", "");
                    tokens.Replace(after.TokenIndex, ws);
                }
                else
                {
                    tokens.Delete(after.TokenIndex);
                }
            }
        }
示例#2
0
 private static void KillTrailingNewline( TokenRewriteStream tokens, int index )
 {
     IList<IToken> all = tokens.GetTokens();
     IToken tok = all[index];
     IToken after = all[index + 1];
     string ws = after.Text;
     if ( ws.StartsWith( "\n" ) )
     {
         //Console.Out.WriteLine( "killing WS after action" );
         if ( ws.Length > 1 )
         {
             int space = ws.IndexOf( ' ' );
             int tab = ws.IndexOf( '\t' );
             if ( ws.StartsWith( "\n" ) && space >= 0 || tab >= 0 )
             {
                 return; // do nothing if \n + indent
             }
             // otherwise kill all \n
             ws = ws.Replace( "\n", "" );
             tokens.Replace( after.TokenIndex, ws );
         }
         else
         {
             tokens.Delete( after.TokenIndex );
         }
     }
 }