Search in sources :

Example 1 with LambdaExpressionsCleanUp

use of org.eclipse.jdt.internal.ui.fix.LambdaExpressionsCleanUp in project che by eclipse.

the class QuickAssistProcessor method getConvertLambdaToAnonymousClassCreationsProposals.

private 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<String, String>();
    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;
}
Also used : FixCorrectionProposal(org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal) Hashtable(java.util.Hashtable) LambdaExpressionsCleanUp(org.eclipse.jdt.internal.ui.fix.LambdaExpressionsCleanUp) IProposableFix(org.eclipse.jdt.internal.corext.fix.IProposableFix) Image(org.eclipse.swt.graphics.Image)

Aggregations

Hashtable (java.util.Hashtable)1 IProposableFix (org.eclipse.jdt.internal.corext.fix.IProposableFix)1 LambdaExpressionsCleanUp (org.eclipse.jdt.internal.ui.fix.LambdaExpressionsCleanUp)1 FixCorrectionProposal (org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal)1 Image (org.eclipse.swt.graphics.Image)1