Пример #1
0
 public void test_toLTK_Change_CompositeChange_noFile() throws Exception {
   Source source = new FileBasedSource(new File("no-such-file.dart"));
   SourceChange sourceChangeA = new SourceChange("My change A", source);
   SourceChange sourceChangeB = new SourceChange("My change B", source);
   CompositeChange compositeChange =
       new CompositeChange("My composite change", sourceChangeA, sourceChangeB);
   // toLTK
   org.eclipse.ltk.core.refactoring.Change ltkChange_ = ServiceUtils.toLTK(compositeChange);
   org.eclipse.ltk.core.refactoring.CompositeChange ltkChange =
       (org.eclipse.ltk.core.refactoring.CompositeChange) ltkChange_;
   assertEquals("My composite change", ltkChange.getName());
   org.eclipse.ltk.core.refactoring.Change[] ltkChanges = ltkChange.getChildren();
   assertThat(ltkChanges).isEmpty();
 }
Пример #2
0
 public void test_toLTK_Change_CompositeChange() throws Exception {
   Source source = createTestFileSource();
   // fill SourceChange
   SourceChange sourceChangeA = new SourceChange("My change A", source);
   SourceChange sourceChangeB = new SourceChange("My change B", source);
   CompositeChange compositeChange =
       new CompositeChange("My composite change", sourceChangeA, sourceChangeB);
   // toLTK
   org.eclipse.ltk.core.refactoring.Change ltkChange_ = ServiceUtils.toLTK(compositeChange);
   org.eclipse.ltk.core.refactoring.CompositeChange ltkChange =
       (org.eclipse.ltk.core.refactoring.CompositeChange) ltkChange_;
   assertEquals("My composite change", ltkChange.getName());
   org.eclipse.ltk.core.refactoring.Change[] ltkChanges = ltkChange.getChildren();
   assertThat(ltkChanges).hasSize(2);
 }
Пример #3
0
 public void test_toLTK_Change_MergeCompositeChange_emptyPreview() throws Exception {
   IFile testFile = testProject.setFileContent("test.dart", "012345");
   Source source = createFileSource(testFile);
   // fill SourceChange
   SourceChange sourceChangeB = new SourceChange("My change B", source);
   sourceChangeB.addEdit(new Edit(2, 0, "b"));
   CompositeChange compositeChangeA = new CompositeChange("A");
   CompositeChange compositeChangeB = new CompositeChange("B", sourceChangeB);
   MergeCompositeChange mergeChange =
       new MergeCompositeChange("My composite change", compositeChangeA, compositeChangeB);
   // toLTK
   org.eclipse.ltk.core.refactoring.Change ltkChange_ = ServiceUtils.toLTK(mergeChange);
   org.eclipse.ltk.core.refactoring.CompositeChange ltkChange =
       (org.eclipse.ltk.core.refactoring.CompositeChange) ltkChange_;
   assertEquals("My composite change", ltkChange.getName());
   org.eclipse.ltk.core.refactoring.Change[] ltkChanges = ltkChange.getChildren();
   assertThat(ltkChanges).hasSize(1);
   assertThat(ltkChanges[0]).isInstanceOf(CompilationUnitChange.class);
 }
Пример #4
0
 public void test_toLTK_Change_MergeCompositeChange() throws Exception {
   IFile testFile = testProject.setFileContent("test.dart", "012345");
   Source source = createFileSource(testFile);
   // fill SourceChange
   SourceChange sourceChangeA = new SourceChange("My change A", source);
   SourceChange sourceChangeB = new SourceChange("My change B", source);
   sourceChangeA.addEdit(new Edit(0, 0, "a"));
   sourceChangeB.addEdit(new Edit(2, 0, "b"));
   CompositeChange compositeChangeA = new CompositeChange("A", sourceChangeA);
   CompositeChange compositeChangeB = new CompositeChange("B", sourceChangeB);
   MergeCompositeChange mergeChange =
       new MergeCompositeChange("My composite change", compositeChangeA, compositeChangeB);
   // toLTK
   org.eclipse.ltk.core.refactoring.Change ltkChange_ = ServiceUtils.toLTK(mergeChange);
   org.eclipse.ltk.core.refactoring.CompositeChange ltkChange =
       (org.eclipse.ltk.core.refactoring.CompositeChange) ltkChange_;
   assertEquals("My composite change", ltkChange.getName());
   org.eclipse.ltk.core.refactoring.Change[] ltkChanges = ltkChange.getChildren();
   assertThat(ltkChanges).hasSize(2);
   //
   ltkChange.perform(NULL_PM);
   String newContent = testProject.getFileString(testFile);
   assertEquals("a01b2345", newContent);
 }