Search in sources :

Example 1 with MoveSettings

use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.MoveSettings 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();
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) RefactoringChange(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringChange) ChangePreview(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ChangePreview) ReorgDestination(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ReorgDestination) MoveSettings(org.eclipse.che.ide.ext.java.shared.dto.refactoring.MoveSettings) RefactoringPreview(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringPreview) IType(org.eclipse.jdt.core.IType) Test(org.junit.Test)

Example 2 with MoveSettings

use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.MoveSettings in project che by eclipse.

the class MoveRefactoringSessionTest method testCtrateMoveChanges.

@Test
public void testCtrateMoveChanges() 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);
    ChangeCreationResult change = manager.createChange(sessionId);
    assertThat(change).isNotNull();
    assertThat(change.isCanShowPreviewPage()).isTrue();
    assertThat(change.getStatus().getSeverity()).isEqualTo(RefactoringStatus.OK);
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) ChangeCreationResult(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ChangeCreationResult) ReorgDestination(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ReorgDestination) MoveSettings(org.eclipse.che.ide.ext.java.shared.dto.refactoring.MoveSettings) IType(org.eclipse.jdt.core.IType) Test(org.junit.Test)

Example 3 with MoveSettings

use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.MoveSettings in project che by eclipse.

the class MovePresenter method prepareMovingChanges.

private Promise<ChangeCreationResult> prepareMovingChanges(final RefactoringSession session) {
    MoveSettings moveSettings = dtoFactory.createDto(MoveSettings.class);
    moveSettings.setSessionId(refactoringSessionId);
    moveSettings.setUpdateReferences(view.isUpdateReferences());
    moveSettings.setUpdateQualifiedNames(view.isUpdateQualifiedNames());
    if (moveSettings.isUpdateQualifiedNames()) {
        moveSettings.setFilePatterns(view.getFilePatterns());
    }
    return refactorService.setMoveSettings(moveSettings).thenPromise(new Function<Void, Promise<ChangeCreationResult>>() {

        @Override
        public Promise<ChangeCreationResult> apply(Void arg) throws FunctionException {
            return refactorService.createChange(session);
        }
    });
}
Also used : Promise(org.eclipse.che.api.promises.client.Promise) FunctionException(org.eclipse.che.api.promises.client.FunctionException) MoveSettings(org.eclipse.che.ide.ext.java.shared.dto.refactoring.MoveSettings)

Example 4 with MoveSettings

use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.MoveSettings in project che by eclipse.

the class MoveRefactoringSessionTest method testApplyMove.

@Test
public void testApplyMove() 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);
    RefactoringStatus status = manager.applyRefactoring(sessionId);
    assertThat(status).isNotNull();
    assertThat(status.getSeverity()).isEqualTo(RefactoringStatus.OK);
    IType movedType = fProject.findType("p1.A");
    assertThat(movedType).isNotNull();
    assertThat(movedType.exists()).isTrue();
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) RefactoringStatus(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringStatus) ReorgDestination(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ReorgDestination) MoveSettings(org.eclipse.che.ide.ext.java.shared.dto.refactoring.MoveSettings) IType(org.eclipse.jdt.core.IType) Test(org.junit.Test)

Example 5 with MoveSettings

use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.MoveSettings in project che by eclipse.

the class MoveRefactoringSessionTest method testGetMoveChanges.

@Test
public void testGetMoveChanges() 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);
    assertThat(change).isNotNull();
    assertThat(change.getText()).isEqualTo("Move");
    assertThat(change.getChildrens()).isNotNull().hasSize(2);
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) ReorgDestination(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ReorgDestination) MoveSettings(org.eclipse.che.ide.ext.java.shared.dto.refactoring.MoveSettings) RefactoringPreview(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringPreview) IType(org.eclipse.jdt.core.IType) Test(org.junit.Test)

Aggregations

MoveSettings (org.eclipse.che.ide.ext.java.shared.dto.refactoring.MoveSettings)5 ReorgDestination (org.eclipse.che.ide.ext.java.shared.dto.refactoring.ReorgDestination)4 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)4 IType (org.eclipse.jdt.core.IType)4 Test (org.junit.Test)4 RefactoringPreview (org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringPreview)2 FunctionException (org.eclipse.che.api.promises.client.FunctionException)1 Promise (org.eclipse.che.api.promises.client.Promise)1 ChangeCreationResult (org.eclipse.che.ide.ext.java.shared.dto.refactoring.ChangeCreationResult)1 ChangePreview (org.eclipse.che.ide.ext.java.shared.dto.refactoring.ChangePreview)1 RefactoringChange (org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringChange)1 RefactoringStatus (org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringStatus)1