AstCreator

io.joern.javasrc2cpg.astcreation.AstCreator
class AstCreator(val filename: String, javaParserAst: CompilationUnit, fileContent: Option[String], global: Global, val symbolSolver: JavaSymbolSolver)(implicit val withSchemaValidation: ValidationMode) extends AstCreatorBase, AstNodeBuilder[Node, AstCreator], AstForDeclarationsCreator, AstForExpressionsCreator, AstForStatementsCreator

Translate a Java Parser AST into a CPG AST

Attributes

Graph
Supertypes

Members list

Value members

Concrete methods

def argumentTypesForMethodLike(maybeResolvedMethodLike: Try[ResolvedMethodLikeDeclaration]): Option[List[String]]
protected def code(node: Node): String
protected def column(node: Node): Option[Integer]
protected def columnEnd(node: Node): Option[Integer]
def createAst(): DiffGraphBuilder

Entry point of AST creation. Translates a compilation unit created by JavaParser into a DiffGraph containing the corresponding CPG AST.

Entry point of AST creation. Translates a compilation unit created by JavaParser into a DiffGraph containing the corresponding CPG AST.

Attributes

def expressionReturnTypeFullName(expr: Expression): Option[String]
def getBindingTable(typeDecl: ResolvedReferenceTypeDeclaration): BindingTable
protected def line(node: Node): Option[Integer]
protected def lineEnd(node: Node): Option[Integer]
override protected def offset(node: Node): Option[(Int, Int)]

Attributes

Definition Classes
AstNodeBuilder
def storeInDiffGraph(ast: Ast): Unit

Copy nodes/edges of given AST into the diff graph

Copy nodes/edges of given AST into the diff graph

Attributes

def toOptionList[T](items: Seq[Option[T]]): Option[List[T]]
def unknownAst(node: Node): Ast

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 annotationNode(node: Node, code: String, name: String, fullName: String): NewAnnotation

Attributes

Inherited from:
AstNodeBuilder
def argAstsForCall(call: Node, tryResolvedDecl: Try[ResolvedMethodLikeDeclaration], args: NodeList[Expression]): Seq[Ast]

Attributes

Inherited from:
AstForCallExpressionsCreator
def assignmentsForVarDecl(variables: Iterable[VariableDeclarator]): Seq[Ast]

Attributes

Inherited from:
AstForVarDeclAndAssignsCreator
def astForAnonymousClassDecl(expr: ObjectCreationExpr, body: List[BodyDeclaration[_]], typeName: String, typeFullName: Option[String], baseTypeFullName: Option[String]): Ast

Attributes

Inherited from:
AstForTypeDeclsCreator (hidden)
def astForBlockStatement(stmt: BlockStmt, codeStr: String, prefixAsts: Seq[Ast]): Ast

Attributes

Inherited from:
AstForSimpleStatementsCreator
def astForDefaultConstructor(originNode: Node, instanceFieldDeclarations: List[FieldDeclaration]): Ast

Attributes

Inherited from:
AstForMethodsCreator (hidden)
def astForFor(stmt: ForStmt): Ast

Attributes

Inherited from:
AstForForLoopsCreator
def astForForEach(stmt: ForEachStmt): Seq[Ast]

Attributes

Inherited from:
AstForForLoopsCreator
def astForLambdaExpr(expr: LambdaExpr, expectedType: ExpectedType): Ast

Attributes

Inherited from:
AstForLambdasCreator (hidden)
def astForLocalClassDeclaration(localClassDecl: LocalClassDeclarationStmt): Ast

Attributes

Inherited from:
AstForTypeDeclsCreator (hidden)
def astForMethod(methodDeclaration: MethodDeclaration): Ast

Attributes

Inherited from:
AstForMethodsCreator (hidden)
def astForTypeDeclaration(typeDeclaration: TypeDeclaration[_], fullNameOverride: Option[String]): Ast

Attributes

Inherited from:
AstForTypeDeclsCreator (hidden)
def astsForConstructors(constructorDeclarations: List[ConstructorDeclaration], instanceFieldDeclarations: List[FieldDeclaration]): Map[Node, Ast]

Attributes

Inherited from:
AstForMethodsCreator (hidden)
def astsForExpression(expression: Expression, expectedType: ExpectedType): Seq[Ast]

Attributes

Inherited from:
AstForExpressionsCreator
def astsForStatement(statement: Statement): Seq[Ast]

Attributes

Inherited from:
AstForStatementsCreator
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
protected def blockNode(node: Node, code: String, typeFullName: String): NewBlock

Attributes

Inherited from:
AstNodeBuilder
protected def blockNode(node: Node): NewBlock

Attributes

Inherited from:
AstNodeBuilder
def calcParameterTypes(methodLike: ResolvedMethodLikeDeclaration, typeParamValues: ResolvedTypeParametersMap): Option[List[String]]

Attributes

Inherited from:
AstForMethodsCreator (hidden)
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: Node, code: String, name: String, methodFullName: String, dispatchType: String, signature: Option[String], typeFullName: Option[String]): NewCall

Attributes

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

Attributes

Inherited from:
AstNodeBuilder
def clinitAstFromStaticInits(staticInits: Seq[Ast]): Option[Ast]

Attributes

