component-resource-collector.d.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. import * as ts from 'typescript';
  9. import { LineAndCharacter } from './utils/line-mappings';
  10. export interface ResolvedResource {
  11. /** Class declaration that contains this resource. */
  12. container: ts.ClassDeclaration | null;
  13. /** File content of the given template. */
  14. content: string;
  15. /** Start offset of the resource content (e.g. in the inline source file) */
  16. start: number;
  17. /** Whether the given resource is inline or not. */
  18. inline: boolean;
  19. /** Path to the file that contains this resource. */
  20. filePath: string;
  21. /**
  22. * Gets the character and line of a given position index in the resource.
  23. * If the resource is declared inline within a TypeScript source file, the line and
  24. * character are based on the full source file content.
  25. */
  26. getCharacterAndLineOfPosition: (pos: number) => LineAndCharacter;
  27. }
  28. /**
  29. * Collector that can be used to find Angular templates and stylesheets referenced within
  30. * given TypeScript source files (inline or external referenced files)
  31. */
  32. export declare class ComponentResourceCollector {
  33. typeChecker: ts.TypeChecker;
  34. resolvedTemplates: ResolvedResource[];
  35. resolvedStylesheets: ResolvedResource[];
  36. constructor(typeChecker: ts.TypeChecker);
  37. visitNode(node: ts.Node): void;
  38. private _visitClassDeclaration;
  39. /** Resolves an external stylesheet by reading its content and computing line mappings. */
  40. resolveExternalStylesheet(filePath: string, container: ts.ClassDeclaration | null): ResolvedResource;
  41. }