🚧 Still under progress. Soon will be finished.

Project

CLASS code

Description

Represents a collection of modules (TypeScript/JavaScript files) that have been successfully analysed.

Methods

  • getSystem

    code

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

    getSystem(): AnalyserSystem

    Returns

    AnalyserSystem:

    The system environment used

  • 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

  • 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

  • getOptions

    code

    The user provided analyzer options.

    getOptions(): Partial<AnalyserOptions>

    Returns

    Partial<AnalyserOptions>:

    The options that were provided when calling the parser function

  • 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

  • getModules

    code

    All the reflected modules/files that have been successfully analysed.

    getModules(): ModuleNode[]

    Returns

    ModuleNode[]:

    The reflected modules

  • has

    code

    Whether the given source file path is present in the reflected modules

    has(filePath: string): boolean

    Parameters

    filePath string

    The source file path to check

    Returns

    boolean:

    True if the source file has been already analysed, false otherwise

  • add

    code

    Adds a new source file to the collection of reflected modules. Will throw an error if the source file already exists in the program.

    add(filePath: string, content: string): ModuleNode

    Parameters

    filePath string

    The path of the new source file

    content string

    The content of the source file

    Returns

    ModuleNode:

    The new reflected module

  • update

    code

    Updates the content of an existing source file. Will throw an error if the source file doesn’t exist in the program.

    update(filePath: string, content: string): ModuleNode

    Parameters

    filePath string

    The path of the source file to update

    content string

    The new content of the source file

    Returns

    ModuleNode:

    The updated reflected module

  • getName

    code

    The name of the package defined in the package.json in case one was found

    getName(): string

    Returns

    string:

    The package name if found, otherwise an empty string

  • serialize

    code

    Serializes the project

    serialize(): Module[]

    Returns

    Module[]:

    The reflected node as a serializable object