(ctx: ResolutionContext)
| 132 | |
| 133 | /** Every component in the project, read once per resolution state. */ |
| 134 | export function angularComponents(ctx: ResolutionContext): AngularComponent[] { |
| 135 | const source = ctx.getNodesByKind('route'); |
| 136 | const hit = componentIndexes.get(ctx); |
| 137 | if (hit && hit.source === source) return hit.components; |
| 138 | const components: AngularComponent[] = []; |
| 139 | for (const file of ctx.getAllFiles()) { |
| 140 | if (!/\.[cm]?ts$/.test(file) || file.endsWith('.d.ts') || isTestPath(file)) continue; |
| 141 | if (!(ctx.fileContains?.(file, '@Component') ?? ctx.readFile(file)?.includes('@Component'))) continue; |
| 142 | const content = ctx.readFile(file); |
| 143 | if (!content) continue; |
| 144 | components.push(...componentsIn(file, content, ctx.getNodesInFile(file), ctx)); |
| 145 | } |
| 146 | componentIndexes.set(ctx, { source, components }); |
| 147 | return components; |
| 148 | } |
| 149 | |
| 150 | // ============================================================================= |
| 151 | // Reading a template |
no test coverage detected