本文整理汇总了Java中org.eclipse.jdt.internal.corext.refactoring.code.PromoteTempToFieldRefactoring类的典型用法代码示例。如果您正苦于以下问题:Java PromoteTempToFieldRefactoring类的具体用法?Java PromoteTempToFieldRefactoring怎么用?Java PromoteTempToFieldRefactoring使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PromoteTempToFieldRefactoring类属于org.eclipse.jdt.internal.corext.refactoring.code包,在下文中一共展示了PromoteTempToFieldRefactoring类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例4: canEnable
import org.eclipse.jdt.internal.corext.refactoring.code.PromoteTempToFieldRefactoring; //导入依赖的package包/类
private boolean canEnable(int initializeIn){
switch(initializeIn){
case PromoteTempToFieldRefactoring.INITIALIZE_IN_CONSTRUCTOR:
return getPromoteTempRefactoring().canEnableSettingDeclareInConstructors();
case PromoteTempToFieldRefactoring.INITIALIZE_IN_FIELD:
return getPromoteTempRefactoring().canEnableSettingDeclareInFieldDeclaration();
case PromoteTempToFieldRefactoring.INITIALIZE_IN_METHOD:
return getPromoteTempRefactoring().canEnableSettingDeclareInMethod();
default: Assert.isTrue(false); return false;
}
}
示例5: run
import org.eclipse.jdt.internal.corext.refactoring.code.PromoteTempToFieldRefactoring; //导入依赖的package包/类
@Override
public void run(ITextSelection selection) {
if (!ActionUtil.isEditable(fEditor))
return;
ICompilationUnit cunit= SelectionConverter.getInputAsCompilationUnit(fEditor);
PromoteTempToFieldRefactoring refactoring= new PromoteTempToFieldRefactoring(cunit, selection.getOffset(), selection.getLength());
new RefactoringStarter().activate(new PromoteTempWizard(refactoring), getShell(), RefactoringMessages.ConvertLocalToField_title, RefactoringSaveHelper.SAVE_NOTHING);
}
示例6: createRefactoring
import org.eclipse.jdt.internal.corext.refactoring.code.PromoteTempToFieldRefactoring; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public final Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException {
JavaRefactoringArguments arguments= new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor));
return new PromoteTempToFieldRefactoring(arguments, status);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:PromoteTempToFieldRefactoringContribution.java
示例7: FieldNameProcessor
import org.eclipse.jdt.internal.corext.refactoring.code.PromoteTempToFieldRefactoring; //导入依赖的package包/类
public FieldNameProcessor(String[] guessedFieldNames, PromoteTempToFieldRefactoring refactoring) {
fRefactoring= refactoring;
fFieldNameProposals= refactoring.guessFieldNames();
Arrays.sort(fFieldNameProposals);
}
示例8: PromoteTempWizard
import org.eclipse.jdt.internal.corext.refactoring.code.PromoteTempToFieldRefactoring; //导入依赖的package包/类
public PromoteTempWizard(PromoteTempToFieldRefactoring ref) {
super(ref, DIALOG_BASED_USER_INTERFACE | PREVIEW_EXPAND_FIRST_NODE);
setDefaultPageTitle(RefactoringMessages.ConvertLocalToField_title);
}
示例9: getPromoteTempRefactoring
import org.eclipse.jdt.internal.corext.refactoring.code.PromoteTempToFieldRefactoring; //导入依赖的package包/类
private PromoteTempToFieldRefactoring getPromoteTempRefactoring(){
return (PromoteTempToFieldRefactoring)getRefactoring();
}