use of com.intellij.psi.impl.PsiCachedValueImpl in project intellij-community by JetBrains.
the class XmlDocumentImpl method getDefaultNSDescriptor.
@Override
public XmlNSDescriptor getDefaultNSDescriptor(final String namespace, final boolean strict) {
long curExtResourcesModCount = ExternalResourceManagerEx.getInstanceEx().getModificationCount(getProject());
if (myExtResourcesModCount != curExtResourcesModCount) {
myDefaultDescriptorsCacheNotStrict.clear();
myDefaultDescriptorsCacheStrict.clear();
myExtResourcesModCount = curExtResourcesModCount;
}
final ConcurrentMap<String, CachedValue<XmlNSDescriptor>> defaultDescriptorsCache;
if (strict) {
defaultDescriptorsCache = myDefaultDescriptorsCacheStrict;
} else {
defaultDescriptorsCache = myDefaultDescriptorsCacheNotStrict;
}
CachedValue<XmlNSDescriptor> cachedValue = defaultDescriptorsCache.get(namespace);
if (cachedValue == null) {
defaultDescriptorsCache.put(namespace, cachedValue = new PsiCachedValueImpl<>(getManager(), () -> {
final XmlNSDescriptor defaultNSDescriptorInner = getDefaultNSDescriptorInner(namespace, strict);
if (isGeneratedFromDtd(defaultNSDescriptorInner)) {
return new CachedValueProvider.Result<>(defaultNSDescriptorInner, this, ExternalResourceManager.getInstance());
}
return new CachedValueProvider.Result<>(defaultNSDescriptorInner, defaultNSDescriptorInner != null ? defaultNSDescriptorInner.getDependences() : ExternalResourceManager.getInstance());
}));
}
return cachedValue.getValue();
}
Aggregations