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

io.joern.x2cpg.passes.base.ParameterIndexCompatPass.scala Maven / Gradle / Ivy

There is a newer version: 4.0.131
Show newest version
package io.joern.x2cpg.passes.base

import io.shiftleft.codepropertygraph.generated.Cpg
import io.shiftleft.codepropertygraph.generated.PropertyNames
import io.shiftleft.codepropertygraph.generated.nodes.MethodParameterIn.PropertyDefaults
import io.shiftleft.passes.CpgPass
import io.shiftleft.semanticcpg.language.*

/** Old CPGs use the `order` field to indicate the parameter index while newer CPGs use the `parameterIndex` field. This
  * pass checks whether `parameterIndex` is not set, in which case the value of `order` is copied over.
  */
class ParameterIndexCompatPass(cpg: Cpg) extends CpgPass(cpg) {

  override def run(diffGraph: DiffGraphBuilder): Unit = {
    cpg.parameter.foreach { param =>
      if (param.index == PropertyDefaults.Index) {
        diffGraph.setNodeProperty(param, PropertyNames.INDEX, param.order)
      }
    }
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy