private Map<String, String> getRequiredOptions() { Map<String, String> result= new Hashtable<>(); if (isEnabled(CleanUpConstants.REMOVE_REDUNDANT_TYPE_ARGUMENTS)) result.put(JavaCore.COMPILER_PB_REDUNDANT_TYPE_ARGUMENTS, JavaCore.WARNING); return result; }
@Override protected ICleanUpFix createFix(CompilationUnit compilationUnit) throws CoreException { if (compilationUnit == null) return null; return TypeParametersFix.createCleanUp(compilationUnit, isEnabled(CleanUpConstants.INSERT_INFERRED_TYPE_ARGUMENTS), isEnabled(CleanUpConstants.REMOVE_REDUNDANT_TYPE_ARGUMENTS)); }
private Map<String, String> getRequiredOptions() { Map<String, String> result= new Hashtable<>(); if (isEnabled(CleanUpConstants.REMOVE_REDUNDANT_TYPE_ARGUMENTS)) result.put(JavaCore.COMPILER_PB_REDUNDANT_TYPE_ARGUMENTS, JavaCore.WARNING); return result; }
@Override protected ICleanUpFix createFix(CompilationUnit compilationUnit, IProblemLocation[] problems) throws CoreException { if (compilationUnit == null) return null; return TypeParametersFix.createCleanUp(compilationUnit, problems, isEnabled(CleanUpConstants.INSERT_INFERRED_TYPE_ARGUMENTS), isEnabled(CleanUpConstants.REMOVE_REDUNDANT_TYPE_ARGUMENTS)); }
@Override public boolean canFix(ICompilationUnit compilationUnit, IProblemLocation problem) { int problemId= problem.getProblemId(); if (problemId == IProblem.RedundantSpecificationOfTypeArguments) return isEnabled(CleanUpConstants.REMOVE_REDUNDANT_TYPE_ARGUMENTS); if (problemId == IProblem.DiamondNotBelow17) return isEnabled(CleanUpConstants.INSERT_INFERRED_TYPE_ARGUMENTS); return false; }
@Override public boolean canFix(ICompilationUnit compilationUnit, IProblemLocation problem) { int problemId= problem.getProblemId(); if (problemId == IProblem.RedundantSpecificationOfTypeArguments) return isEnabled(CleanUpConstants.REMOVE_REDUNDANT_TYPE_ARGUMENTS); if (problemId == IProblem.DiamondNotBelow17) return isEnabled(CleanUpConstants.INSERT_INFERRED_TYPE_ARGUMENTS); return false; }
@Override protected ICleanUpFix createFix(CompilationUnit compilationUnit) throws CoreException { if (compilationUnit == null) return null; return TypeParametersFix.createCleanUp(compilationUnit, isEnabled(CleanUpConstants.INSERT_INFERRED_TYPE_ARGUMENTS), isEnabled(CleanUpConstants.REMOVE_REDUNDANT_TYPE_ARGUMENTS)); }
@Override protected ICleanUpFix createFix(CompilationUnit compilationUnit, IProblemLocation[] problems) throws CoreException { if (compilationUnit == null) return null; return TypeParametersFix.createCleanUp(compilationUnit, problems, isEnabled(CleanUpConstants.INSERT_INFERRED_TYPE_ARGUMENTS), isEnabled(CleanUpConstants.REMOVE_REDUNDANT_TYPE_ARGUMENTS)); }
@Override public String[] getStepDescriptions() { List<String> result= new ArrayList<>(); if (isEnabled(CleanUpConstants.INSERT_INFERRED_TYPE_ARGUMENTS)) { result.add(MultiFixMessages.TypeParametersCleanUp_InsertInferredTypeArguments_description); } else if (isEnabled(CleanUpConstants.REMOVE_REDUNDANT_TYPE_ARGUMENTS)) { result.add(MultiFixMessages.TypeParametersCleanUp_RemoveUnnecessaryTypeArguments_description); } return result.toArray(new String[result.size()]); }
@Override public String[] getStepDescriptions() { List<String> result= new ArrayList<>(); if (isEnabled(CleanUpConstants.INSERT_INFERRED_TYPE_ARGUMENTS)) { result.add(MultiFixMessages.TypeParametersCleanUp_InsertInferredTypeArguments_description); } else if (isEnabled(CleanUpConstants.REMOVE_REDUNDANT_TYPE_ARGUMENTS)) { result.add(MultiFixMessages.TypeParametersCleanUp_RemoveUnnecessaryTypeArguments_description); } return result.toArray(new String[result.size()]); }
@Override public String getPreview() { StringBuffer buf= new StringBuffer(); if (isEnabled(CleanUpConstants.REMOVE_REDUNDANT_TYPE_ARGUMENTS)) { buf.append("\nMap<Integer, String> map= new HashMap<>();"); //$NON-NLS-1$ } else { buf.append("\nMap<Integer, String> map= new HashMap<Integer, String>();"); //$NON-NLS-1$ } return buf.toString(); } }
@Override public String getPreview() { StringBuilder buf= new StringBuilder(); if (isEnabled(CleanUpConstants.REMOVE_REDUNDANT_TYPE_ARGUMENTS)) { buf.append("\nMap<Integer, String> map= new HashMap<>();"); //$NON-NLS-1$ } else { buf.append("\nMap<Integer, String> map= new HashMap<Integer, String>();"); //$NON-NLS-1$ } return buf.toString(); } }
@Override public CleanUpRequirements getRequirements() { boolean requireAST= isEnabled(CleanUpConstants.INSERT_INFERRED_TYPE_ARGUMENTS) || isEnabled(CleanUpConstants.REMOVE_REDUNDANT_TYPE_ARGUMENTS); Map<String, String> requiredOptions= requireAST ? getRequiredOptions() : null; return new CleanUpRequirements(requireAST, false, false, requiredOptions); }
@Override public CleanUpRequirements getRequirements() { boolean requireAST= isEnabled(CleanUpConstants.INSERT_INFERRED_TYPE_ARGUMENTS) || isEnabled(CleanUpConstants.REMOVE_REDUNDANT_TYPE_ARGUMENTS); Map<String, String> requiredOptions= requireAST ? getRequiredOptions() : null; return new CleanUpRequirements(requireAST, false, false, requiredOptions); }
@Override public int computeNumberOfFixes(CompilationUnit compilationUnit) { if (fOptions == null) return 0; int result= 0; IProblem[] problems= compilationUnit.getProblems(); if (isEnabled(CleanUpConstants.REMOVE_REDUNDANT_TYPE_ARGUMENTS)) result= getNumberOfProblems(problems, IProblem.RedundantSpecificationOfTypeArguments); else if (isEnabled(CleanUpConstants.INSERT_INFERRED_TYPE_ARGUMENTS)) result= getNumberOfProblems(problems, IProblem.DiamondNotBelow17); return result; }
@Override public int computeNumberOfFixes(CompilationUnit compilationUnit) { if (fOptions == null) return 0; int result= 0; IProblem[] problems= compilationUnit.getProblems(); if (isEnabled(CleanUpConstants.REMOVE_REDUNDANT_TYPE_ARGUMENTS)) result= getNumberOfProblems(problems, IProblem.RedundantSpecificationOfTypeArguments); else if (isEnabled(CleanUpConstants.INSERT_INFERRED_TYPE_ARGUMENTS)) result= getNumberOfProblems(problems, IProblem.DiamondNotBelow17); return result; }