(compiler: NgCompiler, fileName: string)
| 25 | import {getFirstComponentForTemplateFile, isTypeScriptFile, toTextSpan} from './utils'; |
| 26 | |
| 27 | export function getOutliningSpans(compiler: NgCompiler, fileName: string): ts.OutliningSpan[] { |
| 28 | if (isTypeScriptFile(fileName)) { |
| 29 | const sf = compiler.getCurrentProgram().getSourceFile(fileName); |
| 30 | if (sf === undefined) { |
| 31 | return []; |
| 32 | } |
| 33 | |
| 34 | const templatesInFile: Array<TmplAstNode[]> = []; |
| 35 | for (const stmt of sf.statements) { |
| 36 | if (isNamedClassDeclaration(stmt)) { |
| 37 | const resources = compiler.getDirectiveResources(stmt); |
| 38 | if ( |
| 39 | resources === null || |
| 40 | resources.template === null || |
| 41 | isExternalResource(resources.template) |
| 42 | ) { |
| 43 | continue; |
| 44 | } |
| 45 | const template = compiler.getTemplateTypeChecker().getTemplate(stmt); |
| 46 | if (template === null) { |
| 47 | continue; |
| 48 | } |
| 49 | templatesInFile.push(template); |
| 50 | } |
| 51 | } |
| 52 | return templatesInFile.map((template) => BlockVisitor.getBlockSpans(template)).flat(); |
| 53 | } else { |
| 54 | const typeCheckInfo = getFirstComponentForTemplateFile(fileName, compiler); |
| 55 | return typeCheckInfo === undefined ? [] : BlockVisitor.getBlockSpans(typeCheckInfo.nodes); |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | class BlockVisitor extends TmplAstRecursiveVisitor { |
| 60 | readonly blocks = [] as Array<TmplAstBlockNode>; |
no test coverage detected
searching dependent graphs…