use of com.intellij.refactoring.removemiddleman.RemoveMiddlemanProcessor in project intellij-community by JetBrains.
the class RemoveMiddleManTest method doTest.
private void doTest(final String conflict) throws Exception {
doTest((rootDir, rootAfter) -> {
PsiClass aClass = myJavaFacade.findClass("Test", GlobalSearchScope.allScope(getProject()));
if (aClass == null)
aClass = myJavaFacade.findClass("p.Test", GlobalSearchScope.allScope(getProject()));
assertNotNull("Class Test not found", aClass);
final PsiField field = aClass.findFieldByName("myField", false);
final Set<PsiMethod> methods = DelegationUtils.getDelegatingMethodsForField(field);
List<MemberInfo> infos = new ArrayList<>();
for (PsiMethod method : methods) {
final MemberInfo info = new MemberInfo(method);
info.setChecked(true);
info.setToAbstract(true);
infos.add(info);
}
try {
RemoveMiddlemanProcessor processor = new RemoveMiddlemanProcessor(field, infos);
processor.run();
LocalFileSystem.getInstance().refresh(false);
FileDocumentManager.getInstance().saveAllDocuments();
if (conflict != null)
fail("Conflict expected");
} catch (BaseRefactoringProcessor.ConflictsInTestsException e) {
if (conflict == null)
throw e;
assertEquals(conflict, e.getMessage());
}
});
}
Aggregations