Search in sources :

Example 1 with ICleanUp

use of org.eclipse.jdt.ui.cleanup.ICleanUp 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 ICleanUp

use of org.eclipse.jdt.ui.cleanup.ICleanUp in project che by eclipse.

the class LocalCorrectionsSubProcessor method addUnimplementedMethodsProposals.

public static void addUnimplementedMethodsProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
    IProposableFix addMethodFix = UnimplementedCodeFix.createAddUnimplementedMethodsFix(context.getASTRoot(), problem);
    if (addMethodFix != null) {
        Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
        Map<String, String> settings = new Hashtable<String, String>();
        settings.put(CleanUpConstants.ADD_MISSING_METHODES, CleanUpOptions.TRUE);
        ICleanUp cleanUp = new UnimplementedCodeCleanUp(settings);
        proposals.add(new FixCorrectionProposal(addMethodFix, cleanUp, IProposalRelevance.ADD_UNIMPLEMENTED_METHODS, image, context));
    }
    IProposableFix makeAbstractFix = UnimplementedCodeFix.createMakeTypeAbstractFix(context.getASTRoot(), problem);
    if (makeAbstractFix != null) {
        Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
        Map<String, String> settings = new Hashtable<String, String>();
        settings.put(UnimplementedCodeCleanUp.MAKE_TYPE_ABSTRACT, CleanUpOptions.TRUE);
        ICleanUp cleanUp = new UnimplementedCodeCleanUp(settings);
        proposals.add(new FixCorrectionProposal(makeAbstractFix, cleanUp, IProposalRelevance.MAKE_TYPE_ABSTRACT, image, context));
    }
}
Also used : FixCorrectionProposal(org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal) ICleanUp(org.eclipse.jdt.ui.cleanup.ICleanUp) Hashtable(java.util.Hashtable) IProposableFix(org.eclipse.jdt.internal.corext.fix.IProposableFix) UnimplementedCodeCleanUp(org.eclipse.jdt.internal.ui.fix.UnimplementedCodeCleanUp) Image(org.eclipse.swt.graphics.Image)

Example 3 with ICleanUp

use of org.eclipse.jdt.ui.cleanup.ICleanUp 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)

Example 4 with ICleanUp

use of org.eclipse.jdt.ui.cleanup.ICleanUp in project che by eclipse.

the class QuickAssistProcessor method getRemoveBlockProposals.

private static boolean getRemoveBlockProposals(IInvocationContext context, ASTNode coveringNode, Collection<ICommandAccess> resultingCollections) {
    IProposableFix[] fixes = ControlStatementsFix.createRemoveBlockFix(context.getASTRoot(), coveringNode);
    if (fixes != null) {
        if (resultingCollections == null) {
            return true;
        }
        Map<String, String> options = new Hashtable<String, String>();
        options.put(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS, CleanUpOptions.TRUE);
        options.put(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NEVER, CleanUpOptions.TRUE);
        ICleanUp cleanUp = new ControlStatementsCleanUp(options);
        for (int i = 0; i < fixes.length; i++) {
            IProposableFix fix = fixes[i];
            Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
            FixCorrectionProposal proposal = new FixCorrectionProposal(fix, cleanUp, IProposalRelevance.REMOVE_BLOCK_FIX, image, context);
            resultingCollections.add(proposal);
        }
        return true;
    }
    return false;
}
Also used : FixCorrectionProposal(org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal) ICleanUp(org.eclipse.jdt.ui.cleanup.ICleanUp) Hashtable(java.util.Hashtable) IProposableFix(org.eclipse.jdt.internal.corext.fix.IProposableFix) Image(org.eclipse.swt.graphics.Image) ControlStatementsCleanUp(org.eclipse.jdt.internal.ui.fix.ControlStatementsCleanUp)

Aggregations

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