public SimpleExtractMethodTests() { this.logger = NLoggerUtil.GetNLogger(typeof (SimpleExtractMethodTests)); this.sourceBefore = FileUtil.ReadAllText(TestUtil.GetFakeSourceFolder() + "SimpleExtractMethodBefore.txt"); this.sourceAfter = FileUtil.ReadAllText(TestUtil.GetFakeSourceFolder() + "SimpleExtractMethodAfter.txt"); this.detector = RefactoringDetectorFactory.CreateDummyExtractMethodDetector(); }
public RenameDetectorTests() { var sourceBefore = FileUtil.ReadAllText(TestUtil.GetFakeSourceFolder() + "RenameDetectorExampleBefore.txt"); var sourceAfter = FileUtil.ReadAllText(TestUtil.GetFakeSourceFolder() + "RenameDetectorExampleAfter.txt"); before = ASTUtil.GetSyntaxTreeFromSource(sourceBefore).GetRoot(); after = ASTUtil.GetSyntaxTreeFromSource(sourceAfter).GetRoot(); detector = RefactoringDetectorFactory.CreateRenameDetector(); logger = NLoggerUtil.GetNLogger(typeof (RenameDetectorTests)); }
public ChangeSignatureDetectorTests() { sourceBefore = FileUtil.ReadAllText(TestUtil.GetFakeSourceFolder() + "ChangeMethodSignatureBefore.txt"); sourceAfter = FileUtil.ReadAllText(TestUtil.GetFakeSourceFolder() + "ChangeMethodSignatureAfter.txt"); detector = RefactoringDetectorFactory.CreateChangeMethodSignatureDetector(); detector.SetSourceBefore(sourceBefore); detector.SetSourceAfter(sourceAfter); logger = NLoggerUtil.GetNLogger(typeof (ChangeSignatureDetectorTests)); }
public SimpleExtractMethodTests() { this.logger = NLoggerUtil.GetNLogger(typeof (SimpleExtractMethodTests)); this.sourceBefore = FileUtil.ReadAllText(TestUtil.GetFakeSourceFolder() + "SimpleExtractMethodBefore.txt"); this.sourceAfter = FileUtil.ReadAllText(TestUtil.GetFakeSourceFolder() + "SimpleExtractMethodAfter.txt"); this.detector = RefactoringDetectorFactory.GetDummyRefactoringDetectorByType (RefactoringType.EXTRACT_METHOD); }
public ChangeSignatureDetectorTests() { sourceBefore = FileUtil.ReadAllText(TestUtil.GetFakeSourceFolder() + "ChangeMethodSignatureBefore.txt"); sourceAfter = FileUtil.ReadAllText(TestUtil.GetFakeSourceFolder() + "ChangeMethodSignatureAfter.txt"); detector = RefactoringDetectorFactory.GetRefactoringDetectorByType (RefactoringType.CHANGE_METHOD_SIGNATURE); detector.SetSourceBefore(sourceBefore); detector.SetSourceAfter(sourceAfter); logger = NLoggerUtil.GetNLogger(typeof (ChangeSignatureDetectorTests)); }
public InlineMethodIssueResolver() { this.detector = RefactoringDetectorFactory.GetRefactoringDetectorByType(RefactoringType. INLINE_METHOD); this.checker = ConditionCheckingFactory.GetConditionsListByRefactoringType(RefactoringType. INLINE_METHOD); this.code0 = FileUtil.ReadAllText(TestUtil.GetStudyFakeSourceFolder() + "ConsoleLibInlinebefore.txt"); this.code1 = FileUtil.ReadAllText(TestUtil.GetStudyFakeSourceFolder() + "ConsoleLibInlineafter.txt"); this.code2 = FileUtil.ReadAllText(TestUtil.GetStudyFakeSourceFolder() + "ConsoleLibInlineResolved.txt"); }
public ExtractMethodIssueResolveTests() { detector = RefactoringDetectorFactory.GetRefactoringDetectorByType(RefactoringType. EXTRACT_METHOD); conditions = ConditionCheckingFactory.GetConditionsListByRefactoringType(RefactoringType. EXTRACT_METHOD); source1 = FileUtil.ReadAllText(TestUtil.GetStudyFakeSourceFolder() + "ExtractMethod1.txt"); source2 = FileUtil.ReadAllText(TestUtil.GetStudyFakeSourceFolder() + "ExtractMethod2.txt"); source3 = FileUtil.ReadAllText(TestUtil.GetStudyFakeSourceFolder() + "ExtractMethod3.txt"); source4 = FileUtil.ReadAllText(TestUtil.GetStudyFakeSourceFolder() + "ExtractMethod4.txt"); source5 = FileUtil.ReadAllText(TestUtil.GetStudyFakeSourceFolder() + "ExtractMethod5.txt"); source6 = FileUtil.ReadAllText(TestUtil.GetStudyFakeSourceFolder() + "ExtractMethod6.txt"); }
/* Detect intermediate refactorings the determined before record. */ private void DetectIntermediateRefactorings(ICodeHistoryRecord baseBefore, ICodeHistoryRecord head, IExternalRefactoringDetector detector) { // Get the source code for base before. var before = baseBefore.GetSource(); // From the head, iteratively get previous record (until reach base before record) // and detect if refactorings exist. for (var currentRecord = head; !currentRecord.Equals(baseBefore); currentRecord = currentRecord.GetPreviousRecord()) { var after = currentRecord.GetSource(); DetectRefactoringByDetector(before, after, detector); } }
public InlineMethodRefactoringTests() { var convertor = new String2IDocumentConverter(); this.detector = RefactoringDetectorFactory.CreateInlineMethodDetector(); this.checkersList = ConditionCheckingFactory.GetInlineMethodConditionsList(); this.codeBefore = FileUtil.ReadAllText(TestUtil.GetFakeSourceFolder() + "InlineMethodBefore.txt"); this.codeAfter = FileUtil.ReadAllText(TestUtil.GetFakeSourceFolder() + "InlineMethodAfter.txt"); this.documentBefore = (IDocument)convertor.Convert(codeBefore, null, null, null); this.documentAfter = (IDocument)convertor.Convert(codeAfter, null, null, null); detector.SetSourceBefore(codeBefore); detector.SetSourceAfter(codeAfter); this.dummyDetector = RefactoringDetectorFactory.CreateDummyInlineMethodDetector(); dummyDetector.SetSourceBefore(codeBefore); dummyDetector.SetSourceAfter(codeAfter); }
private bool DetectRefactoringByDetector(string before, string after, IExternalRefactoringDetector detector) { // Set source before and after. detector.SetSourceBefore(before); detector.SetSourceAfter(after); // If a refactoring is detected. if (detector.HasRefactoring()) { // Get the detected refactorings, and log them. var refactorings = detector.GetRefactorings(); foreach (var refactoring in refactorings) { var path = HandleDetectedRefactoring(before, after, refactoring); refactoringsCount ++; logger.Info("Refactoring detected! Saved at " + path); } return true; } return false; }
/* Handle a previous record with the head of the record chain. */ private bool HandlePreviousRecord(ICodeHistoryRecord previous, ICodeHistoryRecord head, IExternalRefactoringDetector detector) { var after = head.GetSource(); var before = previous.GetSource(); // Detect if a refactoring happens before head and the previous record. if (DetectRefactoringByDetector(before, after, detector)) { // If there is a refactoring detected, search intermediate refactorings. DetectIntermediateRefactorings(previous, head.GetPreviousRecord(), detector); return true; } return false; }