Exemple #1
0
 public ITextBuffer CreateTextBuffer(string text, IContentType contentType, bool spurnGroup)
 {
     if (text == null)
     {
         throw new ArgumentNullException(nameof(text));
     }
     if (contentType == null)
     {
         throw new ArgumentNullException(nameof(contentType));
     }
     return(Make(contentType, StringRebuilder.Create(text), spurnGroup));
 }
Exemple #2
0
        public ITextBuffer CreateTextBuffer(ITextImage image, IContentType contentType)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }
            if (contentType == null)
            {
                throw new ArgumentNullException(nameof(contentType));
            }

            StringRebuilder content = StringRebuilder.Create(image);

            return(Make(contentType, content, false));
        }
        public static StringRebuilder Create(ITextImage image)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }

            var cti = image as CachingTextImage;

            if (cti != null)
            {
                return(cti.Builder);
            }

            // This shouldn't happen but as a fallback, create a new string rebuilder from the text of the provided image.
            return(StringRebuilder.Create(image.GetText(0, image.Length)));
        }
Exemple #4
0
        public static StringRebuilder ChangeNewSubText(ITextChange change, int start, int length)
        {
            var textChange = change as TextChange;

            if (textChange != null)
            {
                return(textChange._newText.GetSubText(new Span(start, length)));
            }

            var change3 = change as ITextChange3;

            if (change3 != null)
            {
                return(StringRebuilder.Create(change3.GetNewText(new Span(start, length))));
            }

            return(StringRebuilder.Create(change.NewText.Substring(start, length)));
        }
Exemple #5
0
 public static TextChange Create(int oldPosition, string oldText, StringRebuilder newText, ITextSnapshot currentSnapshot)
 {
     return(new TextChange(oldPosition, StringRebuilder.Create(oldText), newText, ComputeLineBreakBoundaryConditions(currentSnapshot, oldPosition, oldText.Length)));
 }
Exemple #6
0
 internal TextChange(int oldPosition, string oldText, string newText, LineBreakBoundaryConditions boundaryConditions)
     : this(oldPosition, StringRebuilder.Create(oldText), StringRebuilder.Create(newText), boundaryConditions)
 {
 }
Exemple #7
0
        public static StringRebuilder NewStringRebuilder(ITextChange change)
        {
            var textChange = change as TextChange;

            return((textChange != null) ? textChange._newText : StringRebuilder.Create(change.NewText));
        }
Exemple #8
0
        public static StringRebuilder OldStringRebuilder(ITextChange change)
        {
            var textChange = change as TextChange;

            return((textChange != null) ? textChange._oldText : StringRebuilder.Create(change.OldText));
        }
 /// <summary>
 /// Create a new StringRebuilder equivalent to replacing a contiguous span of characters
 /// with different text.
 /// </summary>
 /// <param name="span">
 /// Span of text in this <see cref="StringRebuilder"/> to replace.
 /// </param>
 /// <param name="text">
 /// The new text to replace the old.
 /// </param>
 /// <returns>
 /// A new string rebuilder containing the replacement.
 /// </returns>
 /// <remarks>
 /// <para>this <see cref="StringRebuilder"/> is not modified.</para>
 /// <para>This operation can be performed simultaneously on multiple threads.</para>
 /// </remarks>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="span"/>.End is greater than <see cref="Length"/>.</exception>
 /// <exception cref="ArgumentNullException"><paramref name="text"/> is null.</exception>
 public StringRebuilder Replace(Span span, string text)
 {
     return(this.Replace(span, StringRebuilder.Create(text)));
 }
 /// <summary>
 /// Create a new StringRebuilder equivalent to inserting text into this <see cref="StringRebuilder"/>.
 /// </summary>
 /// <param name="position">Position at which to insert.</param>
 /// <param name="text">Text to insert.</param>
 /// <returns>A new StringRebuilder containing the insertion.</returns>
 /// <remarks>
 /// <para>this <see cref="StringRebuilder"/> is not modified.</para>
 /// <para>This operation can be performed simultaneously on multiple threads.</para>
 /// </remarks>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="position"/> is less than zero or greater than <see cref="Length"/>.</exception>
 /// <exception cref="ArgumentNullException"><paramref name="text"/> is null.</exception>
 public StringRebuilder Insert(int position, string text)
 {
     return(this.Insert(position, StringRebuilder.Create(text)));
 }
Exemple #11
0
 public ITextImage CreateTextImage(string text)
 {
     return(CachingTextImage.Create(StringRebuilder.Create(text), null));
 }