CachedFormData (final PsiPlainTextFile element) { CachedValue<CachedFormData> data = element.getUserData(CACHED_DATA); if(data == null) { data = CachedValuesManager.getManager(element.getProject()).createCachedValue(new CachedValueProvider<>() { final Map<String, Pair<PsiType, TextRange>> map = new HashMap<>(); @Override public Result<CachedFormData> compute() { final PsiReferenceProcessor.CollectElements processor = new PsiReferenceProcessor.CollectElements() { @Override public boolean execute(PsiReference ref) { if (ref instanceof FieldFormReference fieldRef) { final String componentClassName = fieldRef.getComponentClassName(); if (componentClassName != null) { final PsiClassType type = JavaPsiFacade.getInstance(element.getProject()).getElementFactory() .createTypeByFQClassName(componentClassName, element.getResolveScope()); map.put(fieldRef.getRangeText(), new Pair<>(type, fieldRef.getComponentClassNameTextRange())); } } return super.execute(ref); } }; processReferences(element, processor); final PsiReference[] refs = processor.toArray(PsiReference.EMPTY_ARRAY); return new Result<>(new CachedFormData(refs, map), element); } }, false); element.putUserData(CACHED_DATA, data); } return data.getValue(); }