Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9140953

Browse files
tamasvajkigfoo
authored andcommitted
Unify parameter order in type access extraction functions
1 parent a8f595c commit 9140953

1 file changed

Lines changed: 33 additions & 33 deletions

File tree

java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@ open class KotlinFileExtractor(
10331033
@Suppress("UNCHECKED_CAST")
10341034
tw.writeIsAnonymClass(ids.type.javaResult.id as Label<DbClass>, idNewexpr)
10351035

1036-
extractTypeAccessRecursive(pluginContext.irBuiltIns.anyType, enclosingCallable, idNewexpr, -3, callsite, enclosingStmt)
1036+
extractTypeAccessRecursive(pluginContext.irBuiltIns.anyType, callsite, idNewexpr, -3, enclosingCallable, enclosingStmt)
10371037
} else {
10381038
// Returns true if type is C<T1, T2, ...> where C is declared `class C<T1, T2, ...> { ... }`
10391039
fun isUnspecialised(type: IrSimpleType) =
@@ -1058,7 +1058,7 @@ open class KotlinFileExtractor(
10581058
if (dispatchReceiver != null) {
10591059
extractExpressionExpr(dispatchReceiver, enclosingCallable, id, -1, enclosingStmt)
10601060
} else if(callTarget.isStaticMethodOfClass) {
1061-
extractTypeAccessRecursive(callTarget.parentAsClass.toRawType(), enclosingCallable, id, -1, callsite, enclosingStmt)
1061+
extractTypeAccessRecursive(callTarget.parentAsClass.toRawType(), callsite, id, -1, enclosingCallable, enclosingStmt)
10621062
}
10631063
}
10641064

@@ -1477,7 +1477,7 @@ open class KotlinFileExtractor(
14771477
tw.writeStmts_throwstmt(throwId, stmtParent.parent, stmtParent.idx, callable)
14781478
tw.writeHasLocation(throwId, locId)
14791479
val newExprId = extractNewExpr(it, null, thrownType, locId, throwId, 0, callable, throwId)
1480-
extractTypeAccess(thrownType, callable, newExprId, -3, c, throwId)
1480+
extractTypeAccess(thrownType, c, newExprId, -3, callable, throwId)
14811481
}
14821482
}
14831483
isBuiltinCallInternal(c, "illegalArgumentException") -> {
@@ -1582,7 +1582,7 @@ open class KotlinFileExtractor(
15821582
}
15831583
} else {
15841584
val elementType = c.type.getArrayElementType(pluginContext.irBuiltIns)
1585-
extractTypeAccessRecursive(elementType, callable, id, -1, c, enclosingStmt)
1585+
extractTypeAccessRecursive(elementType, c, id, -1, callable, enclosingStmt)
15861586
}
15871587

