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 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) }; }
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;
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;