Exemplo n.º 1
0
        private static GreenNode CreateNode(SyntaxTrivia[] trivias)
        {
            if (trivias == null)
            {
                return(null);
            }

            var builder = new SyntaxTriviaListBuilder(trivias.Length);

            builder.Add(trivias);
            return(builder.ToList().Node);
        }
Exemplo n.º 2
0
        public static SyntaxTriviaList Create(IEnumerable <SyntaxTrivia> trivia)
        {
            if (trivia == null)
            {
                return(new SyntaxTriviaList());
            }

            var builder = SyntaxTriviaListBuilder.Create();

            builder.AddRange(trivia);
            return(builder.ToList());
        }
Exemplo n.º 3
0
        private static void ClearAndFreeBuilder(SyntaxTriviaListBuilder builder)
        {
            // It's possible someone might create a list with a huge amount of trivia
            // in it.  We don't want to hold onto such items forever.  So only cache
            // reasonably sized lists.  In IDE testing, around 99% of all trivia lists
            // were 16 or less elements.
            const int MaxBuilderCount = 16;

            if (builder.Count <= MaxBuilderCount)
            {
                builder.Clear();
                s_builderPool.Free(builder);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a list of trivia.
 /// </summary>
 /// <param name="trivias">A sequence of trivia.</param>
 public SyntaxTriviaList(IEnumerable <SyntaxTrivia> trivias)
     : this(null, SyntaxTriviaListBuilder.Create(trivias).Node, 0, 0)
 {
 }