Java Code Examples for org.eclipse.jdt.core.dom.VariableDeclarationStatement#FRAGMENTS_PROPERTY
The following examples show how to use
org.eclipse.jdt.core.dom.VariableDeclarationStatement#FRAGMENTS_PROPERTY .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QuickAssistProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
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; }
Example 2
Source File: QuickAssistProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static boolean getConvertLocalToFieldProposal(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 == null || decl.getLocationInParent() != VariableDeclarationStatement.FRAGMENTS_PROPERTY) return false; if (proposals == null) { return true; } PromoteTempToFieldRefactoring refactoring= new PromoteTempToFieldRefactoring((VariableDeclaration) decl); if (refactoring.checkInitialConditions(new NullProgressMonitor()).isOK()) { String label= CorrectionMessages.QuickAssistProcessor_convert_local_to_field_description; Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); LinkedProposalModel linkedProposalModel= new LinkedProposalModel(); refactoring.setLinkedProposalModel(linkedProposalModel); RefactoringCorrectionProposal proposal= new RefactoringCorrectionProposal(label, context.getCompilationUnit(), refactoring, IProposalRelevance.CONVERT_LOCAL_TO_FIELD, image); proposal.setLinkedProposalModel(linkedProposalModel); proposal.setCommandId(CONVERT_LOCAL_TO_FIELD_ID); proposals.add(proposal); } return true; }