/** * Creates a new refactoring descriptor for the specified input data. * * @param id * the unique id of the refactoring * @param project * the project name, or <code>null</code> * @param description * a description * @param comment * the comment, or <code>null</code> * @param arguments * the argument map * @param flags * the flags * @return the refactoring descriptor */ public RefactoringDescriptor createDescriptor(final String id, final String project, final String description, final String comment, final Map arguments, final int flags) { Assert.isNotNull(id); Assert.isNotNull(description); Assert.isNotNull(arguments); Assert.isLegal(flags >= RefactoringDescriptor.NONE); final RefactoringContribution contribution= getRefactoringContribution(id); if (contribution != null) return contribution.createDescriptor(id, project, description, comment, arguments, flags); return new DefaultRefactoringDescriptor(id, project, description, comment, arguments, flags); }
RefactoringContribution contribution= RefactoringCore.getRefactoringContribution(javaDescriptor.getID()); Map<String, String> map= contribution.retrieveArgumentMap(descriptor); if (fJavaProject == null) { status.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.InitializableRefactoring_inacceptable_arguments)); descriptor= contribution.createDescriptor(descriptor.getID(), name, descriptor.getDescription(), descriptor.getComment(), map, descriptor.getFlags()); } catch (IllegalArgumentException e) { status.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.InitializableRefactoring_inacceptable_arguments));
@Override public final Map<String, String> retrieveArgumentMap(final RefactoringDescriptor descriptor) { Assert.isNotNull(descriptor); if (descriptor instanceof JavaRefactoringDescriptor) return ((JavaRefactoringDescriptor) descriptor).getArguments(); return super.retrieveArgumentMap(descriptor); }
/** * Returns the argument map of the specified descriptor. * * @param descriptor * the refactoring descriptor * @return the argument map, or <code>null</code> */ public static Map getArgumentMap(final RefactoringDescriptor descriptor) { Map arguments= null; final RefactoringContribution contribution= RefactoringContributionManager.getInstance().getRefactoringContribution(descriptor.getID()); if (contribution != null) arguments= contribution.retrieveArgumentMap(descriptor); else if (descriptor instanceof DefaultRefactoringDescriptor) arguments= ((DefaultRefactoringDescriptor) descriptor).getArguments(); return arguments; }
/** * Creates a new refactoring descriptor for the specified input data. * * @param id * the unique id of the refactoring * @param project * the project name, or <code>null</code> * @param description * a description * @param comment * the comment, or <code>null</code> * @param arguments * the argument map * @param flags * the flags * @return the refactoring descriptor * @throws IllegalArgumentException if the argument map contains invalid keys/values */ public RefactoringDescriptor createDescriptor(final String id, final String project, final String description, final String comment, final Map<String, String> arguments, final int flags) throws IllegalArgumentException { Assert.isNotNull(id); Assert.isNotNull(description); Assert.isNotNull(arguments); Assert.isLegal(flags >= RefactoringDescriptor.NONE); final RefactoringContribution contribution= getRefactoringContribution(id); if (contribution != null) return contribution.createDescriptor(id, project, description, comment, arguments, flags); return new DefaultRefactoringDescriptor(id, project, description, comment, arguments, flags); }
RefactoringContribution contribution= RefactoringCore.getRefactoringContribution(javaDescriptor.getID()); Map<String, String> map= contribution.retrieveArgumentMap(descriptor); if (fJavaProject == null) { status.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.InitializableRefactoring_inacceptable_arguments)); descriptor= contribution.createDescriptor(descriptor.getID(), name, descriptor.getDescription(), descriptor.getComment(), map, descriptor.getFlags()); } catch (IllegalArgumentException e) { status.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.InitializableRefactoring_inacceptable_arguments));
/** * Returns the argument map of the specified descriptor. * * @param descriptor * the refactoring descriptor * @return the argument map, or <code>null</code> */ public static Map<String, String> getArgumentMap(final RefactoringDescriptor descriptor) { Map<String, String> arguments= null; final RefactoringContribution contribution= RefactoringContributionManager.getInstance().getRefactoringContribution(descriptor.getID()); if (contribution != null) arguments= contribution.retrieveArgumentMap(descriptor); else if (descriptor instanceof DefaultRefactoringDescriptor) arguments= ((DefaultRefactoringDescriptor) descriptor).getArguments(); return arguments; }
/** * Creates a new refactoring descriptor for the specified input data. * * @param id * the unique id of the refactoring * @param project * the project name, or <code>null</code> * @param description * a description * @param comment * the comment, or <code>null</code> * @param arguments * the argument map * @param flags * the flags * @return the refactoring descriptor * @throws IllegalArgumentException if the argument map contains invalid keys/values */ public RefactoringDescriptor createDescriptor(final String id, final String project, final String description, final String comment, final Map<String, String> arguments, final int flags) throws IllegalArgumentException { Assert.isNotNull(id); Assert.isNotNull(description); Assert.isNotNull(arguments); Assert.isLegal(flags >= RefactoringDescriptor.NONE); final RefactoringContribution contribution= getRefactoringContribution(id); if (contribution != null) return contribution.createDescriptor(id, project, description, comment, arguments, flags); return new DefaultRefactoringDescriptor(id, project, description, comment, arguments, flags); }
/** * Returns the argument map of the specified descriptor. * * @param descriptor * the refactoring descriptor * @return the argument map, or <code>null</code> */ public static Map<String, String> getArgumentMap(final RefactoringDescriptor descriptor) { Map<String, String> arguments= null; final RefactoringContribution contribution= RefactoringContributionManager.getInstance().getRefactoringContribution(descriptor.getID()); if (contribution != null) arguments= contribution.retrieveArgumentMap(descriptor); else if (descriptor instanceof DefaultRefactoringDescriptor) arguments= ((DefaultRefactoringDescriptor) descriptor).getArguments(); return arguments; }
@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()); }
RefactoringContribution contribution = RefactoringCore .getRefactoringContribution(MoveResourcesDescriptor.ID); MoveResourcesDescriptor descriptor = (MoveResourcesDescriptor) contribution.createDescriptor(); descriptor.setResourcesToMove(sources); descriptor.setDestination(target);
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()); }
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);