From 6fd756520e200e4849ab9e42aba0521e24c6a4c6 Mon Sep 17 00:00:00 2001 From: Alice Kober-Sotzek Date: Wed, 11 Nov 2020 09:01:15 -0800 Subject: [PATCH] SubclassTestChooser: Avoid unchecked warnings by using newer APIs Instead of setting the renderer on a JBList, which results in an unchecked warning, we directly set it on the IPopupChooserBuilder. That approach is even better as we avoid the previous, deprecated use of JBPopupFactory#createListPopupBuilder. PiperOrigin-RevId: 341840854 --- .../java/run/producers/SubclassTestChooser.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/java/src/com/google/idea/blaze/java/run/producers/SubclassTestChooser.java b/java/src/com/google/idea/blaze/java/run/producers/SubclassTestChooser.java index 0adc4577bb9..cd987e34e68 100644 --- a/java/src/com/google/idea/blaze/java/run/producers/SubclassTestChooser.java +++ b/java/src/com/google/idea/blaze/java/run/producers/SubclassTestChooser.java @@ -21,7 +21,6 @@ import com.intellij.psi.PsiClass; import com.intellij.psi.PsiModifier; import com.intellij.psi.search.searches.ClassInheritorsSearch; -import com.intellij.ui.components.JBList; import java.util.List; import java.util.function.Consumer; import java.util.stream.Collectors; @@ -50,26 +49,22 @@ static void chooseSubclass( } PsiClassListCellRenderer renderer = new PsiClassListCellRenderer(); classes.sort(renderer.getComparator()); - JBList list = new JBList<>(classes); - list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - list.setCellRenderer(renderer); JBPopupFactory.getInstance() - .createListPopupBuilder(list) + .createPopupChooserBuilder(classes) .setTitle("Choose test class to run") .setMovable(false) .setResizable(false) .setRequestFocus(true) .setCancelOnWindowDeactivation(false) - .setItemChoosenCallback( - () -> callbackOnClassSelection.accept((PsiClass) list.getSelectedValue())) + .setRenderer(renderer) + .setSelectionMode(ListSelectionModel.SINGLE_SELECTION) + .setItemChosenCallback(callbackOnClassSelection::accept) .createPopup() .showInBestPositionFor(context.getDataContext()); } static List findTestSubclasses(PsiClass testClass) { - return ClassInheritorsSearch.search(testClass) - .findAll() - .stream() + return ClassInheritorsSearch.search(testClass).findAll().stream() .filter(ProducerUtils::isTestClass) .collect(Collectors.toList()); }