CSharpScope

io.joern.csharpsrc2cpg.datastructures.CSharpScope
class CSharpScope(summary: CSharpProgramSummary) extends Scope[String, DeclarationNew, TypedScopeElement], TypedScope[CSharpMethod, CSharpField, CSharpType]

Attributes

Graph
Supertypes
trait TypedScope[CSharpMethod, CSharpField, CSharpType]
class Scope[String, DeclarationNew, TypedScopeElement]
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def findFieldInScope(fieldName: String): Option[FieldDecl]

Works for this.field accesses or .field accesses.

Works for this.field accesses or .field accesses.

Attributes

override def isOverloadedBy(method: CSharpMethod, argTypes: List[String]): Boolean

Determines if, by observing the given argument types, that the method's signature is a plausible match to the observed arguments.

Determines if, by observing the given argument types, that the method's signature is a plausible match to the observed arguments.

The default implementation only considers that the same number of arguments are added and does not account for variadic arguments nor polymorphism.

Value parameters

argTypes

the observed arguments from the call-site.

method

the method meta data.

Attributes

Returns

true if the method could be overloaded by a call with these argument types.

Definition Classes
TypedScope
def isTopLevel: Boolean

Attributes

Returns

true if the scope is currently on the top-level, false if the scope is within some nested scope.

def peekScope(): Option[TypedScopeElement]

Returns the top of the scope, without removing it from the stack.

Returns the top of the scope, without removing it from the stack.

Attributes

override def popScope(): Option[TypedScopeElement]

Pops the scope, removing types from the scope if necessary.

Pops the scope, removing types from the scope if necessary.

Attributes

Definition Classes
Scope
def pushField(field: FieldDecl): Unit
override def pushNewScope(scopeNode: TypedScopeElement): Unit

Pops the scope, adding types from the scope if necessary.

Pops the scope, adding types from the scope if necessary.

Attributes

Definition Classes
Scope
def pushTypeToScope(typeFullName: String): Unit
def surroundingScopeFullName: Option[String]

Attributes

Returns

the full name of the surrounding scope.

def surroundingTypeDeclFullName: Option[String]

Attributes

Returns

the surrounding type declaration if one exists.

override def tryResolveTypeReference(typeName: String): Option[CSharpType]

Given a type name or alias, attempts to resolve its full name using the types currently in scope.

Given a type name or alias, attempts to resolve its full name using the types currently in scope.

Value parameters

typeName

the shorthand name.

Attributes

Returns

the type meta-data if found.

Definition Classes
TypedScope

Inherited methods

def addImportedMember(typeOrModule: String, memberNames: String*): Unit

Appends known members to the scope.

Appends known members to the scope.

Value parameters

memberNames

the names of the members, or, if empty, imports all members from the type.

typeOrModule

the type name or full name.

Attributes

Inherited from:
TypedScope
def addImportedNamespace(namespace: String): Unit

Appends known types imported into the scope.

Appends known types imported into the scope.

Value parameters

namespace

the fully qualified imported namespace.

Attributes

Inherited from:
TypedScope
def addImportedTypeOrModule(typeOrModule: String): Unit

Appends known types imported into the scope.

Appends known types imported into the scope.

Value parameters

typeOrModule

the type name or full name.

Attributes

Inherited from:
TypedScope
def addToScope(identifier: String, variable: DeclarationNew): TypedScopeElement

Attributes

Inherited from:
Scope
def isEmpty: Boolean

Attributes

Inherited from:
Scope
def lookupVariable(identifier: String): Option[DeclarationNew]

Attributes

Inherited from:
Scope
def size: Int

Attributes

Inherited from:
Scope
def tryResolveFieldAccess(fieldName: String, typeFullName: Option[String]): Option[CSharpField]

Given the type full name and field name, will attempt to find the matching entry.

Given the type full name and field name, will attempt to find the matching entry.

Value parameters

fieldName

the field/object property/module variable name.

typeFullName

the base type full name. If none, will refer to loosely imported member or functions.

Attributes

Returns

the field/object property/module variable's meta data.

Inherited from:
TypedScope
def tryResolveMethodInvocation(callName: String, argTypes: List[String], typeFullName: Option[String])(implicit tag: ClassTag[CSharpMethod]): Option[CSharpMethod]

Given the type full name and call name, will attempt to find the matching entry.

Given the type full name and call name, will attempt to find the matching entry.

Value parameters

argTypes

the observed argument types. Only relevant for languages that implement overloading.

callName

the call name.

typeFullName

the base type full name. If none, will refer to loosely imported member or functions.

Attributes

Returns

the method meta data if found.

Inherited from:
TypedScope

Given a method, will attempt to find the associated type with preference to the types in scope.

Given a method, will attempt to find the associated type with preference to the types in scope.

Value parameters

m

the method meta data.

Attributes

Returns

the type meta data, if found.

Inherited from:
TypedScope

Concrete fields

override val typesInScope: Set[CSharpType]

Tracks the types that are visible to this scope.

Tracks the types that are visible to this scope.

Attributes

Inherited fields

protected val aliasedTypes: HashMap[String, String]

Tracks any types or modules imported under alternative names to their type full names.

Tracks any types or modules imported under alternative names to their type full names.

Attributes

Inherited from:
TypedScope
protected val membersInScope: Set[MemberLike]

Tracks the members visible to this scope. In languages like JavaScript or Python, where members can be directly imported and accessed without an explicit base, they are kept here.

Tracks the members visible to this scope. In languages like JavaScript or Python, where members can be directly imported and accessed without an explicit base, they are kept here.

Attributes

Inherited from:
TypedScope