( context: IndexingContext<T>, adapter: NodeAdapter<T>, )
| 17 | * The context must be populated before `generateIndexerAnalysis` is called. |
| 18 | */ |
| 19 | export function generateIndexerAnalysis<T>( |
| 20 | context: IndexingContext<T>, |
| 21 | adapter: NodeAdapter<T>, |
| 22 | ): Map<T, IndexedComponent<T>> { |
| 23 | const analysis = new Map<T, IndexedComponent<T>>(); |
| 24 | |
| 25 | context.components.forEach(({declaration, selector, boundTemplate, templateMeta}) => { |
| 26 | const name = adapter.getName(declaration); |
| 27 | const fileName = adapter.getFileName(declaration); |
| 28 | |
| 29 | // Get source files for the component and the template. If the template is inline, its source |
| 30 | // file is the component's. |
| 31 | let templateFileUrl: string; |
| 32 | if (templateMeta.isInline) { |
| 33 | templateFileUrl = fileName; |
| 34 | } else { |
| 35 | templateFileUrl = templateMeta.file.url; |
| 36 | } |
| 37 | |
| 38 | const {identifiers, errors} = getIndexerTemplateIdentifiers<T>(boundTemplate); |
| 39 | analysis.set(declaration, { |
| 40 | name, |
| 41 | selector, |
| 42 | fileUrl: fileName, |
| 43 | template: { |
| 44 | identifiers, |
| 45 | fileUrl: templateFileUrl, |
| 46 | }, |
| 47 | errors, |
| 48 | }); |
| 49 | }); |
| 50 | |
| 51 | return analysis; |
| 52 | } |
no test coverage detected