AstCreator

io.joern.php2cpg.astcreation.AstCreator
See theAstCreator companion object
class AstCreator(val relativeFileName: String, fileName: String, phpAst: PhpFile, disableFileContent: Boolean)(implicit withSchemaValidation: ValidationMode) extends AstCreatorBase[PhpNode, AstCreator], AstCreatorHelper, AstForExpressionsCreator, AstForControlStructuresCreator, AstForDeclarationsCreator, AstForFunctionsCreator, AstForTypesCreator

Attributes

Companion
object
Graph
Supertypes
class AstCreatorBase[PhpNode, AstCreator]
trait AstNodeBuilder[PhpNode, AstCreator]
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

override def createAst(): DiffGraphBuilder

Attributes

Definition Classes
AstCreatorBase

Inherited methods

def absolutePath(filename: String): String

Absolute path for the given file name

Absolute path for the given file name

Attributes

Inherited from:
AstCreatorBase
def annotationAssignmentAst(assignmentValueName: String, code: String, assignmentAst: Ast): Ast

Creates an AST that represents an annotation assignment with a name for the assigned value, its overall code, and the respective assignment AST.

Creates an AST that represents an annotation assignment with a name for the assigned value, its overall code, and the respective assignment AST.

Attributes

Inherited from:
AstCreatorBase
def annotationAst(annotation: NewAnnotation, children: Seq[Ast]): Ast

Creates an AST that represents an annotation, including its content (annotation parameter assignments).

Creates an AST that represents an annotation, including its content (annotation parameter assignments).

Attributes

Inherited from:
AstCreatorBase
protected def astForAssignment(assignment: PhpAssignment): Ast

Attributes

Inherited from:
AstForExpressionsCreator
protected def astForAttributeGroup(attrGrp: PhpAttributeGroup): Seq[Ast]

Attributes

Inherited from:
AstForFunctionsCreator
protected def astForBreakStmt(breakStmt: PhpBreakStmt): Ast

Attributes

Inherited from:
AstForControlStructuresCreator
protected def astForCallArg(arg: PhpArgument): Ast

Attributes

Inherited from:
AstForExpressionsCreator
protected def astForClassLikeStmt(stmt: PhpClassLikeStmt): Ast

Attributes

Inherited from:
AstForTypesCreator
protected def astForClosureExpr(closureExpr: PhpClosureExpr): Ast

Attributes

Inherited from:
AstForFunctionsCreator
protected def astForConstructor(constructorDecl: PhpMethodDecl): Ast

Attributes

Inherited from:
AstForFunctionsCreator
protected def astForContinueStmt(continueStmt: PhpContinueStmt): Ast

Attributes

Inherited from:
AstForControlStructuresCreator
protected def astForDeclareStmt(stmt: PhpDeclareStmt): Ast

Attributes

Inherited from:
AstForDeclarationsCreator
protected def astForDoStmt(doStmt: PhpDoStmt): Ast

Attributes

Inherited from:
AstForControlStructuresCreator
protected def astForEnumCase(stmt: PhpEnumCaseStmt): Ast

Attributes

Inherited from:
AstForTypesCreator
protected def astForExpr(expr: PhpExpr): Ast

Attributes

Inherited from:
AstForExpressionsCreator
protected def astForForStmt(stmt: PhpForStmt): Ast

Attributes

Inherited from:
AstForControlStructuresCreator
protected def astForForeachStmt(stmt: PhpForeachStmt): Ast

Attributes

Inherited from:
AstForControlStructuresCreator
protected def astForGotoStmt(stmt: PhpGotoStmt): Ast

Attributes

Inherited from:
AstForControlStructuresCreator
protected def astForIfStmt(ifStmt: PhpIfStmt): Ast

Attributes

Inherited from:
AstForControlStructuresCreator
protected def astForKeyValPair(origin: PhpNode, key: PhpExpr, value: PhpExpr): Ast

Attributes

Inherited from:
AstForExpressionsCreator
protected def astForLabelStmt(stmt: PhpLabelStmt): Ast

Attributes

Inherited from:
AstForControlStructuresCreator
protected def astForMemberAssignment(originNode: PhpNode, memberNode: NewMember, valueExpr: PhpExpr, isField: Boolean): Ast

Attributes

Inherited from:
AstForExpressionsCreator
protected def astForMethodDecl(decl: PhpMethodDecl, bodyPrefixAsts: List[Ast], fullNameOverride: Option[String], isConstructor: Boolean): Ast

Attributes

Inherited from:
AstForFunctionsCreator
protected def astForReturnStmt(stmt: PhpReturnStmt): Ast

Attributes

Inherited from:
AstForControlStructuresCreator
protected def astForStaticAndConstInits(node: PhpNode): Option[Ast]

Attributes

Inherited from:
AstForFunctionsCreator
protected def astForSwitchStmt(stmt: PhpSwitchStmt): Ast

Attributes

Inherited from:
AstForControlStructuresCreator
protected def astForThrow(expr: PhpThrowExpr): Ast

Attributes

Inherited from:
AstForControlStructuresCreator
protected def astForTryStmt(stmt: PhpTryStmt): Ast

