Skip to content

Commit 0aea667

Browse files
committed
fix toc on other file
1 parent 4c8706b commit 0aea667

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/main/kotlin/com/emberjs/utils/EmberUtils.kt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import com.intellij.psi.impl.file.PsiDirectoryImpl
5656
import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference
5757
import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet
5858
import com.intellij.psi.impl.source.tree.LeafPsiElement
59-
import com.intellij.psi.search.ProjectScope
59+
import com.intellij.psi.templateLanguages.OuterLanguageElement
6060
import com.intellij.psi.util.PsiTreeUtil
6161
import com.intellij.psi.util.elementType
6262
import com.intellij.psi.util.parents
@@ -148,6 +148,17 @@ class EmberUtils {
148148
}
149149

150150
val r = ref as PsiElement? ?: exp
151+
152+
if (r is JSVariable) {
153+
val v = r.children[1]
154+
val viewProvider = file.containingFile.viewProvider
155+
val ts = viewProvider.findElementAt(v.textOffset, JavaScriptSupportLoader.TYPESCRIPT)
156+
val js = viewProvider.findElementAt(v.textOffset, JavaScriptSupportLoader.ECMA_SCRIPT_6)
157+
if (ts is OuterLanguageElement || js is OuterLanguageElement) {
158+
return r
159+
}
160+
}
161+
151162
val func = r?.children?.find { it is JSCallExpression }
152163
if (func is JSCallExpression) {
153164
return func
@@ -335,6 +346,11 @@ class EmberUtils {
335346
}
336347

337348
if (element is ES6ImportedBinding) {
349+
var resolvedElement = (element).multiResolve(true)[0]?.element
350+
resolvedElement = followReferences(resolvedElement)
351+
if (resolvedElement != null) {
352+
return resolvedElement
353+
}
338354
var ref:PsiReference? = element.declaration?.fromClause?.references?.findLast { it is EmberJSModuleReference && it.rangeInElement.endOffset == it.element.textLength - 1 && it.resolve() != null } as EmberJSModuleReference?
339355
if (ref == null) {
340356
ref = element.declaration?.fromClause?.references?.findLast { it is JSFileModuleReference }

0 commit comments

Comments
 (0)