if (value == null) {
file.putUserData(USED_RULES_KEY, value = CachedValuesManager.getManager(file.getProject()).createCachedValue(new CachedValueProvider<Set<PsiElement>>() {
@Override
public Result<Set<PsiElement>> compute() {
final THashSet<PsiElement> psiElements = new THashSet<PsiElement>();
file.acceptChildren(new PsiRecursiveElementWalkingVisitor() {
@Override
public void visitElement(PsiElement element) {
if (element instanceof BnfReferenceOrToken || element instanceof BnfStringLiteralExpression) {
PsiReference reference = element.getReference();
PsiElement target = reference != null? reference.resolve() : null;