public IEnumerable <CloneDesc> GetAllPossibleExtractedMethods(MethodDeclaration right, int targetChildCount) { var children = right.Body.Children; if (children.Count == 0) { yield break; } var window = new Window(0, children.Count - 1); // This way fixes the unused parameter problem, but causes the Target and Expected to be reversed. /* * MethodDeclaration md = right.DeepCopy(); * if (md != null) * yield return new CloneDesc(md, window, children) { ReplacementInvocation = new CSharpMethodExtractor().GetCall(right, right, new VariableDeclaration("heyman")) }; */ // But this way fixes the reversed problem, but leaves the unused param problem. var desc = OscillatingExtractMethodRefactoringExpansion.ExtractMethodAsCloneDesc(window, right, children); if (desc != null) { yield return(desc); } }
private void TestCounterOnSnippet(string codeText) { var expansion = new OscillatingExtractMethodRefactoringExpansion(); var counter = new OscillatingExtractMethodCounter(); var md = AstMatchHelper.ParseToMethodDeclaration(codeText); var methods = expansion.GetAllPossibleExtractedMethods(md, 3); var count = counter.CountAllExtractedMethods(md, 3); Assert.AreEqual(methods.Count(), count); methods = expansion.GetAllPossibleExtractedMethods(md, 1); count = counter.CountAllExtractedMethods(md, 1); Assert.AreEqual(methods.Count(), count); }
private int ProcessChild(MethodDeclaration right, INode child, int targetChildCount) { var children1 = OscillatingExtractMethodRefactoringExpansion.GetExtractableChildren(child); return(ProcessChildren(right, children1, AstMatchHelper.OscillateWindows(children1.Count), targetChildCount)); }