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);
}
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);
}
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.");
}
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());
}
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;
}
Aggregations