Search in sources :

Example 1 with RefactoringSession

use of org.eclipse.che.plugin.java.server.refactoring.session.RefactoringSession in project che by eclipse.

the class RefactoringManager method getRefactoringPreview.

/**
     * Get refactoring preview tree.
     *
     * @param sessionId
     *         id of the refactoring session
     * @return refactoring preview
     * @throws RefactoringException
     *         when refactoring session not found.
     */
public RefactoringPreview getRefactoringPreview(String sessionId) throws RefactoringException {
    RefactoringSession session = getRefactoringSession(sessionId);
    PreviewNode node = session.getChangePreview();
    return DtoConverter.toRefactoringPreview(node);
}
Also used : MoveRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.MoveRefactoringSession) RenameLinkedModeRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.RenameLinkedModeRefactoringSession) ReorgRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.ReorgRefactoringSession) RefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.RefactoringSession) RenameRefactoringSession(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameRefactoringSession) PreviewNode(org.eclipse.ltk.internal.ui.refactoring.PreviewNode)

Example 2 with RefactoringSession

use of org.eclipse.che.plugin.java.server.refactoring.session.RefactoringSession in project che by eclipse.

the class RefactoringManager method setRefactoringDestination.

public RefactoringStatus setRefactoringDestination(ReorgDestination destination) throws RefactoringException, JavaModelException {
    RefactoringSession session = getRefactoringSession(destination.getSessionId());
    if (!(session instanceof ReorgRefactoringSession)) {
        throw new RefactoringException("Can't set destination on none reorg refactoring session.");
    }
    ReorgRefactoringSession rs = ((ReorgRefactoringSession) session);
    Object dest = getDestination(destination.getProjectPath(), destination.getType(), destination.getDestination());
    org.eclipse.ltk.core.refactoring.RefactoringStatus refactoringStatus = rs.verifyDestination(dest);
    return DtoConverter.toRefactoringStatusDto(refactoringStatus);
}
Also used : ReorgRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.ReorgRefactoringSession) MoveRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.MoveRefactoringSession) RenameLinkedModeRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.RenameLinkedModeRefactoringSession) ReorgRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.ReorgRefactoringSession) RefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.RefactoringSession) RenameRefactoringSession(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameRefactoringSession)

Example 3 with RefactoringSession

use of org.eclipse.che.plugin.java.server.refactoring.session.RefactoringSession in project che by eclipse.

the class RefactoringManager method applyLinkedRename.

/**
     * Apply linked mode rename refactoring.
     *
     * @param apply
     *         contains new element name
     * @return refactoring result
     * @throws RefactoringException
     *         when refactoring session not found.
     * @throws CoreException
     *         when impossible to apply rename refactoring
     */
public RefactoringResult applyLinkedRename(LinkedRenameRefactoringApply apply) throws RefactoringException, CoreException {
    RefactoringSession session = getRefactoringSession(apply.getSessionId());
    if (session instanceof RenameLinkedModeRefactoringSession) {
        RenameLinkedModeRefactoringSession renameSession = (RenameLinkedModeRefactoringSession) session;
        try {
            RefactoringResult refactoringResult = renameSession.doRename(apply.getNewName());
            deleteRefactoringSession(apply.getSessionId());
            return refactoringResult;
        } catch (InvocationTargetException | InterruptedException | AssertionFailedException e) {
            LOG.error(e.getMessage(), e);
            return DtoConverter.toRefactoringResultDto(org.eclipse.ltk.core.refactoring.RefactoringStatus.createFatalErrorStatus(e.getMessage()));
        }
    }
    throw new RefactoringException("There is no RenameLinkedModeRefactoringSession.");
}
Also used : RefactoringResult(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringResult) RenameLinkedModeRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.RenameLinkedModeRefactoringSession) MoveRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.MoveRefactoringSession) RenameLinkedModeRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.RenameLinkedModeRefactoringSession) ReorgRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.ReorgRefactoringSession) RefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.RefactoringSession) RenameRefactoringSession(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameRefactoringSession) AssertionFailedException(org.eclipse.core.runtime.AssertionFailedException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 4 with RefactoringSession

use of org.eclipse.che.plugin.java.server.refactoring.session.RefactoringSession in project che by eclipse.

the class RefactoringManager method setMoveSettings.

/**
     * Sets move refactoring settings.
     * update references, update qualified names, files pattern
     *
     * @param settings
     *         the move refactoring settings
     * @throws RefactoringException
     *         when move refactoring session not found.
     */
public void setMoveSettings(MoveSettings settings) throws RefactoringException {
    RefactoringSession session = getRefactoringSession(settings.getSessionId());
    if (!(session instanceof MoveRefactoringSession)) {
        throw new RefactoringException("Can't set move on none move refactoring session.");
    }
    MoveRefactoringSession refactoring = ((MoveRefactoringSession) session);
    refactoring.setUpdateReferences(settings.isUpdateReferences());
    if (settings.isUpdateQualifiedNames()) {
        refactoring.setFilePatterns(settings.getFilePatterns());
    }
    refactoring.setUpdateQualifiedNames(settings.isUpdateQualifiedNames());
}
Also used : MoveRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.MoveRefactoringSession) RenameLinkedModeRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.RenameLinkedModeRefactoringSession) ReorgRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.ReorgRefactoringSession) RefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.RefactoringSession) RenameRefactoringSession(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameRefactoringSession) MoveRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.MoveRefactoringSession)

Example 5 with RefactoringSession

use of org.eclipse.che.plugin.java.server.refactoring.session.RefactoringSession in project che by eclipse.

the class RefactoringManager method applyRefactoring.

/**
     * Apply refactoring.
     *
     * @param sessionId
     *         id of the refactoring session
     * @return refactoring result
     * @throws RefactoringException
     *         when refactoring session not found.
     */
public RefactoringResult applyRefactoring(String sessionId) throws RefactoringException {
    RefactoringSession session = getRefactoringSession(sessionId);
    RefactoringResult result = session.apply();
    deleteRefactoringSession(sessionId);
    return result;
}
Also used : RefactoringResult(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringResult) MoveRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.MoveRefactoringSession) RenameLinkedModeRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.RenameLinkedModeRefactoringSession) ReorgRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.ReorgRefactoringSession) RefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.RefactoringSession) RenameRefactoringSession(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameRefactoringSession)

Aggregations

RenameRefactoringSession (org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameRefactoringSession)7 MoveRefactoringSession (org.eclipse.che.plugin.java.server.refactoring.session.MoveRefactoringSession)7 RefactoringSession (org.eclipse.che.plugin.java.server.refactoring.session.RefactoringSession)7 RenameLinkedModeRefactoringSession (org.eclipse.che.plugin.java.server.refactoring.session.RenameLinkedModeRefactoringSession)7 ReorgRefactoringSession (org.eclipse.che.plugin.java.server.refactoring.session.ReorgRefactoringSession)7 RefactoringResult (org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringResult)2 PreviewNode (org.eclipse.ltk.internal.ui.refactoring.PreviewNode)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 AssertionFailedException (org.eclipse.core.runtime.AssertionFailedException)1 CoreException (org.eclipse.core.runtime.CoreException)1 ChangePreviewViewerDescriptor (org.eclipse.ltk.internal.ui.refactoring.ChangePreviewViewerDescriptor)1 IChangePreviewViewer (org.eclipse.ltk.ui.refactoring.IChangePreviewViewer)1