EA-85603 fix unconditional cast which fails in incorrect YAML docs

This commit is contained in:
Valentin Fondaratov
2016-07-05 13:49:35 +03:00
parent ad9792254e
commit 2dd6464132
2 changed files with 12 additions and 6 deletions
@@ -56,11 +56,11 @@ public class YAMLBreadcrumbsInfoProvider extends BreadcrumbsInfoProvider {
return ((YAMLKeyValue)e).getKeyText() + ':';
}
if (e instanceof YAMLSequenceItem) {
final YAMLSequence parent = (YAMLSequence)e.getParent();
if (parent == null) {
final PsiElement parent = e.getParent();
if (!(parent instanceof YAMLSequence)) {
return "Item";
}
final List<YAMLSequenceItem> items = parent.getItems();
final List<YAMLSequenceItem> items = ((YAMLSequence)parent).getItems();
return "Item " + getIndexOf(items, e);
}
if (e instanceof YAMLScalar) {
@@ -61,12 +61,18 @@ public class YAMLBreadcrumbsTest extends LightPlatformCodeInsightFixtureTestCase
"bar: asjdjkas,\n" +
"baz: [foo: qoo, boo: fo<caret>o, doo: 123]\n" +
"}\n" +
"---\n" +
"foo: \n" +
" bar:\n" +
"- av<caret>r\n" +
"...";
private static final String OUTPUT = "[Document 1/2;null][items:;null][Item 2/2;null][descrip:;null][High Heeled \"Ruby\" S...;null]\n" +
private static final String OUTPUT = "[Document 1/3;null][items:;null][Item 2/2;null][descrip:;null][High Heeled \"Ruby\" S...;null]\n" +
"------\n" +
"[Document 1/2;null][specialDelivery:;null][Follow the Yellow Br...;null]\n" +
"[Document 1/3;null][specialDelivery:;null][Follow the Yellow Br...;null]\n" +
"------\n" +
"[Document 2/2;null][baz:;null][Item 2/3;null][boo:;null][foo;null]";
"[Document 2/3;null][baz:;null][Item 2/3;null][boo:;null][foo;null]\n" +
"------\n" +
"[Document 3/3;null][foo:;null][Item;null][avr;null]";
public void testAll() {
myFixture.configureByText(YAMLFileType.YML, INPUT);