mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Merge pull request #10227 from igfoo/igfoo/extractStaticTypeAccessQualifier
Kotlin: Refactor extractStaticTypeAccessQualifier
This commit is contained in:
@@ -1544,19 +1544,18 @@ open class KotlinFileExtractor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun extractStaticTypeAccessQualifier(target: IrDeclaration, parentExpr: Label<out DbExprparent>, locId: Label<DbLocation>, enclosingCallable: Label<out DbCallable>, enclosingStmt: Label<out DbStmt>) {
|
private fun extractStaticTypeAccessQualifier(target: IrDeclaration, parentExpr: Label<out DbExprparent>, locId: Label<DbLocation>, enclosingCallable: Label<out DbCallable>, enclosingStmt: Label<out DbStmt>) {
|
||||||
if (target.shouldExtractAsStaticMemberOfClass) {
|
if (target.shouldExtractAsStatic) {
|
||||||
extractTypeAccessRecursive(target.parentAsClass.toRawType(), locId, parentExpr, -1, enclosingCallable, enclosingStmt)
|
val parent = target.parent
|
||||||
} else if (target.shouldExtractAsStaticMemberOfFile) {
|
if (parent is IrClass) {
|
||||||
extractTypeAccess(useFileClassType(target.parent as IrFile), locId, parentExpr, -1, enclosingCallable, enclosingStmt)
|
extractTypeAccessRecursive(parent.toRawType(), locId, parentExpr, -1, enclosingCallable, enclosingStmt)
|
||||||
|
} else if (parent is IrFile) {
|
||||||
|
extractTypeAccess(useFileClassType(parent), locId, parentExpr, -1, enclosingCallable, enclosingStmt)
|
||||||
|
} else {
|
||||||
|
logger.warnElement("Unexpected static type access qualifer ${parent.javaClass}", target)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val IrDeclaration.shouldExtractAsStaticMemberOfClass: Boolean
|
|
||||||
get() = this.shouldExtractAsStatic && parent is IrClass
|
|
||||||
|
|
||||||
private val IrDeclaration.shouldExtractAsStaticMemberOfFile: Boolean
|
|
||||||
get() = this.shouldExtractAsStatic && parent is IrFile
|
|
||||||
|
|
||||||
private fun isStaticAnnotatedNonCompanionMember(f: IrSimpleFunction) =
|
private fun isStaticAnnotatedNonCompanionMember(f: IrSimpleFunction) =
|
||||||
f.parentClassOrNull?.isNonCompanionObject == true &&
|
f.parentClassOrNull?.isNonCompanionObject == true &&
|
||||||
(f.hasAnnotation(jvmStaticFqName) || f.correspondingPropertySymbol?.owner?.hasAnnotation(jvmStaticFqName) == true)
|
(f.hasAnnotation(jvmStaticFqName) || f.correspondingPropertySymbol?.owner?.hasAnnotation(jvmStaticFqName) == true)
|
||||||
|
|||||||
Reference in New Issue
Block a user