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