use of org.eclipse.jdt.internal.ui.text.correction.proposals.RefactoringCorrectionProposal in project che by eclipse.
the class QuickAssistProcessor method getInlineLocalProposal.
private static boolean getInlineLocalProposal(IInvocationContext context, final ASTNode node, Collection<ICommandAccess> proposals) throws CoreException {
if (!(node instanceof SimpleName))
return false;
SimpleName name = (SimpleName) node;
IBinding binding = name.resolveBinding();
if (!(binding instanceof IVariableBinding))
return false;
IVariableBinding varBinding = (IVariableBinding) binding;
if (varBinding.isField() || varBinding.isParameter())
return false;
ASTNode decl = context.getASTRoot().findDeclaringNode(varBinding);
if (!(decl instanceof VariableDeclarationFragment) || decl.getLocationInParent() != VariableDeclarationStatement.FRAGMENTS_PROPERTY)
return false;
if (proposals == null) {
return true;
}
InlineTempRefactoring refactoring = new InlineTempRefactoring((VariableDeclaration) decl);
if (refactoring.checkInitialConditions(new NullProgressMonitor()).isOK()) {
String label = CorrectionMessages.QuickAssistProcessor_inline_local_description;
Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
RefactoringCorrectionProposal proposal = new RefactoringCorrectionProposal(label, context.getCompilationUnit(), refactoring, IProposalRelevance.INLINE_LOCAL, image);
proposal.setCommandId(INLINE_LOCAL_ID);
proposals.add(proposal);
}
return true;
}
Aggregations