Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DeclarationIndex

Global index of declarations. Contains declarations and origins. Provides reverse index for search and declaration info for imports.

export
class

DeclarationIndex

Hierarchy

  • DeclarationIndex

Index

Constructors

constructor

Properties

Private _index

_index: object | undefined

Declaration index. Reverse index from a name to many declarations assotiated to the name.

type

{({ [declaration: string]: DeclarationInfo[] } | undefined)}

memberof

DeclarationIndex

Private building

building: boolean = false

Private parsedResources

parsedResources: Resources = Object.create(null)

Hash of parsed resources. Contains all parsed files / namespaces / declarations of the current workspace.

type

{Resources}

memberof

DeclarationIndex

Private parser

Private rootPath

rootPath: string

Accessors

declarationInfos

  • List of all declaration information. Contains the typescript declaration and the "from" information (from where the symbol is imported).

    readonly
    type

    {DeclarationInfo[]}

    memberof

    DeclarationIndex

    Returns DeclarationInfo[]

index

  • get index(): object | undefined
  • Reverse index of the declarations.

    readonly
    type

    {({ [declaration: string]: DeclarationInfo[] } | undefined)}

    memberof

    DeclarationIndex

    Returns object | undefined

indexReady

  • get indexReady(): boolean
  • Indicator if the first index was loaded and calculated or not.

    readonly
    type

    {boolean}

    memberof

    DeclarationIndex

    Returns boolean

Methods

buildIndex

  • buildIndex(filePathes: string[]): Promise<void>
  • Tells the index to build a new index. Can be canceled with a cancellationToken.

    memberof

    DeclarationIndex

    Parameters

    • filePathes: string[]

    Returns Promise<void>

Private createIndex

  • createIndex(resources: Resources): Promise<object>
  • Creates a reverse index out of the give resources. Can be cancelled with the token.

    memberof

    DeclarationIndex

    Parameters

    Returns Promise<object>

Private doesExportResource

  • doesExportResource(resource: File, resourcePath: string): boolean
  • Checks if a file does export another resource. (i.e. export ... from ...)

    memberof

    DeclarationIndex

    Parameters

    • resource: File

      The file that is checked

    • resourcePath: string

      The resource that is searched for

    Returns boolean

Private getExportedResources

  • getExportedResources(resourceToCheck: string): string[]
  • Returns a list of files that export a certain resource (declaration).

    memberof

    DeclarationIndex

    Parameters

    • resourceToCheck: string

    Returns string[]

Private parseResources

  • Does parse the resources (symbols and declarations) of a given file. Can be cancelled with the token.

    memberof

    DeclarationIndex

    Parameters

    • Default value files: File[] = []

    Returns Promise<Resources>

Private processAllFromExport

  • Processes an all export, does move the declarations accordingly. (i.e. export * from './myFile')

    memberof

    DeclarationIndex

    Parameters

    Returns void

Private processAssignedExport

  • Processes an assigned export, does move the declarations accordingly. (i.e. export = namespaceName)

    memberof

    DeclarationIndex

    Parameters

    Returns void

Private processNamedFromExport

  • Processes a named export, does move the declarations accordingly. (i.e. export {MyClass} from './myFile')

    memberof

    DeclarationIndex

    Parameters

    Returns void

Private processResourceExports

  • Process all exports of a the parsed resources. Does move the declarations accordingly to their export nature.

    memberof

    DeclarationIndex

    Parameters

    Returns void

reindexForChanges

  • Is called when file events happen. Does reindex for the changed files and creates a new index. Returns the differences for the new index.

    memberof

    DeclarationIndex

    Parameters

    Returns Promise<IndexDelta>

reset

  • reset(): void
  • Resets the whole index. Does delete everything. Period. Is useful for unit testing or similar things.

    memberof

    DeclarationIndex

    Returns void

Static calculateIndexDelta

  • calculateIndexDelta(oldIndex: object, newIndex: object): IndexDelta
  • Calculates the differences between two indices. Calculates removed, added and updated declarations. The updated declarations are calculated and all declarations that the new index contains are inserted in the list.

    static
    memberof

    DeclarationIndex

    Parameters

    Returns IndexDelta

Generated using TypeDoc