use of org.eclipse.jdt.internal.ui.fix.LambdaExpressionsCleanUpCore in project eclipse.jdt.ls by eclipse.
the class RefactorProcessor method getConvertLambdaToAnonymousClassCreationsProposals.
private static boolean getConvertLambdaToAnonymousClassCreationsProposals(IInvocationContext context, ASTNode covering, Collection<ChangeCorrectionProposal> resultingCollections) {
if (resultingCollections == null) {
return true;
}
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 = LambdaExpressionsFixCore.createConvertToAnonymousClassCreationsFix(lambda);
if (fix == null) {
return false;
}
// add correction proposal
Map<String, String> options = new HashMap<>();
options.put(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES, CleanUpOptionsCore.TRUE);
options.put(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION, CleanUpOptionsCore.TRUE);
FixCorrectionProposal proposal = new FixCorrectionProposal(fix, new LambdaExpressionsCleanUpCore(options), IProposalRelevance.CONVERT_TO_ANONYMOUS_CLASS_CREATION, context, CodeActionKind.Refactor);
resultingCollections.add(proposal);
return true;
}
use of org.eclipse.jdt.internal.ui.fix.LambdaExpressionsCleanUpCore in project eclipse.jdt.ls by eclipse.
the class RefactorProcessor method getConvertAnonymousClassCreationsToLambdaProposals.
private static boolean getConvertAnonymousClassCreationsToLambdaProposals(IInvocationContext context, ASTNode covering, Collection<ChangeCorrectionProposal> resultingCollections) {
ClassInstanceCreation cic = getClassInstanceCreation(covering);
if (cic == null) {
return false;
}
IProposableFix fix = LambdaExpressionsFixCore.createConvertToLambdaFix(cic);
if (fix == null) {
return false;
}
if (resultingCollections == null) {
return true;
}
Map<String, String> options = new HashMap<>();
options.put(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES, CleanUpOptionsCore.TRUE);
options.put(CleanUpConstants.USE_LAMBDA, CleanUpOptionsCore.TRUE);
FixCorrectionProposal proposal = new FixCorrectionProposal(fix, new LambdaExpressionsCleanUpCore(options), IProposalRelevance.CONVERT_TO_LAMBDA_EXPRESSION, context, CodeActionKind.Refactor);
resultingCollections.add(proposal);
return true;
}
Aggregations