use of com.intellij.xml.breadcrumbs.BreadcrumbsInfoProvider in project intellij-community by JetBrains.
the class YAMLBreadcrumbsTest method getBreadcrumbs.
// TODO move this method and class to platform when breadcrumbs are moved there, too
@NotNull
private static List<BreadcrumbsItem> getBreadcrumbs(@NotNull CodeInsightTestFixture fixture) {
PsiElement element = fixture.getFile().findElementAt(fixture.getCaretOffset());
if (element == null) {
return Collections.emptyList();
}
final Language language = element.getContainingFile().getLanguage();
final BreadcrumbsInfoProvider provider = ContainerUtil.find(Extensions.getExtensions(BreadcrumbsInfoProvider.EP_NAME), (p) -> Arrays.asList(p.getLanguages()).contains(language));
if (provider == null) {
return Collections.emptyList();
}
List<BreadcrumbsItem> result = new ArrayList<>();
while (element != null) {
if (provider.acceptElement(element)) {
result.add(new MockBreadcrumbsItem(provider.getElementInfo(element), provider.getElementTooltip(element)));
}
element = provider.getParent(element);
}
return result;
}
Aggregations