Attributes

Inherited from:
AstForControlStructuresCreator
protected def astForWhileStmt(whileStmt: PhpWhileStmt): Ast

Attributes

Inherited from:
AstForControlStructuresCreator
protected def astForYieldFromExpr(expr: PhpYieldFromExpr): Ast

Attributes

Inherited from:
AstForControlStructuresCreator
protected def astsForClassLikeBody(classLike: PhpStmt, bodyStmts: List[PhpStmt], createDefaultConstructor: Boolean): List[Ast]

Attributes

Inherited from:
AstForTypesCreator
def blockAst(blockNode: NewBlock, statements: List[Ast]): Ast

For a given block node and statement ASTs, create an AST that represents the block. The main purpose of this method is to increase the readability of the code which creates block asts.

For a given block node and statement ASTs, create an AST that represents the block. The main purpose of this method is to increase the readability of the code which creates block asts.

Attributes

Inherited from:
AstCreatorBase
def callAst(callNode: NewCall, arguments: Seq[Ast], base: Option[Ast], receiver: Option[Ast]): Ast

Create an abstract syntax tree for a call, including CPG-specific edges required for arguments and the receiver.

Create an abstract syntax tree for a call, including CPG-specific edges required for arguments and the receiver.

Our call representation is inspired by ECMAScript, that is, in addition to arguments, a call has a base and a receiver. For languages other than Javascript, leave receiver empty for now.

Value parameters

arguments

arguments (without the base argument (instance))

base

the value to use as this in the method call.

callNode

the node that represents the entire call

receiver

the object in which the property lookup is performed

Attributes

Inherited from:
AstCreatorBase
def callNode(node: PhpNode, code: String, name: String, methodFullName: String, dispatchType: String, signature: Option[String], typeFullName: Option[String]): NewCall

Attributes

Inherited from:
AstNodeBuilder
def callNode(node: PhpNode, code: String, name: String, methodFullName: String, dispatchType: String): NewCall

Attributes

Inherited from:
AstNodeBuilder
protected def code(phpNode: PhpNode): String

Attributes

Inherited from:
AstCreatorHelper
protected def codeForMethodCall(call: PhpCallExpr, targetAst: Ast, name: String): String

Attributes

Inherited from:
AstCreatorHelper
protected def codeForStaticMethodCall(call: PhpCallExpr, name: String): String

Attributes

Inherited from:
AstCreatorHelper
protected def column(phpNode: PhpNode): Option[Int]

Attributes

Inherited from:
AstCreatorHelper
protected def columnEnd(phpNode: PhpNode): Option[Int]

Attributes

Inherited from:
AstCreatorHelper
protected def composeMethodFullName(methodName: String, isStatic: Boolean): String

Attributes

Inherited from:
AstCreatorHelper
def controlStructureAst(controlStructureNode: NewControlStructure, condition: Option[Ast], children: Seq[Ast], placeConditionLast: Boolean): Ast

For a given node, condition AST and children ASTs, create an AST that represents the control structure. The main purpose of this method is to automatically assign the correct condition edges.

For a given node, condition AST and children ASTs, create an AST that represents the control structure. The main purpose of this method is to automatically assign the correct condition edges.

Attributes

Inherited from:
AstCreatorBase
protected def defaultConstructorAst(originNode: PhpNode): Ast

Attributes

Inherited from:
AstForFunctionsCreator

Attributes

Inherited from:
AstCreatorHelper
def doWhileAst(condition: Option[Ast], body: Seq[Ast], code: Option[String], lineNumber: Option[Int], columnNumber: Option[Int]): Ast

Attributes

Inherited from:
AstCreatorBase
def fieldAccessAst(originNode: PhpNode, fieldIdentifierOrigin: PhpNode, base: Ast, code: String, fieldName: String, fieldTypeFullName: String): Ast

Attributes

Inherited from:
AstCreatorBase
def forAst(forNode: NewControlStructure, locals: Seq[Ast], initAsts: Seq[Ast], conditionAsts: Seq[Ast], updateAsts: Seq[Ast], bodyAsts: Seq[Ast]): Ast

Attributes

Inherited from:
AstCreatorBase
def forAst(forNode: NewControlStructure, locals: Seq[Ast], initAsts: Seq[Ast], conditionAsts: Seq[Ast], updateAsts: Seq[Ast], bodyAst: Ast): Ast

Attributes

Inherited from:
AstCreatorBase
protected def getTmpIdentifier(originNode: PhpNode, maybeTypeFullName: Option[String], prefix: String): NewIdentifier

Attributes

Inherited from:
AstCreatorHelper
def globalNamespaceBlock(): NewNamespaceBlock

Create a global namespace block for the given filename

Create a global namespace block for the given filename

Attributes

Inherited from:
AstCreatorBase
protected def intToLiteralAst(num: Int): Ast

Attributes

Inherited from:
AstCreatorHelper
protected def line(phpNode: PhpNode): Option[Int]

Attributes

Inherited from:
AstCreatorHelper
protected def lineEnd(phpNode: PhpNode): Option[Int]

Attributes

