@@ -6,8 +6,9 @@ import org.jetbrains.kotlin.analysis.api.resolution.symbol
6
6
import org.jetbrains.kotlin.analysis.api.symbols.KaFunctionSymbol
7
7
import org.jetbrains.kotlin.analysis.api.types.KaType
8
8
import org.jetbrains.kotlin.psi.KtCallExpression
9
- import org.jetbrains.kotlin.psi.KtDotQualifiedExpression
10
9
import org.jetbrains.kotlin.psi.KtExpression
10
+ import org.jetbrains.kotlin.psi.KtQualifiedExpression
11
+ import org.jetbrains.kotlin.psi.KtSafeQualifiedExpression
11
12
import org.jetbrains.kotlin.utils.mapToIndex
12
13
13
14
context(KaSession )
@@ -43,14 +44,15 @@ fun KotlinFileExtractor.extractMethodCall(
43
44
.sortedBy { p -> p.first }
44
45
.map { p -> p.second }
45
46
46
- // TODO: fix getting the qualifier, we should handle safe qualified expressions too
47
- val qualifier: KtExpression ? = (call.parent as ? KtDotQualifiedExpression )?.receiverExpression
47
+ val callQualifiedParent = call.parent as ? KtQualifiedExpression
48
+ val qualifier =
49
+ if (callQualifiedParent?.selectorExpression == call) callQualifiedParent.receiverExpression else null
48
50
val extensionReceiver = if (target.isExtension) qualifier else null
49
51
val dispatchReceiver = if (! target.isExtension) qualifier else null
50
52
51
53
val exprParent = stmtExprParent.expr(call, enclosingCallable)
52
54
53
- extractRawMethodAccess(
55
+ val callId = extractRawMethodAccess(
54
56
target,
55
57
tw.getLocation(call),
56
58
call.expressionType!! ,
@@ -62,6 +64,10 @@ fun KotlinFileExtractor.extractMethodCall(
62
64
extensionReceiver,
63
65
args
64
66
)
67
+
68
+ if (call.parent is KtSafeQualifiedExpression ) {
69
+ tw.writeKtSafeAccess(callId)
70
+ }
65
71
}
66
72
67
73
context(KaSession )
@@ -138,7 +144,7 @@ private fun KotlinFileExtractor.extractRawMethodAccess(
138
144
extractClassTypeArguments: Boolean = false,
139
145
superQualifierSymbol: IrClassSymbol? = null
140
146
*/
141
- ) {
147
+ ): Label < DbMethodaccess > {
142
148
/* OLD KE1:
143
149
val callTarget = getCalleeRealOverrideTarget(syntacticCallTarget)
144
150
val methodId = getCalleeMethodId(callTarget, drType, extractClassTypeArguments)
@@ -229,6 +235,8 @@ private fun KotlinFileExtractor.extractRawMethodAccess(
229
235
}
230
236
val idxOffset = if (extensionReceiver != null ) 1 else 0
231
237
extractCallValueArguments(id, valueArguments, enclosingStmt, enclosingCallable, idxOffset)
238
+
239
+ return id
232
240
}
233
241
234
242
context(KaSession )
0 commit comments