mirror of
https://github.com/github/codeql.git
synced 2025-12-18 01:33:15 +01:00
Kotlin: Move extractFileContents into KotlinFileExtractor
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.github.codeql
|
||||
|
||||
import com.github.codeql.comments.CommentExtractor
|
||||
import com.github.codeql.utils.TypeSubstitution
|
||||
import com.github.codeql.utils.versions.functionN
|
||||
import com.github.codeql.utils.substituteTypeAndArguments
|
||||
@@ -34,6 +35,16 @@ open class KotlinFileExtractor(
|
||||
genericSpecialisationsExtracted: MutableSet<String>
|
||||
): KotlinUsesExtractor(logger, tw, dependencyCollector, externalClassExtractor, primitiveTypeMapping, pluginContext, genericSpecialisationsExtracted) {
|
||||
|
||||
fun extractFileContents(file: IrFile, id: Label<DbFile>) {
|
||||
val locId = tw.getWholeFileLocation()
|
||||
val pkg = file.fqName.asString()
|
||||
val pkgId = extractPackage(pkg)
|
||||
tw.writeHasLocation(id, locId)
|
||||
tw.writeCupackage(id, pkgId)
|
||||
file.declarations.map { extractDeclaration(it) }
|
||||
CommentExtractor(this, file).extract()
|
||||
}
|
||||
|
||||
fun extractDeclaration(declaration: IrDeclaration) {
|
||||
when (declaration) {
|
||||
is IrClass -> {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.github.codeql
|
||||
|
||||
import com.github.codeql.comments.CommentExtractor
|
||||
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||
@@ -21,14 +20,4 @@ class KotlinSourceFileExtractor(
|
||||
genericSpecialisationsExtracted: MutableSet<String>
|
||||
) :
|
||||
KotlinFileExtractor(logger, tw, null, externalClassExtractor, primitiveTypeMapping, pluginContext, genericSpecialisationsExtracted) {
|
||||
|
||||
fun extractFileContents(file: IrFile, id: Label<DbFile>) {
|
||||
val locId = tw.getWholeFileLocation()
|
||||
val pkg = file.fqName.asString()
|
||||
val pkgId = extractPackage(pkg)
|
||||
tw.writeHasLocation(id, locId)
|
||||
tw.writeCupackage(id, pkgId)
|
||||
file.declarations.map { extractDeclaration(it) }
|
||||
CommentExtractor(this, file).extract()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.jetbrains.kotlin.psi.KtVisitor
|
||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
||||
|
||||
class CommentExtractor(private val fileExtractor: KotlinSourceFileExtractor, private val file: IrFile) {
|
||||
class CommentExtractor(private val fileExtractor: KotlinFileExtractor, private val file: IrFile) {
|
||||
private val tw = fileExtractor.tw
|
||||
private val logger = fileExtractor.logger
|
||||
private val ktFile = Psi2Ir().getKtFile(file)
|
||||
|
||||
Reference in New Issue
Block a user