Search in sources :

Example 1 with ConvertLoopCleanUp

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

the class QuickAssistProcessor method getConvertIterableLoopProposal.

private static boolean getConvertIterableLoopProposal(IInvocationContext context, ASTNode node, Collection<ICommandAccess> resultingCollections) {
    ForStatement forStatement = getEnclosingForStatementHeader(node);
    if (forStatement == null)
        return false;
    if (resultingCollections == null)
        return true;
    IProposableFix fix = ConvertLoopFix.createConvertIterableLoopToEnhancedFix(context.getASTRoot(), forStatement);
    if (fix == null)
        return false;
    Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
    Map<String, String> options = new HashMap<String, String>();
    options.put(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED, CleanUpOptions.TRUE);
    ICleanUp cleanUp = new ConvertLoopCleanUp(options);
    FixCorrectionProposal proposal = new FixCorrectionProposal(fix, cleanUp, IProposalRelevance.CONVERT_ITERABLE_LOOP_TO_ENHANCED, image, context);
    proposal.setCommandId(CONVERT_FOR_LOOP_ID);
    resultingCollections.add(proposal);
    return true;
}
Also used : FixCorrectionProposal(org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal) ICleanUp(org.eclipse.jdt.ui.cleanup.ICleanUp) HashMap(java.util.HashMap) IProposableFix(org.eclipse.jdt.internal.corext.fix.IProposableFix) ConvertLoopCleanUp(org.eclipse.jdt.internal.ui.fix.ConvertLoopCleanUp) Image(org.eclipse.swt.graphics.Image)

Example 2 with ConvertLoopCleanUp

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

the class QuickAssistProcessor method getConvertForLoopProposal.

private static boolean getConvertForLoopProposal(IInvocationContext context, ASTNode node, Collection<ICommandAccess> resultingCollections) {
    ForStatement forStatement = getEnclosingForStatementHeader(node);
    if (forStatement == null)
        return false;
    if (resultingCollections == null)
        return true;
    IProposableFix fix = ConvertLoopFix.createConvertForLoopToEnhancedFix(context.getASTRoot(), forStatement);
    if (fix == null)
        return false;
    Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
    Map<String, String> options = new HashMap<String, String>();
    options.put(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED, CleanUpOptions.TRUE);
    ICleanUp cleanUp = new ConvertLoopCleanUp(options);
    FixCorrectionProposal proposal = new FixCorrectionProposal(fix, cleanUp, IProposalRelevance.CONVERT_FOR_LOOP_TO_ENHANCED, image, context);
    proposal.setCommandId(CONVERT_FOR_LOOP_ID);
    resultingCollections.add(proposal);
    return true;
}
Also used : FixCorrectionProposal(org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal) ICleanUp(org.eclipse.jdt.ui.cleanup.ICleanUp) HashMap(java.util.HashMap) IProposableFix(org.eclipse.jdt.internal.corext.fix.IProposableFix) ConvertLoopCleanUp(org.eclipse.jdt.internal.ui.fix.ConvertLoopCleanUp) Image(org.eclipse.swt.graphics.Image)

Aggregations

HashMap (java.util.HashMap)2 IProposableFix (org.eclipse.jdt.internal.corext.fix.IProposableFix)2 ConvertLoopCleanUp (org.eclipse.jdt.internal.ui.fix.ConvertLoopCleanUp)2 FixCorrectionProposal (org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal)2 ICleanUp (org.eclipse.jdt.ui.cleanup.ICleanUp)2 Image (org.eclipse.swt.graphics.Image)2