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;
}
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));
}
}
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;
}
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;
}
Aggregations