Beispiel #1
0
        public ElisionBuffer(IProjectionEditResolver resolver,
                             IContentType contentType,
                             ITextBuffer sourceBuffer,
                             NormalizedSpanCollection exposedSpans,
                             ElisionBufferOptions options,
                             ITextDifferencingService textDifferencingService,
                             GuardedOperations guardedOperations)
            : base(resolver, contentType, textDifferencingService, guardedOperations)
        {
            Debug.Assert(sourceBuffer != null);
            this.sourceBuffer   = sourceBuffer;
            this.sourceSnapshot = sourceBuffer.CurrentSnapshot;

            BaseBuffer baseSourceBuffer = (BaseBuffer)sourceBuffer;

            this.eventHook = new WeakEventHook(this, baseSourceBuffer);

            this.group = baseSourceBuffer.group;
            this.group.AddMember(this);

            this.content = new ElisionMap(this.sourceSnapshot, exposedSpans);

            StringRebuilder newBuilder = StringRebuilder.Empty;

            for (int i = 0; (i < exposedSpans.Count); ++i)
            {
                newBuilder = newBuilder.Append(BufferFactoryService.StringRebuilderFromSnapshotAndSpan(this.sourceSnapshot, exposedSpans[i]));
            }
            this.builder = newBuilder;

            this.elisionOptions = options;
            this.currentVersion.SetLength(content.Length);
            this.currentElisionSnapshot = new ElisionSnapshot(this, this.sourceSnapshot, base.currentVersion, this.builder, this.content, (options & ElisionBufferOptions.FillInMappingMode) != 0);
            this.currentSnapshot        = this.currentElisionSnapshot;
        }
Beispiel #2
0
        public IElisionBuffer CreateElisionBuffer(IProjectionEditResolver projectionEditResolver,
                                                  NormalizedSnapshotSpanCollection exposedSpans,
                                                  ElisionBufferOptions options,
                                                  IContentType contentType)
        {
            // projectionEditResolver is allowed to be null.
            if (exposedSpans == null)
            {
                throw new ArgumentNullException(nameof(exposedSpans));
            }
            if (exposedSpans.Count == 0)
            {
                throw new ArgumentOutOfRangeException(nameof(exposedSpans));  // really?
            }
            if (contentType == null)
            {
                throw new ArgumentNullException(nameof(contentType));
            }

            if (exposedSpans[0].Snapshot != exposedSpans[0].Snapshot.TextBuffer.CurrentSnapshot)
            {
                // TODO:
                // build against given snapshot and then move forward if necessary?
                throw new ArgumentException("Elision buffer must be created against the current snapshot of its source buffer");
            }

            IElisionBuffer buffer = new ElisionBuffer(projectionEditResolver, contentType, exposedSpans[0].Snapshot.TextBuffer,
                                                      exposedSpans, options, _textDifferencingSelectorService.DefaultTextDifferencingService, _guardedOperations);

            RaiseProjectionBufferCreatedEvent(buffer);
            return(buffer);
        }
Beispiel #3
0
        public ElisionBuffer(IProjectionEditResolver resolver,
                             IContentType contentType,
                             ITextBuffer sourceBuffer,
                             NormalizedSpanCollection exposedSpans,
                             ElisionBufferOptions options,
                             ITextDifferencingService textDifferencingService,
                             GuardedOperations guardedOperations)
            : base(resolver, contentType, textDifferencingService, guardedOperations)
        {
            Debug.Assert(sourceBuffer != null);
            this.sourceBuffer   = sourceBuffer;
            this.sourceSnapshot = sourceBuffer.CurrentSnapshot;

            BaseBuffer baseSourceBuffer = (BaseBuffer)sourceBuffer;

            this.eventHook = new WeakEventHook(this, baseSourceBuffer);

            this.group = baseSourceBuffer.group;
            this.group.AddMember(this);

            this.content        = new ElisionMap(this.sourceSnapshot, exposedSpans);
            this.elisionOptions = options;
            this.currentVersion.InternalLength = content.Length;
            this.currentElisionSnapshot        = new ElisionSnapshot(this, this.sourceSnapshot, base.currentVersion, this.content, (options & ElisionBufferOptions.FillInMappingMode) != 0);
            this.currentSnapshot = this.currentElisionSnapshot;
        }
Beispiel #4
0
 public IElisionBuffer CreateElisionBuffer(IProjectionEditResolver projectionEditResolver,
                                           NormalizedSnapshotSpanCollection exposedSpans,
                                           ElisionBufferOptions options)
 {
     return(CreateElisionBuffer(projectionEditResolver, exposedSpans, options, ProjectionContentType));
 }