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