use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameSettings in project che by eclipse.
the class RenameRefactoringTest method testDoRename.
@Test
public void testDoRename() throws Exception {
StringBuilder b = new StringBuilder();
b.append("package p;\n");
b.append("public class A{}\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");
manager.renameValidateNewName(validateNewName);
RenameSettings settings = new DtoServerImpls.RenameSettingsImpl();
settings.setSessionId(refactoring.getSessionId());
settings.setDeprecateDelegates(true);
settings.setUpdateReferences(true);
manager.setRenameSettings(settings);
ChangeCreationResult change = manager.createChange(refactoring.getSessionId());
assertThat(change).isNotNull();
RefactoringStatus applyRefactoring = manager.applyRefactoring(refactoring.getSessionId());
assertThat(applyRefactoring).isNotNull();
assertThat(applyRefactoring.getSeverity()).isEqualTo(RefactoringStatus.OK);
assertThat(unit.exists()).isFalse();
ICompilationUnit newUnit = getPackageP().getCompilationUnit("MyClass.java");
assertThat(newUnit.exists()).isTrue();
}
use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameSettings in project che by eclipse.
the class RenamePresenter method createRenameSettingsDto.
private RenameSettings createRenameSettingsDto(RefactoringSession session) {
RenameSettings renameSettings = dtoFactory.createDto(RenameSettings.class);
renameSettings.setSessionId(session.getSessionId());
renameSettings.setDelegateUpdating(view.isUpdateDelegateUpdating());
if (view.isUpdateDelegateUpdating()) {
renameSettings.setDeprecateDelegates(view.isUpdateMarkDeprecated());
}
renameSettings.setUpdateSubpackages(view.isUpdateSubpackages());
renameSettings.setUpdateReferences(view.isUpdateReferences());
renameSettings.setUpdateQualifiedNames(view.isUpdateQualifiedNames());
if (view.isUpdateQualifiedNames()) {
renameSettings.setFilePatterns(view.getFilePatterns());
}
renameSettings.setUpdateTextualMatches(view.isUpdateTextualOccurrences());
renameSettings.setUpdateSimilarDeclarations(view.isUpdateSimilarlyVariables());
if (view.isUpdateSimilarlyVariables()) {
renameSettings.setMachStrategy(similarNamesConfigurationPresenter.getMachStrategy().getValue());
}
return renameSettings;
}
Aggregations