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

Function makeScope

packages/compiler-cli/src/ngtsc/typecheck/testing/index.ts:932–1015  ·  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

930 * Synthesize `ScopeData` metadata from an array of `TestDeclaration`s.
931 */
932function makeScope(program: ts.Program, sf: ts.SourceFile, decls: TestDeclaration[]): ScopeData {
933 const scope: ScopeData = {dependencies: [], isPoisoned: false};
934
935 for (const decl of decls) {
936 let declSf = sf;
937 if (decl.file !== undefined) {
938 declSf = getSourceFileOrError(program, decl.file);
939 }
940 const declClass = getClass(declSf, decl.name);
941
942 if (decl.type === 'directive') {
943 scope.dependencies.push({
944 kind: MetaKind.Directive,
945 matchSource: MatchSource.Selector,
946 ref: new Reference(declClass),
947 baseClass: null,
948 name: decl.name,
949 selector: decl.selector,
950 queries: [],
951 inputs: ClassPropertyMapping.fromMappedObject<InputMapping>(decl.inputs || {}),
952 outputs: ClassPropertyMapping.fromMappedObject(decl.outputs || {}),
953 isComponent: decl.isComponent ?? false,
954 exportAs: decl.exportAs ?? null,
955 ngTemplateGuards: decl.ngTemplateGuards ?? [],
956 hasNgTemplateContextGuard: decl.hasNgTemplateContextGuard ?? false,
957 coercedInputFields: new Set<string>(decl.coercedInputFields ?? []),
958 restrictedInputFields: new Set<string>(decl.restrictedInputFields ?? []),
959 stringLiteralInputFields: new Set<string>(decl.stringLiteralInputFields ?? []),
960 undeclaredInputFields: new Set<string>(decl.undeclaredInputFields ?? []),
961 publicMethods: new Set<string>(decl.publicMethods ?? []),
962 isGeneric: decl.isGeneric ?? false,
963 isPoisoned: false,
964 isStructural: false,
965 animationTriggerNames: null,
966 isStandalone: false,
967 isSignal: false,
968 imports: null,
969 rawImports: null,
970 deferredImports: null,
971 schemas: null,
972 decorator: null,
973 assumedToExportProviders: false,
974 ngContentSelectors: decl.ngContentSelectors || null,
975 preserveWhitespaces: decl.preserveWhitespaces ?? false,
976 isExplicitlyDeferred: false,
977 inputFieldNamesFromMetadataArray: null,
978 selectorlessEnabled: false,
979 localReferencedSymbols: null,
980 hostDirectives:
981 decl.hostDirectives === undefined
982 ? null
983 : decl.hostDirectives.map((hostDecl) => {
984 return {
985 directive: new Reference(
986 getClass(
987 hostDecl.directive.file
988 ? getSourceFileOrError(program, hostDecl.directive.file)
989 : sf,

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