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

Function makeScope

packages/compiler-cli/src/ngtsc/typecheck/testing/index.ts:962–1046  ·  view source on GitHub ↗

* Synthesize `ScopeData` metadata from an array of `TestDeclaration`s.

(program: ts.Program, sf: ts.SourceFile, decls: TestDeclaration[])

Source from the content-addressed store, hash-verified

960 * Synthesize `ScopeData` metadata from an array of `TestDeclaration`s.
961 */
962function makeScope(program: ts.Program, sf: ts.SourceFile, decls: TestDeclaration[]): ScopeData {
963 const scope: ScopeData = {dependencies: [], isPoisoned: false};
964
965 for (const decl of decls) {
966 let declSf = sf;
967 if (decl.file !== undefined) {
968 declSf = getSourceFileOrError(program, decl.file);
969 }
970 const declClass = getClass(declSf, decl.name);
971
972 if (decl.type === 'directive') {
973 scope.dependencies.push({
974 kind: MetaKind.Directive,
975 matchSource: MatchSource.Selector,
976 ref: new Reference(declClass),
977 baseClass: null,
978 name: decl.name,
979 selector: decl.selector,
980 queries: [],
981 inputs: ClassPropertyMapping.fromMappedObject<InputMapping>(decl.inputs || {}),
982 outputs: ClassPropertyMapping.fromMappedObject(decl.outputs || {}),
983 isComponent: decl.isComponent ?? false,
984 exportAs: decl.exportAs ?? null,
985 ngTemplateGuards: decl.ngTemplateGuards ?? [],
986 hasNgTemplateContextGuard: decl.hasNgTemplateContextGuard ?? false,
987 coercedInputFields: new Set<string>(decl.coercedInputFields ?? []),
988 restrictedInputFields: new Set<string>(decl.restrictedInputFields ?? []),
989 stringLiteralInputFields: new Set<string>(decl.stringLiteralInputFields ?? []),
990 undeclaredInputFields: new Set<string>(decl.undeclaredInputFields ?? []),
991 publicMethods: new Set<string>(decl.publicMethods ?? []),
992 isGeneric: decl.isGeneric ?? false,
993 isPoisoned: false,
994 isStructural: false,
995 animationTriggerNames: null,
996 isStandalone: false,
997 isSignal: false,
998 imports: null,
999 foreignImports: null,
1000 rawImports: null,
1001 deferredImports: null,
1002 schemas: null,
1003 decorator: null,
1004 assumedToExportProviders: false,
1005 ngContentSelectors: decl.ngContentSelectors || null,
1006 preserveWhitespaces: decl.preserveWhitespaces ?? false,
1007 isExplicitlyDeferred: false,
1008 inputFieldNamesFromMetadataArray: null,
1009 selectorlessEnabled: false,
1010 localReferencedSymbols: null,
1011 hostDirectives:
1012 decl.hostDirectives === undefined
1013 ? null
1014 : decl.hostDirectives.map((hostDecl) => {
1015 return {
1016 directive: new Reference(
1017 getClass(
1018 hostDecl.directive.file
1019 ? getSourceFileOrError(program, hostDecl.directive.file)

Callers 1

setupFunction · 0.85

Calls 5

getSourceFileOrErrorFunction · 0.90
fromMappedObjectMethod · 0.80
mapMethod · 0.80
getClassFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected