MCPcopy Create free account
hub / github.com/angular/angular / prepareDeclarations

Function prepareDeclarations

packages/compiler/test/typecheck/util.ts:419–457  ·  view source on GitHub ↗
(
  declarations: TestDeclaration[],
  config: TypeCheckingConfig,
  foreignComponentNames: string[],
)

Source from the content-addressed store, hash-verified

417}
418
419function prepareDeclarations(
420 declarations: TestDeclaration[],
421 config: TypeCheckingConfig,
422 foreignComponentNames: string[],
423) {
424 const directives: TcbDirectiveMetadata[] = [];
425 const hostDirectives = new Map<TcbDirectiveMetadata, TcbDirectiveMetadata[]>();
426 const pipes = new Map<string, TcbPipeMetadata>();
427
428 for (const decl of declarations) {
429 if (decl.type === 'directive') {
430 const meta = toDirectiveMetadata(decl);
431 directives.push(meta);
432 hostDirectives.set(meta, resolveHostDirectives(decl));
433 } else {
434 pipes.set(decl.pipeName, {
435 name: decl.pipeName,
436 ref: createReference(decl.name),
437 isExplicitlyDeferred: false,
438 deferredBlocks: null,
439 });
440 }
441 }
442
443 const foreignRegistry = new Map<string, ForeignComponentMeta[]>();
444 for (const name of foreignComponentNames) {
445 foreignRegistry.set(name, [{name}]);
446 }
447 const foreignMatcher = new SelectorlessMatcher<ForeignComponentMeta>(foreignRegistry);
448
449 const matcher = new SelectorMatcher<TcbDirectiveMetadata[]>();
450 for (const meta of directives) {
451 matcher.addSelectables(CssSelector.parse(meta.selector || ''), [
452 ...hostDirectives.get(meta)!,
453 meta,
454 ]);
455 }
456 return {matcher, pipes, foreignMatcher};
457}
458
459function toDirectiveMetadata(
460 decl: TestDirective,

Callers 1

tcbFunction · 0.70

Calls 8

addSelectablesMethod · 0.95
toDirectiveMetadataFunction · 0.85
createReferenceFunction · 0.85
resolveHostDirectivesFunction · 0.70
setMethod · 0.65
parseMethod · 0.65
getMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected