/** * {@inheritDoc} */ public final Refactoring createRefactoring(final RefactoringDescriptor descriptor) throws CoreException { return new UseSuperTypeRefactoring(new UseSuperTypeProcessor(null, null)); }
public final RefactoringStatus checkFinalConditions(final IProgressMonitor monitor, final CheckConditionsContext context) throws CoreException, OperationCanceledException { Assert.isNotNull(monitor); Assert.isNotNull(context); final RefactoringStatus status= new RefactoringStatus(); fChangeManager= new TextEditBasedChangeManager(); try { monitor.beginTask("", 200); //$NON-NLS-1$ monitor.setTaskName(RefactoringCoreMessages.UseSuperTypeProcessor_checking); fChangeManager= createChangeManager(new SubProgressMonitor(monitor, 200), status); if (!status.hasFatalError()) { final RefactoringStatus validation= Checks.validateModifiesFiles(ResourceUtil.getFiles(fChangeManager.getAllCompilationUnits()), getRefactoring().getValidationContext()); if (!validation.isOK()) return validation; } } finally { monitor.done(); } return status; }
/** * Finds the type with the given fully qualified name (generic type * parameters included) in the hierarchy. * * @param type * The hierarchy type to find the super type in * @param name * The fully qualified name of the super type * @return The found super type, or <code>null</code> */ protected static ITypeBinding findTypeInHierarchy(final ITypeBinding type, final String name) { if (type.isArray() || type.isPrimitive()) return null; if (name.equals(type.getTypeDeclaration().getQualifiedName())) return type; final ITypeBinding binding= type.getSuperclass(); if (binding != null) { final ITypeBinding result= findTypeInHierarchy(binding, name); if (result != null) return result; } final ITypeBinding[] bindings= type.getInterfaces(); for (int index= 0; index < bindings.length; index++) { final ITypeBinding result= findTypeInHierarchy(bindings[index], name); if (result != null) return result; } return null; }
label.setText(Messages.format( RefactoringMessages.UseSupertypeInputPage_Select_supertype_to_use, JavaElementLabels.getElementLabel(getUseSupertypeProcessor().getSubType(), JavaElementLabels.T_FULLY_QUALIFIED))); label.setLayoutData(new GridData()); checkbox.setText(RefactoringMessages.UseSupertypeInputPage_Use_in_instanceof); checkbox.setLayoutData(new GridData()); checkbox.setSelection(getUseSupertypeProcessor().isInstanceOf()); checkbox.addSelectionListener(new SelectionAdapter(){ @Override
final JDTRefactoringDescriptorComment comment= new JDTRefactoringDescriptorComment(name, this, header); comment.addSetting(Messages.format(RefactoringCoreMessages.UseSuperTypeProcessor_refactored_element_pattern, JavaElementLabels.getElementLabel(fSuperType, JavaElementLabels.ALL_FULLY_QUALIFIED))); addSuperTypeSettings(comment, false); final UseSupertypeDescriptor descriptor= new UseSupertypeDescriptor(); descriptor.setProject(name); descriptor.setComment(comment.asString()); descriptor.setFlags(flags); descriptor.setSubtype(getSubType()); descriptor.setSupertype(getSuperType()); descriptor.setReplaceInstanceof(fInstanceOf); return new DynamicValidationRefactoringChange(descriptor, RefactoringCoreMessages.UseSupertypeWherePossibleRefactoring_name, fChangeManager.getAllChanges());
final IBinding[] bindings= parser.createBindings(new IJavaElement[] { fSubType, fSuperType }, new SubProgressMonitor(monitor, 50)); if (bindings != null && bindings.length == 2 && bindings[0] instanceof ITypeBinding && bindings[1] instanceof ITypeBinding) { solveSuperTypeConstraints(null, null, fSubType, (ITypeBinding) bindings[0], (ITypeBinding) bindings[1], new SubProgressMonitor(monitor, 100), status); if (!status.hasFatalError()) rewriteTypeOccurrences(manager, null, null, null, null, new HashSet(), status, new SubProgressMonitor(monitor, 150));
@Override public boolean performFinish(){ initializeRefactoring(); boolean superFinish= super.performFinish(); if (! superFinish) return false; final int count= getUseSupertypeProcessor().getChanges(); if (count == 0) { updateUpdateLabels(); return false; } return superFinish; }
final ASTNode result= NodeFinder.perform(node, ((ITypeConstraintVariable) variable).getRange().getSourceRange()); if (result != null) rewriteTypeOccurrence(estimate, currentRewrite, result, currentRewrite.createCategorizedGroupDescription(RefactoringCoreMessages.SuperTypeRefactoringProcessor_update_type_occurrence, SET_SUPER_TYPE));
fTreeViewer.setInput(SuperTypeHierarchyCache.getTypeHierarchy(getUseSupertypeProcessor().getSubType())); } catch (JavaModelException exception) { JavaPlugin.log(exception);
@Override public final RefactoringStatus checkFinalConditions(final IProgressMonitor monitor, final CheckConditionsContext context) throws CoreException, OperationCanceledException { Assert.isNotNull(monitor); Assert.isNotNull(context); final RefactoringStatus status= new RefactoringStatus(); fChangeManager= new TextEditBasedChangeManager(); try { monitor.beginTask("", 200); //$NON-NLS-1$ monitor.setTaskName(RefactoringCoreMessages.UseSuperTypeProcessor_checking); fChangeManager= createChangeManager(new SubProgressMonitor(monitor, 200), status); if (!status.hasFatalError()) { Checks.addModifiedFilesToChecker(ResourceUtil.getFiles(fChangeManager.getAllCompilationUnits()), context); } } finally { monitor.done(); } return status; }
final JDTRefactoringDescriptorComment comment= new JDTRefactoringDescriptorComment(name, this, header); comment.addSetting(Messages.format(RefactoringCoreMessages.UseSuperTypeProcessor_refactored_element_pattern, JavaElementLabels.getElementLabel(fSuperType, JavaElementLabels.ALL_FULLY_QUALIFIED))); addSuperTypeSettings(comment, false); final UseSupertypeDescriptor descriptor= RefactoringSignatureDescriptorFactory.createUseSupertypeDescriptor(); descriptor.setProject(name); descriptor.setComment(comment.asString()); descriptor.setFlags(flags); descriptor.setSubtype(getSubType()); descriptor.setSupertype(getSuperType()); descriptor.setReplaceInstanceof(fInstanceOf); return new DynamicValidationRefactoringChange(descriptor, RefactoringCoreMessages.UseSupertypeWherePossibleRefactoring_name, fChangeManager.getAllChanges());
public void createControl(Composite parent) { initializeDialogUnits(parent); loadSettings(); Composite composite= new Composite(parent, SWT.NONE); setControl(composite); composite.setLayout(new GridLayout()); Label label= new Label(composite, SWT.NONE); label.setText(Messages.format( RefactoringMessages.UseSupertypeInputPage_Select_supertype_to_use, JavaElementLabels.getElementLabel(getUseSupertypeProcessor().getSubType(), JavaElementLabels.T_FULLY_QUALIFIED))); label.setLayoutData(new GridData()); addTreeViewer(composite); final Button checkbox= new Button(composite, SWT.CHECK); checkbox.setText(RefactoringMessages.UseSupertypeInputPage_Use_in_instanceof); checkbox.setLayoutData(new GridData()); checkbox.setSelection(getUseSupertypeProcessor().isInstanceOf()); checkbox.addSelectionListener(new SelectionAdapter(){ public void widgetSelected(SelectionEvent e) { getUseSupertypeProcessor().setInstanceOf(checkbox.getSelection()); fSettings.put(REWRITE_INSTANCEOF, checkbox.getSelection()); setMessage(MESSAGE); setPageComplete(true); fFileCount.clear(); fTreeViewer.refresh(); } }); Dialog.applyDialogFont(composite); PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.USE_SUPERTYPE_WIZARD_PAGE); }
final IBinding[] bindings= parser.createBindings(new IJavaElement[] { fSubType, fSuperType }, new SubProgressMonitor(monitor, 50)); if (bindings != null && bindings.length == 2 && bindings[0] instanceof ITypeBinding && bindings[1] instanceof ITypeBinding) { solveSuperTypeConstraints(null, null, fSubType, (ITypeBinding) bindings[0], (ITypeBinding) bindings[1], new SubProgressMonitor(monitor, 100), status); if (!status.hasFatalError()) rewriteTypeOccurrences(manager, null, null, null, null, new HashSet<String>(), status, new SubProgressMonitor(monitor, 150));
public boolean performFinish(){ initializeRefactoring(); boolean superFinish= super.performFinish(); if (! superFinish) return false; final int count= getUseSupertypeProcessor().getChanges(); if (count == 0) { updateUpdateLabels(); return false; } return superFinish; }
final ASTNode result= NodeFinder.perform(node, ((ITypeConstraintVariable) variable).getRange().getSourceRange()); if (result != null) rewriteTypeOccurrence(estimate, currentRewrite, result, currentRewrite.createCategorizedGroupDescription(RefactoringCoreMessages.SuperTypeRefactoringProcessor_update_type_occurrence, SET_SUPER_TYPE));
fTreeViewer.setInput(SuperTypeHierarchyCache.getTypeHierarchy(getUseSupertypeProcessor().getSubType())); } catch (JavaModelException exception) { JavaPlugin.log(exception);
@Override public final RefactoringStatus checkFinalConditions(final IProgressMonitor monitor, final CheckConditionsContext context) throws CoreException, OperationCanceledException { Assert.isNotNull(monitor); Assert.isNotNull(context); final RefactoringStatus status= new RefactoringStatus(); fChangeManager= new TextEditBasedChangeManager(); try { monitor.beginTask("", 200); //$NON-NLS-1$ monitor.setTaskName(RefactoringCoreMessages.UseSuperTypeProcessor_checking); fChangeManager= createChangeManager(new SubProgressMonitor(monitor, 200), status); if (!status.hasFatalError()) { Checks.addModifiedFilesToChecker(ResourceUtil.getFiles(fChangeManager.getAllCompilationUnits()), context); } } finally { monitor.done(); } return status; }
final JDTRefactoringDescriptorComment comment= new JDTRefactoringDescriptorComment(name, this, header); comment.addSetting(Messages.format(RefactoringCoreMessages.UseSuperTypeProcessor_refactored_element_pattern, JavaElementLabels.getElementLabel(fSuperType, JavaElementLabels.ALL_FULLY_QUALIFIED))); addSuperTypeSettings(comment, false); final UseSupertypeDescriptor descriptor= RefactoringSignatureDescriptorFactory.createUseSupertypeDescriptor(); descriptor.setProject(name); descriptor.setComment(comment.asString()); descriptor.setFlags(flags); descriptor.setSubtype(getSubType()); descriptor.setSupertype(getSuperType()); descriptor.setReplaceInstanceof(fInstanceOf); return new DynamicValidationRefactoringChange(descriptor, RefactoringCoreMessages.UseSupertypeWherePossibleRefactoring_name, fChangeManager.getAllChanges());
label.setText(Messages.format( RefactoringMessages.UseSupertypeInputPage_Select_supertype_to_use, JavaElementLabels.getElementLabel(getUseSupertypeProcessor().getSubType(), JavaElementLabels.T_FULLY_QUALIFIED))); label.setLayoutData(new GridData()); checkbox.setText(RefactoringMessages.UseSupertypeInputPage_Use_in_instanceof); checkbox.setLayoutData(new GridData()); checkbox.setSelection(getUseSupertypeProcessor().isInstanceOf()); checkbox.addSelectionListener(new SelectionAdapter(){ @Override
final IBinding[] bindings= parser.createBindings(new IJavaElement[] { fSubType, fSuperType }, new SubProgressMonitor(monitor, 50)); if (bindings != null && bindings.length == 2 && bindings[0] instanceof ITypeBinding && bindings[1] instanceof ITypeBinding) { solveSuperTypeConstraints(null, null, fSubType, (ITypeBinding) bindings[0], (ITypeBinding) bindings[1], new SubProgressMonitor(monitor, 100), status); if (!status.hasFatalError()) rewriteTypeOccurrences(manager, null, null, null, null, new HashSet<String>(), status, new SubProgressMonitor(monitor, 150));