use of org.eclipse.jdt.core.refactoring.descriptors.RenameJavaElementDescriptor in project eclipse.jdt.ls by eclipse.
the class RenamePackageProcessor method createRefactoringDescriptor.
private RenameJavaElementDescriptor createRefactoringDescriptor() {
String project = null;
IJavaProject javaProject = fPackage.getJavaProject();
if (javaProject != null) {
project = javaProject.getElementName();
}
final int flags = JavaRefactoringDescriptor.JAR_MIGRATION | JavaRefactoringDescriptor.JAR_REFACTORING | RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE;
final String description = Messages.format(RefactoringCoreMessages.RenamePackageProcessor_descriptor_description_short, getElementLabel(fPackage));
final String header = Messages.format(RefactoringCoreMessages.RenamePackageProcessor_descriptor_description, new String[] { getElementLabel(fPackage), getNewElementName() });
final JDTRefactoringDescriptorComment comment = new JDTRefactoringDescriptorComment(project, this, header);
if (fRenameSubpackages) {
comment.addSetting(RefactoringCoreMessages.RenamePackageProcessor_rename_subpackages);
}
final RenameJavaElementDescriptor descriptor = RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(IJavaRefactorings.RENAME_PACKAGE);
descriptor.setProject(project);
descriptor.setDescription(description);
descriptor.setComment(comment.asString());
descriptor.setFlags(flags);
descriptor.setJavaElement(fPackage);
descriptor.setNewName(getNewElementName());
descriptor.setUpdateReferences(fUpdateReferences);
descriptor.setUpdateTextualOccurrences(fUpdateTextualMatches);
descriptor.setUpdateQualifiedNames(fUpdateQualifiedNames);
if (fUpdateQualifiedNames && fFilePatterns != null && !"".equals(fFilePatterns)) {
descriptor.setFileNamePatterns(fFilePatterns);
}
descriptor.setUpdateHierarchy(fRenameSubpackages);
return descriptor;
}
use of org.eclipse.jdt.core.refactoring.descriptors.RenameJavaElementDescriptor in project eclipse.jdt.ls by eclipse.
the class RenamePackageProcessor method createChange.
@Override
public Change createChange(IProgressMonitor monitor) throws CoreException {
try {
monitor.beginTask(RefactoringCoreMessages.RenamePackageRefactoring_creating_change, 1);
final RenameJavaElementDescriptor descriptor = createRefactoringDescriptor();
final DynamicValidationRefactoringChange result = new DynamicValidationRefactoringChange(descriptor, RefactoringCoreMessages.RenamePackageRefactoring_change_name);
result.addAll(fChangeManager.getAllChanges());
fRenamePackageChange = new RenamePackageChange(fPackage, getNewElementName(), fRenameSubpackages);
result.add(fRenamePackageChange);
monitor.worked(1);
return result;
} finally {
fChangeManager = null;
fImportsManager = null;
monitor.done();
}
}
use of org.eclipse.jdt.core.refactoring.descriptors.RenameJavaElementDescriptor in project eclipse.jdt.ls by eclipse.
the class RenameLocalVariableProcessor method createRefactoringDescriptor.
private RenameJavaElementDescriptor createRefactoringDescriptor() {
String project = null;
IJavaProject javaProject = fCu.getJavaProject();
if (javaProject != null) {
project = javaProject.getElementName();
}
final String header = Messages.format(RefactoringCoreMessages.RenameLocalVariableProcessor_descriptor_description, new String[] { BasicElementLabels.getJavaElementName(fCurrentName), JavaElementLabels.getElementLabel(fLocalVariable.getParent(), JavaElementLabels.ALL_FULLY_QUALIFIED), BasicElementLabels.getJavaElementName(fNewName) });
final String description = Messages.format(RefactoringCoreMessages.RenameLocalVariableProcessor_descriptor_description_short, BasicElementLabels.getJavaElementName(fCurrentName));
final String comment = new JDTRefactoringDescriptorComment(project, this, header).asString();
final RenameJavaElementDescriptor descriptor = RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(IJavaRefactorings.RENAME_LOCAL_VARIABLE);
descriptor.setProject(project);
descriptor.setDescription(description);
descriptor.setComment(comment);
descriptor.setFlags(RefactoringDescriptor.NONE);
descriptor.setJavaElement(fLocalVariable);
descriptor.setNewName(getNewElementName());
descriptor.setUpdateReferences(fUpdateReferences);
return descriptor;
}
use of org.eclipse.jdt.core.refactoring.descriptors.RenameJavaElementDescriptor in project eclipse.jdt.ui by eclipse-jdt.
the class RenameSourceFolderProcessor method createChange.
@Override
public Change createChange(IProgressMonitor monitor) throws CoreException {
monitor.beginTask(RefactoringCoreMessages.RenameTypeRefactoring_creating_change, 1);
try {
final IResource resource = fSourceFolder.getResource();
final String project = resource.getProject().getName();
final String newName = getNewElementName();
final String description = Messages.format(RefactoringCoreMessages.RenameSourceFolderChange_descriptor_description_short, JavaElementLabels.getElementLabel(fSourceFolder, JavaElementLabels.ALL_DEFAULT));
final String header = Messages.format(RefactoringCoreMessages.RenameSourceFolderChange_descriptor_description, new String[] { BasicElementLabels.getPathLabel(resource.getFullPath(), false), BasicElementLabels.getJavaElementName(newName) });
final String comment = new JDTRefactoringDescriptorComment(project, this, header).asString();
final RenameJavaElementDescriptor descriptor = RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(IJavaRefactorings.RENAME_SOURCE_FOLDER);
descriptor.setProject(project);
descriptor.setDescription(description);
descriptor.setComment(comment);
descriptor.setFlags(RefactoringDescriptor.NONE);
descriptor.setJavaElement(fSourceFolder);
descriptor.setNewName(newName);
return new DynamicValidationRefactoringChange(descriptor, RefactoringCoreMessages.RenameSourceFolderRefactoring_rename, new Change[] { new RenameSourceFolderChange(fSourceFolder, newName) });
} finally {
monitor.done();
}
}
use of org.eclipse.jdt.core.refactoring.descriptors.RenameJavaElementDescriptor in project eclipse.jdt.ui by eclipse-jdt.
the class RenameLinkedMode method undoAndCreateRenameSupport.
private RenameSupport undoAndCreateRenameSupport(String newName) throws CoreException {
// Assumption: the linked mode model should be shut down by now.
final ISourceViewer viewer = fEditor.getViewer();
try {
if (!fOriginalName.equals(newName)) {
fEditor.getSite().getWorkbenchWindow().run(false, true, monitor -> {
if (viewer instanceof ITextViewerExtension6) {
IUndoManager undoManager = ((ITextViewerExtension6) viewer).getUndoManager();
if (undoManager instanceof IUndoManagerExtension) {
IUndoManagerExtension undoManagerExtension = (IUndoManagerExtension) undoManager;
IUndoContext undoContext = undoManagerExtension.getUndoContext();
IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory();
while (undoManager.undoable()) {
if (fStartingUndoOperation != null && fStartingUndoOperation.equals(operationHistory.getUndoOperation(undoContext)))
return;
undoManager.undo();
}
}
}
});
}
} catch (InvocationTargetException e) {
throw new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), ReorgMessages.RenameLinkedMode_error_saving_editor, e));
} catch (InterruptedException e) {
// canceling is OK
return null;
} finally {
JavaModelUtil.reconcile(getCompilationUnit());
}
viewer.setSelectedRange(fOriginalSelection.x, fOriginalSelection.y);
if (newName.length() == 0)
return null;
RenameJavaElementDescriptor descriptor = createRenameDescriptor(fJavaElement, newName);
RenameSupport renameSupport = RenameSupport.create(descriptor);
return renameSupport;
}
Aggregations