Search in sources :

Example 1 with PsiCachedValueImpl

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();
}
Also used : PsiCachedValueImpl(com.intellij.psi.impl.PsiCachedValueImpl) XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) CachedValue(com.intellij.psi.util.CachedValue)

Aggregations

PsiCachedValueImpl (com.intellij.psi.impl.PsiCachedValueImpl)1 CachedValue (com.intellij.psi.util.CachedValue)1 XmlNSDescriptor (com.intellij.xml.XmlNSDescriptor)1