Result<CachedFormData> () { 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); }