Ejemplo n.º 1
0
        public void Replace(RelatedLocation location, LazyString replacement)
        {
            // only tail replacing
            if (location.StartIndex < TailStartIndex)
            {
                return;
            }

            var tail = _workingText.Last.Value;

            var beforeLength = location.StartIndex - TailStartIndex;
            var afterLength  = tail.Length - beforeLength - location.Length;

            _workingText.RemoveLast();

            // tail_1_2_3 -> tail_1 + replacement + tail_3
            if (beforeLength > 0)
            {
                _workingText.Append(tail.Substring(0, beforeLength));
            }
            _workingText.Append(replacement);
            if (afterLength > 0)
            {
                _workingText.Append(tail.Substring(beforeLength + location.Length, afterLength));
            }

            TotalLegthCorrection.Value += replacement.Length - location.Length;
        }
Ejemplo n.º 2
0
 public static SerializableRelatedLocation Dehydrate(RelatedLocation location)
 => new SerializableRelatedLocation
 {
     ConflictCheckSpan = location.ConflictCheckSpan,
     Type                   = location.Type,
     IsReference            = location.IsReference,
     DocumentId             = location.DocumentId,
     ComplexifiedTargetSpan = location.ComplexifiedTargetSpan,
 };
Ejemplo n.º 3
0
        private static InlineRenameReplacementKind GetReplacementKind(RelatedLocation location)
        {
            switch (location.Type)
            {
            case RelatedLocationType.NoConflict:
                return(InlineRenameReplacementKind.NoConflict);

            case RelatedLocationType.ResolvedReferenceConflict:
                return(InlineRenameReplacementKind.ResolvedReferenceConflict);

            case RelatedLocationType.ResolvedNonReferenceConflict:
                return(InlineRenameReplacementKind.ResolvedNonReferenceConflict);

            case RelatedLocationType.UnresolvableConflict:
            case RelatedLocationType.UnresolvedConflict:
                return(InlineRenameReplacementKind.UnresolvedConflict);

            default:
            case RelatedLocationType.PossiblyResolvableConflict:
                throw ExceptionUtilities.Unreachable;
            }
        }
Ejemplo n.º 4
0
 internal InlineRenameReplacement(RelatedLocation location, TextSpan newSpan)
     : this(GetReplacementKind(location), location.ConflictCheckSpan, newSpan)
 {
 }