Example #1
0
        public static IEnumerable <ChangeSample> GetChangesWithContext(SyntaxTree beforeTree, SyntaxTree afterTree)
        {
            var spanMap   = new SpanMap(beforeTree, afterTree);
            var seenSpans = new HashSet <(TextSpan Before, TextSpan After)>();

            foreach (var(beforeSpan, afterSpan) in spanMap.GetAllSimpleChangeSpans())
            {
                foreach (var expanedChange in spanMap.GetExpandedChanges(beforeSpan, afterSpan,
                                                                         (b, a) => !IsChangeTooBig(b, beforeTree) && !IsChangeTooBig(a, afterTree)))
                {
                    if (seenSpans.Contains(expanedChange))
                    {
                        continue;
                    }

                    var baseChangeSample = new ChangeSample(
                        new ChangeAndContextSpan(expanedChange.Before, GetContextFor(expanedChange.Before, beforeTree)),
                        new ChangeAndContextSpan(expanedChange.After, GetContextFor(expanedChange.After, afterTree))
                        );

                    if (!spanMap.ContextOverlapsWithChange(baseChangeSample))
                    {
                        yield return(baseChangeSample);

                        seenSpans.Add(expanedChange);
                        break;
                    }
                }
            }
        }
Example #2
0
 private void SetSampleName(IEnumerable <TextBox> textBoxes)
 {
     foreach (var textBox in textBoxes)
     {
         var type  = textBox.Tag as Type;
         var value = textBox.Text.Trim();
         if (value != GetterOfType.GetSampleNaming(type))
         {
             var sample = value == string.Empty ? GetterOfType.GetDefaultSampleNaming(type) : textBox.Text;
             GetterOfType.SetSampleNaming(type, sample);
             ChangeSample?.Invoke(type);
         }
     }
 }