@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 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); }
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; }
public static void addRemoveRedundantTypeArgumentsProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) { IProposableFix fix= TypeParametersFix.createRemoveRedundantTypeArgumentsFix(context.getASTRoot(), problem); if (fix != null) { Image image= JavaPlugin.getDefault().getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE); Map<String, String> options= new HashMap<>(); options.put(CleanUpConstants.REMOVE_REDUNDANT_TYPE_ARGUMENTS, CleanUpOptions.TRUE); FixCorrectionProposal proposal= new FixCorrectionProposal(fix, new TypeParametersCleanUp(options), IProposalRelevance.REMOVE_REDUNDANT_TYPE_ARGUMENTS, image, context); proposals.add(proposal); } }
@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)); }
public static void addRemoveRedundantTypeArgumentsProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) { IProposableFix fix= TypeParametersFix.createRemoveRedundantTypeArgumentsFix(context.getASTRoot(), problem); if (fix != null) { Image image= JavaPlugin.getDefault().getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE); Map<String, String> options= new HashMap<>(); options.put(CleanUpConstants.REMOVE_REDUNDANT_TYPE_ARGUMENTS, CleanUpOptions.TRUE); FixCorrectionProposal proposal= new FixCorrectionProposal(fix, new TypeParametersCleanUp(options), IProposalRelevance.REMOVE_REDUNDANT_TYPE_ARGUMENTS, image, context); proposals.add(proposal); } }
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 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 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 protected AbstractCleanUp[] createPreviewCleanUps(Map<String, String> values) { return new AbstractCleanUp[] { new UnusedCodeCleanUp(values), new UnnecessaryCodeCleanUp(values), new StringCleanUp(values), new TypeParametersCleanUp(values) }; }
@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 protected AbstractCleanUp[] createPreviewCleanUps(Map<String, String> values) { return new AbstractCleanUp[] { new UnusedCodeCleanUp(values), new UnnecessaryCodeCleanUp(values), new StringCleanUp(values), new TypeParametersCleanUp(values), new RedundantModifiersCleanUp(values), new RedundantSemicolonsCleanUp(values) }; }
@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; }
Map<String, String> options= new HashMap<>(); options.put(CleanUpConstants.INSERT_INFERRED_TYPE_ARGUMENTS, CleanUpOptions.TRUE); FixCorrectionProposal proposal= new FixCorrectionProposal(fix, new TypeParametersCleanUp(options), relevance, image, context); resultingCollections.add(proposal);
@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; }
Map<String, String> options= new HashMap<>(); options.put(CleanUpConstants.INSERT_INFERRED_TYPE_ARGUMENTS, CleanUpOptions.TRUE); FixCorrectionProposal proposal= new FixCorrectionProposal(fix, new TypeParametersCleanUp(options), relevance, image, context); resultingCollections.add(proposal);
@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()]); }