/* Handle a detected refactoring by saveing it at an independent file. */ private string HandleDetectedRefactoring(string before, string after, ManualRefactoring refactoring) { // Get the folder and the file name for this detected refactoring. string refactoringDirectory = DETECTED_REFACTORINGS_ROOT + GetSolutionName() + "/" + GetRefactoringType(refactoring); string refactoringFilePath = refactoringDirectory + "/" + GetSimpleFileName() + refactoringsCount + ".txt"; // If the directory does not exist, create it. if(!Directory.Exists(refactoringDirectory)) { Directory.CreateDirectory(refactoringDirectory); } // Streaming all the needed information to the file. var stream = File.CreateText(refactoringFilePath); stream.WriteLine("Source Before:"); stream.WriteLine(before); stream.WriteLine("Source After:"); stream.WriteLine(after); stream.WriteLine("Detected Refactoring:"); stream.WriteLine(refactoring.ToString()); stream.Flush(); stream.Close(); // Return the saved refactoring file path. return refactoringFilePath; }
private void OnRefactoringDetected(ManualRefactoring refactoring) { logger.Info("Refactoring detected:"); logger.Info(refactoring.ToString()); GhostFactorComponents.conditionCheckingComponent.CheckRefactoringCondition (refactoring); }