@@ -11,6 +11,7 @@ import com.emberjs.hbs.HbsLocalReference
1111import com.emberjs.hbs.HbsModuleReference
1212import com.emberjs.hbs.ImportNameReferences
1313import com.emberjs.index.EmberNameIndex
14+ import com.emberjs.navigation.EmberGotoRelatedProvider
1415import com.emberjs.psi.EmberNamedElement
1516import com.emberjs.resolver.EmberJSModuleReference
1617import com.intellij.injected.editor.VirtualFileWindow
@@ -28,6 +29,8 @@ import com.intellij.lang.javascript.psi.ecmal4.JSClass
2829import com.intellij.lang.javascript.psi.jsdoc.JSDocComment
2930import com.intellij.lang.javascript.psi.types.JSArrayType
3031import com.intellij.lang.typescript.modules.TypeScriptFileModuleReference
32+ import com.intellij.navigation.GotoRelatedItem
33+ import com.intellij.navigation.GotoRelatedProvider
3134import com.intellij.openapi.application.ApplicationManager
3235import com.intellij.openapi.application.WriteAction
3336import com.intellij.openapi.vfs.VirtualFile
@@ -217,7 +220,12 @@ class EmberUtils {
217220 ? : dir?.findFile(" $fileName .js" )
218221 ? : dir?.findFile(" controller.ts" )
219222 ? : dir?.findFile(" controller.js" )
220- return cls ? : file?.let { findDefaultExportClass(it) }
223+ val relatedItems = EmberGotoRelatedProvider ().getItems(element.originalVirtualFile!! , element.project)
224+ val related = (relatedItems.find { it.first.type == " component" } ? :
225+ relatedItems.find { it.first.type == " controller" } ? :
226+ relatedItems.find { it.first.type == " router" })?.second
227+ val relatedFile = related?.let { PsiManager .getInstance(element.project).findFile(it) }
228+ return cls ? : file?.let { findDefaultExportClass(it) } ? : relatedFile?.let { findDefaultExportClass(it) }
221229 }
222230
223231 fun findComponentArgsType (element : JSElement ): JSRecordType ? {
0 commit comments