1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { Tree } from '@angular-devkit/schematics';
|
---|
9 | import { Change } from '@schematics/angular/utility/change';
|
---|
10 | import * as ts from 'typescript';
|
---|
11 | /**
|
---|
12 | * Add Import `import { symbolName } from fileName` if the import doesn't exit
|
---|
13 | * already. Assumes fileToEdit can be resolved and accessed.
|
---|
14 | * @param fileToEdit (file we want to add import to)
|
---|
15 | * @param symbolName (item to import)
|
---|
16 | * @param fileName (path to the file)
|
---|
17 | * @param isDefault (if true, import follows style for importing default exports)
|
---|
18 | * @return Change
|
---|
19 | */
|
---|
20 | export declare function insertImport(source: ts.SourceFile, fileToEdit: string, symbolName: string, fileName: string, isDefault?: boolean): Change;
|
---|
21 | /**
|
---|
22 | * Find all nodes from the AST in the subtree of node of SyntaxKind kind.
|
---|
23 | * @param node
|
---|
24 | * @param kind
|
---|
25 | * @param max The maximum number of items to return.
|
---|
26 | * @param recursive Continue looking for nodes of kind recursive until end
|
---|
27 | * the last child even when node of kind has been found.
|
---|
28 | * @return all nodes of kind, or [] if none is found
|
---|
29 | */
|
---|
30 | export declare function findNodes(node: ts.Node, kind: ts.SyntaxKind, max?: number, recursive?: boolean): ts.Node[];
|
---|
31 | /**
|
---|
32 | * Get all the nodes from a source.
|
---|
33 | * @param sourceFile The source file object.
|
---|
34 | * @returns {Observable<ts.Node>} An observable of all the nodes in the source.
|
---|
35 | */
|
---|
36 | export declare function getSourceNodes(sourceFile: ts.SourceFile): ts.Node[];
|
---|
37 | export declare function findNode(node: ts.Node, kind: ts.SyntaxKind, text: string): ts.Node | null;
|
---|
38 | /**
|
---|
39 | * Insert `toInsert` after the last occurence of `ts.SyntaxKind[nodes[i].kind]`
|
---|
40 | * or after the last of occurence of `syntaxKind` if the last occurence is a sub child
|
---|
41 | * of ts.SyntaxKind[nodes[i].kind] and save the changes in file.
|
---|
42 | *
|
---|
43 | * @param nodes insert after the last occurence of nodes
|
---|
44 | * @param toInsert string to insert
|
---|
45 | * @param file file to insert changes into
|
---|
46 | * @param fallbackPos position to insert if toInsert happens to be the first occurence
|
---|
47 | * @param syntaxKind the ts.SyntaxKind of the subchildren to insert after
|
---|
48 | * @return Change instance
|
---|
49 | * @throw Error if toInsert is first occurence but fall back is not set
|
---|
50 | */
|
---|
51 | export declare function insertAfterLastOccurrence(nodes: ts.Node[], toInsert: string, file: string, fallbackPos: number, syntaxKind?: ts.SyntaxKind): Change;
|
---|
52 | export declare function getDecoratorMetadata(source: ts.SourceFile, identifier: string, module: string): ts.Node[];
|
---|
53 | export declare function getMetadataField(node: ts.ObjectLiteralExpression, metadataField: string): ts.ObjectLiteralElement[];
|
---|
54 | export declare function addSymbolToNgModuleMetadata(source: ts.SourceFile, ngModulePath: string, metadataField: string, symbolName: string, importPath?: string | null): Change[];
|
---|
55 | /**
|
---|
56 | * Custom function to insert a declaration (component, pipe, directive)
|
---|
57 | * into NgModule declarations. It also imports the component.
|
---|
58 | */
|
---|
59 | export declare function addDeclarationToModule(source: ts.SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[];
|
---|
60 | /**
|
---|
61 | * Custom function to insert an NgModule into NgModule imports. It also imports the module.
|
---|
62 | */
|
---|
63 | export declare function addImportToModule(source: ts.SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[];
|
---|
64 | /**
|
---|
65 | * Custom function to insert an export into NgModule. It also imports it.
|
---|
66 | */
|
---|
67 | export declare function addExportToModule(source: ts.SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[];
|
---|
68 | export declare function findBootstrapModuleCall(host: Tree, mainPath: string): ts.CallExpression | null;
|
---|
69 | export declare function findBootstrapModulePath(host: Tree, mainPath: string): string;
|
---|
70 | export declare function getAppModulePath(host: Tree, mainPath: string): string;
|
---|