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

io.shiftleft.js2cpg.datastructures.scope.PendingReference.scala Maven / Gradle / Ivy

There is a newer version: 0.3.3
Show newest version
package io.shiftleft.js2cpg.datastructures.scope

import io.shiftleft.codepropertygraph.generated.nodes.NewNode

case class PendingReference(variableName: String, referenceNodeId: NewNode, stack: Option[ScopeElement]) {

  def tryResolve(): Option[ResolvedReference] = {
    var foundVariableOption = Option.empty[NewNode]
    val stackIterator       = new ScopeElementIterator(stack)

    while (stackIterator.hasNext && foundVariableOption.isEmpty) {
      val scopeElement = stackIterator.next()
      foundVariableOption = scopeElement.nameToVariableNode.get(variableName)
    }

    foundVariableOption.map { variableNodeId =>
      ResolvedReference(variableNodeId, this)
    }
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy