use of org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationRefactoringChange in project che by eclipse.
the class ReplaceInvocationsRefactoring method createChange.
@Override
public Change createChange(IProgressMonitor pm) throws CoreException {
// TODO: update for fSelectionStart == -1
final Map<String, String> arguments = new HashMap<String, String>();
String project = null;
IJavaProject javaProject = fSelectionTypeRoot.getJavaProject();
if (javaProject != null)
project = javaProject.getElementName();
final IMethodBinding binding = fSourceProvider.getDeclaration().resolveBinding();
int flags = RefactoringDescriptor.STRUCTURAL_CHANGE | JavaRefactoringDescriptor.JAR_REFACTORING | JavaRefactoringDescriptor.JAR_SOURCE_ATTACHMENT;
if (!Modifier.isPrivate(binding.getModifiers()))
flags |= RefactoringDescriptor.MULTI_CHANGE;
final String description = Messages.format(RefactoringCoreMessages.ReplaceInvocationsRefactoring_descriptor_description_short, BasicElementLabels.getJavaElementName(binding.getName()));
final String header = Messages.format(RefactoringCoreMessages.ReplaceInvocationsRefactoring_descriptor_description, new String[] { BindingLabelProvider.getBindingLabel(binding, JavaElementLabels.ALL_FULLY_QUALIFIED), BindingLabelProvider.getBindingLabel(binding.getDeclaringClass(), JavaElementLabels.ALL_FULLY_QUALIFIED) });
final JDTRefactoringDescriptorComment comment = new JDTRefactoringDescriptorComment(project, this, header);
comment.addSetting(Messages.format(RefactoringCoreMessages.ReplaceInvocationsRefactoring_original_pattern, BindingLabelProvider.getBindingLabel(binding, JavaElementLabels.ALL_FULLY_QUALIFIED)));
if (!fTargetProvider.isSingle())
comment.addSetting(RefactoringCoreMessages.ReplaceInvocationsRefactoring_replace_references);
//REVIEW Unregistered ID!
final JavaRefactoringDescriptor descriptor = new JavaRefactoringDescriptor(ID_REPLACE_INVOCATIONS, project, description, comment.asString(), arguments, flags) {
};
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT, JavaRefactoringDescriptorUtil.elementToHandle(project, fSelectionTypeRoot));
//$NON-NLS-1$
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, new Integer(fSelectionStart).toString() + " " + new Integer(fSelectionLength).toString());
arguments.put(ATTRIBUTE_MODE, new Integer(fTargetProvider.isSingle() ? 0 : 1).toString());
return new DynamicValidationRefactoringChange(descriptor, RefactoringCoreMessages.ReplaceInvocationsRefactoring_change_name, fChangeManager.getAllChanges());
}
use of org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationRefactoringChange in project che by eclipse.
the class RenameCompilationUnitProcessor method createChange.
@Override
public Change createChange(IProgressMonitor pm) throws CoreException {
// renaming the file is taken care of in renameTypeRefactoring
if (fWillRenameType)
return fRenameTypeProcessor.createChange(pm);
fRenameTypeProcessor = null;
final String newName = getNewElementName();
final IResource resource = fCu.getResource();
if (resource != null && resource.isLinked()) {
final IProject project = resource.getProject();
final String name = project.getName();
final String description = Messages.format(RefactoringCoreMessages.RenameCompilationUnitChange_descriptor_description_short, BasicElementLabels.getResourceName(resource.getName()));
final String header = Messages.format(RefactoringCoreMessages.RenameCompilationUnitChange_descriptor_description, new String[] { BasicElementLabels.getPathLabel(resource.getFullPath(), false), BasicElementLabels.getResourceName(resource.getName()) });
final String comment = new JDTRefactoringDescriptorComment(name, this, header).asString();
final int flags = RefactoringDescriptor.STRUCTURAL_CHANGE;
final RenameResourceDescriptor descriptor = (RenameResourceDescriptor) RefactoringCore.getRefactoringContribution(RenameResourceDescriptor.ID).createDescriptor();
descriptor.setProject(name);
descriptor.setDescription(description);
descriptor.setComment(comment);
descriptor.setFlags(flags);
descriptor.setResourcePath(resource.getFullPath());
descriptor.setNewName(newName);
RenameResourceChange resourceChange = new RenameResourceChange(resource.getFullPath(), newName);
resourceChange.setDescriptor(new RefactoringChangeDescriptor(descriptor));
return new DynamicValidationStateChange(resourceChange);
}
String label = JavaElementLabels.getTextLabel(fCu, JavaElementLabels.ALL_FULLY_QUALIFIED);
final String name = fCu.getJavaProject().getElementName();
final String description = Messages.format(RefactoringCoreMessages.RenameCompilationUnitChange_descriptor_description_short, BasicElementLabels.getFileName(fCu));
final String header = Messages.format(RefactoringCoreMessages.RenameCompilationUnitChange_descriptor_description, new String[] { label, BasicElementLabels.getResourceName(newName) });
final String comment = new JDTRefactoringDescriptorComment(name, this, header).asString();
final int flags = RefactoringDescriptor.STRUCTURAL_CHANGE;
final RenameJavaElementDescriptor descriptor = RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(IJavaRefactorings.RENAME_COMPILATION_UNIT);
descriptor.setProject(name);
descriptor.setDescription(description);
descriptor.setComment(comment);
descriptor.setFlags(flags);
descriptor.setJavaElement(fCu);
descriptor.setNewName(newName);
return new DynamicValidationRefactoringChange(descriptor, RefactoringCoreMessages.RenameCompilationUnitRefactoring_name, new Change[] { new RenameCompilationUnitChange(fCu, newName) });
}
use of org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationRefactoringChange in project che by eclipse.
the class RenameFieldProcessor method createChange.
@Override
public Change createChange(IProgressMonitor monitor) throws CoreException {
try {
monitor.beginTask(RefactoringCoreMessages.RenameFieldRefactoring_checking, 1);
TextChange[] changes = fChangeManager.getAllChanges();
RenameJavaElementDescriptor descriptor = createRefactoringDescriptor();
return new DynamicValidationRefactoringChange(descriptor, getProcessorName(), changes);
} finally {
monitor.done();
}
}
use of org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationRefactoringChange in project che 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.internal.corext.refactoring.changes.DynamicValidationRefactoringChange in project che by eclipse.
the class RenameTypeParameterProcessor method createChange.
@Override
public Change createChange(IProgressMonitor monitor) throws CoreException, OperationCanceledException {
Assert.isNotNull(monitor);
try {
Change change = fChange;
if (change != null) {
String project = null;
IJavaProject javaProject = fTypeParameter.getJavaProject();
if (javaProject != null)
project = javaProject.getElementName();
String description = Messages.format(RefactoringCoreMessages.RenameTypeParameterProcessor_descriptor_description_short, BasicElementLabels.getJavaElementName(fTypeParameter.getElementName()));
String header = Messages.format(RefactoringCoreMessages.RenameTypeParameterProcessor_descriptor_description, new String[] { BasicElementLabels.getJavaElementName(fTypeParameter.getElementName()), JavaElementLabels.getElementLabel(fTypeParameter.getDeclaringMember(), JavaElementLabels.ALL_FULLY_QUALIFIED), BasicElementLabels.getJavaElementName(getNewElementName()) });
String comment = new JDTRefactoringDescriptorComment(project, this, header).asString();
RenameJavaElementDescriptor descriptor = RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(IJavaRefactorings.RENAME_TYPE_PARAMETER);
descriptor.setProject(project);
descriptor.setDescription(description);
descriptor.setComment(comment);
descriptor.setFlags(RefactoringDescriptor.NONE);
descriptor.setJavaElement(fTypeParameter);
descriptor.setNewName(getNewElementName());
descriptor.setUpdateReferences(fUpdateReferences);
change = new DynamicValidationRefactoringChange(descriptor, RefactoringCoreMessages.RenameTypeParameterProcessor_change_name, new Change[] { change });
}
return change;
} finally {
fChange = null;
monitor.done();
}
}
Aggregations