All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.joern.kotlin2cpg.passes.AstCreationPass.scala Maven / Gradle / Ivy

There is a newer version: 4.0.82
Show newest version
package io.joern.kotlin2cpg.passes

import io.joern.kotlin2cpg.KtFileWithMeta
import io.joern.kotlin2cpg.ast.AstCreator
import io.joern.kotlin2cpg.types.TypeInfoProvider
import io.joern.x2cpg.ValidationMode
import io.joern.x2cpg.datastructures.Global
import io.shiftleft.codepropertygraph.generated.Cpg
import io.shiftleft.passes.ForkJoinParallelCpgPass
import org.slf4j.LoggerFactory

import scala.jdk.CollectionConverters.EnumerationHasAsScala

class AstCreationPass(filesWithMeta: Iterable[KtFileWithMeta], typeInfoProvider: TypeInfoProvider, cpg: Cpg)(implicit
  withSchemaValidation: ValidationMode
) extends ForkJoinParallelCpgPass[KtFileWithMeta](cpg) {

  private val logger         = LoggerFactory.getLogger(getClass)
  private val global: Global = new Global()

  def usedTypes(): List[String] = global.usedTypes.keys().asScala.toList

  override def generateParts(): Array[KtFileWithMeta] = filesWithMeta.toArray

  override def runOnPart(diffGraph: DiffGraphBuilder, fileWithMeta: KtFileWithMeta): Unit = {
    diffGraph.absorb(new AstCreator(fileWithMeta, typeInfoProvider, global).createAst())
    logger.debug(s"AST created for file at `${fileWithMeta.f.getVirtualFilePath}`.")
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy