示例#1
0
        public void ChangeContentType(IContentType newContentType, object editTag)
        {
            var before = ContentType;

            ContentType = newContentType;
            ContentTypeChanged?.Invoke(this, new ContentTypeChangedEventArgs(CurrentSnapshot, CurrentSnapshot, before, newContentType, new object()));
        }
示例#2
0
        public void ApplyEdits(params TestEdit[] edits)
        {
            var args = new TextContentChangedEventArgs(edits[0].OldSnapshot, edits[edits.Length - 1].NewSnapshot, new EditOptions(), null);

            foreach (var edit in edits)
            {
                args.Changes.Add(new TestTextChange(edit.Change));
            }

            _currentSnapshot = edits[edits.Length - 1].NewSnapshot;
            if (_currentSnapshot is StringTextSnapshot testSnapshot)
            {
                testSnapshot.TextBuffer = this;
            }

            foreach (var changedEvent in AttachedChangedEvents)
            {
                changedEvent.Invoke(this, args);
            }

            PostChanged?.Invoke(null, null);

            ReadOnlyRegionsChanged?.Invoke(null, null);
            ChangedLowPriority?.Invoke(null, null);
            ChangedHighPriority?.Invoke(null, null);
            Changing?.Invoke(null, null);
            ContentTypeChanged?.Invoke(null, null);
        }
        public void ChangeContentType(IContentType newContentType, object editTag)
        {
            _contentType = newContentType;

            if (CurrentSnapshot is StringTextSnapshot oldStringTextSnapshot)
            {
                var newStringTextSnapshot = new StringTextSnapshot(oldStringTextSnapshot.Content, oldStringTextSnapshot.Version.VersionNumber + 1);
                newStringTextSnapshot.TextBuffer = this;
                CurrentSnapshot = newStringTextSnapshot;
            }

            ContentTypeChanged?.Invoke(this, null);
        }
            public void ApplyEdit(TestEdit edit)
            {
                var args = new TextContentChangedEventArgs(edit.OldSnapshot, edit.NewSnapshot, new EditOptions(), null);

                args.Changes.Add(new TextChange(edit));
                Changed?.Invoke(this, args);

                ReadOnlyRegionsChanged?.Invoke(null, null);
                ChangedLowPriority?.Invoke(null, null);
                ChangedHighPriority?.Invoke(null, null);
                Changing?.Invoke(null, null);
                PostChanged?.Invoke(null, null);
                ContentTypeChanged?.Invoke(null, null);

                _currentSnapshot = edit.NewSnapshot;
            }
示例#5
0
 public void ChangeContentType(IContentType newContentType, object editTag)
 {
     VerifyAccess();
     if (newContentType == null)
     {
         throw new ArgumentNullException(nameof(newContentType));
     }
     if (contentType != newContentType)
     {
         var oldContentType = contentType;
         contentType = newContentType;
         // ContentType is part of the snapshot, so make sure we create a new one
         var beforeSnapshot = CurrentSnapshot;
         CreateNewCurrentSnapshot(Array.Empty <ITextChange>());
         var afterSnapshot = CurrentSnapshot;
         ContentTypeChanged?.Invoke(this, new ContentTypeChangedEventArgs(beforeSnapshot, afterSnapshot, oldContentType, contentType, editTag));
     }
 }
 private void OnDocumentBufferContentTypeChanged(object sender, ContentTypeChangedEventArgs e)
 {
     ContentTypeChanged?.Invoke(this, new TextDataModelContentTypeChangedEventArgs(e.BeforeContentType, e.AfterContentType));
 }