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


Java ExtractMethodRefactoring类代码示例

本文整理汇总了Java中org.eclipse.jdt.internal.corext.refactoring.code.ExtractMethodRefactoring的典型用法代码示例。如果您正苦于以下问题:Java ExtractMethodRefactoring类的具体用法?Java ExtractMethodRefactoring怎么用?Java ExtractMethodRefactoring使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ExtractMethodRefactoring类属于org.eclipse.jdt.internal.corext.refactoring.code包,在下文中一共展示了ExtractMethodRefactoring类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import org.eclipse.jdt.internal.corext.refactoring.code.ExtractMethodRefactoring; //导入依赖的package包/类
@Override
public void run(ITextSelection selection) {
	if (!ActionUtil.isEditable(fEditor))
		return;
	ExtractMethodRefactoring refactoring= new ExtractMethodRefactoring(SelectionConverter.getInputAsCompilationUnit(fEditor), selection.getOffset(), selection.getLength());
	new RefactoringStarter().activate(new ExtractMethodWizard(refactoring), getShell(), RefactoringMessages.ExtractMethodAction_dialog_title, RefactoringSaveHelper.SAVE_NOTHING);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:8,代码来源:ExtractMethodAction.java

示例2: getExtractMethodProposal

import org.eclipse.jdt.internal.corext.refactoring.code.ExtractMethodRefactoring; //导入依赖的package包/类
private static boolean getExtractMethodProposal(IInvocationContext context, ASTNode coveringNode, boolean problemsAtLocation, Collection<ICommandAccess> proposals) throws CoreException {
	if (!(coveringNode instanceof Expression) && !(coveringNode instanceof Statement) && !(coveringNode instanceof Block)) {
		return false;
	}
	if (coveringNode instanceof Block) {
		List<Statement> statements= ((Block) coveringNode).statements();
		int startIndex= getIndex(context.getSelectionOffset(), statements);
		if (startIndex == -1)
			return false;
		int endIndex= getIndex(context.getSelectionOffset() + context.getSelectionLength(), statements);
		if (endIndex == -1 || endIndex <= startIndex)
			return false;
	}

	if (proposals == null) {
		return true;
	}

	final ICompilationUnit cu= context.getCompilationUnit();
	final ExtractMethodRefactoring extractMethodRefactoring= new ExtractMethodRefactoring(context.getASTRoot(), context.getSelectionOffset(), context.getSelectionLength());
	extractMethodRefactoring.setMethodName("extracted"); //$NON-NLS-1$
	if (extractMethodRefactoring.checkInitialConditions(new NullProgressMonitor()).isOK()) {
		String label= CorrectionMessages.QuickAssistProcessor_extractmethod_description;
		LinkedProposalModel linkedProposalModel= new LinkedProposalModel();
		extractMethodRefactoring.setLinkedProposalModel(linkedProposalModel);

		Image image= JavaPluginImages.get(JavaPluginImages.IMG_MISC_PUBLIC);
		int relevance= problemsAtLocation ? IProposalRelevance.EXTRACT_METHOD_ERROR : IProposalRelevance.EXTRACT_METHOD;
		RefactoringCorrectionProposal proposal= new RefactoringCorrectionProposal(label, cu, extractMethodRefactoring, relevance, image);
		proposal.setCommandId(EXTRACT_METHOD_INPLACE_ID);
		proposal.setLinkedProposalModel(linkedProposalModel);
		proposals.add(proposal);
	}
	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:36,代码来源:QuickAssistProcessor.java

示例3: getExtractMethodProposal

import org.eclipse.jdt.internal.corext.refactoring.code.ExtractMethodRefactoring; //导入依赖的package包/类
private static boolean getExtractMethodProposal(IInvocationContext context, ASTNode coveringNode, boolean problemsAtLocation, Collection<ICommandAccess> proposals) throws CoreException {
	if (!(coveringNode instanceof Expression) && !(coveringNode instanceof Statement) && !(coveringNode instanceof Block)) {
		return false;
	}
	if (coveringNode instanceof Block) {
		List<Statement> statements= ((Block) coveringNode).statements();
		int startIndex= getIndex(context.getSelectionOffset(), statements);
		if (startIndex == -1)
			return false;
		int endIndex= getIndex(context.getSelectionOffset() + context.getSelectionLength(), statements);
		if (endIndex == -1 || endIndex <= startIndex)
			return false;
	}

	if (proposals == null) {
		return true;
	}

	final ICompilationUnit cu= context.getCompilationUnit();
	final ExtractMethodRefactoring extractMethodRefactoring= new ExtractMethodRefactoring(context.getASTRoot(), context.getSelectionOffset(), context.getSelectionLength());
	extractMethodRefactoring.setMethodName("extracted"); //$NON-NLS-1$
	if (extractMethodRefactoring.checkInitialConditions(new NullProgressMonitor()).isOK()) {
		String label= CorrectionMessages.QuickAssistProcessor_extractmethod_description;
		LinkedProposalModel linkedProposalModel= new LinkedProposalModel();
		extractMethodRefactoring.setLinkedProposalModel(linkedProposalModel);

		Image image= JavaPluginImages.get(JavaPluginImages.IMG_MISC_PUBLIC);
		int relevance= problemsAtLocation ? 1 : 4;
		RefactoringCorrectionProposal proposal= new RefactoringCorrectionProposal(label, cu, extractMethodRefactoring, relevance, image);
		proposal.setLinkedProposalModel(linkedProposalModel);
		proposals.add(proposal);
	}
	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:35,代码来源:QuickAssistProcessor.java

示例4: getExtractMethodProposal

import org.eclipse.jdt.internal.corext.refactoring.code.ExtractMethodRefactoring; //导入依赖的package包/类
private static boolean getExtractMethodProposal(
    IInvocationContext context,
    ASTNode coveringNode,
    boolean problemsAtLocation,
    Collection<ICommandAccess> proposals)
    throws CoreException {
  if (!(coveringNode instanceof Expression)
      && !(coveringNode instanceof Statement)
      && !(coveringNode instanceof Block)) {
    return false;
  }
  if (coveringNode instanceof Block) {
    List<Statement> statements = ((Block) coveringNode).statements();
    int startIndex = getIndex(context.getSelectionOffset(), statements);
    if (startIndex == -1) return false;
    int endIndex =
        getIndex(context.getSelectionOffset() + context.getSelectionLength(), statements);
    if (endIndex == -1 || endIndex <= startIndex) return false;
  }

  if (proposals == null) {
    return true;
  }

  final ICompilationUnit cu = context.getCompilationUnit();
  final ExtractMethodRefactoring extractMethodRefactoring =
      new ExtractMethodRefactoring(
          context.getASTRoot(), context.getSelectionOffset(), context.getSelectionLength());
  extractMethodRefactoring.setMethodName("extracted"); // $NON-NLS-1$
  if (extractMethodRefactoring.checkInitialConditions(new NullProgressMonitor()).isOK()) {
    String label = CorrectionMessages.QuickAssistProcessor_extractmethod_description;
    LinkedProposalModel linkedProposalModel = new LinkedProposalModel();
    extractMethodRefactoring.setLinkedProposalModel(linkedProposalModel);

    Image image = JavaPluginImages.get(JavaPluginImages.DESC_MISC_PUBLIC);
    int relevance =
        problemsAtLocation
            ? IProposalRelevance.EXTRACT_METHOD_ERROR
            : IProposalRelevance.EXTRACT_METHOD;
    RefactoringCorrectionProposal proposal =
        new RefactoringCorrectionProposal(label, cu, extractMethodRefactoring, relevance, image);
    proposal.setCommandId(EXTRACT_METHOD_INPLACE_ID);
    proposal.setLinkedProposalModel(linkedProposalModel);
    proposals.add(proposal);
  }
  return true;
}
 
开发者ID:eclipse,项目名称:che,代码行数:48,代码来源:QuickAssistProcessor.java

示例5: createRefactoring

import org.eclipse.jdt.internal.corext.refactoring.code.ExtractMethodRefactoring; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public final Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException {
	JavaRefactoringArguments arguments= new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor));
	return new ExtractMethodRefactoring(arguments, status);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:ExtractMethodRefactoringContribution.java

示例6: ExtractMethodWizard

import org.eclipse.jdt.internal.corext.refactoring.code.ExtractMethodRefactoring; //导入依赖的package包/类
public ExtractMethodWizard(ExtractMethodRefactoring ref){
	super(ref, DIALOG_BASED_USER_INTERFACE | PREVIEW_EXPAND_FIRST_NODE);
	setDefaultPageTitle(RefactoringMessages.ExtractMethodWizard_extract_method);
	setDialogSettings(JavaPlugin.getDefault().getDialogSettings());
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:6,代码来源:ExtractMethodWizard.java


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