}
}
private static boolean scopeMatches(PsiElement element, PsiElement declaration) {
final InjectedLanguageManager injector = InjectedLanguageManager.getInstance(element.getProject());
final PsiLanguageInjectionHost elementContainer = injector.getInjectionHost(element);
final XmlTagChild elementTag = PsiTreeUtil.getNonStrictParentOfType(elementContainer, XmlTag.class, XmlText.class);
final PsiLanguageInjectionHost declarationContainer = injector.getInjectionHost(declaration);
final XmlTagChild declarationTag = PsiTreeUtil.getNonStrictParentOfType(declarationContainer, XmlTag.class, XmlText.class);
if (declarationContainer != null && elementContainer != null && elementTag != null && declarationTag != null) {
return PsiTreeUtil.isAncestor(declarationTag, elementTag, true) ||
(PsiTreeUtil.isAncestor(declarationTag, elementTag, false) &&
declarationContainer.getTextOffset() < elementContainer.getTextOffset());
}
return true;
}