AstCreator

io.joern.csharpsrc2cpg.astcreation.AstCreator
class AstCreator(val relativeFileName: String, val parserResult: ParserResult, val programSummary: CSharpProgramSummary)(implicit withSchemaValidation: ValidationMode) extends AstCreatorBase, AstCreatorHelper, AstForDeclarationsCreator, AstForPrimitivesCreator, AstForExpressionsCreator, AstForStatementsCreator, AstSummaryVisitor, AstGenNodeBuilder[AstCreator]

Attributes

Graph
Supertypes
trait AstGenNodeBuilder[AstCreator]
trait AstNodeBuilder[BaseNodeInfo[_], AstCreator]
class AstCreatorBase
class Object
trait Matchable
class Any
Show all

Members list

Type members

Inherited classlikes

final case class ConditionAstResult(conditionAst: Ast, prependIfBody: List[Ast])

Separates the AST result of a conditional expression into the condition as well as any declared variables to prepend.

Separates the AST result of a conditional expression into the condition as well as any declared variables to prepend.

Value parameters

conditionAst

the condition.

prependIfBody

statements to prepend to the if/then body.

Attributes

Inherited from:
AstForStatementsCreator
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

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 annotationNode(node: BaseNodeInfo[_], code: String, name: String, fullName: String): NewAnnotation

Attributes

Inherited from:
AstNodeBuilder

Attributes

Inherited from:
AstForDeclarationsCreator
protected def astForArrayInitializerExpression(arrayInitializerExpression: DotNetNodeInfo): Seq[Ast]

Attributes

Inherited from:
AstForExpressionsCreator
protected def astForAttributeLists(attributeList: DotNetNodeInfo): Seq[Ast]

Attributes

Inherited from:
AstForExpressionsCreator
protected def astForBinaryExpression(binaryExpr: DotNetNodeInfo): Seq[Ast]

Attributes

Inherited from:
AstForExpressionsCreator
protected def astForBlock(body: DotNetNodeInfo, code: Option[String], prefixAsts: List[Ast]): Ast

Attributes

Inherited from:
AstForDeclarationsCreator
protected def astForCatchClause(catchClause: DotNetNodeInfo): Seq[Ast]

Attributes

Inherited from:
AstForStatementsCreator
protected def astForCatchDeclaration(catchDeclaration: DotNetNodeInfo): Seq[Ast]

Attributes

Inherited from:
AstForStatementsCreator
protected def astForClassDeclaration(classDecl: DotNetNodeInfo): Seq[Ast]

Attributes

Inherited from:
AstForDeclarationsCreator
protected def astForCollectionExpression(collectionExpression: DotNetNodeInfo): Seq[Ast]

Attributes

Inherited from:
AstForExpressionsCreator

Attributes

Inherited from:
AstForStatementsCreator
protected def astForConstructorDeclaration(constructorDecl: DotNetNodeInfo): Seq[Ast]

Attributes

Inherited from:
AstForDeclarationsCreator
protected def astForElementAccessExpression(elementAccessExpression: DotNetNodeInfo): Seq[Ast]

Attributes

Inherited from:
AstForExpressionsCreator
protected def astForEnumDeclaration(enumDecl: DotNetNodeInfo): Seq[Ast]

Attributes

Inherited from:
AstForDeclarationsCreator
protected def astForEnumMemberDeclaration(enumMemberDecl: DotNetNodeInfo): Seq[Ast]

Creates enum members. These are associated with integer types, and by default, are int types.

Creates enum members. These are associated with integer types, and by default, are int types.

Attributes

See also
Inherited from:
AstForDeclarationsCreator
protected def astForEqualsValueClause(clause: DotNetNodeInfo): Seq[Ast]

Handles the = ... part of the equals value clause, thus this only contains an RHS.

Handles the = ... part of the equals value clause, thus this only contains an RHS.

Attributes

Inherited from:
AstForExpressionsCreator
def astForExpression(expr: DotNetNodeInfo): Seq[Ast]

Attributes

Inherited from:
AstForExpressionsCreator
protected def astForExpressionElement(expressionElement: DotNetNodeInfo): Seq[Ast]

Attributes

Inherited from:
AstForExpressionsCreator

Attributes

Inherited from:
AstForExpressionsCreator
protected def astForFieldDeclaration(fieldDecl: DotNetNodeInfo): Seq[Ast]

Attributes

Inherited from:
AstForDeclarationsCreator
protected def astForFinallyClause(finallyClause: DotNetNodeInfo): Seq[Ast]

Attributes

Inherited from:
AstForStatementsCreator
protected def astForGlobalStatement(globalStatement: DotNetNodeInfo): Seq[Ast]

Attributes

