use of com.intellij.xml.breadcrumbs.BreadcrumbsItem in project intellij-community by JetBrains.
the class YAMLBreadcrumbsTest method testAll.
public void testAll() {
myFixture.configureByText(YAMLFileType.YML, INPUT);
final CaretModel caretModel = myFixture.getEditor().getCaretModel();
final String result = caretModel.getAllCarets().stream().map(Caret::getOffset).collect(Collectors.toList()).stream().map((offset) -> {
caretModel.moveToOffset(offset);
return getBreadcrumbs(myFixture).stream().map(BreadcrumbsItem::toString).reduce((left, right) -> right + left).orElse("[]");
}).reduce((left, right) -> left + "\n------\n" + right).orElse("");
assertSameLines(OUTPUT, result);
}
use of com.intellij.xml.breadcrumbs.BreadcrumbsItem 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