Search in sources :

Example 11 with DomEvent

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

the class IncrementalUpdateEventsTest method testRemove2.

public void testRemove2() {
    deleteTag(2);
    putExpected(new DomEvent(myElement, false));
    assertResultsAndClear();
    deleteTag(2);
    putExpected(new DomEvent(myElement, false));
    assertResultsAndClear();
}
Also used : DomEvent(com.intellij.util.xml.events.DomEvent)

Example 12 with DomEvent

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

the class IncrementalUpdateEventsTest method testRemove0.

public void testRemove0() {
    deleteTag(0);
    putExpected(new DomEvent(myElement, false));
    assertResultsAndClear();
    deleteTag(0);
    putExpected(new DomEvent(myElement, false));
    assertResultsAndClear();
    deleteTag(0);
    putExpected(new DomEvent(myElement, false));
    assertResultsAndClear();
    deleteTag(0);
    putExpected(new DomEvent(myElement, false));
    assertResultsAndClear();
}
Also used : DomEvent(com.intellij.util.xml.events.DomEvent)

Example 13 with DomEvent

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

the class DomSimpleValuesTest method testAttributeValues.

public void testAttributeValues() throws Throwable {
    final MyElement element = createElement("<a attra=\"foo\"/>");
    final GenericAttributeValue<String> attributeValue = element.getAttributeValue();
    assertEquals("attra", attributeValue.getXmlElementName());
    assertEquals("foo", attributeValue.getValue());
    final GenericAttributeValue<Integer> attr = element.getAttr();
    attr.setValue(239);
    assertEquals(239, (int) attr.getValue());
    assertEquals("239", element.getXmlTag().getAttributeValue("attr"));
    final DomElement element1 = attr;
    myCallRegistry.putExpected(new DomEvent(element1, true));
    myCallRegistry.assertResultsAndClear();
    attr.setValue(42);
    myCallRegistry.putExpected(new DomEvent(attr, false));
    myCallRegistry.assertResultsAndClear();
    attr.setValue(null);
    assertNull(attr.getValue());
    assertNull(element.getXmlTag().getAttributeValue("attr"));
    assertNull(element.getXmlTag().getAttribute("attr", ""));
    myCallRegistry.putExpected(new DomEvent(attr, false));
    myCallRegistry.assertResultsAndClear();
    assertEquals("some-attribute", element.getSomeAttribute().getXmlElementName());
    assertNull(createElement("<a attra\"attr\"/>").getAttributeValue().getStringValue());
    assertNull(createElement("<a attra\"\"/>").getAttributeValue().getStringValue());
    assertNull(createElement("<a attra\"/>").getAttributeValue().getStringValue());
}
Also used : DomEvent(com.intellij.util.xml.events.DomEvent)

Example 14 with DomEvent

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

the class DomVirtualFileEventsTest method testRenameFile.

public void testRenameFile() throws Throwable {
    new WriteCommandAction.Simple(getProject()) {

        @Override
        protected void run() throws Throwable {
            final VirtualFile dir = getVirtualFile(createTempDirectory());
            addSourceContentToRoots(getModule(), dir);
            final VirtualFile data = dir.createChildData(this, "abc.xml");
            setFileText(data, "<a/>");
            PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
            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());
            fileElement = getFileElement(data);
            data.rename(this, "fff.xml");
            assertEventCount(1);
            putExpected(new DomEvent(fileElement, false));
            assertResultsAndClear();
            assertNull(getFileElement(data));
            assertFalse(fileElement.isValid());
        }
    }.execute().throwException();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) DomEvent(com.intellij.util.xml.events.DomEvent)

Example 15 with DomEvent

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

the class SimpleValuesIncrementalUpdateTest method testAttributeChange.

public void testAttributeChange() throws Throwable {
    final MyElement element = createElement("<a/>");
    element.getXmlTag().setAttribute("attr", "foo");
    putExpected(new DomEvent(element, false));
    assertResultsAndClear();
    assertTrue(element.getAttr().isValid());
    element.getXmlTag().setAttribute("bttr", "foo");
    element.getXmlTag().setAttribute("attr", "bar");
    putExpected(new DomEvent(element, false));
    putExpected(new DomEvent(element, false));
    assertResultsAndClear();
    assertTrue(element.getAttr().isValid());
    element.getXmlTag().setAttribute("attr", null);
    putExpected(new DomEvent(element, false));
    assertResultsAndClear();
    assertTrue(element.getAttr().isValid());
}
Also used : 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