RubyScope

io.joern.rubysrc2cpg.datastructures.RubyScope
class RubyScope(summary: RubyProgramSummary, projectRoot: Option[String]) extends Scope[String, DeclarationNew, TypedScopeElement], TypedScope[RubyMethod, RubyField, RubyType]

Attributes

Graph
Supertypes
trait TypedScope[RubyMethod, RubyField, RubyType]
class Scope[String, DeclarationNew, TypedScopeElement]
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def addInclude(typeOrModule: String): Unit
def addRequire(rawPath: String, isRelative: Boolean): Unit
def anonProcParam: Option[String]

Get the name of the implicit or explict proc param

Get the name of the implicit or explict proc param

Attributes

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

Attributes

Returns

using the stack, will initialize a new module scope object.

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

Attributes

Definition Classes
Scope
def pushSingletonClassDeclaration(singletonClassName: String, variableName: String): Unit

When a singleton class is introduced into the scope, the base variable will now have the singleton's functionality mixed in. This method finds base variable and appends the singleton type.

When a singleton class is introduced into the scope, the base variable will now have the singleton's functionality mixed in. This method finds base variable and appends the singleton type.

Value parameters

singletonClassName

the singleton type full name.

variableName

the base variable

Attributes

def setProcParam(param: String): Unit

Set the name of explict proc param

Set the name of explict proc param

Attributes

Attributes

Returns

true if one should still generate a default constructor for the enclosing type decl.

def surrounding[T <: TypedScopeElement](implicit tag: ClassTag[T]): Option[T]
def surroundingAstLabel: Option[String]

Attributes

Returns

the corresponding node label according to the scope element.

def surroundingScopeFullName: Option[String]

Attributes

Returns

the full name of the surrounding scope.

def surroundingTypeFullName: Option[String]
override def tryResolveTypeReference(typeName: String): Option[RubyType]

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
override def typeForMethod(m: RubyMethod): Option[RubyType]

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.

Definition Classes
TypedScope
def updateSurrounding[T](pf: PartialFunction[ScopeElement[String, DeclarationNew, TypedScopeElement], (ScopeElement[String, DeclarationNew, TypedScopeElement], T)]): Option[T]

Locates a position in the stack matching a partial function, modifies it and emits a result

Locates a position in the stack matching a partial function, modifies it and emits a result

Value parameters

pf

Tests ScopeElements of the stack. If they match, return the new value and the result to emi

Attributes

Returns

the emitted result if the position was found and modifies

def useProcParam: Option[String]

Get the name of the implicit or explict proc param and mark the method scope as using the proc param

Get the name of the implicit or explict proc param and mark the method scope as using the proc param

Attributes

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 popScope(): Option[TypedScopeElement]

Attributes

Inherited from:
Scope
def size: Int

Attributes

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

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[RubyMethod]): Option[RubyMethod]

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

Concrete fields

override 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

override val typesInScope: Set[RubyType]

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