Inherited from:
AstForStatementsCreator
protected def astForIdentifier(ident: DotNetNodeInfo, typeFullName: String): Ast

Attributes

Inherited from:
AstForPrimitivesCreator
protected def astForLiteralExpression(_literalNode: DotNetNodeInfo): Seq[Ast]

Attributes

Inherited from:
AstForExpressionsCreator
protected def astForLocalDeclarationStatement(localDecl: DotNetNodeInfo): Seq[Ast]

Attributes

Inherited from:
AstForDeclarationsCreator
protected def astForMethodDeclaration(methodDecl: DotNetNodeInfo): Seq[Ast]

Attributes

Inherited from:
AstForDeclarationsCreator
protected def astForNamespaceDeclaration(namespace: DotNetNodeInfo): Seq[Ast]

Attributes

Inherited from:
AstForDeclarationsCreator
def astForObjectCreationExpression(objectCreation: DotNetNodeInfo): Seq[Ast]

Attributes

Inherited from:
AstForExpressionsCreator
protected def astForOperand(operandNode: DotNetNodeInfo): Seq[Ast]

Attributes

Inherited from:
AstForExpressionsCreator
protected def astForPropertyDeclaration(propertyDecl: DotNetNodeInfo): Seq[Ast]

Attributes

Inherited from:
AstForDeclarationsCreator
protected def astForRecordDeclaration(recordDecl: DotNetNodeInfo): Seq[Ast]

Attributes

Inherited from:
AstForDeclarationsCreator
protected def astForSimpleLambdaExpression(lambdaExpression: DotNetNodeInfo, paramTypeHint: Option[String]): Seq[Ast]

Creates an AST for a simple x => { ... } style lambda expression

Creates an AST for a simple x => { ... } style lambda expression

Value parameters

lambdaExpression

the expression.

paramTypeHint

a type that could hint at what the parameter type may be.

Attributes

Inherited from:
AstForDeclarationsCreator
protected def astForSimpleMemberAccessExpression(accessExpr: DotNetNodeInfo): Seq[Ast]

Attributes

Inherited from:
AstForExpressionsCreator
protected def astForStatement(nodeInfo: DotNetNodeInfo): Seq[Ast]

Attributes

Inherited from:
AstForStatementsCreator
def astForStatement(statement: Value): Seq[Ast]

Attributes

Inherited from:
AstForStatementsCreator
protected def astForThisReceiver(invocationExpr: DotNetNodeInfo, typeFullName: Option[String]): Ast

Attributes

Inherited from:
AstForDeclarationsCreator
protected def astForThrowStatement(throwStmt: DotNetNodeInfo): Seq[Ast]

Attributes

Inherited from:
AstForStatementsCreator
protected def astForTryStatement(tryStmt: DotNetNodeInfo): Seq[Ast]

Attributes

Inherited from:
AstForStatementsCreator
protected def astForUnaryExpression(unaryExpr: DotNetNodeInfo): Seq[Ast]

Attributes

Inherited from:
AstForExpressionsCreator
protected def astForUsing(usingNode: DotNetNodeInfo): Ast

Attributes

Inherited from:
AstForPrimitivesCreator
protected def astForVariableDeclaration(varDecl: DotNetNodeInfo): Seq[Ast]

Attributes

Inherited from:
AstForDeclarationsCreator
protected def astForVariableDeclaration(varDecl: DotNetNodeInfo, isStatic: Boolean): Seq[Ast]

Attributes

Inherited from:
AstForDeclarationsCreator
protected def astForVariableDeclarator(varDecl: DotNetNodeInfo, typeFullName: String, shouldPushVariable: Boolean): Seq[Ast]

Attributes

Inherited from:
AstForDeclarationsCreator
protected def astVariableDeclarationForInitializedFields(fieldDecls: Seq[FieldDecl]): Seq[Ast]

Attributes

Inherited from:
AstForDeclarationsCreator
protected def astsForIsPatternExpression(isPatternExpression: DotNetNodeInfo): List[Ast]

Lowers a pattern expression into a condition and then a declaration if one occurs.

Lowers a pattern expression into a condition and then a declaration if one occurs.

Value parameters

isPatternExpression

a pattern expression which may include a declaration.

Attributes

Returns

a condition and then (potentially) declaration.

Inherited from:
AstForExpressionsCreator
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: BaseNodeInfo[_], code: String, typeFullName: String): NewBlock

Attributes

Inherited from:
AstNodeBuilder
protected def blockNode(node: BaseNodeInfo[_]): NewBlock

Attributes

Inherited from:
AstNodeBuilder
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: BaseNodeInfo[_], code: String, name: String, methodFullName: String, dispatchType: String, signature: Option[String], typeFullName: Option[String]): NewCall

