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


Java ExtractMethodRefactoring.setMethodName方法代码示例

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


在下文中一共展示了ExtractMethodRefactoring.setMethodName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例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 ? 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

示例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.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


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