🚧 Still under progress. Soon will be finished.

ProjectContext

CLASS code

Description

A class that shares common utilities between all reflected nodes

Methods

  • getProgram

    code

    A Program is an immutable collection of source files and the compiler options. Together represent a compilation unit.

    getProgram(): Program

    Returns

    Program:

    The TypeScript program created with the TypeScript compiler API

  • getCommandLine

    code

    The TypeScript compiler options parsed (if you have a TSConfig file, the parsed options will be the ones defined there)

    getCommandLine(): ParsedCommandLine

    Returns

    ParsedCommandLine:

    The parsed compiler options

  • getTypeChecker

    code

    The TypeScript type checker. Useful to resolve the types and location of the reflected nodes.

    getTypeChecker(): TypeChecker

    Returns

    TypeChecker:

    The TypeScript type checker

  • getSystem

    code

    An abstraction layer around how we interact with the environment (browser or Node.js)

    getSystem(): AnalyserSystem

    Returns

    AnalyserSystem:

    The system environment used

  • getDiagnostics

    code

    Here we save all the errors we find while analysing the source files

    getDiagnostics(): AnalyserDiagnostic

    Returns

    AnalyserDiagnostic:

    An instance of the AnalyserDiagnostic where all errors are enqueue

  • getOptions

    code

    The user provided analyzer options.

    getOptions(): Partial<AnalyserOptions>

    Returns

    Partial<AnalyserOptions>:

    The options that were provided when calling the parser function

  • registerReflectedNode

    code

    Creates a new reflected node only if it doesn’t exist already in the internal cache.

    registerReflectedNode<T extends ReflectedNode<object, Node>>(node: Node, reflectedNodeFactory: () => T): T

    Parameters

    node Node

    The ts.Node associated with the reflected node

    reflectedNodeFactory () => T

    The function to use to build the new reflection if it doesn’t exist

    Returns

    T:

    The reflected node instance

  • getSymbol

    code

    Returns the associated ts.Symbol for the given node

    getSymbol(node: Node): Symbol | null

    Parameters

    node Node

    The ts.Node to search its symbol

    Returns

    Symbol | null:

    The symbol if it has one

  • getLocation

    code

    Given a node or a type it returns it’s associated symbol, line position and the file path where it was defined.

    getLocation(nodeOrType: Node | Type): SymbolWithLocation

    Parameters

    nodeOrType Node | Type

    The node or type to search for

    Returns

    SymbolWithLocation:

    The symbol, line position and path where the node/type is located

  • getLinePosition

    code

    Returns the start line number where the node is located

    getLinePosition(node: Node): number

    Parameters

    node Node

    The node to locate

    Returns

    number:

    The line number where the node is located