Schema (final XmlFile descriptorFile) { CachedValue<Schema> value = descriptorFile.getUserData(SCHEMA_KEY); if (value == null) { final CachedValueProvider<Schema> provider = () -> { final InputSource inputSource = makeInputSource(descriptorFile); try { final Schema schema = new MySchemaReader(descriptorFile).createSchema(inputSource, EMPTY_PROPS); final PsiElementProcessor.CollectElements<XmlFile> processor = new PsiElementProcessor.CollectElements<>(); RelaxIncludeIndex.processForwardDependencies(descriptorFile, processor); if (processor.getCollection().size() > 0) { return CachedValueProvider.Result.create(schema, processor.toArray(), descriptorFile); } else { return CachedValueProvider.Result.createSingleDependency(schema, descriptorFile); } } catch (Exception e) { LOG.info(e); return CachedValueProvider.Result.createSingleDependency(null, descriptorFile); } }; final CachedValuesManager mgr = CachedValuesManager.getManager(descriptorFile.getProject()); value = mgr.createCachedValue(provider, false); descriptorFile.putUserData(SCHEMA_KEY, value); } return value.getValue(); }