use of org.eclipse.jdt.internal.ui.fix.ExpressionsCleanUp 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.ui.fix.ExpressionsCleanUp 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.ui.fix.ExpressionsCleanUp 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;
}
Aggregations