Search in sources :

Example 6 with Resources

use of org.jetbrains.android.dom.resources.Resources 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

VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 Resources (org.jetbrains.android.dom.resources.Resources)6 ResourceElement (org.jetbrains.android.dom.resources.ResourceElement)4 Result (com.intellij.openapi.application.Result)2 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)2 NotNull (org.jetbrains.annotations.NotNull)2 StructureViewModel (com.intellij.ide.structureView.StructureViewModel)1 ValidationInfo (com.intellij.openapi.ui.ValidationInfo)1 Pair (com.intellij.openapi.util.Pair)1 PsiFile (com.intellij.psi.PsiFile)1 XmlFile (com.intellij.psi.xml.XmlFile)1 Attr (org.jetbrains.android.dom.resources.Attr)1 DeclareStyleable (org.jetbrains.android.dom.resources.DeclareStyleable)1 ResourceStructureViewBuilder (org.jetbrains.android.dom.structure.resources.ResourceStructureViewBuilder)1 Nullable (org.jetbrains.annotations.Nullable)1