public bool HasRefactoring() { refactorings = Enumerable.Empty<IManualRefactoring>(); SyntaxTree treeBefore = SyntaxTree.ParseCompilationUnit(before); SyntaxTree treeAfter = SyntaxTree.ParseCompilationUnit(after); // Get the classes in the code before and after. var classesBefore = treeBefore.GetRoot().DescendantNodes().Where(n => n.Kind == SyntaxKind.ClassDeclaration); var classesAfter = treeAfter.GetRoot().DescendantNodes().Where(n => n.Kind == SyntaxKind.ClassDeclaration); // Get the pairs of class declaration in the code before and after var paris = GetClassDeclarationPairs(classesBefore, classesAfter); foreach (var pair in paris) { var detector = new InClassExtractMethodDetector((ClassDeclarationSyntax)pair.Key, (ClassDeclarationSyntax)pair.Value); detector.SetSyntaxTreeBefore(treeBefore); detector.SetSyntaxTreeAfter(treeAfter); if(detector.HasRefactoring()) { refactorings = refactorings.Union(detector.GetRefactorings()); return true; } } return false; }