Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Context

The context describes the current state the converter is in.

Hierarchy

  • Context

Index

Constructors

constructor

  • new Context(converter: Converter, fileNames: string[], checker: TypeChecker, program: Program): Context
  • Create a new Context instance.

    Parameters

    • converter: Converter

      The converter instance that has created the context.

    • fileNames: string[]

      A list of all files that have been passed to the TypeScript compiler.

    • checker: TypeChecker

      The TypeChecker instance returned by the TypeScript compiler.

    • program: Program

    Returns Context

Properties

checker

checker: TypeChecker

The TypeChecker instance returned by the TypeScript compiler.

converter

converter: Converter

The converter instance that has created the context.

Private externalPattern

externalPattern: IMinimatch

The pattern that should be used to flag external source files.

fileNames

fileNames: string[]

A list of all files that have been passed to the TypeScript compiler.

inheritParent

inheritParent: Node

The node that has started the inheritance mode.

inherited

inherited: string[]

The names of the children of the scope before inheritance has been started.

inheritedChildren

inheritedChildren: number[]

List symbol ids of inherited children already visited while inheriting.

isDeclaration

isDeclaration: boolean

Is the current source file a declaration file?

isExternal

isExternal: boolean

Is the current source file marked as being external?

isInherit

isInherit: boolean

Is the converter in inheritance mode?

program

program: Program

The program that is currently processed.

project

The project that is currently processed.

scope

scope: Reflection

The scope or parent reflection that is currently processed.

Private symbolID

symbolID: number = -1024

Next free symbol id used by getSymbolID.

typeArguments

typeArguments: Type[]

The currently set type arguments.

typeParameters

typeParameters: MapLike<Type>

The currently set type parameters.

visitStack

visitStack: Node[]

A list of parent nodes that have been passed to the visit function.

Methods

Private extractTypeParameters

  • extractTypeParameters(parameters: NodeArray<TypeParameterDeclaration>, preserve?: boolean): MapLike<Type>
  • Convert the given list of type parameter declarations into a type mapping.

    Parameters

    • parameters: NodeArray<TypeParameterDeclaration>

      The list of type parameter declarations that should be converted.

    • Optional preserve: boolean

      Should the currently set type parameters of the context be preserved?

    Returns MapLike<Type>

    The resulting type mapping.

getCompilerOptions

  • getCompilerOptions(): CompilerOptions

getLogger

getSymbolID

  • getSymbolID(symbol: Symbol): number
  • Return the symbol id of the given symbol.

    The compiler sometimes does not assign an id to symbols, this method makes sure that we have one. It will assign negative ids if they are not set.

    Parameters

    • symbol: Symbol

      The symbol whose id should be returned.

    Returns number

    The id of the given symbol.

getTypeAtLocation

  • getTypeAtLocation(node: Node): Type
  • Return the type declaration of the given node.

    Parameters

    • node: Node

      The TypeScript node whose type should be resolved.

    Returns Type

    The type declaration of the given node.

inherit

  • inherit(baseNode: Node, typeArguments?: NodeArray<TypeNode>): Reflection
  • Inherit the children of the given TypeScript node to the current scope.

    Parameters

    • baseNode: Node

      The node whose children should be inherited.

    • Optional typeArguments: NodeArray<TypeNode>

      The type arguments that apply while inheriting the given node.

    Returns Reflection

    The resulting reflection / the current scope.

registerReflection

  • registerReflection(reflection: Reflection, node: Node, symbol?: Symbol): void
  • Register a newly generated reflection.

    Ensures that the reflection is both listed in [[Project.reflections]] and [[Project.symbolMapping]] if applicable.

    Parameters

    • reflection: Reflection

      The reflection that should be registered.

    • node: Node

      The node the given reflection was resolved from.

    • Optional symbol: Symbol

      The symbol the given reflection was resolved from.

    Returns void

trigger

  • trigger(name: string, reflection: Reflection, node?: Node): void
  • Trigger a node reflection event.

    All events are dispatched on the current converter instance.

    Parameters

    • name: string

      The name of the event that should be triggered.

    • reflection: Reflection

      The triggering reflection.

    • Optional node: Node

      The triggering TypeScript node if available.

    Returns void

withScope

  • withScope(scope: Reflection, callback: Function): void
  • withScope(scope: Reflection, parameters: NodeArray<TypeParameterDeclaration>, callback: Function): void
  • withScope(scope: Reflection, parameters: NodeArray<TypeParameterDeclaration>, preserve: boolean, callback: Function): void
  • Run the given callback with the scope of the context set to the given reflection.

    Parameters

    • scope: Reflection

      The reflection that should be set as the scope of the context while the callback is invoked.

    • callback: Function

      The callback function that should be executed with the changed context.

    Returns void

  • Run the given callback with the scope of the context set to the given reflection.

    Parameters

    • scope: Reflection

      The reflection that should be set as the scope of the context while the callback is invoked.

    • parameters: NodeArray<TypeParameterDeclaration>

      An array of type parameters that should be set on the context while the callback is invoked.

    • callback: Function

      The callback function that should be executed with the changed context.

    Returns void

  • Run the given callback with the scope of the context set to the given reflection.

    Parameters

    • scope: Reflection

      The reflection that should be set as the scope of the context while the callback is invoked.

    • parameters: NodeArray<TypeParameterDeclaration>

      An array of type parameters that should be set on the context while the callback is invoked.

    • preserve: boolean

      Should the currently set type parameters of the context be preserved?

    • callback: Function

      The callback function that should be executed with the changed context.

    Returns void

withSourceFile

  • withSourceFile(node: SourceFile, callback: Function): void
  • Run the given callback with the context configured for the given source file.

    Parameters

    • node: SourceFile

      The TypeScript node containing the source file declaration.

    • callback: Function

      The callback that should be executed.

    Returns void

Generated using TypeDoc