Search in sources :

Example 1 with ResourceStructureViewBuilder

use of org.jetbrains.android.dom.structure.resources.ResourceStructureViewBuilder in project android by JetBrains.

the class StructureViewTest method testResourceStructure.

public void testResourceStructure() throws Exception {
    VirtualFile file = copyFileToProject("resources/resources_structure.xml", "/res/values/styles.xml");
    PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(file);
    assertInstanceOf(psiFile, XmlFile.class);
    DomFileElement<Resources> element = DomManager.getDomManager(getProject()).getFileElement(((XmlFile) psiFile), Resources.class);
    assertNotNull(element);
    StructureViewModel model = new ResourceStructureViewBuilder(element).createStructureViewModel(null);
    String expected = "Resources file 'styles.xml'\n" + "  Style - AppTheme\n" + "  String - test_string\n" + "  Style - SecondStyle\n";
    assertEquals(expected, model.getRoot().toString());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ResourceStructureViewBuilder(org.jetbrains.android.dom.structure.resources.ResourceStructureViewBuilder) XmlFile(com.intellij.psi.xml.XmlFile) StructureViewModel(com.intellij.ide.structureView.StructureViewModel) PsiFile(com.intellij.psi.PsiFile) Resources(org.jetbrains.android.dom.resources.Resources)

Aggregations

StructureViewModel (com.intellij.ide.structureView.StructureViewModel)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiFile (com.intellij.psi.PsiFile)1 XmlFile (com.intellij.psi.xml.XmlFile)1 Resources (org.jetbrains.android.dom.resources.Resources)1 ResourceStructureViewBuilder (org.jetbrains.android.dom.structure.resources.ResourceStructureViewBuilder)1