@Override public Refactoring createRefactoring(final RefactoringStatus status) throws CoreException { Refactoring refactoring= null; final String id= getID(); final RefactoringContribution contribution= RefactoringCore.getRefactoringContribution(id); if (contribution != null) { if (contribution instanceof JavaRefactoringContribution) { JavaRefactoringContribution javaContribution= (JavaRefactoringContribution) contribution; refactoring= javaContribution.createRefactoring(this, status); } else JavaManipulationPlugin.log(new Status(IStatus.ERROR, JavaManipulationPlugin.getPluginId(), 0, MessageFormat.format(DescriptorMessages.JavaRefactoringDescriptor_no_resulting_descriptor, new Object[] { id}), null)); } return refactoring; }
RefactoringContribution contribution= RefactoringCore.getRefactoringContribution(javaDescriptor.getID());
RefactoringContribution contribution= RefactoringCore.getRefactoringContribution(javaDescriptor.getID());
@Override public Refactoring createRefactoring(JavaRefactoringDescriptor javaDescriptor, RefactoringStatus status) throws CoreException { if (javaDescriptor instanceof RenameResourceDescriptor) { RenameResourceDescriptor descriptor= (RenameResourceDescriptor) javaDescriptor; // use the LTK RenameResourceDescriptor to create the refactoring RefactoringContribution newContribution= RefactoringCore.getRefactoringContribution(org.eclipse.ltk.core.refactoring.resource.RenameResourceDescriptor.ID); if (newContribution != null) { RefactoringDescriptor ltkDescriptor= newContribution.createDescriptor(); if (ltkDescriptor instanceof org.eclipse.ltk.core.refactoring.resource.RenameResourceDescriptor) { ((org.eclipse.ltk.core.refactoring.resource.RenameResourceDescriptor) ltkDescriptor).setNewName(descriptor.getNewName()); ((org.eclipse.ltk.core.refactoring.resource.RenameResourceDescriptor) ltkDescriptor).setResourcePath(descriptor.getResourcePath()); return ltkDescriptor.createRefactoring(status); } } status.addFatalError(DescriptorMessages.RenameResourceRefactoringContribution_error_cannot_access); } return null; }
private IntroduceParameterDescriptor getRefactoringDescriptor() { ChangeMethodSignatureDescriptor extended= (ChangeMethodSignatureDescriptor) fChangeSignatureProcessor.createDescriptor(); RefactoringContribution contribution= RefactoringCore.getRefactoringContribution(IJavaRefactorings.CHANGE_METHOD_SIGNATURE); Map<String, String> argumentsMap= contribution.retrieveArgumentMap(extended); final Map<String, String> arguments= new HashMap<>(); arguments.put(ATTRIBUTE_ARGUMENT, fParameter.getNewName()); arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, Integer.valueOf(fSelectionStart).toString() + " " + Integer.valueOf(fSelectionLength).toString()); //$NON-NLS-1$ arguments.putAll(argumentsMap); String signature= fChangeSignatureProcessor.getMethodName(); try { signature= fChangeSignatureProcessor.getOldMethodSignature(); } catch (JavaModelException exception) { JavaPlugin.log(exception); } final String description= Messages.format(RefactoringCoreMessages.IntroduceParameterRefactoring_descriptor_description_short, BasicElementLabels.getJavaElementName(fChangeSignatureProcessor.getMethod().getElementName())); final String header= Messages.format(RefactoringCoreMessages.IntroduceParameterRefactoring_descriptor_description, new String[] { BasicElementLabels.getJavaElementName(fParameter.getNewName()), signature, BasicElementLabels.getJavaCodeString(ASTNodes.asString(fSelectedExpression))}); final JDTRefactoringDescriptorComment comment= new JDTRefactoringDescriptorComment(extended.getProject(), this, header); comment.addSetting(Messages.format(RefactoringCoreMessages.IntroduceParameterRefactoring_original_pattern, JavaElementLabels.getTextLabel(fChangeSignatureProcessor.getMethod(), JavaElementLabels.ALL_FULLY_QUALIFIED))); comment.addSetting(Messages.format(RefactoringCoreMessages.IntroduceParameterRefactoring_expression_pattern, BasicElementLabels.getJavaCodeString(ASTNodes.asString(fSelectedExpression)))); comment.addSetting(Messages.format(RefactoringCoreMessages.IntroduceParameterRefactoring_parameter_pattern, BasicElementLabels.getJavaElementName(getAddedParameterInfo().getNewName()))); return RefactoringSignatureDescriptorFactory.createIntroduceParameterDescriptor(extended.getProject(), description, comment.asString(), arguments, extended.getFlags()); }
private IntroduceParameterDescriptor getRefactoringDescriptor() { ChangeMethodSignatureDescriptor extended= (ChangeMethodSignatureDescriptor) fChangeSignatureProcessor.createDescriptor(); RefactoringContribution contribution= RefactoringCore.getRefactoringContribution(IJavaRefactorings.CHANGE_METHOD_SIGNATURE); Map<String, String> argumentsMap= contribution.retrieveArgumentMap(extended); final Map<String, String> arguments= new HashMap<>(); arguments.put(ATTRIBUTE_ARGUMENT, fParameter.getNewName()); arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, new Integer(fSelectionStart).toString() + " " + new Integer(fSelectionLength).toString()); //$NON-NLS-1$ arguments.putAll(argumentsMap); String signature= fChangeSignatureProcessor.getMethodName(); try { signature= fChangeSignatureProcessor.getOldMethodSignature(); } catch (JavaModelException exception) { JavaPlugin.log(exception); } final String description= Messages.format(RefactoringCoreMessages.IntroduceParameterRefactoring_descriptor_description_short, BasicElementLabels.getJavaElementName(fChangeSignatureProcessor.getMethod().getElementName())); final String header= Messages.format(RefactoringCoreMessages.IntroduceParameterRefactoring_descriptor_description, new String[] { BasicElementLabels.getJavaElementName(fParameter.getNewName()), signature, BasicElementLabels.getJavaCodeString(ASTNodes.asString(fSelectedExpression))}); final JDTRefactoringDescriptorComment comment= new JDTRefactoringDescriptorComment(extended.getProject(), this, header); comment.addSetting(Messages.format(RefactoringCoreMessages.IntroduceParameterRefactoring_original_pattern, JavaElementLabels.getTextLabel(fChangeSignatureProcessor.getMethod(), JavaElementLabels.ALL_FULLY_QUALIFIED))); comment.addSetting(Messages.format(RefactoringCoreMessages.IntroduceParameterRefactoring_expression_pattern, BasicElementLabels.getJavaCodeString(ASTNodes.asString(fSelectedExpression)))); comment.addSetting(Messages.format(RefactoringCoreMessages.IntroduceParameterRefactoring_parameter_pattern, BasicElementLabels.getJavaElementName(getAddedParameterInfo().getNewName()))); return RefactoringSignatureDescriptorFactory.createIntroduceParameterDescriptor(extended.getProject(), description, comment.asString(), arguments, extended.getFlags()); }
if (descriptor instanceof JDTRefactoringDescriptor) { final JDTRefactoringDescriptor javaDescriptor= (JDTRefactoringDescriptor) descriptor; final RefactoringContribution contribution= RefactoringCore.getRefactoringContribution(javaDescriptor.getID()); if (contribution instanceof JDTRefactoringContribution) { final JDTRefactoringContribution extended= (JDTRefactoringContribution) contribution;
/** * {@inheritDoc} */ public Refactoring createRefactoring(final RefactoringStatus status) throws CoreException { Refactoring refactoring= null; final RefactoringContribution contribution= RefactoringCore.getRefactoringContribution(getID()); if (contribution instanceof JDTRefactoringContribution) { final JDTRefactoringContribution extended= (JDTRefactoringContribution) contribution; refactoring= extended.createRefactoring(this); } if (refactoring != null) { if (refactoring instanceof IScriptableRefactoring) { final JavaRefactoringArguments arguments= createArguments(); if (arguments != null) status.merge(((IScriptableRefactoring) refactoring).initialize(arguments)); else status.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.InitializableRefactoring_inacceptable_arguments)); } else status.merge(RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.JavaRefactoringDescriptor_initialization_error, getID()))); } return refactoring; }
.getRefactoringContribution(MoveResourcesDescriptor.ID); MoveResourcesDescriptor descriptor = (MoveResourcesDescriptor) contribution.createDescriptor(); descriptor.setResourcesToMove(sources);
RenameJavaElementDescriptor descriptor= (RenameJavaElementDescriptor) RefactoringCore.getRefactoringContribution(contributionId).createDescriptor(); descriptor.setJavaElement(javaElement); descriptor.setNewName(newName);
RenameJavaElementDescriptor descriptor= (RenameJavaElementDescriptor) RefactoringCore.getRefactoringContribution(contributionId).createDescriptor(); descriptor.setJavaElement(javaElement); descriptor.setNewName(newName);
RenameJavaElementDescriptor descriptor= (RenameJavaElementDescriptor) RefactoringCore.getRefactoringContribution(contributionId).createDescriptor(); descriptor.setJavaElement(javaElement); descriptor.setNewName(newName);
final int flags= RefactoringDescriptor.STRUCTURAL_CHANGE; final RenameResourceDescriptor descriptor= (RenameResourceDescriptor) RefactoringCore.getRefactoringContribution(RenameResourceDescriptor.ID).createDescriptor(); descriptor.setProject(name); descriptor.setDescription(description);
final int flags= RefactoringDescriptor.STRUCTURAL_CHANGE; final RenameResourceDescriptor descriptor= (RenameResourceDescriptor) RefactoringCore.getRefactoringContribution(RenameResourceDescriptor.ID).createDescriptor(); descriptor.setProject(name); descriptor.setDescription(description);
final int flags= RefactoringDescriptor.STRUCTURAL_CHANGE; final RenameResourceDescriptor descriptor= (RenameResourceDescriptor) RefactoringCore.getRefactoringContribution(RenameResourceDescriptor.ID).createDescriptor(); descriptor.setProject(name); descriptor.setDescription(description);