Inherited from:
AstForMethodsCreator (hidden)
def composeSignature(maybeReturnType: Option[String], maybeParameterTypes: Option[List[String]], parameterCount: Int): String

Attributes

Inherited from:
AstForMethodsCreator (hidden)
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 controlStructureNode(node: Node, controlStructureType: String, code: String): NewControlStructure

Attributes

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

Attributes

Inherited from:
AstCreatorBase
protected def fieldIdentifierNode(node: Node, name: String, code: String): NewFieldIdentifier

Attributes

Inherited from:
AstNodeBuilder
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
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 identifierNode(node: Node, name: String, code: String, typeFullName: String, dynamicTypeHints: Seq[String]): NewIdentifier

Attributes

Inherited from:
AstNodeBuilder
def initNode(namespaceName: Option[String], argumentTypes: Option[List[String]], argsSize: Int, code: String, lineNumber: Option[Integer], columnNumber: Option[Integer]): NewCall

Attributes

Inherited from:
AstForCallExpressionsCreator
protected def jumpTargetNode(node: Node, name: String, code: String, parserTypeName: Option[String]): NewJumpTarget

Attributes

Inherited from:
AstNodeBuilder
protected def literalNode(node: Node, code: String, typeFullName: String, dynamicTypeHints: Seq[String]): NewLiteral

Attributes

Inherited from:
AstNodeBuilder
protected def localNode(node: Node, name: String, code: String, typeFullName: String, closureBindingId: Option[String]): NewLocal

Attributes

Inherited from:
AstNodeBuilder
protected def memberNode(node: Node, name: String, code: String, typeFullName: String, dynamicTypeHints: Seq[String]): NewMember

Attributes

Inherited from:
AstNodeBuilder
protected def memberNode(node: Node, name: String, code: String, typeFullName: String): NewMember

Attributes

Inherited from:
AstNodeBuilder
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
protected def methodNode(node: Node, name: String, code: String, fullName: String, signature: Option[String], fileName: String, astParentType: Option[String], astParentFullName: Option[String]): NewMethod

Attributes

Inherited from:
AstNodeBuilder
def methodNode(node: Node, name: String, fullName: String, signature: String, fileName: String): NewMethod

Attributes

Inherited from:
AstNodeBuilder
protected def methodRefNode(node: Node, code: String, methodFullName: String, typeFullName: String): NewMethodRef

Attributes

Inherited from:
AstNodeBuilder
protected def methodReturnNode(node: Node, typeFullName: String): NewMethodReturn

Attributes

Inherited from:
AstNodeBuilder
def methodSignature(method: ResolvedMethodDeclaration, typeParamValues: ResolvedTypeParametersMap): String

Attributes

Inherited from:
AstForMethodsCreator (hidden)
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
protected def newImportNode(code: String, importedEntity: String, importedAs: String, include: Node): NewImport

Attributes

Inherited from:
AstNodeBuilder
def nextClosureName(): String

Attributes

Returns

the next available name for a closure in this context

Inherited from:
AstCreatorBase
protected def parameterInNode(node: Node, name: String, code: String, index: Int, isVariadic: Boolean, evaluationStrategy: String, typeFullName: Option[String]): NewMethodParameterIn

Attributes

Inherited from:
AstNodeBuilder
protected def parameterInNode(node: Node, name: String, code: String, index: Int, isVariadic: Boolean, evaluationStrategy: String, typeFullName: String): NewMethodParameterIn

Attributes

Inherited from:
AstNodeBuilder
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
protected def returnNode(node: Node, code: String): NewReturn

Attributes

Inherited from:
AstNodeBuilder
def setArgumentIndices(arguments: Seq[Ast]): Unit

Attributes

Inherited from:
AstCreatorBase
protected def shortenCode(code: String): String

Attributes

Inherited from:
AstNodeBuilder
def staticInitMethodAst(initAsts: List[Ast], fullName: String, signature: Option[String], returnType: String, fileName: Option[String], lineNumber: Option[Integer], columnNumber: Option[Integer]): Ast

Attributes

Inherited from:
AstCreatorBase
def thisNodeForMethod(maybeTypeFullName: Option[String], lineNumber: Option[Integer]): NewMethodParameterIn

Attributes

Inherited from:
AstForMethodsCreator (hidden)
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 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

Inherited from:
AstCreatorBase
protected def typeDeclNode(node: Node, name: String, fullName: String, filename: String, code: String, astParentType: String, astParentFullName: String, inherits: Seq[String], alias: Option[String]): NewTypeDecl

Attributes

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

Attributes

Inherited from:
AstNodeBuilder
protected def typeRefNode(node: Node, code: String, typeFullName: String): NewTypeRef

Attributes

Inherited from:
AstNodeBuilder
protected def unknownNode(node: Node, code: String): NewUnknown

Attributes

Inherited from:
AstNodeBuilder
def whileAst(condition: Option[Ast], body: Seq[Ast], code: Option[String], lineNumber: Option[Integer], columnNumber: Option[Integer]): 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[Integer]): Ast

Attributes

Inherited from:
AstCreatorBase

Concrete fields

val filename: String
val symbolSolver: JavaSymbolSolver

Inherited fields

val diffGraph: DiffGraphBuilder

Attributes

Inherited from:
AstCreatorBase

Implicits

Implicits

implicit val withSchemaValidation: ValidationMode