Search in sources :

Example 1 with LayoutStructureViewBuilder

use of org.jetbrains.android.dom.structure.layout.LayoutStructureViewBuilder in project android by JetBrains.

the class StructureViewTest method testLayoutStructureOrder2.

public void testLayoutStructureOrder2() throws Exception {
    VirtualFile file = copyFileToProject("layout/structure_view_test_order_2.xml", "/res/layout/layout.xml");
    PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(file);
    assertInstanceOf(psiFile, XmlFile.class);
    DomFileElement<LayoutViewElement> element = DomManager.getDomManager(getProject()).getFileElement(((XmlFile) psiFile), LayoutViewElement.class);
    assertNotNull(element);
    final StructureViewModel model = new LayoutStructureViewBuilder(element).createStructureViewModel(null);
    String expected = "LinearLayout\n" + "  Include\n" + "  Fragment\n";
    assertEquals(expected, model.getRoot().toString());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LayoutViewElement(org.jetbrains.android.dom.layout.LayoutViewElement) XmlFile(com.intellij.psi.xml.XmlFile) StructureViewModel(com.intellij.ide.structureView.StructureViewModel) PsiFile(com.intellij.psi.PsiFile) LayoutStructureViewBuilder(org.jetbrains.android.dom.structure.layout.LayoutStructureViewBuilder)

Example 2 with LayoutStructureViewBuilder

use of org.jetbrains.android.dom.structure.layout.LayoutStructureViewBuilder in project android by JetBrains.

the class StructureViewTest method testLayoutStructure.

public void testLayoutStructure() throws Exception {
    VirtualFile file = copyFileToProject("layout/structure_view_test.xml", "/res/layout/layout.xml");
    PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(file);
    assertInstanceOf(psiFile, XmlFile.class);
    DomFileElement<LayoutViewElement> element = DomManager.getDomManager(getProject()).getFileElement(((XmlFile) psiFile), LayoutViewElement.class);
    assertNotNull(element);
    final StructureViewModel model = new LayoutStructureViewBuilder(element).createStructureViewModel(null);
    String expected = "LinearLayout\n" + "  TextView\n" + "  TextView (@+id/login)\n" + "  TextView (@+id/password)\n" + "  LinearLayout\n" + "    Include @layout/some_other_layout\n" + "    TextView\n";
    assertEquals(expected, model.getRoot().toString());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LayoutViewElement(org.jetbrains.android.dom.layout.LayoutViewElement) XmlFile(com.intellij.psi.xml.XmlFile) StructureViewModel(com.intellij.ide.structureView.StructureViewModel) PsiFile(com.intellij.psi.PsiFile) LayoutStructureViewBuilder(org.jetbrains.android.dom.structure.layout.LayoutStructureViewBuilder)

Example 3 with LayoutStructureViewBuilder

use of org.jetbrains.android.dom.structure.layout.LayoutStructureViewBuilder in project android by JetBrains.

the class StructureViewTest method testLayoutStructureOrder1.

public void testLayoutStructureOrder1() throws Exception {
    VirtualFile file = copyFileToProject("layout/structure_view_test_order_1.xml", "/res/layout/layout.xml");
    PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(file);
    assertInstanceOf(psiFile, XmlFile.class);
    DomFileElement<LayoutViewElement> element = DomManager.getDomManager(getProject()).getFileElement(((XmlFile) psiFile), LayoutViewElement.class);
    assertNotNull(element);
    final StructureViewModel model = new LayoutStructureViewBuilder(element).createStructureViewModel(null);
    String expected = "LinearLayout\n" + "  Fragment\n" + "  Include\n";
    assertEquals(expected, model.getRoot().toString());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LayoutViewElement(org.jetbrains.android.dom.layout.LayoutViewElement) XmlFile(com.intellij.psi.xml.XmlFile) StructureViewModel(com.intellij.ide.structureView.StructureViewModel) PsiFile(com.intellij.psi.PsiFile) LayoutStructureViewBuilder(org.jetbrains.android.dom.structure.layout.LayoutStructureViewBuilder)

Aggregations

StructureViewModel (com.intellij.ide.structureView.StructureViewModel)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 PsiFile (com.intellij.psi.PsiFile)3 XmlFile (com.intellij.psi.xml.XmlFile)3 LayoutViewElement (org.jetbrains.android.dom.layout.LayoutViewElement)3 LayoutStructureViewBuilder (org.jetbrains.android.dom.structure.layout.LayoutStructureViewBuilder)3