Skip to content

Commit 780f5ab

Browse files
authored
Merge pull request #9724 from igfoo/igfoo/private
Kotlin: Make more methods private
2 parents b6790ef + 4e4b342 commit 780f5ab

File tree

3 files changed

+58
-58
lines changed

3 files changed

+58
-58
lines changed

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

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ open class KotlinFileExtractor(
181181
}
182182
}
183183

184-
fun extractTypeParameter(tp: IrTypeParameter, apparentIndex: Int, javaTypeParameter: JavaTypeParameter?): Label<out DbTypevariable>? {
184+
private fun extractTypeParameter(tp: IrTypeParameter, apparentIndex: Int, javaTypeParameter: JavaTypeParameter?): Label<out DbTypevariable>? {
185185
with("type parameter", tp) {
186186
val parentId = getTypeParameterParentLabel(tp) ?: return null
187187
val id = tw.getLabelFor<DbTypevariable>(getTypeParameterLabel(tp))
@@ -216,7 +216,7 @@ open class KotlinFileExtractor(
216216
}
217217
}
218218

219-
fun extractVisibility(elementForLocation: IrElement, id: Label<out DbModifiable>, v: DescriptorVisibility) {
219+
private fun extractVisibility(elementForLocation: IrElement, id: Label<out DbModifiable>, v: DescriptorVisibility) {
220220
with("visibility", elementForLocation) {
221221
when (v) {
222222
DescriptorVisibilities.PRIVATE -> addModifiers(id, "private")
@@ -250,7 +250,7 @@ open class KotlinFileExtractor(
250250
}
251251
}
252252

253-
fun extractClassModifiers(c: IrClass, id: Label<out DbClassorinterface>) {
253+
private fun extractClassModifiers(c: IrClass, id: Label<out DbClassorinterface>) {
254254
with("class modifiers", c) {
255255
when (c.modality) {
256256
Modality.FINAL -> addModifiers(id, "final")
@@ -371,7 +371,7 @@ open class KotlinFileExtractor(
371371
tw.writeHasLocation(stmtId, locId)
372372
}
373373

374-
fun extractObinitFunction(c: IrClass, parentId: Label<out DbClassorinterface>) {
374+
private fun extractObinitFunction(c: IrClass, parentId: Label<out DbClassorinterface>) {
375375
// add method:
376376
val obinitLabel = getObinitLabel(c)
377377
val obinitId = tw.getLabelFor<DbMethod>(obinitLabel)
@@ -506,7 +506,7 @@ open class KotlinFileExtractor(
506506

507507
data class FieldResult(val id: Label<DbField>, val name: String)
508508

509-
fun useCompanionObjectClassInstance(c: IrClass): FieldResult? {
509+
private fun useCompanionObjectClassInstance(c: IrClass): FieldResult? {
510510
val parent = c.parent
511511
if(!c.isCompanion) {
512512
logger.error("Using companion instance for non-companion class")
@@ -524,7 +524,7 @@ open class KotlinFileExtractor(
524524
}
525525
}
526526

527-
fun useObjectClassInstance(c: IrClass): FieldResult {
527+
private fun useObjectClassInstance(c: IrClass): FieldResult {
528528
if(!c.isNonCompanionObject) {
529529
logger.error("Using instance for non-object class")
530530
}
@@ -719,13 +719,13 @@ open class KotlinFileExtractor(
719719
}
720720
}
721721

722-
fun extractFunction(f: IrFunction, parentId: Label<out DbReftype>, extractBody: Boolean, extractMethodAndParameterTypeAccesses: Boolean, typeSubstitution: TypeSubstitution?, classTypeArgsIncludingOuterClasses: List<IrTypeArgument>?) =
722+
private fun extractFunction(f: IrFunction, parentId: Label<out DbReftype>, extractBody: Boolean, extractMethodAndParameterTypeAccesses: Boolean, typeSubstitution: TypeSubstitution?, classTypeArgsIncludingOuterClasses: List<IrTypeArgument>?) =
723723
if (isFake(f))
724724
null
725725
else
726726
forceExtractFunction(f, parentId, extractBody, extractMethodAndParameterTypeAccesses, typeSubstitution, classTypeArgsIncludingOuterClasses, null, null)
727727

728-
fun forceExtractFunction(f: IrFunction, parentId: Label<out DbReftype>, extractBody: Boolean, extractMethodAndParameterTypeAccesses: Boolean, typeSubstitution: TypeSubstitution?, classTypeArgsIncludingOuterClasses: List<IrTypeArgument>?, idOverride: Label<DbMethod>?, locOverride: Label<DbLocation>?): Label<out DbCallable> {
728+
private fun forceExtractFunction(f: IrFunction, parentId: Label<out DbReftype>, extractBody: Boolean, extractMethodAndParameterTypeAccesses: Boolean, typeSubstitution: TypeSubstitution?, classTypeArgsIncludingOuterClasses: List<IrTypeArgument>?, idOverride: Label<DbMethod>?, locOverride: Label<DbLocation>?): Label<out DbCallable> {
729729
with("function", f) {
730730
DeclarationStackAdjuster(f).use {
731731

@@ -831,7 +831,7 @@ open class KotlinFileExtractor(
831831
&& f.symbol !is IrConstructorSymbol // not a constructor
832832
}
833833

834-
fun extractField(f: IrField, parentId: Label<out DbReftype>): Label<out DbField> {
834+
private fun extractField(f: IrField, parentId: Label<out DbReftype>): Label<out DbField> {
835835
with("field", f) {
836836
DeclarationStackAdjuster(f).use {
837837
declarationStack.push(f)
@@ -865,7 +865,7 @@ open class KotlinFileExtractor(
865865
return id
866866
}
867867

868-
fun extractProperty(p: IrProperty, parentId: Label<out DbReftype>, extractBackingField: Boolean, extractFunctionBodies: Boolean, typeSubstitution: TypeSubstitution?, classTypeArgsIncludingOuterClasses: List<IrTypeArgument>?) {
868+
private fun extractProperty(p: IrProperty, parentId: Label<out DbReftype>, extractBackingField: Boolean, extractFunctionBodies: Boolean, typeSubstitution: TypeSubstitution?, classTypeArgsIncludingOuterClasses: List<IrTypeArgument>?) {
869869
with("property", p) {
870870
if (isFake(p)) return
871871

@@ -940,7 +940,7 @@ open class KotlinFileExtractor(
940940
}
941941
}
942942

943-
fun extractEnumEntry(ee: IrEnumEntry, parentId: Label<out DbReftype>, extractTypeAccess: Boolean) {
943+
private fun extractEnumEntry(ee: IrEnumEntry, parentId: Label<out DbReftype>, extractTypeAccess: Boolean) {
944944
with("enum entry", ee) {
945945
DeclarationStackAdjuster(ee).use {
946946
val id = useEnumEntry(ee)
@@ -962,7 +962,7 @@ open class KotlinFileExtractor(
962962
}
963963
}
964964

965-
fun extractTypeAlias(ta: IrTypeAlias) {
965+
private fun extractTypeAlias(ta: IrTypeAlias) {
966966
with("type alias", ta) {
967967
if (ta.typeParameters.isNotEmpty()) {
968968
// TODO: Extract this information
@@ -977,7 +977,7 @@ open class KotlinFileExtractor(
977977
}
978978
}
979979

980-
fun extractBody(b: IrBody, callable: Label<out DbCallable>) {
980+
private fun extractBody(b: IrBody, callable: Label<out DbCallable>) {
981981
with("body", b) {
982982
when (b) {
983983
is IrBlockBody -> extractBlockBody(b, callable)
@@ -990,7 +990,7 @@ open class KotlinFileExtractor(
990990
}
991991
}
992992

993-
fun extractBlockBody(b: IrBlockBody, callable: Label<out DbCallable>) {
993+
private fun extractBlockBody(b: IrBlockBody, callable: Label<out DbCallable>) {
994994
with("block body", b) {
995995
val id = tw.getFreshIdLabel<DbBlock>()
996996
val locId = tw.getLocation(b)
@@ -1002,7 +1002,7 @@ open class KotlinFileExtractor(
10021002
}
10031003
}
10041004

1005-
fun extractSyntheticBody(b: IrSyntheticBody, callable: Label<out DbCallable>) {
1005+
private fun extractSyntheticBody(b: IrSyntheticBody, callable: Label<out DbCallable>) {
10061006
with("synthetic body", b) {
10071007
when (b.kind) {
10081008
IrSyntheticBodyKind.ENUM_VALUES -> tw.writeKtSyntheticBody(callable, 1)
@@ -1011,7 +1011,7 @@ open class KotlinFileExtractor(
10111011
}
10121012
}
10131013

1014-
fun extractExpressionBody(b: IrExpressionBody, callable: Label<out DbCallable>) {
1014+
private fun extractExpressionBody(b: IrExpressionBody, callable: Label<out DbCallable>) {
10151015
with("expression body", b) {
10161016
val blockId = tw.getFreshIdLabel<DbBlock>()
10171017
val locId = tw.getLocation(b)
@@ -1035,7 +1035,7 @@ open class KotlinFileExtractor(
10351035
return v
10361036
}
10371037

1038-
fun extractVariable(v: IrVariable, callable: Label<out DbCallable>, parent: Label<out DbStmtparent>, idx: Int) {
1038+
private fun extractVariable(v: IrVariable, callable: Label<out DbCallable>, parent: Label<out DbStmtparent>, idx: Int) {
10391039
with("variable", v) {
10401040
val stmtId = tw.getFreshIdLabel<DbLocalvariabledeclstmt>()
10411041
val locId = tw.getLocation(getVariableLocationProvider(v))
@@ -1045,7 +1045,7 @@ open class KotlinFileExtractor(
10451045
}
10461046
}
10471047

1048-
fun extractVariableExpr(v: IrVariable, callable: Label<out DbCallable>, parent: Label<out DbExprparent>, idx: Int, enclosingStmt: Label<out DbStmt>) {
1048+
private fun extractVariableExpr(v: IrVariable, callable: Label<out DbCallable>, parent: Label<out DbExprparent>, idx: Int, enclosingStmt: Label<out DbStmt>) {
10491049
with("variable expr", v) {
10501050
val varId = useVariable(v)
10511051
val exprId = tw.getFreshIdLabel<DbLocalvariabledeclexpr>()
@@ -1069,7 +1069,7 @@ open class KotlinFileExtractor(
10691069
}
10701070
}
10711071

1072-
fun extractStatement(s: IrStatement, callable: Label<out DbCallable>, parent: Label<out DbStmtparent>, idx: Int) {
1072+
private fun extractStatement(s: IrStatement, callable: Label<out DbCallable>, parent: Label<out DbStmtparent>, idx: Int) {
10731073
with("statement", s) {
10741074
when(s) {
10751075
is IrExpression -> {
@@ -1408,15 +1408,15 @@ open class KotlinFileExtractor(
14081408
}
14091409
}
14101410

1411-
fun findFunction(cls: IrClass, name: String): IrFunction? = cls.declarations.find { it is IrFunction && it.name.asString() == name } as IrFunction?
1411+
private fun findFunction(cls: IrClass, name: String): IrFunction? = cls.declarations.find { it is IrFunction && it.name.asString() == name } as IrFunction?
14121412

14131413
val jvmIntrinsicsClass by lazy {
14141414
val result = pluginContext.referenceClass(FqName("kotlin.jvm.internal.Intrinsics"))?.owner
14151415
result?.let { extractExternalClassLater(it) }
14161416
result
14171417
}
14181418

1419-
fun findJdkIntrinsicOrWarn(name: String, warnAgainstElement: IrElement): IrFunction? {
1419+
private fun findJdkIntrinsicOrWarn(name: String, warnAgainstElement: IrElement): IrFunction? {
14201420
val result = jvmIntrinsicsClass?.let { findFunction(it, name) }
14211421
if(result == null) {
14221422
logger.errorElement("Couldn't find JVM intrinsic function $name", warnAgainstElement)
@@ -1510,7 +1510,7 @@ open class KotlinFileExtractor(
15101510
result
15111511
}
15121512

1513-
fun isFunction(target: IrFunction, pkgName: String, classNameLogged: String, classNamePredicate: (String) -> Boolean, fName: String, hasQuestionMark: Boolean? = false): Boolean {
1513+
private fun isFunction(target: IrFunction, pkgName: String, classNameLogged: String, classNamePredicate: (String) -> Boolean, fName: String, hasQuestionMark: Boolean? = false): Boolean {
15141514
val verbose = false
15151515
fun verboseln(s: String) { if(verbose) println(s) }
15161516
verboseln("Attempting match for $pkgName $classNameLogged $fName")
@@ -1554,10 +1554,10 @@ open class KotlinFileExtractor(
15541554
return true
15551555
}
15561556

1557-
fun isFunction(target: IrFunction, pkgName: String, className: String, fName: String, hasQuestionMark: Boolean? = false) =
1557+
private fun isFunction(target: IrFunction, pkgName: String, className: String, fName: String, hasQuestionMark: Boolean? = false) =
15581558
isFunction(target, pkgName, className, { it == className }, fName, hasQuestionMark)
15591559

1560-
fun isNumericFunction(target: IrFunction, fName: String): Boolean {
1560+
private fun isNumericFunction(target: IrFunction, fName: String): Boolean {
15611561
return isFunction(target, "kotlin", "Int", fName) ||
15621562
isFunction(target, "kotlin", "Byte", fName) ||
15631563
isFunction(target, "kotlin", "Short", fName) ||
@@ -1566,7 +1566,7 @@ open class KotlinFileExtractor(
15661566
isFunction(target, "kotlin", "Double", fName)
15671567
}
15681568

1569-
fun isArrayType(typeName: String) =
1569+
private fun isArrayType(typeName: String) =
15701570
when(typeName) {
15711571
"Array" -> true
15721572
"IntArray" -> true
@@ -1580,7 +1580,7 @@ open class KotlinFileExtractor(
15801580
else -> false
15811581
}
15821582

1583-
fun extractCall(c: IrCall, callable: Label<out DbCallable>, stmtExprParent: StmtExprParent) {
1583+
private fun extractCall(c: IrCall, callable: Label<out DbCallable>, stmtExprParent: StmtExprParent) {
15841584
with("call", c) {
15851585
val target = tryReplaceSyntheticFunction(c.symbol.owner)
15861586

@@ -2259,7 +2259,7 @@ open class KotlinFileExtractor(
22592259
else -> null
22602260
}
22612261

2262-
fun getUpdateInPlaceRHS(origin: IrStatementOrigin?, isExpectedLhs: (IrExpression?) -> Boolean, updateRhs: IrExpression): IrExpression? {
2262+
private fun getUpdateInPlaceRHS(origin: IrStatementOrigin?, isExpectedLhs: (IrExpression?) -> Boolean, updateRhs: IrExpression): IrExpression? {
22632263
// Check for a desugared in-place update operator, such as "v += e":
22642264
return getStatementOriginOperator(origin)?.let {
22652265
if (updateRhs is IrCall &&
@@ -2274,7 +2274,7 @@ open class KotlinFileExtractor(
22742274
}
22752275
}
22762276

2277-
fun writeUpdateInPlaceExpr(origin: IrStatementOrigin, tw: TrapWriter, id: Label<DbAssignexpr>, type: TypeResults, exprParent: ExprParent): Boolean {
2277+
private fun writeUpdateInPlaceExpr(origin: IrStatementOrigin, tw: TrapWriter, id: Label<DbAssignexpr>, type: TypeResults, exprParent: ExprParent): Boolean {
22782278
when(origin) {
22792279
IrStatementOrigin.PLUSEQ -> tw.writeExprs_assignaddexpr(id.cast<DbAssignaddexpr>(), type.javaResult.id, exprParent.parent, exprParent.idx)
22802280
IrStatementOrigin.MINUSEQ -> tw.writeExprs_assignsubexpr(id.cast<DbAssignsubexpr>(), type.javaResult.id, exprParent.parent, exprParent.idx)
@@ -2286,7 +2286,7 @@ open class KotlinFileExtractor(
22862286
return true
22872287
}
22882288

2289-
fun tryExtractArrayUpdate(e: IrContainerExpression, callable: Label<out DbCallable>, parent: StmtExprParent): Boolean {
2289+
private fun tryExtractArrayUpdate(e: IrContainerExpression, callable: Label<out DbCallable>, parent: StmtExprParent): Boolean {
22902290
/*
22912291
* We're expecting the pattern
22922292
* {
@@ -2357,15 +2357,15 @@ open class KotlinFileExtractor(
23572357
return false
23582358
}
23592359

2360-
fun extractExpressionStmt(e: IrExpression, callable: Label<out DbCallable>, parent: Label<out DbStmtparent>, idx: Int) {
2360+
private fun extractExpressionStmt(e: IrExpression, callable: Label<out DbCallable>, parent: Label<out DbStmtparent>, idx: Int) {
23612361
extractExpression(e, callable, StmtParent(parent, idx))
23622362
}
23632363

23642364
fun extractExpressionExpr(e: IrExpression, callable: Label<out DbCallable>, parent: Label<out DbExprparent>, idx: Int, enclosingStmt: Label<out DbStmt>) {
23652365
extractExpression(e, callable, ExprParent(parent, idx, enclosingStmt))
23662366
}
23672367

2368-
fun extractExpression(e: IrExpression, callable: Label<out DbCallable>, parent: StmtExprParent) {
2368+
private fun extractExpression(e: IrExpression, callable: Label<out DbCallable>, parent: StmtExprParent) {
23692369
with("expression", e) {
23702370
when(e) {
23712371
is IrDelegatingConstructorCall -> {
@@ -3828,7 +3828,7 @@ open class KotlinFileExtractor(
38283828
}
38293829
}
38303830

3831-
fun extractVarargElement(e: IrVarargElement, callable: Label<out DbCallable>, parent: Label<out DbExprparent>, idx: Int, enclosingStmt: Label<out DbStmt>) {
3831+
private fun extractVarargElement(e: IrVarargElement, callable: Label<out DbCallable>, parent: Label<out DbExprparent>, idx: Int, enclosingStmt: Label<out DbStmt>) {
38323832
with("vararg element", e) {
38333833
val argExpr = when(e) {
38343834
is IrExpression -> e
@@ -4020,7 +4020,7 @@ open class KotlinFileExtractor(
40204020
return initId
40214021
}
40224022

4023-
fun extractTypeOperatorCall(e: IrTypeOperatorCall, callable: Label<out DbCallable>, parent: Label<out DbExprparent>, idx: Int, enclosingStmt: Label<out DbStmt>) {
4023+
private fun extractTypeOperatorCall(e: IrTypeOperatorCall, callable: Label<out DbCallable>, parent: Label<out DbExprparent>, idx: Int, enclosingStmt: Label<out DbStmt>) {
40244024
with("type operator call", e) {
40254025
when(e.operator) {
40264026
IrTypeOperator.CAST -> {

0 commit comments

Comments
 (0)