Skip to content

Commit

Permalink
feat(metadata): emit all methods
Browse files Browse the repository at this point in the history
This is needed to detect lifecycle hooks.
  • Loading branch information
tbosch committed May 4, 2016
1 parent 3229bf1 commit 29700aa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
24 changes: 11 additions & 13 deletions tools/metadata/src/collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,18 @@ export class MetadataCollector {
hasParameterData = true;
}
}
if (methodDecorators || hasDecoratorData || hasParameterData) {
const data: MethodMetadata = {__symbolic: isConstructor ? "constructor" : "method"};
const name = isConstructor ? "__ctor__" : evaluator.nameOf(member.name);
if (methodDecorators) {
data.decorators = methodDecorators;
}
if (hasDecoratorData) {
data.parameterDecorators = parameterDecoratorData;
}
if (hasParameterData) {
(<ConstructorMetadata>data).parameters = parametersData;
}
recordMember(name, data);
const data: MethodMetadata = {__symbolic: isConstructor ? "constructor" : "method"};
const name = isConstructor ? "__ctor__" : evaluator.nameOf(member.name);
if (methodDecorators) {
data.decorators = methodDecorators;
}
if (hasDecoratorData) {
data.parameterDecorators = parameterDecoratorData;
}
if (hasParameterData) {
(<ConstructorMetadata>data).parameters = parametersData;
}
recordMember(name, data);
break;
case ts.SyntaxKind.PropertyDeclaration:
case ts.SyntaxKind.GetAccessor:
Expand Down
13 changes: 8 additions & 5 deletions tools/metadata/test/collector.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ describe('Collector', () => {
parameters:
[{__symbolic: 'reference', name: undefined, module: './hero.service'}]
}
]
],
onSelect: [{__symbolic: 'method'}],
ngOnInit: [{__symbolic: 'method'}],
getHeroes: [{__symbolic: 'method'}]
}
}
}
Expand Down Expand Up @@ -232,7 +235,7 @@ const FILES: Directory = {
import HeroService from './hero.service';
// thrown away
import 'angular2/core';
@MyComponent({
selector: 'my-app',
template:` + "`" + `
Expand Down Expand Up @@ -336,23 +339,23 @@ const FILES: Directory = {
export class CaseAny {
constructor(param: any) {}
}
@Injectable()
export class GetProp {
private _name: string;
@Input('firstName') get name(): string {
return this._name;
}
}
@Injectable()
export class SetProp {
private _name: string;
@Input('firstName') set name(value: string) {
this._name = value;
}
}
@Injectable()
export class FullProp {
private _name: string;
Expand Down

0 comments on commit 29700aa

Please sign in to comment.