public void RenameLocalVariableExpansion_Other()
        {
            const string codeText1 = @"void Expected(int i, int i2) { foo(i, 7, i2, 8); }";
            const string codeText2 = @"void Target(System.Int32 i, System.Int32 i1) { foo(i, 7, i1, 8); }";

            var expected = AstMatchHelper.ParseToMethodDeclaration(codeText1);
            var target   = AstMatchHelper.ParseToMethodDeclaration(codeText2);

            var r            = new RenameLocalVariableExpansion();
            var permutations = r.FindCandidatesViaRefactoringPermutations(new TargetInfo(expected, target), target);

            Util.AssertExists(permutations, x => x.MatchesPrint(expected));
        }
Beispiel #2
0
        public static bool MatchesIgnoreVarNames(this CloneDesc p, string expectedCode)
        {
            RenameLocalVariableExpansion rename = new RenameLocalVariableExpansion();

            var expected = AstMatchHelper.ParseToMethodDeclaration(expectedCode);

            foreach (var prd in rename.FindCandidatesViaRefactoringPermutations(new TargetInfo(expected, p.PermutatedMethod), p.PermutatedMethod))
            {
                if (expected.Matches(prd))
                {
                    return(true);
                }
            }
            return(false);
        }
        public void RenameLocalVariableExpansion_IncludesParameters()
        {
            const string codeText =
                @"void Bar(string bar_str)
                    {
                        bar_str += ""zippy"";
                        Console.Write(bar_str);
                    }";

            var foo_meth = AstMatchHelper.ParseToMethodDeclaration(codeText);

            var expected_method_text = codeText.Replace("bar_str", "jibberjab");
            var expected_method      = AstMatchHelper.ParseToMethodDeclaration(expected_method_text);

            RenameLocalVariableExpansion r = new RenameLocalVariableExpansion();
            var candidates = r.FindCandidatesViaRefactoringPermutations(new TargetInfo(expected_method, foo_meth), foo_meth);

            Util.AssertExists(candidates, x => expected_method.MatchesPrint(x));
        }