本文整理汇总了Java中org.eclipse.jdt.internal.corext.refactoring.code.PromoteTempToFieldRefactoring.setLinkedProposalModel方法的典型用法代码示例。如果您正苦于以下问题:Java PromoteTempToFieldRefactoring.setLinkedProposalModel方法的具体用法?Java PromoteTempToFieldRefactoring.setLinkedProposalModel怎么用?Java PromoteTempToFieldRefactoring.setLinkedProposalModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.corext.refactoring.code.PromoteTempToFieldRefactoring
的用法示例。
在下文中一共展示了PromoteTempToFieldRefactoring.setLinkedProposalModel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getConvertLocalToFieldProposal
import org.eclipse.jdt.internal.corext.refactoring.code.PromoteTempToFieldRefactoring; //导入方法依赖的package包/类
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;
}
示例2: getConvertLocalToFieldProposal
import org.eclipse.jdt.internal.corext.refactoring.code.PromoteTempToFieldRefactoring; //导入方法依赖的package包/类
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) || name.getLocationInParent() != VariableDeclarationFragment.NAME_PROPERTY)
return false;
IVariableBinding varBinding= (IVariableBinding) binding;
if (varBinding.isField() || varBinding.isParameter())
return false;
VariableDeclarationFragment decl= (VariableDeclarationFragment) name.getParent();
if (decl.getLocationInParent() != VariableDeclarationStatement.FRAGMENTS_PROPERTY)
return false;
if (proposals == null) {
return true;
}
PromoteTempToFieldRefactoring refactoring= new PromoteTempToFieldRefactoring(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, 5, image);
proposal.setLinkedProposalModel(linkedProposalModel);
proposal.setCommandId(CONVERT_LOCAL_TO_FIELD_ID);
proposals.add(proposal);
}
return true;
}
示例3: getConvertLocalToFieldProposal
import org.eclipse.jdt.internal.corext.refactoring.code.PromoteTempToFieldRefactoring; //导入方法依赖的package包/类
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;
}