use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringChange in project che by eclipse.
the class MoveRefactoringSessionTest method testPreviewChanges.
@Test
public void testPreviewChanges() throws Exception {
IType type = fProject.findType("p.A");
ICompilationUnit unit = type.getCompilationUnit();
String sessionId = manager.createMoveRefactoringSession(new IJavaElement[] { unit });
ReorgDestination destination = new DtoServerImpls.ReorgDestinationImpl();
destination.setSessionId(sessionId);
destination.setProjectPath(RefactoringTestSetup.getProject().getPath().toOSString());
destination.setDestination(p1.getPath().toOSString());
destination.setType(ReorgDestination.DestinationType.PACKAGE);
manager.setRefactoringDestination(destination);
MoveSettings settings = new DtoServerImpls.MoveSettingsImpl();
settings.setUpdateReferences(true);
settings.setSessionId(sessionId);
manager.setMoveSettings(settings);
manager.createChange(sessionId);
RefactoringPreview change = manager.getRefactoringPreview(sessionId);
RefactoringChange change1 = new DtoServerImpls.ChangeEnabledStateImpl();
change1.setSessionId(sessionId);
change1.setChangeId(change.getChildrens().get(0).getId());
ChangePreview preview = manager.getChangePreview(change1);
assertThat(preview).isNotNull();
assertThat(preview.getFileName()).isNotNull().isNotEmpty();
assertThat(preview.getOldContent()).isNotNull().isNotEmpty();
assertThat(preview.getNewContent()).isNotNull().isNotEmpty();
}
use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringChange in project che by eclipse.
the class RenameRefactoringTest method testRenamePreviewChanges.
@Test
public void testRenamePreviewChanges() throws Exception {
StringBuilder b = new StringBuilder();
b.append("package p;\n");
b.append("public class A{\n private A a; \n}\n");
ICompilationUnit unit = getPackageP().createCompilationUnit("A.java", b.toString(), false, null);
IType type = unit.getAllTypes()[0];
RenameRefactoringSession refactoring = manager.createRenameRefactoring(type, unit, b.indexOf("A"), false);
DtoServerImpls.ValidateNewNameImpl validateNewName = new DtoServerImpls.ValidateNewNameImpl();
validateNewName.setSessionId(refactoring.getSessionId());
validateNewName.setNewName("MyClass");
RefactoringStatus status = manager.renameValidateNewName(validateNewName);
manager.createChange(refactoring.getSessionId());
RefactoringPreview preview = manager.getRefactoringPreview(refactoring.getSessionId());
RefactoringChange change1 = new DtoServerImpls.ChangeEnabledStateImpl();
change1.setSessionId(refactoring.getSessionId());
change1.setChangeId(preview.getChildrens().get(0).getId());
ChangePreview changePreview = manager.getChangePreview(change1);
assertThat(changePreview).isNotNull();
assertThat(changePreview.getFileName()).isNotNull().isNotEmpty();
assertThat(changePreview.getOldContent()).isNotNull().isNotEmpty();
assertThat(changePreview.getNewContent()).isNotNull().isNotEmpty();
assertThat(changePreview.getNewContent()).isNotEqualTo(changePreview.getOldContent());
}
use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringChange in project che by eclipse.
the class PreviewPresenter method onSelectionChanged.
/** {@inheritDoc} */
@Override
public void onSelectionChanged(RefactoringPreview change) {
RefactoringChange refactoringChanges = dtoFactory.createDto(RefactoringChange.class);
refactoringChanges.setChangeId(change.getId());
refactoringChanges.setSessionId(session.getSessionId());
Promise<ChangePreview> changePreviewPromise = refactoringService.getChangePreview(refactoringChanges);
changePreviewPromise.then(new Operation<ChangePreview>() {
@Override
public void apply(ChangePreview arg) throws OperationException {
view.showDiff(arg);
}
});
}
Aggregations