MCPcopy Index your code
hub / github.com/angular/angular / getOutliningSpans

Function getOutliningSpans

packages/language-service/src/outlining_spans.ts:27–57  ·  view source on GitHub ↗
(compiler: NgCompiler, fileName: string)

Source from the content-addressed store, hash-verified

25import {getFirstComponentForTemplateFile, isTypeScriptFile, toTextSpan} from './utils';
26
27export 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
59class BlockVisitor extends TmplAstRecursiveVisitor {
60 readonly blocks = [] as Array<TmplAstBlockNode>;

Callers 1

getOutliningSpansMethod · 0.90

Calls 12

isTypeScriptFileFunction · 0.90
isNamedClassDeclarationFunction · 0.90
isExternalResourceFunction · 0.90
getCurrentProgramMethod · 0.80
getDirectiveResourcesMethod · 0.80
mapMethod · 0.80
getBlockSpansMethod · 0.80
getTemplateMethod · 0.65
getSourceFileMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…