@@ -604,14 +604,14 @@ module TypeScript {
604
604
}
605
605
else {
606
606
roleName = operand1 . actualText ;
607
- if ( roleName in this . thisFunctionNode . roleDeclarations ) {
607
+ if ( roleName in dciContext . roleDeclarations ) {
608
608
isCallToRoleMethod = true ;
609
609
}
610
610
}
611
611
}
612
612
else {
613
613
roleName = operand1 . actualText ;
614
- if ( roleName in this . thisFunctionNode . roleDeclarations ) {
614
+ if ( roleName in dciContext . roleDeclarations ) {
615
615
isCallToRoleMethod = true ;
616
616
}
617
617
}
@@ -622,20 +622,24 @@ module TypeScript {
622
622
if ( isCallToRoleMethod ) {
623
623
//If the call is within a role and begins with `this.`
624
624
if ( isCallToSelf ) {
625
- this . writeToOutput ( "DCI.callMethodOnSelf" ) ;
625
+ this . writeToOutput ( "__dci_internal__.callMethodOnSelf" ) ;
626
+ //this.writeToOutput("DCI.callMethodOnSelf");
626
627
this . writeToOutput ( "(__context, this, '" + roleName + "'" ) ;
627
628
this . writeToOutput ( ", '" + operand2 . actualText + "'" ) ;
628
629
}
629
630
else {
630
- this . writeToOutput ( "__context.__$" + roleName + "." ) ;
631
+ this . writeToOutput ( "__context.__$" + roleName + "." + operand2 . actualText + "." ) ;
631
632
this . writeToOutput ( "call(__context." + roleName ) ;
632
633
}
633
634
if ( args && args . members . length ) this . writeToOutput ( ", " ) ;
634
635
635
636
this . recordSourceMappingStart ( args ) ;
636
- if ( isCallToSelf ) this . writeToOutput ( "[" ) ;
637
- this . emitCommaSeparatedList ( args ) ;
638
- if ( isCallToSelf ) this . writeToOutput ( "]" ) ;
637
+
638
+ if ( args && args . members . length ) {
639
+ if ( isCallToSelf ) this . writeToOutput ( "[" ) ;
640
+ this . emitCommaSeparatedList ( args ) ;
641
+ if ( isCallToSelf ) this . writeToOutput ( "]" ) ;
642
+ }
639
643
}
640
644
else {
641
645
if ( target . nodeType ( ) === NodeType . FunctionDeclaration ) {
@@ -998,6 +1002,15 @@ module TypeScript {
998
1002
hasDCIContext = true ;
999
1003
}
1000
1004
}
1005
+ else if ( initVal instanceof InvocationExpression ) {
1006
+ ( < InvocationExpression > initVal ) . arguments . members . forEach ( function ( arg ) {
1007
+ if ( arg instanceof FunctionDeclaration ) {
1008
+ if ( Object . keys ( ( < FunctionDeclaration > arg ) . roleDeclarations ) . length ) {
1009
+ hasDCIContext = true ;
1010
+ }
1011
+ }
1012
+ } ) ;
1013
+ }
1001
1014
} ) ;
1002
1015
}
1003
1016
} ) ;
@@ -1026,11 +1039,11 @@ module TypeScript {
1026
1039
//DCI
1027
1040
if ( hasDCIContext ) {
1028
1041
//DCI TODO indent
1029
- this . writeLineToOutput ( "var DCI = typescriptDCI.DCI;" ) ;
1042
+ this . writeLineToOutput ( "var __dci_internal__ = typescriptDCI.DCI;" ) ;
1030
1043
}
1031
1044
}
1032
1045
//DCI
1033
- else if ( hasDCIContext ) this . writeLineToOutput ( "var DCI = require('typescript-dci').DCI;" ) ;
1046
+ else if ( hasDCIContext ) this . writeLineToOutput ( "var __dci_internal__ = require('typescript-dci').DCI;" ) ;
1034
1047
}
1035
1048
else {
1036
1049
if ( ! isExported ) {
0 commit comments