use of com.intellij.util.xml.events.DomEvent in project intellij-community by JetBrains.
the class TreeIncrementalUpdateTest method testTypeBeforeRootTag.
public void testTypeBeforeRootTag() throws Throwable {
getDomManager().registerFileDescription(new DomFileDescription<>(MyElement.class, "a"), getTestRootDisposable());
final XmlFile file = (XmlFile) createFile("file.xml", "<?xml version='1.0' encoding='UTF-8'?>\n" + "<a/>");
assertTrue(getDomManager().isDomFile(file));
final DomFileElementImpl<MyElement> fileElement = getDomManager().getFileElement(file, MyElement.class);
assertTrue(fileElement.isValid());
myCallRegistry.clear();
putExpected(new DomEvent(fileElement, false));
new WriteCommandAction(getProject()) {
@Override
protected void run(@NotNull Result result) throws Throwable {
final Document document = getDocument(file);
final int i = document.getText().indexOf("<a");
document.insertString(i, "a");
commitDocument(document);
}
}.execute();
assertFalse(getDomManager().isDomFile(file));
assertFalse(fileElement.isValid());
assertResultsAndClear();
}
use of com.intellij.util.xml.events.DomEvent in project intellij-community by JetBrains.
the class TreeIncrementalUpdateTest method testRemoveFixedElement.
public void testRemoveFixedElement() throws Throwable {
final MyElement element = createElement("<a>" + "<child/>" + "<child><child/></child>" + "<child><child/></child>" + "</a>");
final MyElement child = element.getChild();
final MyElement child2 = element.getChild2();
final MyElement oldLeaf = child2.getChild();
final XmlTag tag = element.getXmlTag();
XmlTag leafTag = tag.getSubTags()[2].getSubTags()[0];
assertNoCache(leafTag);
ApplicationManager.getApplication().runWriteAction(() -> {
tag.getSubTags()[1].delete();
assertFalse(oldLeaf.isValid());
putExpected(new DomEvent(element, false));
assertResultsAndClear();
assertEquals(child, element.getChild());
assertFalse(child2.isValid());
tag.getSubTags()[1].delete();
});
putExpected(new DomEvent(element, false));
assertResultsAndClear();
}
use of com.intellij.util.xml.events.DomEvent in project intellij-community by JetBrains.
the class TreeIncrementalUpdateTest method testActuallyRemoveCollectionElement.
public void testActuallyRemoveCollectionElement() throws Throwable {
final MyElement element = createElement("<a><child-element><child/></child-element><child-element/></a>");
final MyElement child = element.getChild();
final MyElement child2 = element.getChild2();
final MyElement firstChild = element.getChildElements().get(0);
final MyElement lastChild = element.getChildElements().get(1);
final XmlTag tag = element.getXmlTag();
final XmlTag childTag = tag.getSubTags()[0];
WriteCommandAction.runWriteCommandAction(null, () -> childTag.delete());
putExpected(new DomEvent(element, false));
assertResultsAndClear();
assertEquals(child, element.getChild());
assertEquals(child2, element.getChild2());
assertEquals(Arrays.asList(lastChild), element.getChildElements());
assertCached(lastChild, tag.getSubTags()[0]);
}
use of com.intellij.util.xml.events.DomEvent in project intellij-community by JetBrains.
the class DomBasicsTest method testEnsureTagExists.
public void testEnsureTagExists() throws Throwable {
final MyElement element = createElement("<a/>");
myCallRegistry.clear();
final MyElement child = element.getChild();
assertNull(child.getXmlTag());
child.ensureTagExists();
final XmlTag[] subTags = element.getXmlTag().getSubTags();
assertEquals(1, subTags.length);
final XmlTag childTag = subTags[0];
assertEquals("child", childTag.getName());
assertCached(child, childTag);
assertSame(child.getXmlTag(), childTag);
final DomElement element1 = child;
myCallRegistry.putExpected(new DomEvent(element1, true));
myCallRegistry.assertResultsAndClear();
final MyElement childElement = element.addChildElement();
final XmlTag childElementTag = childElement.getXmlTag();
assertSame(childElementTag, childElement.ensureTagExists());
}
use of com.intellij.util.xml.events.DomEvent in project intellij-community by JetBrains.
the class DomBasicsTest method testEnsureRootTagExists.
public void testEnsureRootTagExists() throws Throwable {
final MyElement rootElement = createEmptyElement();
myCallRegistry.clear();
assertNull(rootElement.getXmlTag());
rootElement.ensureTagExists();
final DomElement element = rootElement;
myCallRegistry.putExpected(new DomEvent(element, true));
assertCached(rootElement, assertRootTag(rootElement));
myCallRegistry.assertResultsAndClear();
}
Aggregations