Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "angular/ast-utils"

Index

Functions

addBootstrapToModule

  • addBootstrapToModule(source: SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[]
  • Custom function to insert an export into NgModule. It also imports it.

    Parameters

    • source: SourceFile
    • modulePath: string
    • classifiedName: string
    • importPath: string

    Returns Change[]

addDeclarationToModule

  • addDeclarationToModule(source: SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[]
  • Custom function to insert a declaration (component, pipe, directive) into NgModule declarations. It also imports the component.

    Parameters

    • source: SourceFile
    • modulePath: string
    • classifiedName: string
    • importPath: string

    Returns Change[]

addEntryComponentToModule

  • addEntryComponentToModule(source: SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[]
  • Custom function to insert an entryComponent into NgModule. It also imports it.

    Parameters

    • source: SourceFile
    • modulePath: string
    • classifiedName: string
    • importPath: string

    Returns Change[]

addExportToModule

  • addExportToModule(source: SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[]
  • Custom function to insert an export into NgModule. It also imports it.

    Parameters

    • source: SourceFile
    • modulePath: string
    • classifiedName: string
    • importPath: string

    Returns Change[]

addImportToModule

  • addImportToModule(source: SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[]
  • Custom function to insert an NgModule into NgModule imports. It also imports the module.

    Parameters

    • source: SourceFile
    • modulePath: string
    • classifiedName: string
    • importPath: string

    Returns Change[]

addProviderToModule

  • addProviderToModule(source: SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[]
  • Custom function to insert a provider into NgModule. It also imports it.

    Parameters

    • source: SourceFile
    • modulePath: string
    • classifiedName: string
    • importPath: string

    Returns Change[]

addRouteDeclarationToModule

  • addRouteDeclarationToModule(source: SourceFile, fileToAdd: string, routeLiteral: string): Change
  • Adds a new route declaration to a router module (i.e. has a RouterModule declaration)

    Parameters

    • source: SourceFile
    • fileToAdd: string
    • routeLiteral: string

    Returns Change

addSymbolToNgModuleMetadata

  • addSymbolToNgModuleMetadata(source: SourceFile, ngModulePath: string, metadataField: string, symbolName: string, importPath?: string | null): Change[]
  • Parameters

    • source: SourceFile
    • ngModulePath: string
    • metadataField: string
    • symbolName: string
    • Default value importPath: string | null = null

    Returns Change[]

findNode

  • findNode(node: Node, kind: SyntaxKind, text: string): Node | null

findNodes

  • findNodes(node: Node, kind: SyntaxKind, max?: number, recursive?: boolean): Node[]
  • Find all nodes from the AST in the subtree of node of SyntaxKind kind.

    Parameters

    • node: Node
    • kind: SyntaxKind
    • Default value max: number = Infinity

      The maximum number of items to return.

    • Default value recursive: boolean = false

      Continue looking for nodes of kind recursive until end the last child even when node of kind has been found.

    Returns Node[]

    all nodes of kind, or [] if none is found

getContentOfKeyLiteral

  • getContentOfKeyLiteral(_source: SourceFile, node: Node): string | null

getDecoratorMetadata

  • getDecoratorMetadata(source: SourceFile, identifier: string, module: string): Node[]
  • Parameters

    • source: SourceFile
    • identifier: string
    • module: string

    Returns Node[]

getFirstNgModuleName

  • getFirstNgModuleName(source: SourceFile): string | undefined
  • Given a source file with @NgModule class(es), find the name of the first @NgModule class.

    Parameters

    • source: SourceFile

      source file containing one or more @NgModule

    Returns string | undefined

    the name of the first @NgModule, or undefined if none is found

getMetadataField

  • getMetadataField(node: ObjectLiteralExpression, metadataField: string): ObjectLiteralElement[]
  • Parameters

    • node: ObjectLiteralExpression
    • metadataField: string

    Returns ObjectLiteralElement[]

getRouterModuleDeclaration

  • getRouterModuleDeclaration(source: SourceFile): Expression | undefined
  • Returns the RouterModule declaration from NgModule metadata, if any.

    Parameters

    • source: SourceFile

    Returns Expression | undefined

getSourceNodes

  • getSourceNodes(sourceFile: SourceFile): Node[]
  • Get all the nodes from a source.

    Parameters

    • sourceFile: SourceFile

      The source file object.

    Returns Node[]

    An observable of all the nodes in the source.

insertAfterLastOccurrence

  • insertAfterLastOccurrence(nodes: Node[], toInsert: string, file: string, fallbackPos: number, syntaxKind?: SyntaxKind): Change
  • Insert toInsert after the last occurence of ts.SyntaxKind[nodes[i].kind] or after the last of occurence of syntaxKind if the last occurence is a sub child of ts.SyntaxKind[nodes[i].kind] and save the changes in file.

    throw

    Error if toInsert is first occurence but fall back is not set

    Parameters

    • nodes: Node[]

      insert after the last occurence of nodes

    • toInsert: string

      string to insert

    • file: string

      file to insert changes into

    • fallbackPos: number

      position to insert if toInsert happens to be the first occurence

    • Optional syntaxKind: SyntaxKind

      the ts.SyntaxKind of the subchildren to insert after

    Returns Change

    Change instance

insertImport

  • insertImport(source: SourceFile, fileToEdit: string, symbolName: string, fileName: string, isDefault?: boolean): Change
  • Add Import import { symbolName } from fileName if the import doesn't exit already. Assumes fileToEdit can be resolved and accessed.

    Parameters

    • source: SourceFile
    • fileToEdit: string

      (file we want to add import to)

    • symbolName: string

      (item to import)

    • fileName: string

      (path to the file)

    • Default value isDefault: boolean = false

      (if true, import follows style for importing default exports)

    Returns Change

    Change

isImported

  • isImported(source: SourceFile, classifiedName: string, importPath: string): boolean
  • Determine if an import already exists.

    Parameters

    • source: SourceFile
    • classifiedName: string
    • importPath: string

    Returns boolean