use of com.intellij.pom.event.PomModelEvent in project intellij-community by JetBrains.
the class XmlTagImpl method setName.
@Override
public PsiElement setName(@NotNull final String name) throws IncorrectOperationException {
final PomModel model = PomManager.getModel(getProject());
final XmlAspect aspect = model.getModelAspect(XmlAspect.class);
model.runTransaction(new PomTransactionBase(this, aspect) {
@Override
public PomModelEvent runInner() throws IncorrectOperationException {
final String oldName = getName();
final XmlTagImpl dummyTag = (XmlTagImpl) XmlElementFactory.getInstance(getProject()).createTagFromText(XmlTagUtil.composeTagText(name, "aa"));
final XmlTagImpl tag = XmlTagImpl.this;
final CharTable charTableByTree = SharedImplUtil.findCharTableByTree(tag);
ASTNode child = XmlChildRole.START_TAG_NAME_FINDER.findChild(tag);
LOG.assertTrue(child != null, "It seems '" + name + "' is not a valid tag name");
TreeElement tagElement = (TreeElement) XmlChildRole.START_TAG_NAME_FINDER.findChild(dummyTag);
LOG.assertTrue(tagElement != null, "What's wrong with it? '" + name + "'");
tag.replaceChild(child, ChangeUtil.copyElement(tagElement, charTableByTree));
final ASTNode childByRole = XmlChildRole.CLOSING_TAG_NAME_FINDER.findChild(tag);
if (childByRole != null) {
final TreeElement treeElement = (TreeElement) XmlChildRole.CLOSING_TAG_NAME_FINDER.findChild(dummyTag);
if (treeElement != null) {
tag.replaceChild(childByRole, ChangeUtil.copyElement(treeElement, charTableByTree));
}
}
return XmlTagNameChangedImpl.createXmlTagNameChanged(model, tag, oldName);
}
});
return this;
}
use of com.intellij.pom.event.PomModelEvent in project intellij-community by JetBrains.
the class XmlDocumentImpl method addInternal.
@Override
public TreeElement addInternal(final TreeElement first, final ASTNode last, final ASTNode anchor, final Boolean before) {
final PomModel model = PomManager.getModel(getProject());
final XmlAspect aspect = model.getModelAspect(XmlAspect.class);
final TreeElement[] holder = new TreeElement[1];
try {
model.runTransaction(new PomTransactionBase(this, aspect) {
@Override
public PomModelEvent runInner() {
holder[0] = XmlDocumentImpl.super.addInternal(first, last, anchor, before);
return XmlDocumentChangedImpl.createXmlDocumentChanged(model, XmlDocumentImpl.this);
}
});
} catch (IncorrectOperationException ignored) {
}
return holder[0];
}
use of com.intellij.pom.event.PomModelEvent in project intellij-community by JetBrains.
the class XmlDocumentImpl method replaceChildInternal.
@Override
public void replaceChildInternal(@NotNull final ASTNode child, @NotNull final TreeElement newElement) {
final PomModel model = PomManager.getModel(getProject());
final XmlAspect aspect = model.getModelAspect(XmlAspect.class);
try {
model.runTransaction(new PomTransactionBase(this, aspect) {
@Override
public PomModelEvent runInner() {
XmlDocumentImpl.super.replaceChildInternal(child, newElement);
return XmlDocumentChangedImpl.createXmlDocumentChanged(model, XmlDocumentImpl.this);
}
});
} catch (IncorrectOperationException ignored) {
}
}
use of com.intellij.pom.event.PomModelEvent 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;
}
use of com.intellij.pom.event.PomModelEvent in project intellij-community by JetBrains.
the class XmlDocumentChangedImpl method createXmlDocumentChanged.
public static PomModelEvent createXmlDocumentChanged(PomModel source, XmlDocument document) {
final PomModelEvent event = new PomModelEvent(source);
XmlFile xmlFile = PsiTreeUtil.getParentOfType(document, XmlFile.class);
final XmlAspectChangeSetImpl xmlAspectChangeSet = new XmlAspectChangeSetImpl(source, xmlFile);
xmlAspectChangeSet.add(new XmlDocumentChangedImpl(document));
event.registerChangeSet(source.getModelAspect(XmlAspect.class), xmlAspectChangeSet);
return event;
}
Aggregations