use of org.eclipse.jdt.internal.corext.fix.IProposableFix in project che by eclipse.
the class AdvancedQuickAssistProcessor method getAddParanoidalParenthesesProposals.
private static boolean getAddParanoidalParenthesesProposals(IInvocationContext context, ArrayList<ASTNode> coveredNodes, Collection<ICommandAccess> resultingCollections) {
IProposableFix fix = ExpressionsFix.createAddParanoidalParenthesisFix(context.getASTRoot(), coveredNodes.toArray(new ASTNode[coveredNodes.size()]));
if (fix == null)
return false;
if (resultingCollections == null)
return true;
// add correction proposal
Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CAST);
Map<String, String> options = new Hashtable<String, String>();
options.put(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES, CleanUpOptions.TRUE);
options.put(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_ALWAYS, CleanUpOptions.TRUE);
FixCorrectionProposal proposal = new FixCorrectionProposal(fix, new ExpressionsCleanUp(options), IProposalRelevance.ADD_PARANOIDAL_PARENTHESES, image, context);
resultingCollections.add(proposal);
return true;
}
use of org.eclipse.jdt.internal.corext.fix.IProposableFix in project che by eclipse.
the class AdvancedQuickAssistProcessor method getRemoveExtraParenthesesProposals.
private static boolean getRemoveExtraParenthesesProposals(IInvocationContext context, ASTNode covering, ArrayList<ASTNode> coveredNodes, Collection<ICommandAccess> resultingCollections) {
ArrayList<ASTNode> nodes;
if (context.getSelectionLength() == 0 && covering instanceof ParenthesizedExpression) {
nodes = new ArrayList<ASTNode>();
nodes.add(covering);
} else {
nodes = coveredNodes;
}
if (nodes.isEmpty())
return false;
IProposableFix fix = ExpressionsFix.createRemoveUnnecessaryParenthesisFix(context.getASTRoot(), nodes.toArray(new ASTNode[nodes.size()]));
if (fix == null)
return false;
if (resultingCollections == null)
return true;
Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_REMOVE);
Map<String, String> options = new Hashtable<String, String>();
options.put(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES, CleanUpOptions.TRUE);
options.put(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_NEVER, CleanUpOptions.TRUE);
FixCorrectionProposal proposal = new FixCorrectionProposal(fix, new ExpressionsCleanUp(options), IProposalRelevance.REMOVE_EXTRA_PARENTHESES, image, context);
resultingCollections.add(proposal);
return true;
}
use of org.eclipse.jdt.internal.corext.fix.IProposableFix in project che by eclipse.
the class QuickAssistProcessor method getConvertAnonymousClassCreationsToLambdaProposals.
private static boolean getConvertAnonymousClassCreationsToLambdaProposals(IInvocationContext context, ASTNode covering, Collection<ICommandAccess> resultingCollections) {
while (covering instanceof Name || covering instanceof Type || covering instanceof Dimension || covering.getParent() instanceof MethodDeclaration || covering.getLocationInParent() == AnonymousClassDeclaration.BODY_DECLARATIONS_PROPERTY) {
covering = covering.getParent();
}
ClassInstanceCreation cic;
if (covering instanceof ClassInstanceCreation) {
cic = (ClassInstanceCreation) covering;
} else if (covering.getLocationInParent() == ClassInstanceCreation.ANONYMOUS_CLASS_DECLARATION_PROPERTY) {
cic = (ClassInstanceCreation) covering.getParent();
} else if (covering instanceof Name) {
ASTNode normalized = ASTNodes.getNormalizedNode(covering);
if (normalized.getLocationInParent() != ClassInstanceCreation.TYPE_PROPERTY)
return false;
cic = (ClassInstanceCreation) normalized.getParent();
} else {
return false;
}
IProposableFix fix = LambdaExpressionsFix.createConvertToLambdaFix(cic);
if (fix == null)
return false;
if (resultingCollections == null)
return true;
// add correction proposal
Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
Map<String, String> options = new Hashtable<String, String>();
options.put(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES, CleanUpOptions.TRUE);
options.put(CleanUpConstants.USE_LAMBDA, CleanUpOptions.TRUE);
FixCorrectionProposal proposal = new FixCorrectionProposal(fix, new ExpressionsCleanUp(options), IProposalRelevance.CONVERT_TO_LAMBDA_EXPRESSION, image, context);
resultingCollections.add(proposal);
return true;
}
use of org.eclipse.jdt.internal.corext.fix.IProposableFix 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.internal.corext.fix.IProposableFix 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);
}
}
Aggregations