Search in sources :

Example 1 with RenameSettings

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();
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) DtoServerImpls(org.eclipse.che.plugin.java.server.dto.DtoServerImpls) RefactoringStatus(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringStatus) RenameSettings(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameSettings) ChangeCreationResult(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ChangeCreationResult) RenameRefactoringSession(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameRefactoringSession) IType(org.eclipse.jdt.core.IType) Test(org.junit.Test)

Example 2 with RenameSettings

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;
}
Also used : RenameSettings(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameSettings)

Aggregations

RenameSettings (org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameSettings)2 ChangeCreationResult (org.eclipse.che.ide.ext.java.shared.dto.refactoring.ChangeCreationResult)1 RefactoringStatus (org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringStatus)1 RenameRefactoringSession (org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameRefactoringSession)1 DtoServerImpls (org.eclipse.che.plugin.java.server.dto.DtoServerImpls)1 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)1 IType (org.eclipse.jdt.core.IType)1 Test (org.junit.Test)1