@@ -306,7 +306,9 @@ class HbsLocalReference(private val leaf: PsiElement, val target: PsiElement?) :
306306
307307 fun createReference (element : PsiElement ): PsiReference ? {
308308 val name = element.text.replace(" IntellijIdeaRulezzz" , " " )
309- if (element.parent is HbData ) {
309+
310+ val sibling = PsiTreeUtil .findSiblingBackward(element, HbTokenTypes .ID , null )
311+ if (name == " this" && sibling == null ) {
310312 val fname = element.containingFile.name.split(" ." ).first()
311313 var fileName = fname
312314 if (fileName == " template" ) {
@@ -319,17 +321,21 @@ class HbsLocalReference(private val leaf: PsiElement, val target: PsiElement?) :
319321 ? : dir?.findFile(" controller.ts" )
320322 ? : dir?.findFile(" controller.js" )
321323 if (file != null ) {
322- val cls = EmberUtils .findDefaultExportClass(file)
323- val args = EmberUtils .findComponentArgsType(cls as JSElement )
324- val prop = args?.properties?.find { it.memberName == name }
325- if (prop != null ) {
326- return HbsLocalReference (element, prop.memberSource.singleElement)
327- }
328- return null
324+ return HbsLocalReference (element, resolveToJs(file, listOf ()))
329325 }
330326 }
331- val sibling = PsiTreeUtil .findSiblingBackward(element, HbTokenTypes .ID , null )
332- if (name == " this" && sibling == null ) {
327+
328+ // for this.x.y
329+ if (sibling != null && sibling.references.find { it is HbsLocalReference } != null ) {
330+ val ref = sibling.references.find { it is HbsLocalReference } as HbsLocalReference
331+ val yieldRef = ref.resolveYield()
332+ if (yieldRef != null ) {
333+ return HbsLocalReference (element, resolveToJs(yieldRef, listOf (element.text)))
334+ }
335+ return HbsLocalReference (element, resolveToJs(ref.resolve(), listOf (element.text)))
336+ }
337+
338+ if (element.parent is HbData ) {
333339 val fname = element.containingFile.name.split(" ." ).first()
334340 var fileName = fname
335341 if (fileName == " template" ) {
@@ -342,7 +348,13 @@ class HbsLocalReference(private val leaf: PsiElement, val target: PsiElement?) :
342348 ? : dir?.findFile(" controller.ts" )
343349 ? : dir?.findFile(" controller.js" )
344350 if (file != null ) {
345- return HbsLocalReference (element, resolveToJs(file, listOf ()))
351+ val cls = EmberUtils .findDefaultExportClass(file)
352+ val args = EmberUtils .findComponentArgsType(cls as JSElement )
353+ val prop = args?.properties?.find { it.memberName == name }
354+ if (prop != null ) {
355+ return HbsLocalReference (element, prop.memberSource.singleElement)
356+ }
357+ return null
346358 }
347359 }
348360
@@ -351,16 +363,6 @@ class HbsLocalReference(private val leaf: PsiElement, val target: PsiElement?) :
351363 return HbsLocalRenameReference (element, importRef)
352364 }
353365
354- // for this.x.y
355- if (sibling != null && sibling.references.find { it is HbsLocalReference } != null ) {
356- val ref = sibling.references.find { it is HbsLocalReference } as HbsLocalReference
357- val yieldRef = ref.resolveYield()
358- if (yieldRef != null ) {
359- return HbsLocalReference (element, resolveToJs(yieldRef, listOf (element.text)))
360- }
361- return HbsLocalReference (element, resolveToJs(ref.resolve(), listOf (element.text)))
362- }
363-
364366 if (element.parent is HbOpenBlockMustache ) {
365367 return HbsLocalRenameReference (element, element)
366368 }
0 commit comments