File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/service Expand file tree Collapse file tree 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
4343import spp.jetbrains.artifact.service.define.IArtifactScopeService
4444import spp.jetbrains.artifact.service.isGroovy
4545import spp.jetbrains.artifact.service.isKotlin
46+ import spp.jetbrains.artifact.service.toArtifact
4647import spp.jetbrains.marker.SourceMarkerUtils
4748import spp.jetbrains.marker.SourceMarkerUtils.doOnReadThread
4849
@@ -108,7 +109,24 @@ class JVMArtifactScopeService : IArtifactScopeService {
108109
109110 override fun getCalls (element : PsiElement ): List <PsiElement > {
110111 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+
112130 else -> element.descendantsOfType<PsiCallExpression >().toList()
113131 }
114132 }
You can’t perform that action at this time.
0 commit comments