| 
									
										
										
										
											2021-01-28 14:43:37 -06:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @license | 
					
						
							|  |  |  |  * Copyright Google LLC All Rights Reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Use of this source code is governed by an MIT-style license that can be | 
					
						
							|  |  |  |  * found in the LICENSE file at https://angular.io/license
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * @module | 
					
						
							|  |  |  |  * @description | 
					
						
							|  |  |  |  * Entry point for all public APIs of the language service package. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import * as ts from 'typescript'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-02 15:46:11 -08:00
										 |  |  | export interface PluginConfig { | 
					
						
							| 
									
										
										
										
											2021-02-23 10:51:23 -08:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * If true, return only Angular results. Otherwise, return Angular + TypeScript | 
					
						
							|  |  |  |    * results. | 
					
						
							|  |  |  |    */ | 
					
						
							|  |  |  |   angularOnly: boolean; | 
					
						
							|  |  |  |   /** | 
					
						
							|  |  |  |    * If true, return factory function for Ivy LS during plugin initialization. | 
					
						
							|  |  |  |    * Otherwise return factory function for View Engine LS. | 
					
						
							|  |  |  |    */ | 
					
						
							|  |  |  |   ivy: boolean; | 
					
						
							| 
									
										
										
										
											2021-03-02 15:46:11 -08:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * If true, enable `strictTemplates` in Angular compiler options regardless | 
					
						
							|  |  |  |    * of its value in tsconfig.json. | 
					
						
							|  |  |  |    */ | 
					
						
							|  |  |  |   forceStrictTemplates?: true; | 
					
						
							| 
									
										
										
										
											2021-02-23 10:51:23 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-28 14:43:37 -06:00
										 |  |  | export type GetTcbResponse = { | 
					
						
							|  |  |  |   /** | 
					
						
							|  |  |  |    * The filename of the SourceFile this typecheck block belongs to. | 
					
						
							|  |  |  |    * The filename is entirely opaque and unstable, useful only for debugging | 
					
						
							|  |  |  |    * purposes. | 
					
						
							|  |  |  |    */ | 
					
						
							|  |  |  |   fileName: string, | 
					
						
							|  |  |  |   /** The content of the SourceFile this typecheck block belongs to. */ | 
					
						
							|  |  |  |   content: string, | 
					
						
							|  |  |  |   /** | 
					
						
							|  |  |  |    * Spans over node(s) in the typecheck block corresponding to the | 
					
						
							|  |  |  |    * TS code generated for template node under the current cursor position. | 
					
						
							|  |  |  |    * | 
					
						
							|  |  |  |    * When the cursor position is over a source for which there is no generated | 
					
						
							|  |  |  |    * code, `selections` is empty. | 
					
						
							|  |  |  |    */ | 
					
						
							|  |  |  |   selections: ts.TextSpan[], | 
					
						
							| 
									
										
										
										
											2021-02-22 14:13:43 -08:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2021-01-28 14:43:37 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-28 10:31:04 -08:00
										 |  |  | export type GetComponentLocationsForTemplateResponse = ts.DocumentSpan[]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-28 14:43:37 -06:00
										 |  |  | /** | 
					
						
							|  |  |  |  * `NgLanguageService` describes an instance of an Angular language service, | 
					
						
							|  |  |  |  * whose API surface is a strict superset of TypeScript's language service. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | export interface NgLanguageService extends ts.LanguageService { | 
					
						
							| 
									
										
										
										
											2021-02-22 14:13:43 -08:00
										 |  |  |   getTcb(fileName: string, position: number): GetTcbResponse|undefined; | 
					
						
							| 
									
										
										
										
											2021-01-28 10:31:04 -08:00
										 |  |  |   getComponentLocationsForTemplate(fileName: string): GetComponentLocationsForTemplateResponse; | 
					
						
							| 
									
										
										
										
											2021-01-28 14:43:37 -06:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2021-02-22 14:14:31 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | export function isNgLanguageService(ls: ts.LanguageService| | 
					
						
							|  |  |  |                                     NgLanguageService): ls is NgLanguageService { | 
					
						
							|  |  |  |   return 'getTcb' in ls; | 
					
						
							|  |  |  | } |