Set<Define> (Grammar scope, final String value) { final Map<String, Set<Define>> map = getAllVariants(scope); if (map == null) { return null; } final Set<Define> set = map.get(value); // actually we should always do this, but I'm a bit afraid of the performance impact if (set == null || set.size() == 0) { final PsiElement element = scope.getPsiElement(); if (element != null) { final PsiFile file = element.getContainingFile(); if (file instanceof XmlFile) { final BackwardDefinitionResolver resolver = new BackwardDefinitionResolver(value); RelaxIncludeIndex.processBackwardDependencies((XmlFile)file, resolver); return resolver.getResult(); } } } return set; }