本文整理汇总了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;
}
示例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;
}
示例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;
}