Skip to content

Commit 6fd7565

Browse files
alice-kscopybara-github
authored andcommitted
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
1 parent 076c207 commit 6fd7565

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

java/src/com/google/idea/blaze/java/run/producers/SubclassTestChooser.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import com.intellij.psi.PsiClass;
2222
import com.intellij.psi.PsiModifier;
2323
import com.intellij.psi.search.searches.ClassInheritorsSearch;
24-
import com.intellij.ui.components.JBList;
2524
import java.util.List;
2625
import java.util.function.Consumer;
2726
import java.util.stream.Collectors;
@@ -50,26 +49,22 @@ static void chooseSubclass(
5049
}
5150
PsiClassListCellRenderer renderer = new PsiClassListCellRenderer();
5251
classes.sort(renderer.getComparator());
53-
JBList<PsiClass> list = new JBList<>(classes);
54-
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
55-
list.setCellRenderer(renderer);
5652
JBPopupFactory.getInstance()
57-
.createListPopupBuilder(list)
53+
.createPopupChooserBuilder(classes)
5854
.setTitle("Choose test class to run")
5955
.setMovable(false)
6056
.setResizable(false)
6157
.setRequestFocus(true)
6258
.setCancelOnWindowDeactivation(false)
63-
.setItemChoosenCallback(
64-
() -> callbackOnClassSelection.accept((PsiClass) list.getSelectedValue()))
59+
.setRenderer(renderer)
60+
.setSelectionMode(ListSelectionModel.SINGLE_SELECTION)
61+
.setItemChosenCallback(callbackOnClassSelection::accept)
6562
.createPopup()
6663
.showInBestPositionFor(context.getDataContext());
6764
}
6865

6966
static List<PsiClass> findTestSubclasses(PsiClass testClass) {
70-
return ClassInheritorsSearch.search(testClass)
71-
.findAll()
72-
.stream()
67+
return ClassInheritorsSearch.search(testClass).findAll().stream()
7368
.filter(ProducerUtils::isTestClass)
7469
.collect(Collectors.toList());
7570
}

0 commit comments

Comments
 (0)