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)) //$NON-NLS-1$ descriptor.setFileNamePatterns(fFilePatterns); descriptor.setUpdateHierarchy(fRenameSubpackages); return descriptor; }
public final ChangeDescriptor getDescriptor() { final Map<String, String> arguments= new HashMap<String, String>(); final int length= fJavaElements.length; final String description= length == 1 ? getDescriptionSingular() : getDescriptionPlural(); final IProject resource= getSingleProject(); final String project= resource != null ? resource.getName() : null; final String header= length == 1 ? Messages.format(getHeaderPatternSingular(), new String[] { JavaElementLabels.getTextLabel(fJavaElements[0].getElementName(), JavaElementLabels.ALL_FULLY_QUALIFIED), getDestinationLabel() }) : Messages.format(getHeaderPatternPlural(), new String[] { String.valueOf(length), getDestinationLabel() }); int flags= JavaRefactoringDescriptor.JAR_REFACTORING | JavaRefactoringDescriptor.JAR_MIGRATION | RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE; final JDTRefactoringDescriptorComment comment= new JDTRefactoringDescriptorComment(project, this, header); arguments.put(ATTRIBUTE_POLICY, getPolicyId()); arguments.put(ATTRIBUTE_MEMBERS, new Integer(fJavaElements.length).toString()); for (int offset= 0; offset < fJavaElements.length; offset++) arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + (offset + 1), JavaRefactoringDescriptorUtil.elementToHandle(project, fJavaElements[offset])); arguments.putAll(getRefactoringArguments(project)); final JavaRefactoringDescriptor descriptor= createRefactoringDescriptor(comment, arguments, description, project, flags); return new RefactoringChangeDescriptor(descriptor); }
public final ChangeDescriptor getDescriptor() { final Map<String, String> arguments= new HashMap<String, String>(); final int length= fPackageFragments.length; final String description= length == 1 ? getDescriptionSingular() : getDescriptionPlural(); final IProject resource= getSingleProject(); final String project= resource != null ? resource.getName() : null; final String header= length == 1 ? Messages.format(getHeaderPatternSingular(), new String[] { (fPackageFragments[0]).getElementName(), getDestinationLabel() }) : Messages.format(getHeaderPatternPlural(), new String[] { String.valueOf(length), getDestinationLabel() }); int flags= JavaRefactoringDescriptor.JAR_REFACTORING | JavaRefactoringDescriptor.JAR_MIGRATION | RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE; final JDTRefactoringDescriptorComment comment= new JDTRefactoringDescriptorComment(project, this, header); arguments.put(ATTRIBUTE_POLICY, getPolicyId()); arguments.put(ATTRIBUTE_FRAGMENTS, new Integer(fPackageFragments.length).toString()); for (int offset= 0; offset < fPackageFragments.length; offset++) arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + (offset + 1), JavaRefactoringDescriptorUtil.elementToHandle(project, fPackageFragments[offset])); arguments.putAll(getRefactoringArguments(project)); final JavaRefactoringDescriptor descriptor= createRefactoringDescriptor(comment, arguments, description, project, flags); return new RefactoringChangeDescriptor(descriptor); }
@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); final JavaRefactoringDescriptor descriptor= new JavaRefactoringDescriptor(ID_REPLACE_INVOCATIONS, project, description, comment.asString(), arguments, flags){}; //REVIEW Unregistered ID! arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT, JavaRefactoringDescriptorUtil.elementToHandle(project, fSelectionTypeRoot)); arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, new Integer(fSelectionStart).toString() + " " + new Integer(fSelectionLength).toString()); //$NON-NLS-1$ arguments.put(ATTRIBUTE_MODE, new Integer(fTargetProvider.isSingle() ? 0 : 1).toString()); return new DynamicValidationRefactoringChange(descriptor, RefactoringCoreMessages.ReplaceInvocationsRefactoring_change_name, fChangeManager.getAllChanges()); }
/** * Checks whether there are any refactorings to be executed which need a * source attachment, but none exists. * * @param monitor * the progress monitor * @return a status describing the outcome of the check */ protected RefactoringStatus checkSourceAttachmentRefactorings(final IProgressMonitor monitor) { final RefactoringStatus status= new RefactoringStatus(); try { if (!canUseSourceAttachment()) { final RefactoringDescriptorProxy[] proxies= getRefactoringHistory().getDescriptors(); monitor.beginTask(JarImportMessages.JarImportWizard_prepare_import, proxies.length * 100); for (int index= 0; index < proxies.length; index++) { final RefactoringDescriptor descriptor= proxies[index].requestDescriptor(new SubProgressMonitor(monitor, 100, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)); if (descriptor != null) { final int flags= descriptor.getFlags(); if ((flags & JavaRefactoringDescriptor.JAR_SOURCE_ATTACHMENT) != 0) status.merge(RefactoringStatus.createFatalErrorStatus(Messages.format(JarImportMessages.BinaryRefactoringHistoryWizard_error_missing_source_attachment, descriptor.getDescription()))); } } } else monitor.beginTask(JarImportMessages.JarImportWizard_prepare_import, 1); } finally { monitor.done(); } return status; }
public final ChangeDescriptor getDescriptor() { final Map<String, String> arguments= new HashMap<String, String>(); final int length= fPackageFragmentRoots.length; final String description= length == 1 ? getDescriptionSingular() : getDescriptionPlural(); final IProject resource= getSingleProject(); final String project= resource != null ? resource.getName() : null; final String header= length == 1 ? Messages.format(getHeaderPatternSingular(), new String[] { fPackageFragmentRoots[0].getElementName(), getDestinationLabel() }) : Messages.format( getHeaderPatternPlural(), new String[] { String.valueOf(length), getDestinationLabel() }); int flags= RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE; final JDTRefactoringDescriptorComment comment= new JDTRefactoringDescriptorComment(project, this, header); arguments.put(ATTRIBUTE_POLICY, getPolicyId()); arguments.put(ATTRIBUTE_ROOTS, new Integer(fPackageFragmentRoots.length).toString()); for (int offset= 0; offset < fPackageFragmentRoots.length; offset++) arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + (offset + 1), JavaRefactoringDescriptorUtil.elementToHandle(project, fPackageFragmentRoots[offset])); arguments.putAll(getRefactoringArguments(project)); final JavaRefactoringDescriptor descriptor= createRefactoringDescriptor(comment, arguments, description, project, flags); return new RefactoringChangeDescriptor(descriptor); }
public static void renameVariable(String task, IJavaElement element, String new_name) { RefactoringStatus status = new RefactoringStatus(); RefactoringContribution contrib = RefactoringCore .getRefactoringContribution(IJavaRefactorings.RENAME_LOCAL_VARIABLE); RenameJavaElementDescriptor rnDesc = (RenameJavaElementDescriptor) contrib.createDescriptor(); rnDesc.setFlags(JavaRefactoringDescriptor.JAR_MIGRATION | JavaRefactoringDescriptor.JAR_REFACTORING); rnDesc.setProject(element.getJavaProject().getProject().getName()); rnDesc.setUpdateReferences(true); rnDesc.setJavaElement(element); rnDesc.setNewName(new_name); Refactoring ref; try { ref = rnDesc.createRefactoring(status); ref.checkInitialConditions(NULL_MON); ref.checkFinalConditions(NULL_MON); Change change = ref.createChange(NULL_MON); change.perform(NULL_MON); } catch (CoreException e) { e.printStackTrace(); } }
protected int getDescriptorFlags() { int flags = JavaRefactoringDescriptor.JAR_MIGRATION | JavaRefactoringDescriptor.JAR_REFACTORING | RefactoringDescriptor.STRUCTURAL_CHANGE; try { if (!Flags.isPrivate(fMethod.getFlags())) flags |= RefactoringDescriptor.MULTI_CHANGE; final IType declaring = fMethod.getDeclaringType(); if (declaring.isAnonymous() || declaring.isLocal()) flags |= JavaRefactoringDescriptor.JAR_SOURCE_ATTACHMENT; } catch (JavaModelException exception) { JavaPlugin.log(exception); } return flags; }
/** {@inheritDoc} */ @Override public Refactoring createRefactoring( JavaRefactoringDescriptor descriptor, RefactoringStatus status) { JavaRefactoringArguments arguments = new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor)); RenamePackageProcessor processor = new RenamePackageProcessor(arguments, status); return new RenameRefactoring(processor); }
/** {@inheritDoc} */ @Override public Refactoring createRefactoring( JavaRefactoringDescriptor descriptor, RefactoringStatus status) { JavaRefactoringArguments arguments = new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor)); RenameTypeParameterProcessor processor = new RenameTypeParameterProcessor(arguments, status); return new RenameRefactoring(processor); }
/** {@inheritDoc} */ @Override public Refactoring createRefactoring( JavaRefactoringDescriptor descriptor, RefactoringStatus status) { JavaRefactoringArguments arguments = new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor)); RenameLocalVariableProcessor processor = new RenameLocalVariableProcessor(arguments, status); return new RenameRefactoring(processor); }
/** {@inheritDoc} */ @Override public Refactoring createRefactoring( JavaRefactoringDescriptor descriptor, RefactoringStatus status) { JavaRefactoringArguments arguments = new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor)); RenameTypeProcessor processor = new RenameTypeProcessor(arguments, status); return new RenameRefactoring(processor); }
/** {@inheritDoc} */ @Override public Refactoring createRefactoring( JavaRefactoringDescriptor descriptor, RefactoringStatus status) { JavaRefactoringArguments arguments = new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor)); RenameFieldProcessor processor = new RenameFieldProcessor(arguments, status); return new RenameRefactoring(processor); }
/** {@inheritDoc} */ @Override public Refactoring createRefactoring( JavaRefactoringDescriptor descriptor, RefactoringStatus status) { JavaRefactoringArguments arguments = new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor)); RenameEnumConstProcessor processor = new RenameEnumConstProcessor(arguments, status); return new RenameRefactoring(processor); }
/** {@inheritDoc} */ @Override public Refactoring createRefactoring( JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException { JavaRefactoringArguments arguments = new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor)); RenameCompilationUnitProcessor processor = new RenameCompilationUnitProcessor(arguments, status); return new RenameRefactoring(processor); }
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)) // $NON-NLS-1$ descriptor.setFileNamePatterns(fFilePatterns); descriptor.setUpdateHierarchy(fRenameSubpackages); return descriptor; }
@Override protected JavaRefactoringDescriptor createRefactoringDescriptor( JDTRefactoringDescriptorComment comment, Map<String, String> arguments, String description, String project, int flags) { ReorgExecutionLog log = getReorgExecutionLog(); storeReorgExecutionLog(project, arguments, log); return RefactoringSignatureDescriptorFactory.createCopyDescriptor( project, description, comment.asString(), arguments, flags); }
@Override protected JavaRefactoringDescriptor createRefactoringDescriptor( JDTRefactoringDescriptorComment comment, Map<String, String> arguments, String description, String project, int flags) { CreateTargetExecutionLog log = getCreateTargetExecutionLog(); storeCreateTargetExecutionLog(project, arguments, log); return RefactoringSignatureDescriptorFactory.createMoveDescriptor( project, description, comment.asString(), arguments, flags); }
public final ChangeDescriptor getDescriptor() { final Map<String, String> arguments = new HashMap<String, String>(); final int length = fPackageFragmentRoots.length; final String description = length == 1 ? getDescriptionSingular() : getDescriptionPlural(); final IProject resource = getSingleProject(); final String project = resource != null ? resource.getName() : null; final String header = length == 1 ? Messages.format( getHeaderPatternSingular(), new String[] {fPackageFragmentRoots[0].getElementName(), getDestinationLabel()}) : Messages.format( getHeaderPatternPlural(), new String[] {String.valueOf(length), getDestinationLabel()}); int flags = RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE; final JDTRefactoringDescriptorComment comment = new JDTRefactoringDescriptorComment(project, this, header); arguments.put(ATTRIBUTE_POLICY, getPolicyId()); arguments.put(ATTRIBUTE_ROOTS, new Integer(fPackageFragmentRoots.length).toString()); for (int offset = 0; offset < fPackageFragmentRoots.length; offset++) arguments.put( JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + (offset + 1), JavaRefactoringDescriptorUtil.elementToHandle(project, fPackageFragmentRoots[offset])); arguments.putAll(getRefactoringArguments(project)); final JavaRefactoringDescriptor descriptor = createRefactoringDescriptor(comment, arguments, description, project, flags); return new RefactoringChangeDescriptor(descriptor); }
public final ChangeDescriptor getDescriptor() { final Map<String, String> arguments = new HashMap<String, String>(); final int length = fPackageFragments.length; final String description = length == 1 ? getDescriptionSingular() : getDescriptionPlural(); final IProject resource = getSingleProject(); final String project = resource != null ? resource.getName() : null; final String header = length == 1 ? Messages.format( getHeaderPatternSingular(), new String[] {(fPackageFragments[0]).getElementName(), getDestinationLabel()}) : Messages.format( getHeaderPatternPlural(), new String[] {String.valueOf(length), getDestinationLabel()}); int flags = JavaRefactoringDescriptor.JAR_REFACTORING | JavaRefactoringDescriptor.JAR_MIGRATION | RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE; final JDTRefactoringDescriptorComment comment = new JDTRefactoringDescriptorComment(project, this, header); arguments.put(ATTRIBUTE_POLICY, getPolicyId()); arguments.put(ATTRIBUTE_FRAGMENTS, new Integer(fPackageFragments.length).toString()); for (int offset = 0; offset < fPackageFragments.length; offset++) arguments.put( JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + (offset + 1), JavaRefactoringDescriptorUtil.elementToHandle(project, fPackageFragments[offset])); arguments.putAll(getRefactoringArguments(project)); final JavaRefactoringDescriptor descriptor = createRefactoringDescriptor(comment, arguments, description, project, flags); return new RefactoringChangeDescriptor(descriptor); }
public final ChangeDescriptor getDescriptor() { final Map<String, String> arguments = new HashMap<String, String>(); final int length = fJavaElements.length; final String description = length == 1 ? getDescriptionSingular() : getDescriptionPlural(); final IProject resource = getSingleProject(); final String project = resource != null ? resource.getName() : null; final String header = length == 1 ? Messages.format( getHeaderPatternSingular(), new String[] { JavaElementLabels.getTextLabel( fJavaElements[0].getElementName(), JavaElementLabels.ALL_FULLY_QUALIFIED), getDestinationLabel() }) : Messages.format( getHeaderPatternPlural(), new String[] {String.valueOf(length), getDestinationLabel()}); int flags = JavaRefactoringDescriptor.JAR_REFACTORING | JavaRefactoringDescriptor.JAR_MIGRATION | RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE; final JDTRefactoringDescriptorComment comment = new JDTRefactoringDescriptorComment(project, this, header); arguments.put(ATTRIBUTE_POLICY, getPolicyId()); arguments.put(ATTRIBUTE_MEMBERS, new Integer(fJavaElements.length).toString()); for (int offset = 0; offset < fJavaElements.length; offset++) arguments.put( JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + (offset + 1), JavaRefactoringDescriptorUtil.elementToHandle(project, fJavaElements[offset])); arguments.putAll(getRefactoringArguments(project)); final JavaRefactoringDescriptor descriptor = createRefactoringDescriptor(comment, arguments, description, project, flags); return new RefactoringChangeDescriptor(descriptor); }
/** * Creates a new dynamic validation refactoring change. * * @param descriptor the refactoring descriptor * @param name the name of the change */ public DynamicValidationRefactoringChange( final JavaRefactoringDescriptor descriptor, final String name) { super(name); Assert.isNotNull(descriptor); fDescriptor = 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 Change createChange(final IProgressMonitor monitor) throws CoreException { monitor.beginTask(RefactoringCoreMessages.MoveInnerToTopRefactoring_creating_change, 1); final Map<String, String> arguments= new HashMap<String, String>(); String project= null; IJavaProject javaProject= fType.getJavaProject(); if (javaProject != null) project= javaProject.getElementName(); final String description= Messages.format(RefactoringCoreMessages.MoveInnerToTopRefactoring_descriptor_description_short, BasicElementLabels.getJavaElementName(fType.getElementName())); final String header= Messages.format(RefactoringCoreMessages.MoveInnerToTopRefactoring_descriptor_description, new String[] { JavaElementLabels.getElementLabel(fType, JavaElementLabels.ALL_FULLY_QUALIFIED), JavaElementLabels.getElementLabel(fType.getParent(), JavaElementLabels.ALL_FULLY_QUALIFIED)}); final JDTRefactoringDescriptorComment comment= new JDTRefactoringDescriptorComment(project, this, header); comment.addSetting(Messages.format(RefactoringCoreMessages.MoveInnerToTopRefactoring_original_pattern, JavaElementLabels.getElementLabel(fType, JavaElementLabels.ALL_FULLY_QUALIFIED))); final boolean enclosing= fEnclosingInstanceFieldName != null && !"".equals(fEnclosingInstanceFieldName); //$NON-NLS-1$ if (enclosing) comment.addSetting(Messages.format(RefactoringCoreMessages.MoveInnerToTopRefactoring_field_pattern, BasicElementLabels.getJavaElementName(fEnclosingInstanceFieldName))); if (fNameForEnclosingInstanceConstructorParameter != null && !"".equals(fNameForEnclosingInstanceConstructorParameter)) //$NON-NLS-1$ comment.addSetting(Messages.format(RefactoringCoreMessages.MoveInnerToTopRefactoring_parameter_pattern, BasicElementLabels.getJavaElementName(fNameForEnclosingInstanceConstructorParameter))); if (enclosing && fMarkInstanceFieldAsFinal) comment.addSetting(RefactoringCoreMessages.MoveInnerToTopRefactoring_declare_final); final ConvertMemberTypeDescriptor descriptor= RefactoringSignatureDescriptorFactory.createConvertMemberTypeDescriptor(project, description, comment.asString(), arguments, RefactoringDescriptor.MULTI_CHANGE | RefactoringDescriptor.STRUCTURAL_CHANGE | JavaRefactoringDescriptor.JAR_REFACTORING | JavaRefactoringDescriptor.JAR_SOURCE_ATTACHMENT); arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT, JavaRefactoringDescriptorUtil.elementToHandle(project, fType)); if (enclosing) arguments.put(ATTRIBUTE_FIELD_NAME, fEnclosingInstanceFieldName); if (fNameForEnclosingInstanceConstructorParameter != null && !"".equals(fNameForEnclosingInstanceConstructorParameter)) //$NON-NLS-1$ arguments.put(ATTRIBUTE_PARAMETER_NAME, fNameForEnclosingInstanceConstructorParameter); arguments.put(ATTRIBUTE_FIELD, Boolean.valueOf(fCreateInstanceField).toString()); arguments.put(ATTRIBUTE_FINAL, Boolean.valueOf(fMarkInstanceFieldAsFinal).toString()); arguments.put(ATTRIBUTE_POSSIBLE, Boolean.valueOf(fIsInstanceFieldCreationPossible).toString()); arguments.put(ATTRIBUTE_MANDATORY, Boolean.valueOf(fIsInstanceFieldCreationMandatory).toString()); final DynamicValidationRefactoringChange result= new DynamicValidationRefactoringChange(descriptor, RefactoringCoreMessages.MoveInnerToTopRefactoring_move_to_Top); result.addAll(fChangeManager.getAllChanges()); result.add(createCompilationUnitForMovedType(new SubProgressMonitor(monitor, 1))); return result; }
private MoveStaticMembersDescriptor createDescriptor() { final IMember[] members= getMembersToMove(); String project= null; final IJavaProject javaProject= getDeclaringType().getJavaProject(); if (javaProject != null) project= javaProject.getElementName(); String header= null; if (members.length == 1) header= Messages.format(RefactoringCoreMessages.MoveStaticMembersProcessor_descriptor_description_single, new String[] { JavaElementLabels.getElementLabel(members[0], JavaElementLabels.ALL_FULLY_QUALIFIED), getQualifiedTypeLabel(fDestinationType) }); else header= Messages.format(RefactoringCoreMessages.MoveStaticMembersProcessor_descriptor_description_multi, new String[] { String.valueOf(members.length), getQualifiedTypeLabel(fDestinationType) }); int flags= JavaRefactoringDescriptor.JAR_MIGRATION | JavaRefactoringDescriptor.JAR_REFACTORING | RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE; final IType declaring= members[0].getDeclaringType(); try { if (declaring.isLocal() || declaring.isAnonymous()) flags|= JavaRefactoringDescriptor.JAR_SOURCE_ATTACHMENT; } catch (JavaModelException exception) { JavaPlugin.log(exception); } final String description= members.length == 1 ? Messages.format(RefactoringCoreMessages.MoveStaticMembersProcessor_description_descriptor_short_multi, BasicElementLabels.getJavaElementName(members[0].getElementName())) : RefactoringCoreMessages.MoveMembersRefactoring_move_members; final JDTRefactoringDescriptorComment comment= new JDTRefactoringDescriptorComment(project, this, header); comment.addSetting(Messages.format(RefactoringCoreMessages.MoveStaticMembersProcessor_target_element_pattern, getQualifiedTypeLabel(fDestinationType))); final MoveStaticMembersDescriptor descriptor= RefactoringSignatureDescriptorFactory.createMoveStaticMembersDescriptor(); descriptor.setProject(project); descriptor.setDescription(description); descriptor.setComment(comment.asString()); descriptor.setFlags(flags); descriptor.setDestinationType(fDestinationType); descriptor.setKeepOriginal(fDelegateUpdating); descriptor.setDeprecateDelegate(fDelegateDeprecation); descriptor.setMembers(members); return descriptor; }
protected int getDescriptorFlags() { int flags= JavaRefactoringDescriptor.JAR_MIGRATION | JavaRefactoringDescriptor.JAR_REFACTORING | RefactoringDescriptor.STRUCTURAL_CHANGE; try { if (!Flags.isPrivate(fMethod.getFlags())) flags|= RefactoringDescriptor.MULTI_CHANGE; final IType declaring= fMethod.getDeclaringType(); if (declaring.isAnonymous() || declaring.isLocal()) flags|= JavaRefactoringDescriptor.JAR_SOURCE_ATTACHMENT; } catch (JavaModelException exception) { JavaPlugin.log(exception); } return flags; }
@Override public Change createChange(IProgressMonitor pm) throws CoreException { pm.beginTask(RefactoringCoreMessages.ChangeTypeMessages_CreateChangesForChangeType, 1); try { Map<ICompilationUnit, Set<ConstraintVariable>> relevantVarsByUnit= new HashMap<ICompilationUnit, Set<ConstraintVariable>>(); groupChangesByCompilationUnit(relevantVarsByUnit); final Map<String, String> arguments= new HashMap<String, String>(); String project= null; IJavaProject javaProject= fCu.getJavaProject(); if (javaProject != null) project= javaProject.getElementName(); final String description= RefactoringCoreMessages.ChangeTypeRefactoring_descriptor_description_short; final String header= Messages.format(RefactoringCoreMessages.ChangeTypeRefactoring_descriptor_description, new String[] { BindingLabelProvider.getBindingLabel(fSelectionBinding, JavaElementLabels.ALL_FULLY_QUALIFIED), BindingLabelProvider.getBindingLabel(fSelectedType, JavaElementLabels.ALL_FULLY_QUALIFIED)}); final JDTRefactoringDescriptorComment comment= new JDTRefactoringDescriptorComment(project, this, header); comment.addSetting(Messages.format(RefactoringCoreMessages.ChangeTypeRefactoring_original_element_pattern, BindingLabelProvider.getBindingLabel(fSelectionBinding, JavaElementLabels.ALL_FULLY_QUALIFIED))); comment.addSetting(Messages.format(RefactoringCoreMessages.ChangeTypeRefactoring_original_type_pattern, BindingLabelProvider.getBindingLabel(getOriginalType(), JavaElementLabels.ALL_FULLY_QUALIFIED))); comment.addSetting(Messages.format(RefactoringCoreMessages.ChangeTypeRefactoring_refactored_type_pattern, BindingLabelProvider.getBindingLabel(fSelectedType, JavaElementLabels.ALL_FULLY_QUALIFIED))); final GeneralizeTypeDescriptor descriptor= RefactoringSignatureDescriptorFactory.createGeneralizeTypeDescriptor(project, description, comment.asString(), arguments, (RefactoringDescriptor.STRUCTURAL_CHANGE | JavaRefactoringDescriptor.JAR_REFACTORING | JavaRefactoringDescriptor.JAR_SOURCE_ATTACHMENT)); arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT, JavaRefactoringDescriptorUtil.elementToHandle(project, fCu)); arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, new Integer(fSelectionStart).toString() + " " + new Integer(fSelectionLength).toString()); //$NON-NLS-1$ arguments.put(ATTRIBUTE_TYPE, fSelectedType.getQualifiedName()); final DynamicValidationRefactoringChange result= new DynamicValidationRefactoringChange(descriptor, RefactoringCoreMessages.ChangeTypeRefactoring_allChanges); for (Iterator<ICompilationUnit>it= relevantVarsByUnit.keySet().iterator(); it.hasNext();) { ICompilationUnit icu= it.next(); Set<ConstraintVariable> cVars= relevantVarsByUnit.get(icu); CompilationUnitChange cuChange= new CompilationUnitChange(getName(), icu); addAllChangesFor(icu, cVars, cuChange); result.add(cuChange); pm.worked(1); if (pm.isCanceled()) throw new OperationCanceledException(); } return result; } finally { pm.done(); } }
/** * {@inheritDoc} */ @Override public Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) { JavaRefactoringArguments arguments= new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor)); RenameSourceFolderProcessor processor= new RenameSourceFolderProcessor(arguments, status); return new RenameRefactoring(processor); }
/** * {@inheritDoc} */ @Override public final Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException { JavaRefactoringArguments arguments= new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor)); JavaDeleteProcessor processor= new JavaDeleteProcessor(arguments, status); return new DeleteRefactoring(processor); }
/** * {@inheritDoc} */ @Override public final Refactoring createRefactoring(final JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException { JavaRefactoringArguments arguments= new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor)); JavaCopyProcessor processor= new JavaCopyProcessor(arguments, status); return new CopyRefactoring(processor); }