use of com.intellij.refactoring.extractMethodObject.ExtractMethodObjectProcessor in project intellij-community by JetBrains.
the class ExtractMethodObjectTest method doTest.
private void doTest(final boolean createInnerClass) throws Exception {
final String testName = getTestName(false);
configureByFile("/refactoring/extractMethodObject/" + testName + ".java");
PsiElement element = TargetElementUtil.findTargetElement(myEditor, TargetElementUtil.ELEMENT_NAME_ACCEPTED);
assertTrue(element instanceof PsiMethod);
final PsiMethod method = (PsiMethod) element;
final ExtractMethodObjectProcessor processor = new ExtractMethodObjectProcessor(getProject(), getEditor(), method.getBody().getStatements(), "InnerClass");
final ExtractMethodObjectProcessor.MyExtractMethodProcessor extractProcessor = processor.getExtractProcessor();
processor.setCreateInnerClass(createInnerClass);
extractProcessor.setShowErrorDialogs(false);
extractProcessor.prepare();
extractProcessor.testPrepare();
ExtractMethodObjectHandler.run(getProject(), getEditor(), processor, extractProcessor);
checkResultByFile("/refactoring/extractMethodObject/" + testName + ".java" + ".after");
}
use of com.intellij.refactoring.extractMethodObject.ExtractMethodObjectProcessor in project intellij-community by JetBrains.
the class ExtractMethodObjectWithMultipleExitPointsTest method doTest.
private void doTest(final boolean createInnerClass) throws Exception {
final String testName = getTestName(false);
configureByFile("/refactoring/extractMethodObject/multipleExitPoints/" + testName + ".java");
int startOffset = myEditor.getSelectionModel().getSelectionStart();
int endOffset = myEditor.getSelectionModel().getSelectionEnd();
final PsiElement[] elements;
PsiExpression expr = CodeInsightUtil.findExpressionInRange(myFile, startOffset, endOffset);
if (expr != null) {
elements = new PsiElement[] { expr };
} else {
elements = CodeInsightUtil.findStatementsInRange(myFile, startOffset, endOffset);
}
final ExtractMethodObjectProcessor processor = new ExtractMethodObjectProcessor(getProject(), getEditor(), elements, "Inner");
final ExtractMethodObjectProcessor.MyExtractMethodProcessor extractProcessor = processor.getExtractProcessor();
extractProcessor.setShowErrorDialogs(false);
extractProcessor.prepare();
extractProcessor.testPrepare();
processor.setCreateInnerClass(createInnerClass);
ExtractMethodObjectHandler.run(getProject(), getEditor(), processor, extractProcessor);
checkResultByFile("/refactoring/extractMethodObject/multipleExitPoints/" + testName + ".java" + ".after");
}
Aggregations