File tree Expand file tree Collapse file tree 2 files changed +72
-5
lines changed
main/kotlin/com/sourcegraph/semanticdb_kotlinc
test/kotlin/com/sourcegraph/semanticdb_kotlinc/test Expand file tree Collapse file tree 2 files changed +72
-5
lines changed Original file line number Diff line number Diff line change @@ -5,10 +5,7 @@ import kotlin.contracts.ExperimentalContracts
5
5
import org.jetbrains.kotlin.*
6
6
import org.jetbrains.kotlin.com.intellij.lang.LighterASTNode
7
7
import org.jetbrains.kotlin.com.intellij.util.diff.FlyweightCapableTreeStructure
8
- import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
9
- import org.jetbrains.kotlin.diagnostics.collectDescendantsOfType
10
- import org.jetbrains.kotlin.diagnostics.findChildByType
11
- import org.jetbrains.kotlin.diagnostics.findLastDescendant
8
+ import org.jetbrains.kotlin.diagnostics.*
12
9
import org.jetbrains.kotlin.fir.FirSession
13
10
import org.jetbrains.kotlin.fir.analysis.checkers.MppCheckerKind
14
11
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
@@ -141,7 +138,7 @@ open class AnalyzerCheckers(session: FirSession) : FirAdditionalCheckersExtensio
141
138
val source = import.source ? : return @forEach
142
139
val fqName = import.importedFqName ? : return @forEach
143
140
144
- val names = source.treeStructure.findLastDescendant (source.lighterASTNode) { true }
141
+ val names = source.treeStructure.findDescendantByType (source.lighterASTNode, KtNodeTypes . DOT_QUALIFIED_EXPRESSION )
145
142
if (names != null ) {
146
143
eachFqNameElement(fqName, source.treeStructure, names) { fqName, name ->
147
144
val symbolProvider = context.session.symbolProvider
Original file line number Diff line number Diff line change @@ -122,6 +122,76 @@ class AnalyzerTest {
122
122
assertSoftly(document.symbolsList) { withClue(this ) { symbols.forEach(::shouldContain) } }
123
123
}
124
124
125
+ @Test
126
+ fun imports (@TempDir path : Path ) {
127
+ val document =
128
+ compileSemanticdb(
129
+ path,
130
+ """
131
+ package sample
132
+
133
+ import kotlin.Boolean
134
+ import kotlin.Int as KInt
135
+ """ )
136
+
137
+ val occurrences =
138
+ arrayOf(
139
+ SymbolOccurrence {
140
+ role = Role .REFERENCE
141
+ symbol = " sample/"
142
+ range {
143
+ startLine = 0
144
+ startCharacter = 8
145
+ endLine = 0
146
+ endCharacter = 14
147
+ }
148
+ },
149
+ SymbolOccurrence {
150
+ role = Role .REFERENCE
151
+ symbol = " kotlin/"
152
+ range {
153
+ startLine = 2
154
+ startCharacter = 7
155
+ endLine = 2
156
+ endCharacter = 13
157
+ }
158
+ },
159
+ SymbolOccurrence {
160
+ role = Role .REFERENCE
161
+ symbol = " kotlin/Boolean#"
162
+ range {
163
+ startLine = 2
164
+ startCharacter = 14
165
+ endLine = 2
166
+ endCharacter = 21
167
+ }
168
+ },
169
+ SymbolOccurrence {
170
+ role = Role .REFERENCE
171
+ symbol = " kotlin/"
172
+ range {
173
+ startLine = 3
174
+ startCharacter = 7
175
+ endLine = 3
176
+ endCharacter = 13
177
+ }
178
+ },
179
+ SymbolOccurrence {
180
+ role = Role .REFERENCE
181
+ symbol = " kotlin/Int#"
182
+ range {
183
+ startLine = 3
184
+ startCharacter = 14
185
+ endLine = 3
186
+ endCharacter = 17
187
+ }
188
+ },
189
+ )
190
+ assertSoftly(document.occurrencesList) {
191
+ withClue(this ) { occurrences.forEach(::shouldContain) }
192
+ }
193
+ }
194
+
125
195
@Test
126
196
fun overrides (@TempDir path : Path ) {
127
197
val document =
You can’t perform that action at this time.
0 commit comments