Skip to content

Commit

Permalink
Utilities for decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuckton committed Mar 17, 2015
1 parent 5db3b0d commit fb7dd52
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/compiler/utilities.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// <reference path="types.ts" />
/// <reference path="core.ts" />

This comment has been minimized.

Copy link
@JsonFreeman

JsonFreeman Mar 18, 2015

Contributor

@CyrusNajmabadi is this correct?

This comment has been minimized.

Copy link
@rbuckton

rbuckton Mar 19, 2015

Author Member

I changed this because utilities.ts uses forEach which is defined in core.ts, but it looks like utilities.ts depends on at least binder.ts as it uses ModuleInstanceState from binder, forEachChild (and others) from parser.ts, and forEach (and others) from core.ts.


module ts {
export interface ReferencePathMatchResult {
Expand Down Expand Up @@ -575,6 +575,17 @@ module ts {
return (<CallExpression>node).expression;
}

function getConstructorWithBody(member: ClassElement): ConstructorDeclaration {

This comment has been minimized.

Copy link
@JsonFreeman

JsonFreeman Mar 18, 2015

Contributor

Why not isConstructorWithBody? And then getFirstConstructorWithBody can use where/filter instead of forEach

This comment has been minimized.

Copy link
@rbuckton

rbuckton Mar 19, 2015

Author Member

This was originally an internal function in emitter.ts, and i needed it for checker. I will likely revert this change due to removing reparse for element access.

if (member.kind === SyntaxKind.Constructor && nodeIsPresent((<ConstructorDeclaration>member).body)) {
return <ConstructorDeclaration>member;
}
return undefined;
}

export function getFirstConstructorWithBody(node: ClassDeclaration): ConstructorDeclaration {
return forEach(node.members, getConstructorWithBody);
}

export function isExpression(node: Node): boolean {
switch (node.kind) {
case SyntaxKind.ThisKeyword:
Expand Down

0 comments on commit fb7dd52

Please sign in to comment.