XmlEntityDecl (final XmlElement element, final String text, PsiFile targetFile) { final String entityName = text.substring(1, text.length() - 1); final PsiElement targetElement = targetFile != null ? targetFile : element; CachedValue<XmlEntityDecl> value; synchronized (XmlEntityCache.LOCK) { Map<String, CachedValue<XmlEntityDecl>> map = XmlEntityCache.getCachingMap(targetElement); value = map.get(entityName); final PsiFile containingFile = element.getContainingFile(); if (value == null) { final PsiManager manager = element.getManager(); if (manager == null) { return doResolveEntity(targetElement, entityName, containingFile).getValue(); } value = CachedValuesManager.getManager(manager.getProject()).createCachedValue( () -> doResolveEntity(targetElement, entityName, containingFile), true); map.put(entityName, value); } } return value.getValue(); }