use of org.eclipse.ltk.core.refactoring.RefactoringTickProvider in project eclipse.jdt.ls by eclipse.
the class FileEventHandler method getRenameEdit.
private static WorkspaceEdit getRenameEdit(IJavaElement targetElement, String newName, IProgressMonitor monitor) throws CoreException {
RenameSupport renameSupport = RenameSupport.create(targetElement, newName, RenameSupport.UPDATE_REFERENCES);
if (renameSupport == null) {
return null;
}
if (targetElement instanceof IPackageFragment) {
((RenamePackageProcessor) renameSupport.getJavaRenameProcessor()).setRenameSubpackages(true);
}
RenameRefactoring renameRefactoring = renameSupport.getRenameRefactoring();
RefactoringTickProvider rtp = renameRefactoring.getRefactoringTickProvider();
SubMonitor submonitor = SubMonitor.convert(monitor, "Creating rename changes...", rtp.getAllTicks());
CheckConditionsOperation checkConditionOperation = new CheckConditionsOperation(renameRefactoring, CheckConditionsOperation.ALL_CONDITIONS);
checkConditionOperation.run(submonitor.split(rtp.getCheckAllConditionsTicks()));
if (checkConditionOperation.getStatus().getSeverity() >= RefactoringStatus.FATAL) {
JavaLanguageServerPlugin.logError(checkConditionOperation.getStatus().getMessageMatchingSeverity(RefactoringStatus.ERROR));
}
Change change = renameRefactoring.createChange(submonitor.split(rtp.getCreateChangeTicks()));
change.initializeValidationData(new NotCancelableProgressMonitor(submonitor.split(rtp.getInitializeChangeTicks())));
return ChangeUtil.convertToWorkspaceEdit(change);
}
Aggregations