Skip to content

Commit 29700aa

Browse files
committed
feat(metadata): emit all methods
This is needed to detect lifecycle hooks.
1 parent 3229bf1 commit 29700aa

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

tools/metadata/src/collector.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -131,20 +131,18 @@ export class MetadataCollector {
131131
hasParameterData = true;
132132
}
133133
}
134-
if (methodDecorators || hasDecoratorData || hasParameterData) {
135-
const data: MethodMetadata = {__symbolic: isConstructor ? "constructor" : "method"};
136-
const name = isConstructor ? "__ctor__" : evaluator.nameOf(member.name);
137-
if (methodDecorators) {
138-
data.decorators = methodDecorators;
139-
}
140-
if (hasDecoratorData) {
141-
data.parameterDecorators = parameterDecoratorData;
142-
}
143-
if (hasParameterData) {
144-
(<ConstructorMetadata>data).parameters = parametersData;
145-
}
146-
recordMember(name, data);
134+
const data: MethodMetadata = {__symbolic: isConstructor ? "constructor" : "method"};
135+
const name = isConstructor ? "__ctor__" : evaluator.nameOf(member.name);
136+
if (methodDecorators) {
137+
data.decorators = methodDecorators;
138+
}
139+
if (hasDecoratorData) {
140+
data.parameterDecorators = parameterDecoratorData;
141+
}
142+
if (hasParameterData) {
143+
(<ConstructorMetadata>data).parameters = parametersData;
147144
}
145+
recordMember(name, data);
148146
break;
149147
case ts.SyntaxKind.PropertyDeclaration:
150148
case ts.SyntaxKind.GetAccessor:

tools/metadata/test/collector.spec.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,10 @@ describe('Collector', () => {
146146
parameters:
147147
[{__symbolic: 'reference', name: undefined, module: './hero.service'}]
148148
}
149-
]
149+
],
150+
onSelect: [{__symbolic: 'method'}],
151+
ngOnInit: [{__symbolic: 'method'}],
152+
getHeroes: [{__symbolic: 'method'}]
150153
}
151154
}
152155
}
@@ -232,7 +235,7 @@ const FILES: Directory = {
232235
import HeroService from './hero.service';
233236
// thrown away
234237
import 'angular2/core';
235-
238+
236239
@MyComponent({
237240
selector: 'my-app',
238241
template:` + "`" + `
@@ -336,23 +339,23 @@ const FILES: Directory = {
336339
export class CaseAny {
337340
constructor(param: any) {}
338341
}
339-
342+
340343
@Injectable()
341344
export class GetProp {
342345
private _name: string;
343346
@Input('firstName') get name(): string {
344347
return this._name;
345348
}
346349
}
347-
350+
348351
@Injectable()
349352
export class SetProp {
350353
private _name: string;
351354
@Input('firstName') set name(value: string) {
352355
this._name = value;
353356
}
354357
}
355-
358+
356359
@Injectable()
357360
export class FullProp {
358361
private _name: string;

0 commit comments

Comments
 (0)