LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.COMBINE_STRINGS, image); resultingCollections.add(proposal); return true;
LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.COMBINE_STRINGS, image); resultingCollections.add(proposal); return true;
LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.PICK_SELECTED_STRING, image); proposal.addLinkedPosition(rewrite.track(centerLiteral), true, "CENTER_STRING"); //$NON-NLS-1$ resultingCollections.add(proposal);
LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.PICK_SELECTED_STRING, image); proposal.addLinkedPosition(rewrite.track(centerLiteral), true, "CENTER_STRING"); //$NON-NLS-1$ resultingCollections.add(proposal);
private static boolean getConvertMethodReferenceToLambdaProposal(IInvocationContext context, ASTNode covering, Collection<ICommandAccess> resultingCollections) throws JavaModelException { MethodReference methodReference; if (covering instanceof MethodReference) { methodReference= (MethodReference) covering; } else if (covering.getParent() instanceof MethodReference) { methodReference= (MethodReference) covering.getParent(); } else { return false; } IMethodBinding functionalMethod= getFunctionalMethodForMethodReference(methodReference); if (functionalMethod == null || functionalMethod.isGenericMethod()) { // generic lambda expressions are not allowed return false; } if (resultingCollections == null) return true; ASTRewrite rewrite= ASTRewrite.create(methodReference.getAST()); LinkedProposalModel linkedProposalModel= new LinkedProposalModel(); LambdaExpression lambda= convertMethodRefernceToLambda(methodReference, functionalMethod, context.getASTRoot(), rewrite, linkedProposalModel, false); // add proposal String label= CorrectionMessages.QuickAssistProcessor_convert_to_lambda_expression; Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.CONVERT_METHOD_REFERENCE_TO_LAMBDA, image); proposal.setLinkedProposalModel(linkedProposalModel); proposal.setEndPosition(rewrite.track(lambda)); resultingCollections.add(proposal); return true; }
private static boolean getConvertMethodReferenceToLambdaProposal(IInvocationContext context, ASTNode covering, Collection<ICommandAccess> resultingCollections) throws JavaModelException { MethodReference methodReference; if (covering instanceof MethodReference) { methodReference= (MethodReference) covering; } else if (covering.getParent() instanceof MethodReference) { methodReference= (MethodReference) covering.getParent(); } else { return false; } IMethodBinding functionalMethod= getFunctionalMethodForMethodReference(methodReference); if (functionalMethod == null || functionalMethod.isGenericMethod()) { // generic lambda expressions are not allowed return false; } if (resultingCollections == null) return true; ASTRewrite rewrite= ASTRewrite.create(methodReference.getAST()); LinkedProposalModel linkedProposalModel= new LinkedProposalModel(); LambdaExpression lambda= convertMethodRefernceToLambda(methodReference, functionalMethod, context.getASTRoot(), rewrite, linkedProposalModel, false); // add proposal String label= CorrectionMessages.QuickAssistProcessor_convert_to_lambda_expression; Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.CONVERT_METHOD_REFERENCE_TO_LAMBDA, image); proposal.setLinkedProposalModel(linkedProposalModel); proposal.setEndPosition(rewrite.track(lambda)); resultingCollections.add(proposal); return true; }
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.INVERT_EQUALS, image); resultingCollections.add(proposal); return true;
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, cu, rewrite, IProposalRelevance.INITIALIZE_VARIABLE, image); proposal.addLinkedPosition(rewrite.track(expression), false, "initializer"); //$NON-NLS-1$ proposals.add(proposal);
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, cu, rewrite, IProposalRelevance.INITIALIZE_VARIABLE, image); proposal.addLinkedPosition(rewrite.track(expression), false, "initializer"); //$NON-NLS-1$ proposals.add(proposal);
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.INVERT_EQUALS, image); resultingCollections.add(proposal); return true;
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.ADD_TYPE_TO_ARRAY_INITIALIZER, image);
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.ADD_TYPE_TO_ARRAY_INITIALIZER, image);
ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST()); ICompilationUnit cu= context.getCompilationUnit(); LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, cu, rewrite, IProposalRelevance.OVERRIDE_DEFAULT_METHOD, image);
ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST()); ICompilationUnit cu= context.getCompilationUnit(); LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, cu, rewrite, IProposalRelevance.OVERRIDE_DEFAULT_METHOD, image);
LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.THROW_ALLOCATED_OBJECT, image); proposal.setEndPosition(rewrite.track(throwStatement)); proposals.add(proposal); relevance= IProposalRelevance.RETURN_ALLOCATED_OBJECT; LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, context.getCompilationUnit(), rewrite, relevance, image); proposal.setEndPosition(rewrite.track(returnStatement)); proposals.add(proposal);
LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.THROW_ALLOCATED_OBJECT, image); proposal.setEndPosition(rewrite.track(throwStatement)); proposals.add(proposal); relevance= IProposalRelevance.RETURN_ALLOCATED_OBJECT; LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, context.getCompilationUnit(), rewrite, relevance, image); proposal.setEndPosition(rewrite.track(returnStatement)); proposals.add(proposal);
LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, cu, rewrite, IProposalRelevance.MISSING_RETURN_TYPE, image);
LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, cu, rewrite, IProposalRelevance.VOID_METHOD_RETURNS, image); ImportRewrite imports= proposal.createImportRewrite(astRoot); ImportRewriteContext importRewriteContext= new ContextSensitiveImportRewriteContext(methodDeclaration, imports);
LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, cu, rewrite, IProposalRelevance.VOID_METHOD_RETURNS, image); ImportRewrite imports= proposal.createImportRewrite(astRoot); ImportRewriteContext importRewriteContext= new ContextSensitiveImportRewriteContext(methodDeclaration, imports);
LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, cu, rewrite, IProposalRelevance.MISSING_RETURN_TYPE, image);