Skip to content

Commit 927ae3a

Browse files
crisbetoatscott
authored andcommitted
refactor(compiler): move matchSource into base metadata
Moves the `matchSource` into the base metadata so the binder can use it.
1 parent 4651b93 commit 927ae3a

12 files changed

Lines changed: 39 additions & 17 deletions

File tree

packages/compiler-cli/src/ngtsc/annotations/component/src/handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import {
4242
ViewEncapsulation,
4343
DirectiveMatcher,
4444
SelectorlessMatcher,
45+
MatchSource,
4546
} from '@angular/compiler';
4647
import ts from 'typescript';
4748

@@ -73,7 +74,6 @@ import {
7374
DirectiveMeta,
7475
extractDirectiveTypeCheckMeta,
7576
HostDirectivesResolver,
76-
MatchSource,
7777
MetadataReader,
7878
MetadataRegistry,
7979
MetaKind,

packages/compiler-cli/src/ngtsc/annotations/directive/src/handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
ConstantPool,
1515
FactoryTarget,
1616
makeBindingParser,
17+
MatchSource,
1718
R3ClassMetadata,
1819
R3DirectiveMetadata,
1920
R3TargetBinder,
@@ -33,7 +34,6 @@ import {
3334
extractDirectiveTypeCheckMeta,
3435
HostDirectiveMeta,
3536
InputMapping,
36-
MatchSource,
3737
MetadataReader,
3838
MetadataRegistry,
3939
MetaKind,

packages/compiler-cli/src/ngtsc/annotations/directive/test/directive_spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
R3TargetBinder,
1313
SelectorMatcher,
1414
TmplAstElement,
15+
MatchSource,
1516
} from '@angular/compiler';
1617
import ts from 'typescript';
1718

@@ -137,6 +138,7 @@ runInEachFileSystem(() => {
137138
animationTriggerNames: null,
138139
ngContentSelectors: null,
139140
preserveWhitespaces: false,
141+
matchSource: MatchSource.Selector,
140142
};
141143
matcher.addSelectables(CssSelector.parse('[dir]'), [dirMeta]);
142144

packages/compiler-cli/src/ngtsc/indexer/test/util.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
BoundTarget,
1111
CssSelector,
1212
DirectiveMatcher,
13+
MatchSource,
1314
parseTemplate,
1415
ParseTemplateOptions,
1516
R3TargetBinder,
@@ -69,6 +70,7 @@ export function getBoundTemplate(
6970
animationTriggerNames: null,
7071
ngContentSelectors: null,
7172
preserveWhitespaces: false,
73+
matchSource: MatchSource.Selector,
7274
}));
7375

7476
let matcher: DirectiveMatcher<ComponentMeta>;

packages/compiler-cli/src/ngtsc/metadata/src/api.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
Expression,
1212
SchemaMetadata,
1313
ExternalReference,
14+
MatchSource,
1415
} from '@angular/compiler';
1516
import ts from 'typescript';
1617

@@ -134,17 +135,6 @@ export enum MetaKind {
134135
NgModule,
135136
}
136137

137-
/**
138-
* Possible ways that a directive can be matched.
139-
*/
140-
export enum MatchSource {
141-
/** The directive was matched by its selector. */
142-
Selector,
143-
144-
/** The directive was applied as a host directive. */
145-
HostDirective,
146-
}
147-
148138
/** Metadata for a single input mapping. */
149139
export type InputMapping = InputOrOutput & {
150140
required: boolean;

packages/compiler-cli/src/ngtsc/metadata/src/dts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9+
import {MatchSource} from '@angular/compiler';
910
import ts from 'typescript';
1011

1112
import {OwningModule, Reference} from '../../imports';
@@ -21,7 +22,6 @@ import {
2122
DirectiveMeta,
2223
HostDirectiveMeta,
2324
InputMapping,
24-
MatchSource,
2525
MetadataReader,
2626
MetaKind,
2727
NgModuleMeta,

packages/compiler-cli/src/ngtsc/metadata/src/host_directives_resolver.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import {DirectiveMeta, InputMapping, MatchSource, MetadataReader} from '../../metadata/src/api';
9+
import {MatchSource} from '@angular/compiler';
10+
import {DirectiveMeta, InputMapping, MetadataReader} from '../../metadata/src/api';
1011
import {ClassDeclaration} from '../../reflection';
1112
import {ClassPropertyMapping, InputOrOutput} from '../src/property_mapping';
1213

packages/compiler-cli/src/ngtsc/typecheck/api/api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
BoundTarget,
1212
DirectiveMeta,
1313
LegacyAnimationTriggerNames,
14+
MatchSource,
1415
ParseSourceSpan,
1516
SchemaMetadata,
1617
} from '@angular/compiler';
@@ -88,6 +89,7 @@ export interface TcbDirectiveMetadata {
8889
isExplicitlyDeferred: boolean;
8990
preserveWhitespaces: boolean;
9091
exportAs: string[] | null;
92+
matchSource: MatchSource;
9193

9294
/** Type parameters of the directive, if available. */
9395
typeParameters: TcbTypeParameter[] | null;

packages/compiler-cli/src/ngtsc/typecheck/src/tcb_adapter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ export function adaptTypeCheckBlockMetadata(
111111
stringLiteralInputFields: dir.stringLiteralInputFields,
112112
undeclaredInputFields: dir.undeclaredInputFields,
113113
publicMethods: dir.publicMethods,
114+
matchSource: dir.matchSource,
114115

115116
ref: extractRef(dir.ref as Reference<ClassDeclaration>),
116117
isGeneric: dir.isGeneric,

packages/compiler-cli/src/ngtsc/typecheck/testing/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
AST,
1111
BindingPipe,
1212
CssSelector,
13+
MatchSource,
1314
ParseSourceFile,
1415
parseTemplate,
1516
ParseTemplateOptions,
@@ -60,7 +61,6 @@ import {
6061
DirectiveMeta,
6162
HostDirectivesResolver,
6263
InputMapping,
63-
MatchSource,
6464
MetadataReaderWithIndex,
6565
MetaKind,
6666
NgModuleIndex,
@@ -913,6 +913,7 @@ function getDirectiveMetaFromDeclaration(
913913
isExplicitlyDeferred: false,
914914
imports: decl.imports,
915915
rawImports: null,
916+
matchSource: MatchSource.Selector,
916917
hostDirectives:
917918
decl.hostDirectives === undefined
918919
? null

0 commit comments

Comments
 (0)