Exemplo n.º 1
0
            private void OnTextContentChanged(object?sender, TextContentChangedEventArgs args)
            {
                var changed = this.EtextChanged;

                if (changed == null)
                {
                    return;
                }

                // we should process all changes even though there is no text changes
                // otherwise, Workspace.CurrentSolution won't move forward to latest ITextSnapshot

                // this should convert given editor snapshots to roslyn forked snapshots
                var oldText = (SnapshotSourceText)args.Before.AsText();
                var newText = SnapshotSourceText.From(_textBufferCloneService, args.After);

                _currentText = newText;

                var changes = ImmutableArray.CreateRange(
                    args.Changes.Select(
                        c =>
                        new TextChangeRange(
                            new TextSpan(c.OldSpan.Start, c.OldSpan.Length),
                            c.NewLength
                            )
                        )
                    );
                var eventArgs = new TextChangeEventArgs(oldText, newText, changes);

                this.LastEventArgs = eventArgs;
                changed(sender, eventArgs);
            }
Exemplo n.º 2
0
            private TextBufferContainer(ITextBuffer editorBuffer)
            {
                Contract.ThrowIfNull(editorBuffer);

                _weakEditorBuffer = new WeakReference <ITextBuffer>(editorBuffer);
                _currentText      = SnapshotSourceText.From(editorBuffer.CurrentSnapshot, this);
            }
Exemplo n.º 3
0
 public static SourceText AsText(this ITextSnapshot textSnapshot)
 {
     textSnapshot.TextBuffer.Properties.TryGetProperty <ITextBufferCloneService>(
         typeof(ITextBufferCloneService),
         out var textBufferCloneServiceOpt
         );
     return(SnapshotSourceText.From(textBufferCloneServiceOpt, textSnapshot));
 }
Exemplo n.º 4
0
            private TextBufferContainer(ITextBuffer editorBuffer)
            {
                Contract.ThrowIfNull(editorBuffer);

                _weakEditorBuffer = new WeakReference <ITextBuffer>(editorBuffer);
                editorBuffer.Properties.TryGetProperty(typeof(ITextBufferCloneService), out _textBufferCloneServiceOpt);
                _currentText = SnapshotSourceText.From(_textBufferCloneServiceOpt, editorBuffer.CurrentSnapshot, this);
            }
            private void OnTextContentChanged(object sender, TextContentChangedEventArgs args)
            {
                var changed = this.EtextChanged;

                if (changed != null && args.Changes.Count != 0)
                {
                    // this should convert given editor snapshots to roslyn forked snapshots
                    var oldText = (SnapshotSourceText)args.Before.AsText();
                    var newText = SnapshotSourceText.From(args.After);
                    _currentText = newText;

                    var changes   = ImmutableArray.CreateRange(args.Changes.Select(c => new TextChangeRange(new TextSpan(c.OldSpan.Start, c.OldSpan.Length), c.NewLength)));
                    var eventArgs = new TextChangeEventArgs(oldText, newText, changes);
                    this.LastEventArgs = eventArgs;
                    changed(sender, eventArgs);
                }
            }
Exemplo n.º 6
0
 public static SourceText AsText(this ITextSnapshot textSnapshot)
 => SnapshotSourceText.From(textSnapshot);
Exemplo n.º 7
0
 public static SourceText AsText(this ITextSnapshot textSnapshot)
 {
     return(SnapshotSourceText.From(textSnapshot));
 }
Exemplo n.º 8
0
 public static SourceText AsText(this ITextSnapshot textSnapshot)
 => SnapshotSourceText.From(textBufferCloneServiceOpt: null, textSnapshot);