@@ -260,29 +260,24 @@ open class EmberNamedElement(val target: PsiElement, val range: IntRange? = null
260260 files.forEach { file ->
261261 val hbsView = file.viewProvider.getPsi(Language .findLanguageByID(" Handlebars" )!! )
262262 val htmlView = file.viewProvider.getPsi(Language .findLanguageByID(" HTML" )!! )
263- if (target.language == Language .findLanguageByID(" Handlebars" )) {
263+ val htmlTarget = htmlView.findElementAt(target.startOffset+ 1 )
264+ val hbsTarget = hbsView.findElementAt(target.startOffset+ 1 )
265+ if (hbsTarget?.parents?.find { it is HbBlockWrapper } != null ) {
264266 val hbs = target.parents.find { it is HbBlockWrapper }
265267 if (hbs != null ) {
266- val htmlElements = PsiTreeUtil .collectElements(htmlView) { hbs.textRange.contains(it.textRange) && it.references.any { it.isReferenceTo(target) } }
268+ val htmlElements = PsiTreeUtil .collectElements(htmlView) { hbs.textRange.contains(it.textRange) }
267269 elements.add(hbs)
268270 elements.addAll(htmlElements)
269271 }
270- return @forEach
271272 }
272- if (target.language == Language .findLanguageByID( " HTML " ) && target. parents.find { it is XmlTag } != null ) {
273+ if (htmlTarget?. parents? .find { it is XmlTag } != null ) {
273274 val html = target.parents.find { it is XmlTag }
274275 if (html != null ) {
275- val hbsElements = PsiTreeUtil .collectElements(hbsView) { html.textRange.contains(it.textRange) && ! it.references.any { it.isReferenceTo(target) } }
276+ val hbsElements = PsiTreeUtil .collectElements(hbsView) { html.textRange.contains(it.textRange) }
276277 elements.add(html)
277278 elements.addAll(hbsElements)
278279 }
279- return @forEach
280280 }
281- val htmlElements = PsiTreeUtil .collectElements(htmlView) { it.references.any { it.isReferenceTo(target) } }
282- elements.addAll(htmlElements)
283-
284- val hbsElements = PsiTreeUtil .collectElements(hbsView) { it.references.any { it.isReferenceTo(target) } }
285- elements.addAll(hbsElements)
286281 }
287282
288283 if (elements.size == 0 ) {
0 commit comments