コード例 #1
0
ファイル: EcsTriviaInjector.cs プロジェクト: dadhi/ecsharp
        protected override LNodeList GetTriviaToAttach(LNode node, IListSource <Token> trivia, TriviaLocation loc, LNode parent, int indexInParent)
        {
            int?nli;

            // In an 'if' statement, the 'else' keyword is invisible to the trivia
            // injector, but it often appears on a line by itself; remove one of
            // the two newline trivia to avoid creating a blank line when printing.
            if (loc == TriviaLocation.Leading && indexInParent == 2 && parent != null &&
                parent.Calls(CodeSymbols.If, 3) &&
                trivia.Count(t => t.Type() == TokenType.Newline) >= 2 &&
                (nli = trivia.FirstIndexWhere(t => t.Type() == TokenType.Newline)) != null)
            {
                trivia = new VList <Token>(trivia).RemoveAt(nli.Value);
            }
            return(base.GetTriviaToAttach(node, trivia, loc, parent, indexInParent));
        }