Ejemplo n.º 1
0
        private void FixTextRanges(ICodeRoot root, ActionResult result)
        {
            if (!result.ChangeApplied ||
                result.NumCharactersInserted == 0)
            {
                return;
            }
            var constructs = root.WalkTree().ToList();

            foreach (var bc in constructs)
            {
                if (bc.TextRange.StartOffset > result.ChangeStartIndex)
                {
                    bc.TextRange.StartOffset += result.NumCharactersInserted;
                    bc.TextRange.EndOffset   += result.NumCharactersInserted;
                }
                else if (bc.TextRange.StartOffset < result.ChangeStartIndex &&
                         bc.TextRange.EndOffset > result.ChangeStartIndex)
                {
                    bc.TextRange.EndOffset += result.NumCharactersInserted;
                }
                //else if (bc.TextRange.StartOffset == result.ChangeStartIndex)
                //    bc.TextRange.EndOffset += result.NumCharactersInserted; // GFH
            }
        }
Ejemplo n.º 2
0
        private void FixTextRanges(ICodeRoot root, ActionResult result)
        {
            if (!result.ChangeApplied ||
                result.NumCharactersInserted == 0)
            {
                return;
            }
            var constructs = root.WalkTree().ToList();

            foreach (var bc in constructs)
            {
                if (bc.TextRange.StartOffset > result.ChangeStartIndex)
                {
                    bc.TextRange.StartOffset += result.NumCharactersInserted;
                    bc.TextRange.EndOffset += result.NumCharactersInserted;
                }
                else if (bc.TextRange.StartOffset < result.ChangeStartIndex &&
                    bc.TextRange.EndOffset > result.ChangeStartIndex)
                    bc.TextRange.EndOffset += result.NumCharactersInserted;
                //else if (bc.TextRange.StartOffset == result.ChangeStartIndex)
                //    bc.TextRange.EndOffset += result.NumCharactersInserted; // GFH
            }
        }
 public void Each_Node_Should_Only_Appear_Once()
 {
     Assert.That(codeRoot.WalkTree().Count(), Is.EqualTo(2));
 }