Search in sources :

Example 16 with DomEvent

use of com.intellij.util.xml.events.DomEvent in project intellij-community by JetBrains.

the class SimpleValuesIncrementalUpdateTest method testAttributeValueChangeAsXmlElementChange.

public void testAttributeValueChangeAsXmlElementChange() throws Throwable {
    final MyElement element = createElement("<a attr=\"foo\"/>");
    final GenericAttributeValue<String> attr = element.getAttr();
    attr.getXmlAttributeValue().getFirstChild().replace(createTag("<a attr=\"bar\"/>").getAttribute("attr", null).getValueElement().getFirstChild());
    putExpected(new DomEvent(element, false));
    assertResultsAndClear();
    assertTrue(attr.isValid());
}
Also used : DomEvent(com.intellij.util.xml.events.DomEvent)

Example 17 with DomEvent

use of com.intellij.util.xml.events.DomEvent in project intellij-community by JetBrains.

the class TreeIncrementalUpdateTest method testCustomChildrenEvents.

public void testCustomChildrenEvents() throws Throwable {
    final Sepulka element = createElement("<a><foo/><bar/></a>", Sepulka.class);
    final List<MyElement> list = element.getCustomChildren();
    final XmlTag tag = element.getXmlTag();
    WriteCommandAction.runWriteCommandAction(null, () -> {
        tag.getSubTags()[0].delete();
        tag.getSubTags()[0].delete();
    });
    tag.add(createTag("<goo/>"));
    putExpected(new DomEvent(element, false));
    putExpected(new DomEvent(element, false));
    putExpected(new DomEvent(element, false));
    assertResultsAndClear();
    assertEquals(1, element.getCustomChildren().size());
}
Also used : XmlTag(com.intellij.psi.xml.XmlTag) DomEvent(com.intellij.util.xml.events.DomEvent)

Example 18 with DomEvent

use of com.intellij.util.xml.events.DomEvent in project intellij-community by JetBrains.

the class TreeIncrementalUpdateTest method testAddFixedElementCanDefineIt.

public void testAddFixedElementCanDefineIt() throws Throwable {
    final MyElement element = createElement("<a></a>");
    final MyElement child = element.getChild();
    element.getXmlTag().add(createTag("<child/>"));
    final XmlTag[] subTags = element.getXmlTag().getSubTags();
    assertTrue(child.equals(element.getChild()));
    assertTrue(element.getChild().equals(child));
    assertCached(element.getChild(), subTags[0]);
    putExpected(new DomEvent(element, false));
    assertResultsAndClear();
}
Also used : XmlTag(com.intellij.psi.xml.XmlTag) DomEvent(com.intellij.util.xml.events.DomEvent)

Example 19 with DomEvent

use of com.intellij.util.xml.events.DomEvent in project intellij-community by JetBrains.

the class TreeIncrementalUpdateTest method testAddFixedElement.

public void testAddFixedElement() throws Throwable {
    final MyElement element = createPhysicalElement("<a>" + "<child/>" + "<child><child/></child>" + "<child/></a>");
    final MyElement child = element.getChild();
    final MyElement child2 = element.getChild2();
    final XmlTag leafTag = child2.getChild().getXmlTag();
    new WriteCommandAction(getProject()) {

        @Override
        protected void run(@NotNull Result result) throws Throwable {
            element.getXmlTag().addAfter(createTag("<child/>"), child.getXmlTag());
        }
    }.execute();
    assertNoCache(leafTag);
    final XmlTag[] subTags = element.getXmlTag().getSubTags();
    assertFalse(child2.isValid());
    assertEquals(child, element.getChild());
    assertFalse(child2.equals(element.getChild2()));
    assertCached(child, subTags[0]);
    assertNoCache(subTags[2]);
    assertNoCache(subTags[3]);
    putExpected(new DomEvent(element, false));
    putExpected(new DomEvent(element, false));
    assertResultsAndClear();
}
Also used : WriteCommandAction(com.intellij.openapi.command.WriteCommandAction) XmlTag(com.intellij.psi.xml.XmlTag) Result(com.intellij.openapi.application.Result) DomEvent(com.intellij.util.xml.events.DomEvent)

Example 20 with DomEvent

use of com.intellij.util.xml.events.DomEvent in project intellij-community by JetBrains.

the class TreeIncrementalUpdateTest method testRootTagAppearsLater.

public void testRootTagAppearsLater() throws Throwable {
    final XmlFile file = createXmlFile("");
    final DomFileElementImpl<MyElement> fileElement = getDomManager().getFileElement(file, MyElement.class, "root");
    myCallRegistry.clear();
    assertNull(fileElement.getRootElement().getXmlTag());
    file.getDocument().replace(createXmlFile("<root/>").getDocument());
    final XmlTag rootTag = fileElement.getRootTag();
    assertEquals(rootTag, file.getDocument().getRootTag());
    putExpected(new DomEvent(fileElement.getRootElement(), false));
    assertResultsAndClear();
}
Also used : XmlFile(com.intellij.psi.xml.XmlFile) XmlTag(com.intellij.psi.xml.XmlTag) DomEvent(com.intellij.util.xml.events.DomEvent)

Aggregations

DomEvent (com.intellij.util.xml.events.DomEvent)48 XmlTag (com.intellij.psi.xml.XmlTag)24 Result (com.intellij.openapi.application.Result)7 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)7 XmlFile (com.intellij.psi.xml.XmlFile)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 DomElement (com.intellij.util.xml.DomElement)3 Document (com.intellij.openapi.editor.Document)2 XmlAttribute (com.intellij.psi.xml.XmlAttribute)2 IncorrectOperationException (com.intellij.util.IncorrectOperationException)2 DomSupportEnabled (com.intellij.ide.highlighter.DomSupportEnabled)1 VirtualFileWithId (com.intellij.openapi.vfs.VirtualFileWithId)1 ObjectStubTree (com.intellij.psi.stubs.ObjectStubTree)1 FileStub (com.intellij.util.xml.stubs.FileStub)1 ArrayList (java.util.ArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1