Search in sources :

Example 1 with Foo

use of com.intellij.util.xml.stubs.model.Foo in project intellij-community by JetBrains.

the class DomStubBuilderTest method testInclusion.

public void testInclusion() throws Exception {
    myFixture.copyFileToProject("include.xml");
    doBuilderTest("inclusion.xml", "File:foo\n" + "  Element:foo\n" + "    Element:bar\n" + "      Attribute:string:xxx\n" + "      Attribute:int:666\n" + "    Element:bar\n");
    PsiFile file = myFixture.getFile();
    DomFileElement<Foo> element = DomManager.getDomManager(getProject()).getFileElement((XmlFile) file, Foo.class);
    assert element != null;
    assertEquals(2, element.getRootElement().getBars().size());
}
Also used : Foo(com.intellij.util.xml.stubs.model.Foo) PsiFile(com.intellij.psi.PsiFile)

Example 2 with Foo

use of com.intellij.util.xml.stubs.model.Foo in project intellij-community by JetBrains.

the class DomStubUsingTest method testFileLoading.

public void testFileLoading() {
    XmlFile file = prepareFile("foo.xml");
    ((PsiManagerEx) getPsiManager()).setAssertOnFileLoadingFilter(VirtualFileFilter.ALL, myFixture.getTestRootDisposable());
    DomFileElement<Foo> element = DomManager.getDomManager(getProject()).getFileElement(file, Foo.class);
    assertNotNull(element);
    GenericDomValue<String> id = element.getRootElement().getId();
    assertEquals("foo", id.getValue());
}
Also used : XmlFile(com.intellij.psi.xml.XmlFile) Foo(com.intellij.util.xml.stubs.model.Foo) PsiManagerEx(com.intellij.psi.impl.PsiManagerEx)

Example 3 with Foo

use of com.intellij.util.xml.stubs.model.Foo in project intellij-community by JetBrains.

the class DomStubUsingTest method testFoo.

public void testFoo() {
    DomFileElement<Foo> fileElement = prepare("foo.xml", Foo.class);
    PsiFile file = fileElement.getFile();
    assertFalse(file.getNode().isParsed());
    Foo foo = fileElement.getRootElement();
    assertEquals("foo", foo.getId().getValue());
    assertFalse(file.getNode().isParsed());
    List<Bar> bars = foo.getBars();
    assertFalse(file.getNode().isParsed());
    final List<GenericDomValue<String>> listElements = foo.getLists();
    final GenericDomValue<String> listElement0 = listElements.get(0);
    assertEquals("list0", listElement0.getValue());
    final GenericDomValue<String> listElement1 = listElements.get(1);
    assertEquals("list1", listElement1.getValue());
    assertFalse(file.getNode().isParsed());
    assertEquals(2, bars.size());
    Bar bar = bars.get(0);
    String value = bar.getString().getStringValue();
    assertEquals("xxx", value);
    Object o = bar.getString().getValue();
    assertEquals("xxx", o);
    Integer integer = bar.getInt().getValue();
    assertEquals(666, integer.intValue());
    assertFalse(file.getNode().isParsed());
    Bar emptyBar = bars.get(1);
    GenericAttributeValue<String> string = emptyBar.getString();
    assertNull(string.getXmlElement());
    assertFalse(file.getNode().isParsed());
}
Also used : Bar(com.intellij.util.xml.stubs.model.Bar) Foo(com.intellij.util.xml.stubs.model.Foo) PsiFile(com.intellij.psi.PsiFile)

Example 4 with Foo

use of com.intellij.util.xml.stubs.model.Foo in project intellij-community by JetBrains.

the class DomStubUsingTest method testParent.

public void testParent() {
    DomFileElement<Foo> element = prepare("parent.xml", Foo.class);
    Bar bar = element.getRootElement().getBars().get(0);
    GenericAttributeValue<Integer> notStubbed = bar.getNotStubbed();
    DomElement parent = notStubbed.getParent();
    assertEquals(bar, parent);
    NotStubbed child = bar.getNotStubbeds().get(0);
    parent = child.getParent();
    assertEquals(bar, parent);
}
Also used : Bar(com.intellij.util.xml.stubs.model.Bar) Foo(com.intellij.util.xml.stubs.model.Foo) NotStubbed(com.intellij.util.xml.stubs.model.NotStubbed)

Example 5 with Foo

use of com.intellij.util.xml.stubs.model.Foo in project intellij-community by JetBrains.

the class DomStubUsingTest method testChildrenOfType.

public void testChildrenOfType() {
    DomFileElement<Foo> element = prepare("foo.xml", Foo.class);
    Foo foo = element.getRootElement();
    List<Bar> bars = DomUtil.getChildrenOf(foo, Bar.class);
    assertEquals(2, bars.size());
}
Also used : Bar(com.intellij.util.xml.stubs.model.Bar) Foo(com.intellij.util.xml.stubs.model.Foo)

Aggregations

Foo (com.intellij.util.xml.stubs.model.Foo)8 Bar (com.intellij.util.xml.stubs.model.Bar)6 PsiFile (com.intellij.psi.PsiFile)2 PsiClass (com.intellij.psi.PsiClass)1 PsiManagerEx (com.intellij.psi.impl.PsiManagerEx)1 XmlAttribute (com.intellij.psi.xml.XmlAttribute)1 XmlFile (com.intellij.psi.xml.XmlFile)1 XmlTag (com.intellij.psi.xml.XmlTag)1 NotStubbed (com.intellij.util.xml.stubs.model.NotStubbed)1