当前位置: 首页>>代码示例>>Java>>正文


Java PromoteTempToFieldRefactoring类代码示例

本文整理汇总了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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:34,代码来源:QuickAssistProcessor.java

示例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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:34,代码来源:QuickAssistProcessor.java

示例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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:41,代码来源:QuickAssistProcessor.java

示例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;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:12,代码来源:PromoteTempWizard.java

示例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);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:ConvertLocalToFieldAction.java

示例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);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:6,代码来源:FieldNameProcessor.java

示例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);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:5,代码来源:PromoteTempWizard.java

示例9: getPromoteTempRefactoring

import org.eclipse.jdt.internal.corext.refactoring.code.PromoteTempToFieldRefactoring; //导入依赖的package包/类
private PromoteTempToFieldRefactoring getPromoteTempRefactoring(){
	return (PromoteTempToFieldRefactoring)getRefactoring();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:4,代码来源:PromoteTempWizard.java


注:本文中的org.eclipse.jdt.internal.corext.refactoring.code.PromoteTempToFieldRefactoring类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。