@Override public CleanUpRequirements getRequirements() { return new CleanUpRequirements(requireAST(), false, false, null); }
public static boolean getConvertLambdaToAnonymousClassCreationsProposals(IInvocationContext context, ASTNode covering, Collection<ICommandAccess> resultingCollections) { LambdaExpression lambda; if (covering instanceof LambdaExpression) { lambda= (LambdaExpression) covering; } else if (covering.getLocationInParent() == LambdaExpression.BODY_PROPERTY) { lambda= (LambdaExpression) covering.getParent(); } else { return false; } IProposableFix fix= LambdaExpressionsFix.createConvertToAnonymousClassCreationsFix(lambda); if (fix == null) return false; if (resultingCollections == null) return true; // add correction proposal Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); Map<String, String> options= new Hashtable<>(); options.put(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES, CleanUpOptions.TRUE); options.put(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION, CleanUpOptions.TRUE); FixCorrectionProposal proposal= new FixCorrectionProposal(fix, new LambdaExpressionsCleanUp(options), IProposalRelevance.CONVERT_TO_ANONYMOUS_CLASS_CREATION, image, context); resultingCollections.add(proposal); return true; }
public static boolean getConvertLambdaToAnonymousClassCreationsProposals(IInvocationContext context, ASTNode covering, Collection<ICommandAccess> resultingCollections) { LambdaExpression lambda; if (covering instanceof LambdaExpression) { lambda= (LambdaExpression) covering; } else if (covering.getLocationInParent() == LambdaExpression.BODY_PROPERTY) { lambda= (LambdaExpression) covering.getParent(); } else { return false; } IProposableFix fix= LambdaExpressionsFix.createConvertToAnonymousClassCreationsFix(lambda); if (fix == null) return false; if (resultingCollections == null) return true; // add correction proposal Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); Map<String, String> options= new Hashtable<>(); options.put(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES, CleanUpOptions.TRUE); options.put(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION, CleanUpOptions.TRUE); FixCorrectionProposal proposal= new FixCorrectionProposal(fix, new LambdaExpressionsCleanUp(options), IProposalRelevance.CONVERT_TO_ANONYMOUS_CLASS_CREATION, image, context); resultingCollections.add(proposal); return true; }
@Override protected AbstractCleanUp[] createPreviewCleanUps(Map<String, String> values) { return new AbstractCleanUp[] { new ControlStatementsCleanUp(values), new ConvertLoopCleanUp(values), new ExpressionsCleanUp(values), new VariableDeclarationCleanUp(values), new LambdaExpressionsCleanUp(values) }; }
@Override public CleanUpRequirements getRequirements() { return new CleanUpRequirements(requireAST(), false, false, null); }
@Override public String[] getStepDescriptions() { List<String> result= new ArrayList<>(); if (isEnabled(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES)) { if (isEnabled(CleanUpConstants.USE_LAMBDA)) { result.add(MultiFixMessages.LambdaExpressionsCleanUp_use_lambda_where_possible); } if (isEnabled(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION)) { result.add(MultiFixMessages.LambdaExpressionsCleanUp_use_anonymous); } } return result.toArray(new String[result.size()]); }
@Override protected AbstractCleanUp[] createPreviewCleanUps(Map<String, String> values) { return new AbstractCleanUp[] { new ControlStatementsCleanUp(values), new ConvertLoopCleanUp(values), new ExpressionsCleanUp(values), new VariableDeclarationCleanUp(values), new LambdaExpressionsCleanUp(values) }; }
@Override public String[] getStepDescriptions() { List<String> result= new ArrayList<>(); if (isEnabled(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES)) { if (isEnabled(CleanUpConstants.USE_LAMBDA)) { result.add(MultiFixMessages.LambdaExpressionsCleanUp_use_lambda_where_possible); } if (isEnabled(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION)) { result.add(MultiFixMessages.LambdaExpressionsCleanUp_use_anonymous); } } return result.toArray(new String[result.size()]); }
options.put(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES, CleanUpOptions.TRUE); options.put(CleanUpConstants.USE_LAMBDA, CleanUpOptions.TRUE); FixCorrectionProposal proposal= new FixCorrectionProposal(fix, new LambdaExpressionsCleanUp(options), IProposalRelevance.CONVERT_TO_LAMBDA_EXPRESSION, image, context); resultingCollections.add(proposal); return true;
@Override public ICleanUpFix createFix(CleanUpContext context) throws CoreException { CompilationUnit compilationUnit= context.getAST(); if (compilationUnit == null) return null; boolean convertFunctionalInterfaces= isEnabled(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES); if (!convertFunctionalInterfaces) return null; return LambdaExpressionsFix.createCleanUp(compilationUnit, isEnabled(CleanUpConstants.USE_LAMBDA), isEnabled(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION)); }
options.put(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES, CleanUpOptions.TRUE); options.put(CleanUpConstants.USE_LAMBDA, CleanUpOptions.TRUE); FixCorrectionProposal proposal= new FixCorrectionProposal(fix, new LambdaExpressionsCleanUp(options), IProposalRelevance.CONVERT_TO_LAMBDA_EXPRESSION, image, context); resultingCollections.add(proposal); return true;
@Override public ICleanUpFix createFix(CleanUpContext context) throws CoreException { CompilationUnit compilationUnit= context.getAST(); if (compilationUnit == null) return null; boolean convertFunctionalInterfaces= isEnabled(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES); if (!convertFunctionalInterfaces) return null; return LambdaExpressionsFix.createCleanUp(compilationUnit, isEnabled(CleanUpConstants.USE_LAMBDA), isEnabled(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION)); }