@Override protected RefactoringStatus validateNewName(String newName) { String fullName= JavaModelUtil.getRenamedCUName(getCompilationUnit(), newName); return super.validateNewName(fullName); }
@Override protected RefactoringStatus validateNewName(String newName) { String fullName= JavaModelUtil.getRenamedCUName(getCompilationUnit(), newName); return super.validateNewName(fullName); }
protected RefactoringStatus validateNewName(String newName) { String fullName= JavaModelUtil.getRenamedCUName(getCompilationUnit(), newName); return super.validateNewName(fullName); }
private static ICompilationUnit getNewCompilationUnit(IType type, String newName) { ICompilationUnit cu = type.getCompilationUnit(); if (isPrimaryType(type)) { IPackageFragment parent = type.getPackageFragment(); String renamedCUName = JavaModelUtil.getRenamedCUName(cu, newName); return parent.getCompilationUnit(renamedCUName); } else { return cu; } }
@Override public String isValid(String newText) { if (newText == null || "".equals(newText)) //$NON-NLS-1$ return INVALID_NAME_NO_MESSAGE; String newCuName= JavaModelUtil.getRenamedCUName(cu, newText); IStatus status= JavaConventionsUtil.validateCompilationUnitName(newCuName, cu); if (status.getSeverity() == IStatus.ERROR) return status.getMessage(); RefactoringStatus refStatus; refStatus= Checks.checkCompilationUnitNewName(cu, newText); if (refStatus.hasFatalError()) return refStatus.getMessageMatchingSeverity(RefactoringStatus.FATAL); if (cu.getElementName().equalsIgnoreCase(newCuName)) return ReorgMessages.ReorgQueries_resourceExistsWithDifferentCaseMassage; return null; } };
@Override public String isValid(String newText) { if (newText == null || "".equals(newText)) //$NON-NLS-1$ return INVALID_NAME_NO_MESSAGE; String newCuName= JavaModelUtil.getRenamedCUName(cu, newText); IStatus status= JavaConventionsUtil.validateCompilationUnitName(newCuName, cu); if (status.getSeverity() == IStatus.ERROR) return status.getMessage(); RefactoringStatus refStatus; refStatus= Checks.checkCompilationUnitNewName(cu, newText); if (refStatus.hasFatalError()) return refStatus.getMessageMatchingSeverity(RefactoringStatus.FATAL); if (cu.getElementName().equalsIgnoreCase(newCuName)) return ReorgMessages.ReorgQueries_resourceExistsWithDifferentCaseMassage; return null; } };
private ICompilationUnit getNewCompilationUnit() { ICompilationUnit cu= fType.getCompilationUnit(); if (isPrimaryType()) { IPackageFragment parent= fType.getPackageFragment(); String renamedCUName= JavaModelUtil.getRenamedCUName(cu, getNewElementName()); return parent.getCompilationUnit(renamedCUName); } else { return cu; } }
private ICompilationUnit getNewCompilationUnit() { ICompilationUnit cu= fType.getCompilationUnit(); if (isPrimaryType()) { IPackageFragment parent= fType.getPackageFragment(); String renamedCUName= JavaModelUtil.getRenamedCUName(cu, getNewElementName()); return parent.getCompilationUnit(renamedCUName); } else { return cu; } }
public String getNewName() throws OperationCanceledException { String result= fDelegate.createNewCompilationUnitNameQuery(cu, initialSuggestedName).getNewName(); String newName= JavaModelUtil.getRenamedCUName(cu, result); fExecutionLog.setNewName(cu, newName); ResourceMapping mapping= JavaElementResourceMapping.create(cu); if (mapping != null) { fExecutionLog.setNewName(mapping, newName); } return result; } };
private ICompilationUnit getNewCompilationUnit() { ICompilationUnit cu = fType.getCompilationUnit(); if (isPrimaryType()) { IPackageFragment parent = fType.getPackageFragment(); String renamedCUName = JavaModelUtil.getRenamedCUName(cu, getNewElementName()); return parent.getCompilationUnit(renamedCUName); } else { return cu; } }
@Override public String getNewName() throws OperationCanceledException { String result= fDelegate.createNewCompilationUnitNameQuery(cu, initialSuggestedName).getNewName(); String newName= JavaModelUtil.getRenamedCUName(cu, result); fExecutionLog.setNewName(cu, newName); ResourceMapping mapping= JavaElementResourceMapping.create(cu); if (mapping != null) { fExecutionLog.setNewName(mapping, newName); } return result; } };
private ICompilationUnit getNewCompilationUnit() { ICompilationUnit cu= fType.getCompilationUnit(); if (isPrimaryType()) { IPackageFragment parent= fType.getPackageFragment(); String renamedCUName= JavaModelUtil.getRenamedCUName(cu, getNewElementName()); return parent.getCompilationUnit(renamedCUName); } else { return cu; } }
@Override public String getNewName() throws OperationCanceledException { String result= fDelegate.createNewCompilationUnitNameQuery(cu, initialSuggestedName).getNewName(); String newName= JavaModelUtil.getRenamedCUName(cu, result); fExecutionLog.setNewName(cu, newName); ResourceMapping mapping= JavaElementResourceMapping.create(cu); if (mapping != null) { fExecutionLog.setNewName(mapping, newName); } return result; } };
private Change createCompilationUnitForMovedType(IProgressMonitor pm) throws CoreException { ICompilationUnit newCuWC= null; try { newCuWC= fType.getPackageFragment().getCompilationUnit(JavaModelUtil.getRenamedCUName(fType.getCompilationUnit(), fType.getElementName())).getWorkingCopy(null); String source= createSourceForNewCu(newCuWC, pm); return new CreateCompilationUnitChange(fType.getPackageFragment().getCompilationUnit(JavaModelUtil.getRenamedCUName(fType.getCompilationUnit(), fType.getElementName())), source, null); } finally { if (newCuWC != null) newCuWC.discardWorkingCopy(); } }
private Change createCompilationUnitForMovedType(IProgressMonitor pm) throws CoreException { ICompilationUnit newCuWC= null; try { newCuWC= fType.getPackageFragment().getCompilationUnit(JavaModelUtil.getRenamedCUName(fType.getCompilationUnit(), fType.getElementName())).getWorkingCopy(null); String source= createSourceForNewCu(newCuWC, pm); return new CreateCompilationUnitChange(fType.getPackageFragment().getCompilationUnit(JavaModelUtil.getRenamedCUName(fType.getCompilationUnit(), fType.getElementName())), source, null); } finally { if (newCuWC != null) newCuWC.discardWorkingCopy(); } }
private Change createCompilationUnitForMovedType(IProgressMonitor pm) throws CoreException { ICompilationUnit newCuWC= null; try { newCuWC= fType.getPackageFragment().getCompilationUnit(JavaModelUtil.getRenamedCUName(fType.getCompilationUnit(), fType.getElementName())).getWorkingCopy(null); String source= createSourceForNewCu(newCuWC, pm); return new CreateCompilationUnitChange(fType.getPackageFragment().getCompilationUnit(JavaModelUtil.getRenamedCUName(fType.getCompilationUnit(), fType.getElementName())), source, null); } finally { if (newCuWC != null) newCuWC.discardWorkingCopy(); } }
/** * Returns ok status if the new name is ok. This is when no other file with that name exists. * @param cu * @param newName * @return the status */ public static RefactoringStatus checkCompilationUnitNewName(ICompilationUnit cu, String newName) { String newCUName= JavaModelUtil.getRenamedCUName(cu, newName); if (resourceExists(RenameResourceChange.renamedResourcePath(cu.getResource().getFullPath(), newCUName))) return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.Checks_cu_name_used, newName)); else return new RefactoringStatus(); }
/** * Returns OK status if the new name is OK, i.e. when no file with that name exists. * The name of the given CU is not OK. * * @param cu CU to rename * @param newBareName the new name of the CU (without extension) * @return the status: FATAL if the CU already exists, OK if OK */ public static RefactoringStatus checkCompilationUnitNewName(ICompilationUnit cu, String newBareName) { String newCUName= JavaModelUtil.getRenamedCUName(cu, newBareName); IPath renamedResourcePath= cu.getParent().getPath().append(newCUName); if (resourceExists(renamedResourcePath)) return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.Checks_cu_name_used, BasicElementLabels.getResourceName(newCUName))); else return new RefactoringStatus(); }
/** * Returns OK status if the new name is OK, i.e. when no file with that name exists. * The name of the given CU is not OK. * * @param cu CU to rename * @param newBareName the new name of the CU (without extension) * @return the status: FATAL if the CU already exists, OK if OK */ public static RefactoringStatus checkCompilationUnitNewName(ICompilationUnit cu, String newBareName) { String newCUName= JavaModelUtil.getRenamedCUName(cu, newBareName); IPath renamedResourcePath= cu.getParent().getPath().append(newCUName); if (resourceExists(renamedResourcePath)) return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.Checks_cu_name_used, BasicElementLabels.getResourceName(newCUName))); else return new RefactoringStatus(); }
@Override protected IFile getOldFile(IProgressMonitor monitor) throws OperationCanceledException { try { monitor.beginTask("", 12); //$NON-NLS-1$ String oldSource= super.getSource(); IPath oldPath= super.getPath(); String newTypeName= fNameQuery.getNewName(); try { String newSource= getCopiedFileSource(new SubProgressMonitor(monitor, 9), fOldCu, newTypeName); setSource(newSource); setPath(fOldCu.getResource().getParent().getFullPath().append(JavaModelUtil.getRenamedCUName(fOldCu, newTypeName))); return super.getOldFile(new SubProgressMonitor(monitor, 1)); } catch (CoreException e) { setSource(oldSource); setPath(oldPath); return super.getOldFile(new SubProgressMonitor(monitor, 2)); } } finally { monitor.done(); } }