Search in sources :

Example 51 with XmlFile

use of com.intellij.psi.xml.XmlFile in project intellij-community by JetBrains.

the class DomStubTest method prepareFile.

protected XmlFile prepareFile(String path) {
    VirtualFile virtualFile = myFixture.copyFileToProject(path);
    assertNotNull(virtualFile);
    XmlFile file = (XmlFile) ((PsiManagerEx) getPsiManager()).getFileManager().findFile(virtualFile);
    assertFalse(file.getNode().isParsed());
    ObjectStubTree tree = StubTreeLoader.getInstance().readOrBuild(getProject(), virtualFile, file);
    assertNotNull("Can't build stubs for " + path, tree);
    ((PsiManagerImpl) getPsiManager()).cleanupForNextTest();
    file = (XmlFile) getPsiManager().findFile(virtualFile);
    assertNotNull(file);
    return file;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) XmlFile(com.intellij.psi.xml.XmlFile) PsiManagerImpl(com.intellij.psi.impl.PsiManagerImpl) PsiManagerEx(com.intellij.psi.impl.PsiManagerEx) ObjectStubTree(com.intellij.psi.stubs.ObjectStubTree)

Example 52 with XmlFile

use of com.intellij.psi.xml.XmlFile 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 53 with XmlFile

use of com.intellij.psi.xml.XmlFile in project intellij-community by JetBrains.

the class DomTestCase method createElement.

public static <T extends DomElement> T createElement(final DomManager domManager, final String xml, final Class<T> aClass) throws IncorrectOperationException {
    final String name = "a.xml";
    final XmlFile file = (XmlFile) PsiFileFactory.getInstance(domManager.getProject()).createFileFromText(name, xml);
    final XmlTag tag = file.getDocument().getRootTag();
    final String rootTagName = tag != null ? tag.getName() : "root";
    final T element = domManager.getFileElement(file, aClass, rootTagName).getRootElement();
    assertNotNull(element);
    assertSame(tag, element.getXmlTag());
    return element;
}
Also used : XmlFile(com.intellij.psi.xml.XmlFile) XmlTag(com.intellij.psi.xml.XmlTag)

Example 54 with XmlFile

use of com.intellij.psi.xml.XmlFile in project intellij-community by JetBrains.

the class TreeIncrementalUpdateTest method createPhysicalElement.

private MyElement createPhysicalElement(final String text) throws IncorrectOperationException {
    final XmlFile file = (XmlFile) createFile("file.xml", text);
    final DomFileElementImpl<MyElement> fileElement = getDomManager().getFileElement(file, MyElement.class, "a");
    final MyElement rootElement = fileElement.getRootElement();
    return rootElement;
}
Also used : XmlFile(com.intellij.psi.xml.XmlFile)

Example 55 with XmlFile

use of com.intellij.psi.xml.XmlFile in project intellij-community by JetBrains.

the class DomNamespacesTest method testSpringUtilLike.

public void testSpringUtilLike() throws Throwable {
    getDomManager().registerFileDescription(new DomFileDescription<MyBeans>(MyBeans.class, "beans", "beans", "util") {

        @Override
        protected void initializeFileDescription() {
            super.initializeFileDescription();
            registerNamespacePolicy("beans", "beans");
            registerNamespacePolicy("util", "util");
        }
    }, getTestRootDisposable());
    final XmlFile psiFile = createXmlFile("<beans xmlns=\"beans\" xmlns:util=\"util\">" + "<util:list>" + "<ref>aaa</ref>" + "<util:child>bbb</util:child>" + "</util:list></beans>");
    final MyList listOrSet = assertInstanceOf(getDomManager().getFileElement(psiFile, MyBeans.class).getRootElement().getList(), MyList.class);
    assertNotNull(listOrSet.getXmlTag());
    final XmlTag listTag = psiFile.getDocument().getRootTag().findFirstSubTag("util:list");
    assertNotNull(getDomManager().getDomElement(listTag.findFirstSubTag("ref")));
    assertNotNull(getDomManager().getDomElement(listTag.findFirstSubTag("util:child")));
    assertEquals("aaa", listOrSet.getRef().getValue());
    assertEquals("bbb", listOrSet.getChild().getValue());
}
Also used : XmlFile(com.intellij.psi.xml.XmlFile) XmlTag(com.intellij.psi.xml.XmlTag)

Aggregations

XmlFile (com.intellij.psi.xml.XmlFile)409 XmlTag (com.intellij.psi.xml.XmlTag)155 PsiFile (com.intellij.psi.PsiFile)121 VirtualFile (com.intellij.openapi.vfs.VirtualFile)102 Nullable (org.jetbrains.annotations.Nullable)74 Project (com.intellij.openapi.project.Project)69 NotNull (org.jetbrains.annotations.NotNull)66 PsiElement (com.intellij.psi.PsiElement)64 XmlAttribute (com.intellij.psi.xml.XmlAttribute)39 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)34 Module (com.intellij.openapi.module.Module)34 XmlDocument (com.intellij.psi.xml.XmlDocument)32 Result (com.intellij.openapi.application.Result)28 XmlElementDescriptor (com.intellij.xml.XmlElementDescriptor)23 XmlAttributeValue (com.intellij.psi.xml.XmlAttributeValue)22 XmlNSDescriptor (com.intellij.xml.XmlNSDescriptor)21 ArrayList (java.util.ArrayList)20 Document (com.intellij.openapi.editor.Document)19 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)18 Editor (com.intellij.openapi.editor.Editor)15