void (final @NotNull JComponent component, final Function<Object, ? extends PsiElement> provider) { HintUpdateSupply supply = new HintUpdateSupply(component) { @Override protected @Nullable PsiElement getPsiElementForHint(@Nullable Object selectedValue) { return provider.fun(selectedValue); } }; if (component instanceof JList) supply.installListListener((JList)component); if (component instanceof JTree) supply.installTreeListener((JTree)component); if (component instanceof JTable) supply.installTableListener((JTable)component); }