/** * {@inheritDoc} */ public boolean requireAST(ICompilationUnit unit) throws CoreException { boolean addSUID= isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID); if (!addSUID) return false; return isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_GENERATED) || isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_DEFAULT); }
private Map<String, String> getRequiredOptions() { Map<String, String> result= new Hashtable<>(); if ((isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_GENERATED)) || (isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_DEFAULT))) result.put(JavaCore.COMPILER_PB_MISSING_SERIAL_VERSION, JavaCore.WARNING); return result; }
private Map<String, String> getRequiredOptions() { Map<String, String> result= new Hashtable<>(); if ((isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_GENERATED)) || (isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_DEFAULT))) result.put(JavaCore.COMPILER_PB_MISSING_SERIAL_VERSION, JavaCore.WARNING); return result; }
@Override public boolean canFix(ICompilationUnit compilationUnit, IProblemLocation problem) { if (problem.getProblemId() == IProblem.MissingSerialVersion) return (isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_GENERATED)) || (isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_DEFAULT)); return false; }
@Override public boolean canFix(ICompilationUnit compilationUnit, IProblemLocation problem) { if (problem.getProblemId() == IProblem.MissingSerialVersion) return (isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_GENERATED)) || (isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_DEFAULT)); return false; }
/** * {@inheritDoc} */ public IFix createFix(CompilationUnit compilationUnit, IProblemLocation[] problems) throws CoreException { if (compilationUnit == null) return null; return PotentialProgrammingProblemsFix.createCleanUp(compilationUnit, problems, (isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_GENERATED)) || (isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_DEFAULT))); }
@Override protected ICleanUpFix createFix(CompilationUnit compilationUnit, IProblemLocation[] problems) throws CoreException { if (compilationUnit == null) return null; return PotentialProgrammingProblemsFix.createCleanUp(compilationUnit, problems, (isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_GENERATED)) || (isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_DEFAULT))); }
/** * {@inheritDoc} */ public boolean canFix(CompilationUnit compilationUnit, IProblemLocation problem) throws CoreException { if ((isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_GENERATED)) || (isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_DEFAULT))) { IFix[] fix= PotentialProgrammingProblemsFix.createMissingSerialVersionFixes(compilationUnit, problem); if (fix != null) return true; } return false; }
@Override protected ICleanUpFix createFix(CompilationUnit compilationUnit, IProblemLocation[] problems) throws CoreException { if (compilationUnit == null) return null; return PotentialProgrammingProblemsFix.createCleanUp(compilationUnit, problems, (isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_GENERATED)) || (isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_DEFAULT))); }
@Override protected ICleanUpFix createFix(CompilationUnit compilationUnit) throws CoreException { boolean addSUID= isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID); if (!addSUID) return null; return PotentialProgrammingProblemsFix.createCleanUp(compilationUnit, isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_GENERATED) || isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_DEFAULT)); }
@Override public String[] getStepDescriptions() { List<String> result= new ArrayList<>(); if ((isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_GENERATED))) result.add(MultiFixMessages.SerialVersionCleanUp_Generated_description); if ((isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_DEFAULT))) result.add(MultiFixMessages.CodeStyleCleanUp_addDefaultSerialVersionId_description); return result.toArray(new String[result.size()]); }
@Override public String getPreview() { StringBuffer buf= new StringBuffer(); buf.append("class E implements java.io.Serializable {\n"); //$NON-NLS-1$ if ((isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_GENERATED))) { buf.append(" private static final long serialVersionUID = -391484377137870342L;\n"); //$NON-NLS-1$ } else if ((isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_DEFAULT))) { buf.append(" private static final long serialVersionUID = 1L;\n"); //$NON-NLS-1$ } buf.append("}\n"); //$NON-NLS-1$ return buf.toString(); }
@Override public String getPreview() { StringBuilder buf= new StringBuilder(); buf.append("class E implements java.io.Serializable {\n"); //$NON-NLS-1$ if ((isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_GENERATED))) { buf.append(" private static final long serialVersionUID = -391484377137870342L;\n"); //$NON-NLS-1$ } else if ((isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_DEFAULT))) { buf.append(" private static final long serialVersionUID = 1L;\n"); //$NON-NLS-1$ } buf.append("}\n"); //$NON-NLS-1$ return buf.toString(); }
/** * {@inheritDoc} */ public int maximalNumberOfFixes(CompilationUnit compilationUnit) { if ((isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_GENERATED)) || (isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_DEFAULT))) return getNumberOfProblems(compilationUnit.getProblems(), IProblem.MissingSerialVersion); return 0; } }
@Override public int computeNumberOfFixes(CompilationUnit compilationUnit) { if ((isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_GENERATED)) || (isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_DEFAULT))) return getNumberOfProblems(compilationUnit.getProblems(), IProblem.MissingSerialVersion); return 0; } }
@Override public int computeNumberOfFixes(CompilationUnit compilationUnit) { if ((isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_GENERATED)) || (isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_DEFAULT))) return getNumberOfProblems(compilationUnit.getProblems(), IProblem.MissingSerialVersion); return 0; } }
@Override public RefactoringStatus checkPreConditions(IJavaProject project, ICompilationUnit[] compilationUnits, IProgressMonitor monitor) throws CoreException { RefactoringStatus superStatus= super.checkPreConditions(project, compilationUnits, monitor); if (superStatus.hasFatalError()) return superStatus; return PotentialProgrammingProblemsFix.checkPreConditions(project, compilationUnits, monitor, isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_GENERATED), isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_DEFAULT), false); }
@Override public RefactoringStatus checkPreConditions(IJavaProject project, ICompilationUnit[] compilationUnits, IProgressMonitor monitor) throws CoreException { RefactoringStatus superStatus= super.checkPreConditions(project, compilationUnits, monitor); if (superStatus.hasFatalError()) return superStatus; return PotentialProgrammingProblemsFix.checkPreConditions(project, compilationUnits, monitor, isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_GENERATED), isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_DEFAULT), false); }