Inherited from:
AstCreatorHelper
def methodAst(method: NewMethod, parameters: Seq[Ast], body: Ast, methodReturn: NewMethodReturn, modifiers: Seq[NewModifier]): Ast

Creates an AST that represents an entire method, including its content.

Creates an AST that represents an entire method, including its content.

Attributes

Inherited from:
AstCreatorBase
def methodAstWithAnnotations(method: NewMethod, parameters: Seq[Ast], body: Ast, methodReturn: NewMethodReturn, modifiers: Seq[NewModifier], annotations: Seq[Ast]): Ast

Creates an AST that represents an entire method, including its content and with support for both method and parameter annotations.

Creates an AST that represents an entire method, including its content and with support for both method and parameter annotations.

Attributes

Inherited from:
AstCreatorBase
def methodNode(node: PhpNode, name: String, fullName: String, signature: String, fileName: String): NewMethod

Attributes

Inherited from:
AstNodeBuilder
def methodStubAst(method: NewMethod, parameters: Seq[Ast], methodReturn: NewMethodReturn, modifiers: Seq[NewModifier]): Ast

Creates an AST that represents a method stub, containing information about the method, its parameters, and the return type.

Creates an AST that represents a method stub, containing information about the method, its parameters, and the return type.

Attributes

Inherited from:
AstCreatorBase
def nextClosureName(): String

Attributes

Returns

the next available name for a closure in this context

Inherited from:
AstCreatorBase
override protected def offset(phpNode: PhpNode): Option[(Int, Int)]

Attributes

Definition Classes
Inherited from:
AstCreatorHelper
protected def prependNamespacePrefix(name: String): String

Attributes

Inherited from:
AstCreatorHelper
def returnAst(returnNode: NewReturn, arguments: Seq[Ast]): Ast

For a given return node and arguments, create an AST that represents the return instruction. The main purpose of this method is to automatically assign the correct argument indices.

For a given return node and arguments, create an AST that represents the return instruction. The main purpose of this method is to automatically assign the correct argument indices.

Attributes

Inherited from:
AstCreatorBase
def setArgumentIndices(arguments: Seq[Ast], start: Int): Unit

Attributes

Inherited from:
AstCreatorBase
protected def simpleAssignAst(origin: PhpNode, target: Ast, source: Ast): Ast

Attributes

Inherited from:
AstForExpressionsCreator
def staticInitMethodAst(node: PhpNode, initAsts: List[Ast], fullName: String, signature: Option[String], returnType: String, fileName: Option[String]): Ast

Attributes

Inherited from:
AstCreatorBase
protected def stmtBodyBlockAst(stmt: PhpStmtWithBody): Ast

Attributes

Inherited from:
AstForExpressionsCreator
protected def thisIdentifier(originNode: PhpNode): NewIdentifier

Attributes

Inherited from:
AstForFunctionsCreator
def tryCatchAst(tryNode: NewControlStructure, tryBodyAst: Ast, catchAsts: Seq[Ast], finallyAst: Option[Ast]): Ast

For the given try body, catch ASTs, and finally AST, create a try-catch-finally AST.

For the given try body, catch ASTs, and finally AST, create a try-catch-finally AST.

Attributes

Inherited from:
AstCreatorBase
def typeDeclNode(node: PhpNode, name: String, fullName: String, fileName: String, inheritsFrom: Seq[String], alias: Option[String]): NewTypeDecl

Attributes

Inherited from:
AstNodeBuilder
def whileAst(condition: Option[Ast], body: Seq[Ast], code: Option[String], lineNumber: Option[Int], columnNumber: Option[Int]): Ast

Attributes

Inherited from:
AstCreatorBase
def withArgumentIndex[T <: ExpressionNew](node: T, argIdxOpt: Option[Int]): T

Attributes

Inherited from:
AstCreatorBase
def withArgumentName[T <: ExpressionNew](node: T, argNameOpt: Option[String]): T

Attributes

Inherited from:
AstCreatorBase
def withIndex[T, X](nodes: Array[T])(f: (T, Int) => X): Seq[X]

Attributes

Inherited from:
AstCreatorBase
def withIndex[T, X](nodes: Seq[T])(f: (T, Int) => X): Seq[X]

Attributes

Inherited from:
AstCreatorBase
def wrapMultipleInBlock(asts: Seq[Ast], lineNumber: Option[Int]): Ast

Attributes

Inherited from:
AstCreatorBase

Deprecated and Inherited methods

def tryCatchAstWithOrder(tryNode: NewControlStructure, tryBodyAst: Ast, catchAsts: Seq[Ast], finallyAst: Option[Ast]): Ast

For the given try body, catch ASTs and finally AST, create a try-catch-finally AST with orders set correctly for the ossdataflow engine.

For the given try body, catch ASTs and finally AST, create a try-catch-finally AST with orders set correctly for the ossdataflow engine.

Attributes

Deprecated
true
Inherited from:
AstCreatorBase

Inherited fields

val diffGraph: DiffGraphBuilder

Attributes

Inherited from:
AstCreatorBase
protected val globalNamespace: NewNamespaceBlock

Attributes

Inherited from:
AstCreatorHelper