Пример #1
0
        public void ReplaceWith(SpanBuilder builder)
        {
            Kind           = builder.Kind;
            _greenTokens   = builder.Tokens;
            EditHandler    = builder.EditHandler;
            ChunkGenerator = builder.ChunkGenerator ?? SpanChunkGenerator.Null;
            _start         = builder.Start;
            SyntaxNode     = builder.SyntaxNode?.CreateRed(parent: null, position: _start.AbsoluteIndex);
            _content       = null;
            _length        = null;

            var tokens = EmptyTokenList;

            if (_greenTokens.Count > 0)
            {
                tokens = new List <SyntaxToken>();
                var currentStart = _start.AbsoluteIndex;
                for (var i = 0; i < _greenTokens.Count; i++)
                {
                    var token = new SyntaxToken(_greenTokens[i], parent: SyntaxNode, parentSpan: this, position: currentStart);
                    tokens.Add(token);
                    currentStart += token.FullWidth;
                }
            }

            Tokens = tokens;

            Parent?.ChildChanged();

            // Since we took references to the values in SpanBuilder, clear its references out
            builder.Reset();
        }
Пример #2
0
        public void ReplaceWith(SpanBuilder builder)
        {
            Kind    = builder.Kind;
            Symbols = builder.Symbols;

            for (var i = 0; i < Symbols.Count; i++)
            {
                Symbols[i].Parent = this;
            }

            EditHandler    = builder.EditHandler;
            ChunkGenerator = builder.ChunkGenerator ?? SpanChunkGenerator.Null;
            _start         = builder.Start;
            _content       = null;

            // Since we took references to the values in SpanBuilder, clear its references out
            builder.Reset();
        }
Пример #3
0
        public void ReplaceWith(SpanBuilder builder)
        {
            Kind   = builder.Kind;
            Tokens = builder.Tokens;

            for (var i = 0; i < Tokens.Count; i++)
            {
                Tokens[i].Parent = this;
            }

            EditHandler    = builder.EditHandler;
            ChunkGenerator = builder.ChunkGenerator ?? SpanChunkGenerator.Null;
            _start         = builder.Start;
            _content       = null;
            _length        = null;

            Parent?.ChildChanged();

            // Since we took references to the values in SpanBuilder, clear its references out
            builder.Reset();
        }