use of com.intellij.util.xml.DomElement in project intellij-community by JetBrains.
the class DomElementAnnotationsManagerImpl method _getOrCreateProblemsHolder.
private DomElementsProblemsHolderImpl _getOrCreateProblemsHolder(final DomFileElement element) {
DomElementsProblemsHolderImpl holder;
final DomElement rootElement = element.getRootElement();
final XmlTag rootTag = rootElement.getXmlTag();
if (rootTag == null)
return new DomElementsProblemsHolderImpl(element);
holder = rootTag.getUserData(DOM_PROBLEM_HOLDER_KEY);
if (isHolderOutdated(element.getFile()) || holder == null) {
holder = new DomElementsProblemsHolderImpl(element);
rootTag.putUserData(DOM_PROBLEM_HOLDER_KEY, holder);
final CachedValue<Boolean> cachedValue = CachedValuesManager.getManager(myProject).createCachedValue(() -> new CachedValueProvider.Result<>(Boolean.FALSE, element, PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, this, ProjectRootManager.getInstance(myProject)), false);
cachedValue.getValue();
element.getFile().putUserData(CACHED_VALUE_KEY, cachedValue);
}
return holder;
}
use of com.intellij.util.xml.DomElement in project intellij-community by JetBrains.
the class IndexedElementInvocationHandler method createPathStableCopy.
@Override
public final DomElement createPathStableCopy() {
final DomFixedChildDescription description = getChildDescription();
final DomElement parentCopy = getParent().createStableCopy();
return getManager().createStableValue((Factory<DomElement>) () -> parentCopy.isValid() ? description.getValues(parentCopy).get(myIndex) : null);
}
use of com.intellij.util.xml.DomElement in project intellij-community by JetBrains.
the class DomElementsProblemsHolderImpl method getProblemsMap.
@NotNull
private Map<Class<? extends DomElementsInspection>, List<DomElementProblemDescriptor>> getProblemsMap(final DomElement domElement) {
final Map<Class<? extends DomElementsInspection>, List<DomElementProblemDescriptor>> map = myCachedChildrenErrors.get(domElement);
if (map != null) {
return map;
}
final Map<Class<? extends DomElementsInspection>, List<DomElementProblemDescriptor>> problems = new THashMap<>();
if (domElement == myElement) {
for (Map<Class<? extends DomElementsInspection>, List<DomElementProblemDescriptor>> listMap : myCachedErrors.values()) {
mergeMaps(problems, listMap);
}
} else {
mergeMaps(problems, myCachedErrors.get(domElement));
if (DomUtil.hasXml(domElement)) {
domElement.acceptChildren(new DomElementVisitor() {
@Override
public void visitDomElement(DomElement element) {
mergeMaps(problems, getProblemsMap(element));
}
});
}
}
myCachedChildrenErrors.put(domElement, problems);
return problems;
}
use of com.intellij.util.xml.DomElement in project intellij-community by JetBrains.
the class AttributeChildInvocationHandler method setValue.
@Override
protected void setValue(@Nullable final String value) {
final XmlTag tag = ensureTagExists();
final String attributeName = getXmlElementName();
final String namespace = getXmlApiCompatibleNamespace(getParentHandler());
final String oldValue = StringUtil.unescapeXml(tag.getAttributeValue(attributeName, namespace));
final String newValue = XmlStringUtil.escapeString(value);
if (Comparing.equal(oldValue, newValue, true))
return;
getManager().runChange(() -> {
try {
XmlAttribute attribute = tag.setAttribute(attributeName, namespace, newValue);
setXmlElement(attribute);
getManager().cacheHandler(DomManagerImpl.DOM_ATTRIBUTE_HANDLER_KEY, attribute, this);
} catch (IncorrectOperationException e) {
LOG.error(e);
}
});
final DomElement proxy = getProxy();
getManager().fireEvent(oldValue != null ? new DomEvent(proxy, false) : new DomEvent(proxy, true));
}
use of com.intellij.util.xml.DomElement in project intellij-community by JetBrains.
the class AbstractDomGenerateProvider method generate.
@Override
public T generate(final Project project, final Editor editor, final PsiFile file) {
DomElement parentDomElement = getParentDomElement(project, editor, file);
final T t = generate(parentDomElement, editor);
runTemplate(editor, file, t, getPredefinedVars(parentDomElement, t, editor, file));
return t;
}
Aggregations