Search in sources :

Example 1 with XmlAspectChangeSetImpl

use of com.intellij.pom.xml.impl.XmlAspectChangeSetImpl in project intellij-community by JetBrains.

the class XmlAttributeImpl method setName.

@Override
public PsiElement setName(@NotNull final String nameText) throws IncorrectOperationException {
    final ASTNode name = XmlChildRole.ATTRIBUTE_NAME_FINDER.findChild(this);
    final String oldName = name.getText();
    final PomModel model = PomManager.getModel(getProject());
    final XmlAttribute attribute = XmlElementFactory.getInstance(getProject()).createAttribute(nameText, "", this);
    final ASTNode newName = XmlChildRole.ATTRIBUTE_NAME_FINDER.findChild((ASTNode) attribute);
    final XmlAspect aspect = model.getModelAspect(XmlAspect.class);
    model.runTransaction(new PomTransactionBase(getParent(), aspect) {

        @Override
        public PomModelEvent runInner() {
            final PomModelEvent event = new PomModelEvent(model);
            PsiFile file = getContainingFile();
            XmlChangeSet xmlAspectChangeSet = new XmlAspectChangeSetImpl(model, file instanceof XmlFile ? (XmlFile) file : null);
            xmlAspectChangeSet.add(new XmlAttributeSetImpl(getParent(), oldName, null));
            xmlAspectChangeSet.add(new XmlAttributeSetImpl(getParent(), nameText, getValue()));
            event.registerChangeSet(model.getModelAspect(XmlAspect.class), xmlAspectChangeSet);
            CodeEditUtil.replaceChild(XmlAttributeImpl.this, name, newName);
            return event;
        }
    });
    return this;
}
Also used : XmlAttributeSetImpl(com.intellij.pom.xml.impl.events.XmlAttributeSetImpl) XmlChangeSet(com.intellij.pom.xml.XmlChangeSet) PomTransactionBase(com.intellij.pom.impl.PomTransactionBase) PomModelEvent(com.intellij.pom.event.PomModelEvent) XmlAspectChangeSetImpl(com.intellij.pom.xml.impl.XmlAspectChangeSetImpl) XmlAspect(com.intellij.pom.xml.XmlAspect) ASTNode(com.intellij.lang.ASTNode) PomModel(com.intellij.pom.PomModel)

Example 2 with XmlAspectChangeSetImpl

use of com.intellij.pom.xml.impl.XmlAspectChangeSetImpl in project intellij-community by JetBrains.

the class XmlTextImpl method createEvent.

private PomModelEvent createEvent(final XmlChange... events) {
    final PomModelEvent event = new PomModelEvent(PomManager.getModel(getProject()));
    final XmlAspectChangeSetImpl xmlAspectChangeSet = new XmlAspectChangeSetImpl(PomManager.getModel(getProject()), (XmlFile) getContainingFile());
    for (XmlChange xmlChange : events) {
        xmlAspectChangeSet.add(xmlChange);
    }
    event.registerChangeSet(PomManager.getModel(getProject()).getModelAspect(XmlAspect.class), xmlAspectChangeSet);
    return event;
}
Also used : XmlAspectChangeSetImpl(com.intellij.pom.xml.impl.XmlAspectChangeSetImpl) XmlChange(com.intellij.pom.xml.events.XmlChange) XmlAspect(com.intellij.pom.xml.XmlAspect) PomModelEvent(com.intellij.pom.event.PomModelEvent)

Example 3 with XmlAspectChangeSetImpl

use of com.intellij.pom.xml.impl.XmlAspectChangeSetImpl in project intellij-community by JetBrains.

the class XmlAttributeSetImpl method createXmlAttributeSet.

public static PomModelEvent createXmlAttributeSet(PomModel model, XmlTag xmlTag, String name, String value) {
    final PomModelEvent event = new PomModelEvent(model);
    final XmlAspectChangeSetImpl xmlAspectChangeSet = new XmlAspectChangeSetImpl(model, PsiTreeUtil.getParentOfType(xmlTag, XmlFile.class));
    xmlAspectChangeSet.add(new XmlAttributeSetImpl(xmlTag, name, value));
    event.registerChangeSet(model.getModelAspect(XmlAspect.class), xmlAspectChangeSet);
    return event;
}
Also used : XmlAspectChangeSetImpl(com.intellij.pom.xml.impl.XmlAspectChangeSetImpl) XmlFile(com.intellij.psi.xml.XmlFile) XmlAspect(com.intellij.pom.xml.XmlAspect) PomModelEvent(com.intellij.pom.event.PomModelEvent)

Example 4 with XmlAspectChangeSetImpl

use of com.intellij.pom.xml.impl.XmlAspectChangeSetImpl in project intellij-community by JetBrains.

the class XmlTagChildChangedImpl method createXmlTagChildChanged.

public static PomModelEvent createXmlTagChildChanged(PomModel source, XmlTag context, XmlTagChild treeElement) {
    final PomModelEvent event = new PomModelEvent(source);
    final XmlAspectChangeSetImpl xmlAspectChangeSet = new XmlAspectChangeSetImpl(source, PsiTreeUtil.getParentOfType(context, XmlFile.class));
    xmlAspectChangeSet.add(new XmlTagChildChangedImpl(context, treeElement));
    event.registerChangeSet(source.getModelAspect(XmlAspect.class), xmlAspectChangeSet);
    return event;
}
Also used : XmlAspectChangeSetImpl(com.intellij.pom.xml.impl.XmlAspectChangeSetImpl) XmlFile(com.intellij.psi.xml.XmlFile) XmlAspect(com.intellij.pom.xml.XmlAspect) PomModelEvent(com.intellij.pom.event.PomModelEvent)

Example 5 with XmlAspectChangeSetImpl

use of com.intellij.pom.xml.impl.XmlAspectChangeSetImpl in project intellij-community by JetBrains.

the class XmlTextChangedImpl method createXmlTextChanged.

public static PomModelEvent createXmlTextChanged(PomModel source, XmlText xmlText, String oldText) {
    final PomModelEvent event = new PomModelEvent(source);
    final XmlAspectChangeSetImpl xmlAspectChangeSet = new XmlAspectChangeSetImpl(source, PsiTreeUtil.getParentOfType(xmlText, XmlFile.class));
    xmlAspectChangeSet.add(new XmlTextChangedImpl(xmlText, oldText));
    event.registerChangeSet(source.getModelAspect(XmlAspect.class), xmlAspectChangeSet);
    return event;
}
Also used : XmlAspectChangeSetImpl(com.intellij.pom.xml.impl.XmlAspectChangeSetImpl) XmlFile(com.intellij.psi.xml.XmlFile) XmlAspect(com.intellij.pom.xml.XmlAspect) PomModelEvent(com.intellij.pom.event.PomModelEvent)

Aggregations

PomModelEvent (com.intellij.pom.event.PomModelEvent)7 XmlAspect (com.intellij.pom.xml.XmlAspect)7 XmlAspectChangeSetImpl (com.intellij.pom.xml.impl.XmlAspectChangeSetImpl)7 XmlFile (com.intellij.psi.xml.XmlFile)5 ASTNode (com.intellij.lang.ASTNode)1 PomModel (com.intellij.pom.PomModel)1 PomTransactionBase (com.intellij.pom.impl.PomTransactionBase)1 XmlChangeSet (com.intellij.pom.xml.XmlChangeSet)1 XmlChange (com.intellij.pom.xml.events.XmlChange)1 XmlAttributeSetImpl (com.intellij.pom.xml.impl.events.XmlAttributeSetImpl)1