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 | /// <amd-module name="@angular/language-service/src/ts_utils" />
|
9 | import * as ts from 'typescript/lib/tsserverlibrary';
|
10 | interface DirectiveClassLike {
|
11 | decoratorId: ts.Identifier;
|
12 | classId: ts.Identifier;
|
13 | }
|
14 | /**
|
15 | * Return metadata about `node` if it looks like an Angular directive class.
|
16 | * In this case, potential matches are `@NgModule`, `@Component`, `@Directive`,
|
17 | * `@Pipe`, etc.
|
18 | * These class declarations all share some common attributes, namely their
|
19 | * decorator takes exactly one parameter and the parameter must be an object
|
20 | * literal.
|
21 | *
|
22 | * For example,
|
23 | * v---------- `decoratorId`
|
24 | * @NgModule({ <
|
25 | * declarations: [], < classDecln-al
|
26 | * }) <
|
27 | * class AppModule {} <
|
28 | * ^----- `classId`
|
29 | *
|
30 | * @param node Potential node that represents an Angular directive.
|
31 | */
|
32 | export declare function getDirectiveClassLike(node: ts.Node): DirectiveClassLike | undefined;
|
33 | /**
|
34 | * Finds the value of a property assignment that is nested in a TypeScript node and is of a certain
|
35 | * type T.
|
36 | *
|
37 | * @param startNode node to start searching for nested property assignment from
|
38 | * @param propName property assignment name
|
39 | * @param predicate function to verify that a node is of type T.
|
40 | * @return node property assignment value of type T, or undefined if none is found
|
41 | */
|
42 | export declare function findPropertyValueOfType<T extends ts.Node>(startNode: ts.Node, propName: string, predicate: (node: ts.Node) => node is T): T | undefined;
|
43 | /**
|
44 | * Return the node that most tightly encompass the specified `position`.
|
45 | * @param node
|
46 | * @param position
|
47 | */
|
48 | export declare function findTightestNode(node: ts.Node, position: number): ts.Node | undefined;
|
49 | /**
|
50 | * Returns a property assignment from the assignment value if the property name
|
51 | * matches the specified `key`, or `undefined` if there is no match.
|
52 | */
|
53 | export declare function getPropertyAssignmentFromValue(value: ts.Node, key: string): ts.PropertyAssignment | undefined;
|
54 | /**
|
55 | * Given the node which is the string of the inline template for a component, returns the
|
56 | * `ts.ClassDeclaration` for the component.
|
57 | */
|
58 | export declare function getClassDeclOfInlineTemplateNode(templateStringNode: ts.Node): ts.ClassDeclaration | undefined;
|
59 | /**
|
60 | * Given a decorator property assignment, return the ClassDeclaration node that corresponds to the
|
61 | * directive class the property applies to.
|
62 | * If the property assignment is not on a class decorator, no declaration is returned.
|
63 | *
|
64 | * For example,
|
65 | *
|
66 | * @Component({
|
67 | * template: '<div></div>'
|
68 | * ^^^^^^^^^^^^^^^^^^^^^^^---- property assignment
|
69 | * })
|
70 | * class AppComponent {}
|
71 | * ^---- class declaration node
|
72 | *
|
73 | * @param propAsgnNode property assignment
|
74 | */
|
75 | export declare function getClassDeclFromDecoratorProp(propAsgnNode: ts.PropertyAssignment): ts.ClassDeclaration | undefined;
|
76 | export {};
|