use of com.intellij.refactoring.util.classMembers.MemberInfo in project intellij-community by JetBrains.
the class JavaPushDownDelegate method findInheritors.
@Override
public List<PsiElement> findInheritors(PushDownData<MemberInfo, PsiMember> pushDownData) {
final List<PsiElement> result = new ArrayList<>();
final PsiClass aClass = (PsiClass) pushDownData.getSourceClass();
ClassInheritorsSearch.search(aClass, false).forEach((iClass) -> {
result.add(iClass);
return true;
});
final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(aClass);
if (interfaceMethod != null) {
for (MemberInfo info : pushDownData.getMembersToMove()) {
if (interfaceMethod == info.getMember()) {
FunctionalExpressionSearch.search(aClass).forEach(expression -> {
result.add(expression);
return true;
});
break;
}
}
}
return result;
}
use of com.intellij.refactoring.util.classMembers.MemberInfo in project intellij-community by JetBrains.
the class ExtractSuperClassTest method testAnonymClass.
public void testAnonymClass() throws Exception {
String rootBefore = getRoot() + "/before";
PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk14());
final VirtualFile rootDir = PsiTestUtil.createTestProjectStructure(myProject, myModule, rootBefore, myFilesToDelete);
PsiClass psiClass = myJavaFacade.findClass("Test", ProjectScope.getAllScope(myProject));
assertNotNull(psiClass);
final PsiField[] fields = psiClass.getFields();
assertTrue(fields.length == 1);
final PsiExpression initializer = fields[0].getInitializer();
assertNotNull(initializer);
assertInstanceOf(initializer, PsiNewExpression.class);
final PsiAnonymousClass anonymousClass = ((PsiNewExpression) initializer).getAnonymousClass();
assertNotNull(anonymousClass);
final ArrayList<MemberInfo> infos = new ArrayList<>();
MemberInfo.extractClassMembers(anonymousClass, infos, member -> true, false);
for (MemberInfo info : infos) {
info.setChecked(true);
}
new WriteCommandAction.Simple(myProject) {
@Override
protected void run() throws Throwable {
ExtractSuperClassUtil.extractSuperClass(myProject, psiClass.getContainingFile().getContainingDirectory(), "TestSubclass", anonymousClass, infos.toArray(new MemberInfo[infos.size()]), new DocCommentPolicy(DocCommentPolicy.ASIS));
}
}.execute();
String rootAfter = getRoot() + "/after";
VirtualFile rootDir2 = LocalFileSystem.getInstance().findFileByPath(rootAfter.replace(File.separatorChar, '/'));
myProject.getComponent(PostprocessReformattingAspect.class).doPostponedFormatting();
IdeaTestUtil.assertDirectoriesEqual(rootDir2, rootDir);
}
use of com.intellij.refactoring.util.classMembers.MemberInfo in project intellij-community by JetBrains.
the class CreateTestDialog method updateMethodsTable.
private void updateMethodsTable() {
List<MemberInfo> methods = TestIntegrationUtils.extractClassMethods(myTargetClass, myShowInheritedMethodsBox.isSelected());
Set<PsiMember> selectedMethods = new HashSet<>();
for (MemberInfo each : myMethodsTable.getSelectedMemberInfos()) {
selectedMethods.add(each.getMember());
}
for (MemberInfo each : methods) {
each.setChecked(selectedMethods.contains(each.getMember()));
}
myMethodsTable.setMemberInfos(methods);
}
use of com.intellij.refactoring.util.classMembers.MemberInfo in project intellij-community by JetBrains.
the class MissedTestsDialog method disableMethodsWithTests.
private void disableMethodsWithTests(List<MemberInfo> info) {
final Set<String> existingNames = new HashSet<>();
final String prefix = getTestPrefix(existingNames);
existingNames.addAll(ContainerUtil.map(myTestClass.getMethods(), method -> StringUtil.decapitalize(StringUtil.trimStart(method.getName(), prefix))));
for (MemberInfo memberInfo : info) {
final PsiMember member = memberInfo.getMember();
memberInfo.setChecked(!(member instanceof PsiMethod && existingNames.contains(member.getName())));
}
}
use of com.intellij.refactoring.util.classMembers.MemberInfo in project intellij-community by JetBrains.
the class MissedTestsDialog method createCenterPanel.
@Nullable
@Override
protected JComponent createCenterPanel() {
final List<MemberInfo> info = TestIntegrationUtils.extractClassMethods(mySourceClass, false);
disableMethodsWithTests(info);
final JPanel panel = new JPanel(new BorderLayout());
myTable = new MemberSelectionTable(info, null);
panel.add(ScrollPaneFactory.createScrollPane(myTable), BorderLayout.CENTER);
panel.add(myIncludeInheritedCb, BorderLayout.NORTH);
myIncludeInheritedCb.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateMethodsTable();
}
});
return panel;
}
Aggregations