@@ -2,17 +2,15 @@ package com.mclaughlinconnor.ij_inspector.application
2
2
3
3
import com.intellij.openapi.application.Application
4
4
import com.intellij.openapi.application.ApplicationManager
5
- import com.intellij.openapi.editor.Document
6
5
import com.intellij.openapi.project.Project
7
- import com.intellij.psi.PsiDocumentManager
8
- import com.intellij.psi.PsiElement
9
- import com.intellij.psi.PsiNameIdentifierOwner
10
- import com.intellij.psi.PsiReference
6
+ import com.intellij.openapi.vfs.findDocument
7
+ import com.intellij.psi.*
11
8
import com.intellij.refactoring.suggested.endOffset
12
9
import com.intellij.refactoring.suggested.startOffset
13
10
import com.mclaughlinconnor.ij_inspector.application.Utils.Companion.createDocument
14
11
import com.mclaughlinconnor.ij_inspector.application.lsp.*
15
12
13
+
16
14
class DefinitionService (private val myProject : Project ) {
17
15
private val connection: Connection = Connection .getInstance()
18
16
private val messageFactory: MessageFactory = MessageFactory ()
@@ -37,16 +35,33 @@ class DefinitionService(private val myProject: Project) {
37
35
return @invokeLater
38
36
}
39
37
40
- val resolved = element.resolve() ? : return @invokeLater
41
- val location = resolvedToLocation(resolved, document)
42
-
43
- val response = Response (requestId, location)
38
+ val locations: MutableList <Location > = mutableListOf ()
39
+
40
+ val references = element.references
41
+ for (ref in references) {
42
+ if (ref is PsiPolyVariantReference ) {
43
+ val resolved = ref.multiResolve(true )
44
+ for (r in resolved) {
45
+ if (r.element != null ) {
46
+ locations.add(resolvedToLocation(r.element!! ))
47
+ }
48
+ }
49
+ continue
50
+ }
51
+
52
+ val resolved = ref.resolve()
53
+ if (resolved != null ) {
54
+ locations.add(resolvedToLocation(resolved))
55
+ }
56
+ }
44
57
58
+ val response = Response (requestId, locations)
45
59
connection.write(messageFactory.newMessage(response))
46
60
}
47
61
}
48
62
49
- private fun resolvedToLocation (resolved : PsiElement , document : Document ): Location {
63
+ private fun resolvedToLocation (resolved : PsiElement ): Location {
64
+ val document = resolved.containingFile.virtualFile.findDocument()!!
50
65
val target = getNameIdentifier(resolved)
51
66
52
67
val startOffset = target.startOffset
0 commit comments