Java 类com.intellij.util.xml.impl.DomFileElementImpl 实例源码

项目:intellij-ce-playground    文件:DomVirtualFileEventsTest.java   
public void testDeleteFile() throws Throwable {
  new WriteCommandAction.Simple(getProject()) {
    @Override
    protected void run() throws Throwable {
      final VirtualFile dir = getVirtualFile(createTempDirectory());
      PsiTestUtil.addSourceContentToRoots(getModule(), dir);
      final VirtualFile childData = dir.createChildData(this, "abc.xml");
      assertResultsAndClear();
      VfsUtil.saveText(childData, "<a/>");
      final DomFileElementImpl<DomElement> fileElement = getFileElement(childData);
      assertResultsAndClear();

      childData.delete(this);
      assertEventCount(1);
      putExpected(new DomEvent(fileElement, false));
      assertResultsAndClear();
      assertFalse(fileElement.isValid());
    }
  }.execute().throwException();
}
项目:intellij-ce-playground    文件:DomNamespacesTest.java   
public void testNonemptyRootTagPrefix() throws Throwable {
  getDomManager().registerFileDescription(new DomFileDescription<MyFooElement>(MyFooElement.class, "a", "foons") {

    @Override
    protected void initializeFileDescription() {
      super.initializeFileDescription();
      registerNamespacePolicy("foo", "foons");
    }
  }, getTestRootDisposable());

  final XmlFile psiFile = createXmlFile("<f:a xmlns:f=\"foons\"/>");
  final DomFileElementImpl<MyFooElement> element = getDomManager().getFileElement(psiFile, MyFooElement.class);
  assertNotNull(element);

  final MyFooElement root = element.getRootElement();
  assertNotNull(root);
  assertSame(psiFile.getDocument().getRootTag(), root.getXmlElement());
}
项目:tools-idea    文件:DomVirtualFileEventsTest.java   
public void testDeleteFile() throws Throwable {
  new WriteCommandAction.Simple(getProject()) {
    @Override
    protected void run() throws Throwable {
      final VirtualFile dir = getVirtualFile(createTempDirectory());
      PsiTestUtil.addSourceContentToRoots(getModule(), dir);
      final VirtualFile childData = dir.createChildData(this, "abc.xml");
      assertResultsAndClear();
      VfsUtil.saveText(childData, "<a/>");
      final DomFileElementImpl<DomElement> fileElement = getFileElement(childData);
      assertResultsAndClear();

      childData.delete(this);
      assertEventCount(1);
      putExpected(new DomEvent(fileElement, false));
      assertResultsAndClear();
      assertFalse(fileElement.isValid());
    }
  }.execute().throwException();
}
项目:tools-idea    文件:DomNamespacesTest.java   
public void testNonemptyRootTagPrefix() throws Throwable {
  getDomManager().registerFileDescription(new DomFileDescription<MyFooElement>(MyFooElement.class, "a", "foons") {

    @Override
    protected void initializeFileDescription() {
      super.initializeFileDescription();
      registerNamespacePolicy("foo", "foons");
    }
  }, getTestRootDisposable());

  final XmlFile psiFile = createXmlFile("<f:a xmlns:f=\"foons\"/>");
  final DomFileElementImpl<MyFooElement> element = getDomManager().getFileElement(psiFile, MyFooElement.class);
  assertNotNull(element);

  final MyFooElement root = element.getRootElement();
  assertNotNull(root);
  assertSame(psiFile.getDocument().getRootTag(), root.getXmlElement());
}
项目:consulo-xml    文件:DomNamespacesTest.java   
public void testNonemptyRootTagPrefix() throws Throwable {
  getDomManager().registerFileDescription(new DomFileDescription<MyFooElement>(MyFooElement.class, "a", "foons") {

    @Override
    protected void initializeFileDescription() {
      super.initializeFileDescription();
      registerNamespacePolicy("foo", "foons");
    }
  }, getTestRootDisposable());

  final XmlFile psiFile = createXmlFile("<f:a xmlns:f=\"foons\"/>");
  final DomFileElementImpl<MyFooElement> element = getDomManager().getFileElement(psiFile, MyFooElement.class);
  assertNotNull(element);

  final MyFooElement root = element.getRootElement();
  assertNotNull(root);
  assertSame(psiFile.getDocument().getRootTag(), root.getXmlElement());
}
项目:intellij-ce-playground    文件:DomVirtualFileEventsTest.java   
public void testRenameFile() throws Throwable {
  new WriteCommandAction.Simple(getProject()) {
    @Override
    protected void run() throws Throwable {
      final VirtualFile dir = getVirtualFile(createTempDirectory());
      PsiTestUtil.addSourceContentToRoots(getModule(), dir);
      final VirtualFile data = dir.createChildData(this, "abc.xml");
      VfsUtil.saveText(data, "<a/>");
      PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
      final DomFileElementImpl<DomElement> fileElement = getFileElement(data);
      assertEventCount(0);
      assertResultsAndClear();

      data.rename(this, "deaf.xml");
      assertEventCount(1);
      putExpected(new DomEvent(fileElement, false));
      assertResultsAndClear();
      assertEquals(fileElement, getFileElement(data));
      assertTrue(fileElement.isValid());

      data.rename(this, "fff.xml");
      assertEventCount(1);
      putExpected(new DomEvent(fileElement, false));
      assertResultsAndClear();
      assertNull(getFileElement(data));
      assertFalse(fileElement.isValid());
    }
  }.execute().throwException();
}
项目:tools-idea    文件:DomVirtualFileEventsTest.java   
public void testRenameFile() throws Throwable {
  new WriteCommandAction.Simple(getProject()) {
    @Override
    protected void run() throws Throwable {
      final VirtualFile dir = getVirtualFile(createTempDirectory());
      PsiTestUtil.addSourceContentToRoots(getModule(), dir);
      final VirtualFile data = dir.createChildData(this, "abc.xml");
      VfsUtil.saveText(data, "<a/>");
      final DomFileElementImpl<DomElement> fileElement = getFileElement(data);
      assertEventCount(0);
      assertResultsAndClear();

      data.rename(this, "deaf.xml");
      assertEventCount(1);
      putExpected(new DomEvent(fileElement, false));
      assertResultsAndClear();
      assertEquals(fileElement, getFileElement(data));
      assertTrue(fileElement.isValid());

      data.rename(this, "fff.xml");
      assertEventCount(1);
      putExpected(new DomEvent(fileElement, false));
      assertResultsAndClear();
      assertNull(getFileElement(data));
      assertFalse(fileElement.isValid());
    }
  }.execute().throwException();
}
项目:intellij-ce-playground    文件:DomVirtualFileEventsTest.java   
private DomFileElementImpl<DomElement> getFileElement(final VirtualFile file) {
  return getDomManager().getFileElement((XmlFile)getPsiManager().findFile(file));
}
项目:intellij-ce-playground    文件:DomIncludesTest.java   
private MyElement createDomFile(final String fileName, final String fileText) throws IOException {
  final XmlFile xmlFile = (XmlFile) createFile(fileName, fileText);
  final DomFileElementImpl<MyElement> element = getDomManager().getFileElement(xmlFile, MyElement.class, xmlFile.getDocument().getRootTag().getName());
  return element.getRootElement();
}
项目:tools-idea    文件:DomVirtualFileEventsTest.java   
private DomFileElementImpl<DomElement> getFileElement(final VirtualFile file) {
  return getDomManager().getFileElement((XmlFile)getPsiManager().findFile(file));
}
项目:tools-idea    文件:DomIncludesTest.java   
private MyElement createDomFile(final String fileName, final String fileText) throws IOException {
  final XmlFile xmlFile = (XmlFile) createFile(fileName, fileText);
  final DomFileElementImpl<MyElement> element = getDomManager().getFileElement(xmlFile, MyElement.class, xmlFile.getDocument().getRootTag().getName());
  return element.getRootElement();
}
项目:consulo-xml    文件:DomTestCase.java   
protected void assertCached(final DomFileElementImpl element, final XmlFile file)
{
    assertNotNull(file);
    assertEquals(element, getDomManager().getFileElement(file));
}