File tree 1 file changed +19
-1
lines changed
marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/service
1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ import spp.jetbrains.artifact.service.ArtifactTypeService
43
43
import spp.jetbrains.artifact.service.define.IArtifactScopeService
44
44
import spp.jetbrains.artifact.service.isGroovy
45
45
import spp.jetbrains.artifact.service.isKotlin
46
+ import spp.jetbrains.artifact.service.toArtifact
46
47
import spp.jetbrains.marker.SourceMarkerUtils
47
48
import spp.jetbrains.marker.SourceMarkerUtils.doOnReadThread
48
49
@@ -108,7 +109,24 @@ class JVMArtifactScopeService : IArtifactScopeService {
108
109
109
110
override fun getCalls (element : PsiElement ): List <PsiElement > {
110
111
return when {
111
- ArtifactTypeService .isKotlin(element) -> element.descendantsOfType<KtCallExpression >().toList()
112
+ ArtifactTypeService .isKotlin(element) -> {
113
+ // use top most call expression (e.g. `bar()` becomes `foo.bar()`)
114
+ val callExpressions = element.descendantsOfType<KtCallExpression >().toList()
115
+ callExpressions.map {
116
+ val selfArtifact = it.toArtifact()
117
+ var returnValue: PsiElement = it
118
+ while (selfArtifact != null && returnValue.parent != null ) {
119
+ val parentArtifact = returnValue.parent!! .toArtifact()
120
+ if (parentArtifact != null ) {
121
+ if (parentArtifact::class == selfArtifact::class ) {
122
+ returnValue = parentArtifact.psiElement
123
+ } else break
124
+ } else break
125
+ }
126
+ returnValue
127
+ }.toSet().toList()
128
+ }
129
+
112
130
else -> element.descendantsOfType<PsiCallExpression >().toList()
113
131
}
114
132
}
You can’t perform that action at this time.
0 commit comments