/** * Populates the refactoring descriptor argument map based on the specified * arguments. Subclasses should extend and add their arguments to {@link #fArguments}. */ protected void populateArgumentMap() { RefactoringStatus status= validateDescriptor(); if (status.hasFatalError()) throw new RuntimeException("Validation returns a fatal error status", new CoreException(status.getEntryWithHighestSeverity().toStatus())); //$NON-NLS-1$ }
@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; }
/** * {@inheritDoc} */ public Map getArguments() { return super.getArguments(); }
@Override public final Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException { JavaRefactoringArguments arguments= new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor)); return new IntroduceIndirectionRefactoring(arguments, status); }
/** * Converts an input handle back to the corresponding java element. * * @param project * the project, or <code>null</code> for the workspace * @param handle * the input handle * @return the corresponding java element, or <code>null</code> if no such * element exists */ protected static IJavaElement handleToElement(final String project, final String handle) { return handleToElement(project, handle, true); }
/** * Validates the refactoring descriptor with respect to the constraints * imposed by the represented refactoring. * <p> * Clients must call this method to verify that all arguments have been * correctly set and that they satisfy the constraints imposed by specific * refactorings. Returning a refactoring status of severity * {@link RefactoringStatus#FATAL} indicates that the refactoring descriptor * cannot be used to create a refactoring instance. * </p> * * @return a refactoring status describing the outcome of the validation */ public RefactoringStatus validateDescriptor() { RefactoringStatus status= new RefactoringStatus(); String description= getDescription(); if (description == null || "".equals(description)) //$NON-NLS-1$ status.merge(RefactoringStatus.createFatalErrorStatus(DescriptorMessages.JavaRefactoringDescriptor_no_description)); return status; } }
@Override public final Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException { JavaRefactoringArguments arguments= new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor)); return new IntroduceFactoryRefactoring(arguments, status); }
/** * Converts an input handle back to the corresponding java element. * * @param project * the project, or <code>null</code> for the workspace * @param handle * the input handle * @param check * <code>true</code> to check for existence of the element, * <code>false</code> otherwise * @return the corresponding java element, or <code>null</code> if no such * element exists */ protected static IJavaElement handleToElement(final String project, final String handle, final boolean check) { return handleToElement(null, project, handle, check); }
/** * Creates a new dynamic validation refactoring change. * * @param descriptor * the refactoring descriptor * @param name * the name of the change * @param changes * the changes */ public DynamicValidationRefactoringChange(final JavaRefactoringDescriptor descriptor, final String name, final Change[] changes) { super(name, changes); Assert.isNotNull(descriptor); Assert.isTrue(!descriptor.validateDescriptor().hasFatalError(), RefactoringCoreMessages.DynamicValidationRefactoringChange_fatal_error); fDescriptor= descriptor; }
@Override public final Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException { JavaRefactoringArguments arguments= new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor)); return new IntroduceParameterRefactoring(arguments, status); }
RefactoringContribution contribution= RefactoringCore.getRefactoringContribution(javaDescriptor.getID());
@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); }
/** * Creates a new dynamic validation refactoring change. * * @param descriptor * the refactoring descriptor * @param name * the name of the change * @param changes * the changes */ public DynamicValidationRefactoringChange(final JavaRefactoringDescriptor descriptor, final String name, final Change[] changes) { super(name, changes); Assert.isNotNull(descriptor); Assert.isTrue(!descriptor.validateDescriptor().hasFatalError(), RefactoringCoreMessages.DynamicValidationRefactoringChange_fatal_error); fDescriptor = descriptor; }
@Override public final Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException { JavaRefactoringArguments arguments= new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor)); return new MoveInnerToTopRefactoring(arguments, status); }
RefactoringContribution contribution= RefactoringCore.getRefactoringContribution(javaDescriptor.getID());
/** * Creates a new dynamic validation refactoring change. * * @param descriptor * the refactoring descriptor * @param name * the name of the change * @param changes * the changes */ public DynamicValidationRefactoringChange(final JavaRefactoringDescriptor descriptor, final String name, final Change[] changes) { super(name, changes); Assert.isNotNull(descriptor); Assert.isTrue(!descriptor.validateDescriptor().hasFatalError(), RefactoringCoreMessages.DynamicValidationRefactoringChange_fatal_error); fDescriptor= descriptor; }
@Override public final Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException { JavaRefactoringArguments arguments= new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor)); return new InlineTempRefactoring(arguments, status); }
@Override public RefactoringStatus validateDescriptor() { RefactoringStatus status= super.validateDescriptor(); if (getType() == null) status.addFatalError("The type may not be null"); //$NON-NLS-1$ return status; }
@Override public final Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException { JavaRefactoringArguments arguments= new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor)); return new InlineTempRefactoring(arguments, status); }
/** * Creates a new dynamic validation refactoring change. * * @param descriptor * the refactoring descriptor * @param name * the name of the change * @param changes * the changes */ public DynamicValidationRefactoringChange(final JavaRefactoringDescriptor descriptor, final String name, final Change[] changes) { super(name, changes); Assert.isNotNull(descriptor); Assert.isTrue(!descriptor.validateDescriptor().hasFatalError(), RefactoringCoreMessages.DynamicValidationRefactoringChange_fatal_error); fDescriptor= descriptor; }