use of com.intellij.codeInsight.navigation.NavigationGutterIconRenderer in project intellij-community by JetBrains.
the class DevKitGutterTargetsChecker method checkGutterTargets.
public static void checkGutterTargets(final GutterMark gutterMark, final String tooltip, final Icon icon, final String... expectedTargets) {
assertNotNull(gutterMark);
assertEquals(tooltip, gutterMark.getTooltipText());
assertEquals(icon, gutterMark.getIcon());
final Collection<PsiElement> targetElements;
if (gutterMark instanceof LineMarkerInfo.LineMarkerGutterIconRenderer) {
final LineMarkerInfo.LineMarkerGutterIconRenderer renderer = UsefulTestCase.assertInstanceOf(gutterMark, LineMarkerInfo.LineMarkerGutterIconRenderer.class);
final LineMarkerInfo lineMarkerInfo = renderer.getLineMarkerInfo();
GutterIconNavigationHandler handler = lineMarkerInfo.getNavigationHandler();
if (handler instanceof NavigationGutterIconRenderer) {
targetElements = ((NavigationGutterIconRenderer) handler).getTargetElements();
} else {
throw new IllegalArgumentException(handler + ": handler not supported");
}
} else {
throw new IllegalArgumentException(gutterMark.getClass() + ": gutter not supported");
}
UsefulTestCase.assertSameElements(ContainerUtil.map(targetElements, element -> SymbolPresentationUtil.getSymbolPresentableText(element)), expectedTargets);
}
use of com.intellij.codeInsight.navigation.NavigationGutterIconRenderer in project intellij-plugins by JetBrains.
the class AnnotatorTestUtils method checkGutterTargets.
/**
* Verifies the navigation targets' names of the gutter icon match.
*
* @param renderer Gutter icon.
* @param resultValueFunction Function to transform target to expected name.
* @param expectedValues Expected names.
*/
static void checkGutterTargets(@NotNull final GutterMark renderer, @NotNull final Function<PsiElement, String> resultValueFunction, final String... expectedValues) {
final LineMarkerInfo lineMarkerInfo = ((LineMarkerInfo.LineMarkerGutterIconRenderer) renderer).getLineMarkerInfo();
final NavigationGutterIconRenderer navigationHandler = (NavigationGutterIconRenderer) lineMarkerInfo.getNavigationHandler();
assertNotNull(navigationHandler);
final List<PsiElement> targetElements = navigationHandler.getTargetElements();
final Set<String> foundValues = new HashSet<>();
for (final PsiElement psiElement : targetElements) {
foundValues.add(resultValueFunction.fun(psiElement));
}
assertSameElements(foundValues, expectedValues);
}
Aggregations