Attributes

Inherited from:
AstNodeBuilder
def callNode(node: BaseNodeInfo[_], code: String, name: String, methodFullName: String, dispatchType: String): NewCall

Attributes

Inherited from:
AstNodeBuilder
override def code(node: BaseNodeInfo[_]): String

Attributes

Definition Classes
AstGenNodeBuilder -> AstNodeBuilder
Inherited from:
AstGenNodeBuilder
override def column(node: BaseNodeInfo[_]): Option[Integer]

Attributes

Definition Classes
AstGenNodeBuilder -> AstNodeBuilder
Inherited from:
AstGenNodeBuilder
override def columnEnd(node: BaseNodeInfo[_]): Option[Integer]

Attributes

Definition Classes
AstGenNodeBuilder -> AstNodeBuilder
Inherited from:
AstGenNodeBuilder
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: BaseNodeInfo[_], controlStructureType: String, code: String): NewControlStructure

Attributes

Inherited from:
AstNodeBuilder
def createCallNodeForOperator(node: DotNetNodeInfo, operatorMethod: String, signature: Option[String], typeFullName: Option[String]): NewCall

Attributes

Inherited from:
AstCreatorHelper
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: BaseNodeInfo[_], 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: BaseNodeInfo[_], name: String, code: String, typeFullName: String, dynamicTypeHints: Seq[String]): NewIdentifier

Attributes

Inherited from:
AstNodeBuilder
protected def jumpTargetNode(node: BaseNodeInfo[_], name: String, code: String, parserTypeName: Option[String]): NewJumpTarget

Attributes

Inherited from:
AstNodeBuilder
override def line(node: BaseNodeInfo[_]): Option[Integer]

Attributes

Definition Classes
AstGenNodeBuilder -> AstNodeBuilder
Inherited from:
AstGenNodeBuilder
override def lineEnd(node: BaseNodeInfo[_]): Option[Integer]

Attributes

Definition Classes
AstGenNodeBuilder -> AstNodeBuilder
Inherited from:
AstGenNodeBuilder
protected def literalNode(node: BaseNodeInfo[_], code: String, typeFullName: String, dynamicTypeHints: Seq[String]): NewLiteral

Attributes

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

Attributes

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

Attributes

Inherited from:
AstNodeBuilder
protected def memberNode(node: BaseNodeInfo[_], 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: BaseNodeInfo[_], 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: BaseNodeInfo[_], name: String, fullName: String, signature: String, fileName: String): NewMethod

Attributes

Inherited from:
AstNodeBuilder
protected def methodRefNode(node: BaseNodeInfo[_], code: String, methodFullName: String, typeFullName: String): NewMethodRef

Attributes

Inherited from:
AstNodeBuilder
protected def methodReturnNode(node: BaseNodeInfo[_], typeFullName: String): NewMethodReturn

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
protected def newImportNode(code: String, importedEntity: String, importedAs: String, include: BaseNodeInfo[_]): NewImport

Attributes

Inherited from:
AstNodeBuilder
def nextAnonymousTypeName(): String

Attributes

Inherited from:
AstCreatorHelper
def nextClosureName(): String

Attributes

Returns

the next available name for a closure in this context

Inherited from:
AstCreatorBase
protected def offset(node: BaseNodeInfo[_]): Option[(Int, Int)]

Attributes

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

Attributes

Inherited from:
AstNodeBuilder
protected def parameterInNode(node: BaseNodeInfo[_], 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: BaseNodeInfo[_], 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

Does a high-level parse of the compilation unit to obtain type and method signature information.

Does a high-level parse of the compilation unit to obtain type and method signature information.

Attributes

Inherited from:
AstSummaryVisitor
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: BaseNodeInfo[_], 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: BaseNodeInfo[_], name: String, fullName: String, fileName: String, inheritsFrom: Seq[String], alias: Option[String]): NewTypeDecl

Attributes

Inherited from:
AstNodeBuilder
protected def typeRefNode(node: BaseNodeInfo[_], code: String, typeFullName: String): NewTypeRef

Attributes

Inherited from:
AstNodeBuilder
protected def unknownNode(node: BaseNodeInfo[_], 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

Creates a deep copy of the AST creator with the new summary.

Creates a deep copy of the AST creator with the new summary.

Attributes

Inherited from:
AstSummaryVisitor
def wrapMultipleInBlock(asts: Seq[Ast], lineNumber: Option[Integer]): Ast

Attributes

Inherited from:
AstCreatorBase

Concrete fields

val parserResult: ParserResult
val relativeFileName: String

Inherited fields

val diffGraph: DiffGraphBuilder

Attributes

Inherited from:
AstCreatorBase