Search in sources :

Example 11 with FixCorrectionProposal

use of org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal in project che by eclipse.

the class ModifierCorrectionSubProcessor method addDeprecatedAnnotationProposal.

public static void addDeprecatedAnnotationProposal(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
    IProposableFix fix = Java50Fix.createAddDeprectatedAnnotation(context.getASTRoot(), problem);
    if (fix != null) {
        Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
        Map<String, String> options = new Hashtable<String, String>();
        options.put(CleanUpConstants.ADD_MISSING_ANNOTATIONS, CleanUpOptions.TRUE);
        options.put(CleanUpConstants.ADD_MISSING_ANNOTATIONS_DEPRECATED, CleanUpOptions.TRUE);
        FixCorrectionProposal proposal = new FixCorrectionProposal(fix, new Java50CleanUp(options), IProposalRelevance.ADD_DEPRECATED_ANNOTATION, image, context);
        proposals.add(proposal);
    }
}
Also used : FixCorrectionProposal(org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal) Hashtable(java.util.Hashtable) IProposableFix(org.eclipse.jdt.internal.corext.fix.IProposableFix) Image(org.eclipse.swt.graphics.Image) Java50CleanUp(org.eclipse.jdt.internal.ui.fix.Java50CleanUp)

Example 12 with FixCorrectionProposal

use of org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal in project che by eclipse.

the class NullAnnotationsCorrectionProcessor method addRemoveRedundantAnnotationProposal.

public static void addRemoveRedundantAnnotationProposal(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
    NullAnnotationsFix fix = NullAnnotationsFix.createRemoveRedundantNullAnnotationsFix(context.getASTRoot(), problem);
    if (fix == null)
        return;
    Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
    Map<String, String> options = new Hashtable<String, String>();
    FixCorrectionProposal proposal = new FixCorrectionProposal(fix, new NullAnnotationsCleanUp(options, problem.getProblemId()), IProposalRelevance.REMOVE_REDUNDANT_NULLNESS_ANNOTATION, image, context);
    proposals.add(proposal);
}
Also used : FixCorrectionProposal(org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal) Hashtable(java.util.Hashtable) NullAnnotationsFix(org.eclipse.jdt.internal.corext.fix.NullAnnotationsFix) Image(org.eclipse.swt.graphics.Image) NullAnnotationsCleanUp(org.eclipse.jdt.internal.ui.fix.NullAnnotationsCleanUp)

Example 13 with FixCorrectionProposal

use of org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal 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 14 with FixCorrectionProposal

use of org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal in project che by eclipse.

the class LocalCorrectionsSubProcessor method addUnqualifiedFieldAccessProposal.

public static void addUnqualifiedFieldAccessProposal(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
    IProposableFix fix = CodeStyleFix.createAddFieldQualifierFix(context.getASTRoot(), problem);
    if (fix != null) {
        Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
        Map<String, String> options = new HashMap<String, String>();
        options.put(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS, CleanUpOptions.TRUE);
        options.put(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_ALWAYS, CleanUpOptions.TRUE);
        FixCorrectionProposal proposal = new FixCorrectionProposal(fix, new CodeStyleCleanUp(options), IProposalRelevance.ADD_FIELD_QUALIFIER, image, context);
        proposal.setCommandId(ADD_FIELD_QUALIFICATION_ID);
        proposals.add(proposal);
    }
}
Also used : FixCorrectionProposal(org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal) CodeStyleCleanUp(org.eclipse.jdt.internal.ui.fix.CodeStyleCleanUp) HashMap(java.util.HashMap) IProposableFix(org.eclipse.jdt.internal.corext.fix.IProposableFix) Image(org.eclipse.swt.graphics.Image)

Example 15 with FixCorrectionProposal

use of org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal 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

FixCorrectionProposal (org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal)23 Image (org.eclipse.swt.graphics.Image)23 IProposableFix (org.eclipse.jdt.internal.corext.fix.IProposableFix)19 Hashtable (java.util.Hashtable)15 HashMap (java.util.HashMap)6 ICleanUp (org.eclipse.jdt.ui.cleanup.ICleanUp)4 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)3 ExpressionsCleanUp (org.eclipse.jdt.internal.ui.fix.ExpressionsCleanUp)3 Java50CleanUp (org.eclipse.jdt.internal.ui.fix.Java50CleanUp)3 IType (org.eclipse.jdt.core.IType)2 NullAnnotationsFix (org.eclipse.jdt.internal.corext.fix.NullAnnotationsFix)2 CodeStyleCleanUp (org.eclipse.jdt.internal.ui.fix.CodeStyleCleanUp)2 ConvertLoopCleanUp (org.eclipse.jdt.internal.ui.fix.ConvertLoopCleanUp)2 LambdaExpressionsCleanUp (org.eclipse.jdt.internal.ui.fix.LambdaExpressionsCleanUp)2 NullAnnotationsCleanUp (org.eclipse.jdt.internal.ui.fix.NullAnnotationsCleanUp)2 TypeParametersCleanUp (org.eclipse.jdt.internal.ui.fix.TypeParametersCleanUp)2 ChangeCorrectionProposal (org.eclipse.jdt.ui.text.java.correction.ChangeCorrectionProposal)2 IDocument (org.eclipse.jface.text.IDocument)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 ASTNode (org.eclipse.jdt.core.dom.ASTNode)1