15881588
arg?.let {
@@ -1666,7 +1666,7 @@ open class KotlinFileExtractor(
16661666
tw.writeHasLocation(id, locId)
16671667
tw.writeCallableEnclosingExpr(id, callable)
16681668
tw.writeStatementEnclosingExpr(id, enclosingStmt)
1669-
extractTypeAccessRecursive(c.getTypeArgument(1)!!, callable, id, 0, c, enclosingStmt)
1669+
extractTypeAccessRecursive(c.getTypeArgument(1)!!, c, id, 0, callable, enclosingStmt)
16701670
extractExpressionExpr(c.getValueArgument(0)!!, callable, id, 1, enclosingStmt)
16711671
}
16721672
else -> {
@@ -1699,7 +1699,7 @@ open class KotlinFileExtractor(
16991699
) {
17001700
typeArgs.forEachIndexed { argIdx, arg ->
17011701
val mul = if (reverse) -1 else 1
1702-
extractTypeAccessRecursive(arg, enclosingCallable, parentExpr, argIdx * mul + startIndex, location, enclosingStmt, TypeContext.GENERIC_ARGUMENT)
1702+
extractTypeAccessRecursive(arg, location, parentExpr, argIdx * mul + startIndex, enclosingCallable, enclosingStmt, TypeContext.GENERIC_ARGUMENT)
17031703
}
17041704
}
17051705

@@ -1828,12 +1828,12 @@ open class KotlinFileExtractor(
18281828
}
18291829

18301830
val typeAccessId =
1831-
extractTypeAccess(typeAccessType, callable, id, -3, e, enclosingStmt)
1831+
extractTypeAccess(typeAccessType, e, id, -3, callable, enclosingStmt)
18321832

18331833
if (e is IrConstructorCall) {
18341834
// Only extract type arguments relating to the constructed type, not the constructor itself:
18351835
e.getClassTypeArguments().forEachIndexed({ argIdx, argType ->
1836-
extractTypeAccessRecursive(argType!!, callable, typeAccessId, argIdx, e, enclosingStmt, TypeContext.GENERIC_ARGUMENT)
1836+
extractTypeAccessRecursive(argType!!, e, typeAccessId, argIdx, callable, enclosingStmt, TypeContext.GENERIC_ARGUMENT)
18371837
})
18381838
} else {
18391839
extractTypeArguments(e, typeAccessId, callable, enclosingStmt)
@@ -2078,7 +2078,7 @@ open class KotlinFileExtractor(
20782078
tw.writeStmts_catchclause(catchId, id, catchIdx, callable)
20792079
val catchLocId = tw.getLocation(catchClause)
20802080
tw.writeHasLocation(catchId, catchLocId)
2081-
extractTypeAccessRecursive(catchClause.catchParameter.type, callable, catchId, -1, catchClause.catchParameter, catchId)
2081+
extractTypeAccessRecursive(catchClause.catchParameter.type, catchClause.catchParameter, catchId, -1, callable, catchId)
20822082
extractVariableExpr(catchClause.catchParameter, callable, catchId, 0, catchId)
20832083
extractExpressionStmt(catchClause.result, callable, catchId, 1)
20842084
}
@@ -2261,7 +2261,7 @@ open class KotlinFileExtractor(
22612261

22622262

22632263
fun extractTypeAccess(parent: IrClass){
2264-
extractTypeAccessRecursive(parent.typeWith(listOf()), callable, id, 0, locId, exprParent.enclosingStmt)
2264+
extractTypeAccessRecursive(parent.typeWith(listOf()), locId, id, 0, callable, exprParent.enclosingStmt)
22652265
}
22662266

22672267
when(val ownerParent = owner.parent) {
@@ -2557,7 +2557,7 @@ open class KotlinFileExtractor(
25572557
tw.writeCallableEnclosingExpr(id, callable)
25582558
tw.writeStatementEnclosingExpr(id, exprParent.enclosingStmt)
25592559

2560-
extractTypeAccessRecursive(e.classType, callable, id, 0, locId, exprParent.enclosingStmt)
2560+
extractTypeAccessRecursive(e.classType, locId, id, 0, callable, exprParent.enclosingStmt)
25612561
}
25622562
is IrPropertyReference -> {
25632563
extractPropertyReference(e, parent, callable)
@@ -2991,7 +2991,7 @@ open class KotlinFileExtractor(
29912991
tw.writeExprs_newexpr(callId, callType.javaResult.id, retId, 0)
29922992
tw.writeExprsKotlinType(callId, callType.kotlinResult.id)
29932993

2994-
val typeAccessId = extractTypeAccess(callType, funLabels.methodId, callId, -3, locId, retId)
2994+
val typeAccessId = extractTypeAccess(callType, locId, callId, -3, funLabels.methodId, retId)
29952995

29962996
extractTypeArguments(functionReferenceExpr, typeAccessId, funLabels.methodId, retId)
29972997
return callId
@@ -3196,7 +3196,7 @@ open class KotlinFileExtractor(
31963196
extractCommonExpr(castId)
31973197

31983198
// type access `Ti`
3199-
extractTypeAccessRecursive(pType, funLabels.methodId, castId, 0, locId, enclosingStmtId)
3199+
extractTypeAccessRecursive(pType, locId, castId, 0, funLabels.methodId, enclosingStmtId)
32003200

32013201
// element access: `a0[i]`
32023202
val arrayAccessId = tw.getFreshIdLabel<DbArrayaccess>()
@@ -3247,15 +3247,15 @@ open class KotlinFileExtractor(
32473247
return id
32483248
}
32493249

3250-
private fun extractTypeAccess(type: TypeResults, callable: Label<out DbCallable>, parent: Label<out DbExprparent>, idx: Int, location: Label<DbLocation>, enclosingStmt: Label<out DbStmt>): Label<out DbExpr> {
3250+
private fun extractTypeAccess(type: TypeResults, location: Label<DbLocation>, parent: Label<out DbExprparent>, idx: Int, enclosingCallable: Label<out DbCallable>, enclosingStmt: Label<out DbStmt>): Label<out DbExpr> {
32513251
val id = extractTypeAccess(type, location, parent, idx)
3252-
tw.writeCallableEnclosingExpr(id, callable)
3252+
tw.writeCallableEnclosingExpr(id, enclosingCallable)
32533253
tw.writeStatementEnclosingExpr(id, enclosingStmt)
32543254
return id
32553255
}
32563256

3257-
private fun extractTypeAccess(t: TypeResults, callable: Label<out DbCallable>, parent: Label<out DbExprparent>, idx: Int, elementForLocation: IrElement, enclosingStmt: Label<out DbStmt>): Label<out DbExpr> {
3258-
return extractTypeAccess(t, callable, parent, idx, tw.getLocation(elementForLocation), enclosingStmt)
3257+
private fun extractTypeAccess(t: TypeResults, elementForLocation: IrElement, parent: Label<out DbExprparent>, idx: Int, enclosingCallable: Label<out DbCallable>, enclosingStmt: Label<out DbStmt>): Label<out DbExpr> {
3258+
return extractTypeAccess(t, tw.getLocation(elementForLocation), parent, idx, enclosingCallable, enclosingStmt)
32593259
}
32603260

32613261
private fun extractTypeAccessRecursive(t: IrType, location: Label<DbLocation>, parent: Label<out DbExprparent>, idx: Int, typeContext: TypeContext = TypeContext.OTHER): Label<out DbExpr> {
@@ -3266,16 +3266,16 @@ open class KotlinFileExtractor(
32663266
return typeAccessId
32673267
}
32683268

3269-
private fun extractTypeAccessRecursive(t: IrType, callable: Label<out DbCallable>, parent: Label<out DbExprparent>, idx: Int, location: Label<DbLocation>, enclosingStmt: Label<out DbStmt>, typeContext: TypeContext = TypeContext.OTHER): Label<out DbExpr> {
3270-
val typeAccessId = extractTypeAccess(useType(t, typeContext), callable, parent, idx, location, enclosingStmt)
3269+
private fun extractTypeAccessRecursive(t: IrType, location: Label<DbLocation>, parent: Label<out DbExprparent>, idx: Int, enclosingCallable: Label<out DbCallable>, enclosingStmt: Label<out DbStmt>, typeContext: TypeContext = TypeContext.OTHER): Label<out DbExpr> {
3270+
val typeAccessId = extractTypeAccess(useType(t, typeContext), location, parent, idx, enclosingCallable, enclosingStmt)
32713271
if (t is IrSimpleType) {
3272-
extractTypeArguments(t.arguments, location, typeAccessId, callable, enclosingStmt)
3272+
extractTypeArguments(t.arguments, location, typeAccessId, enclosingCallable, enclosingStmt)
32733273
}
32743274
return typeAccessId
32753275
}
32763276

3277-
private fun extractTypeAccessRecursive(t: IrType, callable: Label<out DbCallable>, parent: Label<out DbExprparent>, idx: Int, elementForLocation: IrElement, enclosingStmt: Label<out DbStmt>, typeContext: TypeContext = TypeContext.OTHER): Label<out DbExpr> {
3278-
return extractTypeAccessRecursive(t, callable, parent, idx, tw.getLocation(elementForLocation), enclosingStmt, typeContext)
3277+
private fun extractTypeAccessRecursive(t: IrType, elementForLocation: IrElement, parent: Label<out DbExprparent>, idx: Int, enclosingCallable: Label<out DbCallable>, enclosingStmt: Label<out DbStmt>, typeContext: TypeContext = TypeContext.OTHER): Label<out DbExpr> {
3278+
return extractTypeAccessRecursive(t, tw.getLocation(elementForLocation), parent, idx, enclosingCallable, enclosingStmt, typeContext)
32793279
}
32803280

32813281
private fun extractTypeAccessRecursive(
@@ -3288,7 +3288,7 @@ open class KotlinFileExtractor(
32883288
enclosingStmt: Label<out DbStmt>,
32893289
typeContext: TypeContext = TypeContext.OTHER
32903290
) : Label<out DbExpr> {
3291-
val typeAccessId = extractTypeAccess(useType(t, typeContext), enclosingCallable, parent, idx, elementForLocation, enclosingStmt)
3291+
val typeAccessId = extractTypeAccess(useType(t, typeContext), elementForLocation, parent, idx, enclosingCallable, enclosingStmt)
32923292
extractTypeArguments(typeAccessArguments, elementForLocation, typeAccessId, enclosingCallable, enclosingStmt)
32933293
return typeAccessId
32943294
}
@@ -3305,7 +3305,7 @@ open class KotlinFileExtractor(
33053305
tw.writeHasLocation(id, locId)
33063306
tw.writeCallableEnclosingExpr(id, callable)
33073307
tw.writeStatementEnclosingExpr(id, enclosingStmt)
3308-
extractTypeAccessRecursive(e.typeOperand, callable, id, 0, e, enclosingStmt)
3308+
extractTypeAccessRecursive(e.typeOperand, e, id, 0, callable, enclosingStmt)
33093309
extractExpressionExpr(e.argument, callable, id, 1, enclosingStmt)
33103310
}
33113311
IrTypeOperator.IMPLICIT_CAST -> {
@@ -3317,7 +3317,7 @@ open class KotlinFileExtractor(
33173317
tw.writeHasLocation(id, locId)
33183318
tw.writeCallableEnclosingExpr(id, callable)
33193319
tw.writeStatementEnclosingExpr(id, enclosingStmt)
3320-
extractTypeAccessRecursive(e.typeOperand, callable, id, 0, e, enclosingStmt)
3320+
extractTypeAccessRecursive(e.typeOperand, e, id, 0, callable, enclosingStmt)
33213321
extractExpressionExpr(e.argument, callable, id, 1, enclosingStmt)
33223322
}
33233323
IrTypeOperator.IMPLICIT_NOTNULL -> {
@@ -3329,7 +3329,7 @@ open class KotlinFileExtractor(
33293329
tw.writeHasLocation(id, locId)
33303330
tw.writeCallableEnclosingExpr(id, callable)
33313331
tw.writeStatementEnclosingExpr(id, enclosingStmt)
3332-
extractTypeAccessRecursive(e.typeOperand, callable, id, 0, e, enclosingStmt)
3332+
extractTypeAccessRecursive(e.typeOperand, e, id, 0, callable, enclosingStmt)
33333333
extractExpressionExpr(e.argument, callable, id, 1, enclosingStmt)
33343334
}
33353335
IrTypeOperator.IMPLICIT_COERCION_TO_UNIT -> {
@@ -3341,7 +3341,7 @@ open class KotlinFileExtractor(
33413341
tw.writeHasLocation(id, locId)
33423342
tw.writeCallableEnclosingExpr(id, callable)
33433343
tw.writeStatementEnclosingExpr(id, enclosingStmt)
3344-
extractTypeAccessRecursive(e.typeOperand, callable, id, 0, e, enclosingStmt)
3344+
extractTypeAccessRecursive(e.typeOperand, e, id, 0, callable, enclosingStmt)
33453345
extractExpressionExpr(e.argument, callable, id, 1, enclosingStmt)
33463346
}
33473347
IrTypeOperator.SAFE_CAST -> {
@@ -3353,7 +3353,7 @@ open class KotlinFileExtractor(
33533353
tw.writeHasLocation(id, locId)
33543354
tw.writeCallableEnclosingExpr(id, callable)
33553355
tw.writeStatementEnclosingExpr(id, enclosingStmt)
3356-
extractTypeAccessRecursive(e.typeOperand, callable, id, 0, e, enclosingStmt)
3356+
extractTypeAccessRecursive(e.typeOperand, e, id, 0, callable, enclosingStmt)
33573357
extractExpressionExpr(e.argument, callable, id, 1, enclosingStmt)
33583358
}
33593359
IrTypeOperator.INSTANCEOF -> {
@@ -3366,7 +3366,7 @@ open class KotlinFileExtractor(
33663366
tw.writeCallableEnclosingExpr(id, callable)
33673367
tw.writeStatementEnclosingExpr(id, enclosingStmt)
33683368
extractExpressionExpr(e.argument, callable, id, 0, enclosingStmt)
3369-
extractTypeAccessRecursive(e.typeOperand, callable, id, 1, e, enclosingStmt)
3369+
extractTypeAccessRecursive(e.typeOperand, e, id, 1, callable, enclosingStmt)
33703370
}
33713371
IrTypeOperator.NOT_INSTANCEOF -> {
33723372
val id = tw.getFreshIdLabel<DbNotinstanceofexpr>()
@@ -3378,7 +3378,7 @@ open class KotlinFileExtractor(
33783378
tw.writeCallableEnclosingExpr(id, callable)
33793379
tw.writeStatementEnclosingExpr(id, enclosingStmt)
33803380
extractExpressionExpr(e.argument, callable, id, 0, enclosingStmt)
3381-
extractTypeAccessRecursive(e.typeOperand, callable, id, 1, e, enclosingStmt)
3381+
extractTypeAccessRecursive(e.typeOperand, e, id, 1, callable, enclosingStmt)
33823382
}
33833383
IrTypeOperator.SAM_CONVERSION -> {
33843384

@@ -3530,7 +3530,7 @@ open class KotlinFileExtractor(
35303530
tw.writeExprsKotlinType(arrayCreationId, at.kotlinResult.id)
35313531
extractCommonExpr(arrayCreationId)
35323532

3533-
extractTypeAccessRecursive(pluginContext.irBuiltIns.anyNType, ids.function, arrayCreationId, -1, e, returnId)
3533+
extractTypeAccessRecursive(pluginContext.irBuiltIns.anyNType, e, arrayCreationId, -1, ids.function, returnId)
35343534

35353535
val initId = tw.getFreshIdLabel<DbArrayinit>()
35363536
tw.writeExprs_arrayinit(initId, at.javaResult.id, arrayCreationId, -2)
@@ -3563,14 +3563,14 @@ open class KotlinFileExtractor(
35633563
tw.writeHasLocation(id, locId)
35643564
tw.writeCallableEnclosingExpr(id, callable)
35653565
tw.writeStatementEnclosingExpr(id, enclosingStmt)
3566-
extractTypeAccessRecursive(e.typeOperand, callable, id, 0, e, enclosingStmt)
3566+
extractTypeAccessRecursive(e.typeOperand, e, id, 0, callable, enclosingStmt)
35673567

35683568
val idNewexpr = extractNewExpr(ids.constructor, ids.type, locId, id, 1, callable, enclosingStmt)
35693569

35703570
@Suppress("UNCHECKED_CAST")
35713571
tw.writeIsAnonymClass(ids.type.javaResult.id as Label<DbClass>, idNewexpr)
35723572

3573-
extractTypeAccessRecursive(e.typeOperand, callable, idNewexpr, -3, e, enclosingStmt)
3573+
extractTypeAccessRecursive(e.typeOperand, e, idNewexpr, -3, callable, enclosingStmt)
35743574

35753575
extractExpressionExpr(e.argument, callable, idNewexpr, 0, enclosingStmt)
35763576
}

0 commit comments

Comments
 (0)