use of org.eclipse.jdt.internal.corext.fix.IProposableFix 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.internal.corext.fix.IProposableFix in project che by eclipse.
the class QuickAssistProcessor method getInferDiamondArgumentsProposal.
public static boolean getInferDiamondArgumentsProposal(IInvocationContext context, ASTNode node, IProblemLocation[] locations, Collection<ICommandAccess> resultingCollections) {
// don't add if already added as quick fix
if (containsMatchingProblem(locations, IProblem.DiamondNotBelow17))
return false;
ParameterizedType createdType = null;
if (node instanceof Name) {
Name name = ASTNodes.getTopMostName((Name) node);
if (name.getLocationInParent() == SimpleType.NAME_PROPERTY || name.getLocationInParent() == NameQualifiedType.NAME_PROPERTY) {
ASTNode type = name.getParent();
if (type.getLocationInParent() == ParameterizedType.TYPE_PROPERTY) {
createdType = (ParameterizedType) type.getParent();
if (createdType.getLocationInParent() != ClassInstanceCreation.TYPE_PROPERTY) {
return false;
}
}
}
} else if (node instanceof ParameterizedType) {
createdType = (ParameterizedType) node;
if (createdType.getLocationInParent() != ClassInstanceCreation.TYPE_PROPERTY) {
return false;
}
} else if (node instanceof ClassInstanceCreation) {
ClassInstanceCreation creation = (ClassInstanceCreation) node;
Type type = creation.getType();
if (type instanceof ParameterizedType) {
createdType = (ParameterizedType) type;
}
}
IProposableFix fix = TypeParametersFix.createInsertInferredTypeArgumentsFix(context.getASTRoot(), createdType);
if (fix != null && resultingCollections != null) {
Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
// if error -> higher than ReorgCorrectionsSubProcessor.getNeedHigherComplianceProposals()
int relevance = locations == null ? IProposalRelevance.INSERT_INFERRED_TYPE_ARGUMENTS : IProposalRelevance.INSERT_INFERRED_TYPE_ARGUMENTS_ERROR;
Map<String, String> options = new HashMap<String, String>();
options.put(CleanUpConstants.USE_TYPE_ARGUMENTS, CleanUpOptions.TRUE);
options.put(CleanUpConstants.INSERT_INFERRED_TYPE_ARGUMENTS, CleanUpOptions.TRUE);
FixCorrectionProposal proposal = new FixCorrectionProposal(fix, new TypeParametersCleanUp(options), relevance, image, context);
resultingCollections.add(proposal);
}
return true;
}
use of org.eclipse.jdt.internal.corext.fix.IProposableFix in project che by eclipse.
the class ReorgCorrectionsSubProcessor method removeImportStatementProposals.
public static void removeImportStatementProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
IProposableFix fix = UnusedCodeFix.createRemoveUnusedImportFix(context.getASTRoot(), problem);
if (fix != null) {
Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_DELETE_IMPORT);
Map<String, String> options = new Hashtable<String, String>();
options.put(CleanUpConstants.REMOVE_UNUSED_CODE_IMPORTS, CleanUpOptions.TRUE);
FixCorrectionProposal proposal = new FixCorrectionProposal(fix, new UnusedCodeCleanUp(options), IProposalRelevance.REMOVE_UNUSED_IMPORT, image, context);
proposals.add(proposal);
}
final ICompilationUnit cu = context.getCompilationUnit();
String name = CorrectionMessages.ReorgCorrectionsSubProcessor_organizeimports_description;
ChangeCorrectionProposal proposal = new ChangeCorrectionProposal(name, null, IProposalRelevance.ORGANIZE_IMPORTS, JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE)) {
@Override
public void apply(IDocument document) {
// }
throw new UnsupportedOperationException("apply doesn't supported for action proposal");
}
@Override
public String getActionId() {
return "javaOrganizeImports";
}
};
proposals.add(proposal);
}
use of org.eclipse.jdt.internal.corext.fix.IProposableFix in project che by eclipse.
the class LocalCorrectionsSubProcessor method addRemoveRedundantTypeArgumentsProposals.
public static void addRemoveRedundantTypeArgumentsProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
IProposableFix fix = TypeParametersFix.createRemoveRedundantTypeArgumentsFix(context.getASTRoot(), problem);
if (fix != null) {
//JavaPlugin.getDefault().getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE);
Image image = JavaPluginImages.get(JavaPluginImages.IMG_TOOL_DELETE);
Map<String, String> options = new HashMap<String, String>();
options.put(CleanUpConstants.USE_TYPE_ARGUMENTS, CleanUpOptions.TRUE);
options.put(CleanUpConstants.REMOVE_REDUNDANT_TYPE_ARGUMENTS, CleanUpOptions.TRUE);
FixCorrectionProposal proposal = new FixCorrectionProposal(fix, new TypeParametersCleanUp(options), IProposalRelevance.REMOVE_REDUNDANT_TYPE_ARGUMENTS, image, context);
proposals.add(proposal);
}
}
use of org.eclipse.jdt.internal.corext.fix.IProposableFix in project che by eclipse.
the class ModifierCorrectionSubProcessor method addOverrideAnnotationProposal.
public static void addOverrideAnnotationProposal(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
IProposableFix fix = Java50Fix.createAddOverrideAnnotationFix(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_OVERRIDE, CleanUpOptions.TRUE);
options.put(CleanUpConstants.ADD_MISSING_ANNOTATIONS_OVERRIDE_FOR_INTERFACE_METHOD_IMPLEMENTATION, CleanUpOptions.TRUE);
FixCorrectionProposal proposal = new FixCorrectionProposal(fix, new Java50CleanUp(options), IProposalRelevance.ADD_OVERRIDE_ANNOTATION, image, context);
proposals.add(proposal);
}
}
Aggregations