@@ -101,7 +101,7 @@ module ts {
101101 } ;
102102 }
103103
104- function createTextWriter ( writeSymbol : ( symbol : Symbol , enclosingDeclaration ?: Node , meaning ?: SymbolFlags ) => void ) : EmitTextWriter {
104+ function createTextWriter ( trackSymbol : ( symbol : Symbol , enclosingDeclaration ?: Node , meaning ?: SymbolFlags ) => void ) : EmitTextWriter {
105105 var output = "" ;
106106 var indent = 0 ;
107107 var lineStart = true ;
@@ -149,7 +149,7 @@ module ts {
149149
150150 return {
151151 write : write ,
152- writeSymbol : writeSymbol ,
152+ trackSymbol : trackSymbol ,
153153 rawWrite : rawWrite ,
154154 writeLiteral : writeLiteral ,
155155 writeLine : writeLine ,
@@ -182,7 +182,7 @@ module ts {
182182 } ) ;
183183 }
184184
185- function emitComments ( comments : Comment [ ] , trailingSeparator : boolean , writer : EmitTextWriter , writeComment : ( comment : Comment , writer : EmitTextWriter ) => void ) {
185+ function emitComments ( comments : CommentRange [ ] , trailingSeparator : boolean , writer : EmitTextWriter , writeComment : ( comment : CommentRange , writer : EmitTextWriter ) => void ) {
186186 var emitLeadingSpace = ! trailingSeparator ;
187187 forEach ( comments , comment => {
188188 if ( emitLeadingSpace ) {
@@ -203,15 +203,15 @@ module ts {
203203 } ) ;
204204 }
205205
206- function emitNewLineBeforeLeadingComments ( node : TextRange , leadingComments : Comment [ ] , writer : EmitTextWriter ) {
206+ function emitNewLineBeforeLeadingComments ( node : TextRange , leadingComments : CommentRange [ ] , writer : EmitTextWriter ) {
207207 // If the leading comments start on different line than the start of node, write new line
208208 if ( leadingComments && leadingComments . length && node . pos !== leadingComments [ 0 ] . pos &&
209209 getLineOfLocalPosition ( node . pos ) !== getLineOfLocalPosition ( leadingComments [ 0 ] . pos ) ) {
210210 writer . writeLine ( ) ;
211211 }
212212 }
213213
214- function writeCommentRange ( comment : Comment , writer : EmitTextWriter ) {
214+ function writeCommentRange ( comment : CommentRange , writer : EmitTextWriter ) {
215215 if ( currentSourceFile . text . charCodeAt ( comment . pos + 1 ) === CharacterCodes . asterisk ) {
216216 var firstCommentLineAndCharacter = currentSourceFile . getLineAndCharacterFromPosition ( comment . pos ) ;
217217 var firstCommentLineIndent : number ;
@@ -307,7 +307,7 @@ module ts {
307307 }
308308
309309 function emitJavaScript ( jsFilePath : string , root ?: SourceFile ) {
310- var writer = createTextWriter ( writeSymbol ) ;
310+ var writer = createTextWriter ( trackSymbol ) ;
311311 var write = writer . write ;
312312 var writeLine = writer . writeLine ;
313313 var increaseIndent = writer . increaseIndent ;
@@ -363,7 +363,7 @@ module ts {
363363 /** Sourcemap data that will get encoded */
364364 var sourceMapData : SourceMapData ;
365365
366- function writeSymbol ( symbol : Symbol , enclosingDeclaration : Node , meaning : SymbolFlags ) { }
366+ function trackSymbol ( symbol : Symbol , enclosingDeclaration : Node , meaning : SymbolFlags ) { }
367367
368368 function initializeEmitterWithSourceMaps ( ) {
369369 var sourceMapDir : string ; // The directory in which sourcemap will be
@@ -585,7 +585,7 @@ module ts {
585585 sourceMapNameIndices . pop ( ) ;
586586 } ;
587587
588- function writeCommentRangeWithMap ( comment : Comment , writer : EmitTextWriter ) {
588+ function writeCommentRangeWithMap ( comment : CommentRange , writer : EmitTextWriter ) {
589589 recordSourceMapSpan ( comment . pos ) ;
590590 writeCommentRange ( comment , writer ) ;
591591 recordSourceMapSpan ( comment . end ) ;
@@ -916,14 +916,15 @@ module ts {
916916 }
917917
918918 function emitPropertyAccess ( node : PropertyAccess ) {
919- var text = resolver . getPropertyAccessSubstitution ( node ) ;
920- if ( text ) {
921- write ( text ) ;
922- return ;
919+ var constantValue = resolver . getConstantValue ( node ) ;
920+ if ( constantValue !== undefined ) {
921+ write ( constantValue . toString ( ) + " /* " + identifierToString ( node . right ) + " */" ) ;
922+ }
923+ else {
924+ emit ( node . left ) ;
925+ write ( "." ) ;
926+ emit ( node . right ) ;
923927 }
924- emit ( node . left ) ;
925- write ( "." ) ;
926- emit ( node . right ) ;
927928 }
928929
929930 function emitIndexedAccess ( node : IndexedAccess ) {
@@ -2155,7 +2156,7 @@ module ts {
21552156
21562157 function getLeadingCommentsWithoutDetachedComments ( ) {
21572158 // get the leading comments from detachedPos
2158- var leadingComments = getLeadingComments ( currentSourceFile . text , detachedCommentsInfo [ detachedCommentsInfo . length - 1 ] . detachedCommentEndPos ) ;
2159+ var leadingComments = getLeadingCommentRanges ( currentSourceFile . text , detachedCommentsInfo [ detachedCommentsInfo . length - 1 ] . detachedCommentEndPos ) ;
21592160 if ( detachedCommentsInfo . length - 1 ) {
21602161 detachedCommentsInfo . pop ( ) ;
21612162 }
@@ -2169,14 +2170,14 @@ module ts {
21692170 function getLeadingCommentsToEmit ( node : Node ) {
21702171 // Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments
21712172 if ( node . parent . kind === SyntaxKind . SourceFile || node . pos !== node . parent . pos ) {
2172- var leadingComments : Comment [ ] ;
2173+ var leadingComments : CommentRange [ ] ;
21732174 if ( hasDetachedComments ( node . pos ) ) {
21742175 // get comments without detached comments
21752176 leadingComments = getLeadingCommentsWithoutDetachedComments ( ) ;
21762177 }
21772178 else {
21782179 // get the leading comments from the node
2179- leadingComments = getLeadingCommentsOfNode ( node , currentSourceFile ) ;
2180+ leadingComments = getLeadingCommentRangesOfNode ( node , currentSourceFile ) ;
21802181 }
21812182 return leadingComments ;
21822183 }
@@ -2192,32 +2193,32 @@ module ts {
21922193 function emitTrailingDeclarationComments ( node : Node ) {
21932194 // Emit the trailing comments only if the parent's end doesn't match
21942195 if ( node . parent . kind === SyntaxKind . SourceFile || node . end !== node . parent . end ) {
2195- var trailingComments = getTrailingComments ( currentSourceFile . text , node . end ) ;
2196+ var trailingComments = getTrailingCommentRanges ( currentSourceFile . text , node . end ) ;
21962197 // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/
21972198 emitComments ( trailingComments , /*trailingSeparator*/ false , writer , writeComment ) ;
21982199 }
21992200 }
22002201
22012202 function emitLeadingCommentsOfLocalPosition ( pos : number ) {
2202- var leadingComments : Comment [ ] ;
2203+ var leadingComments : CommentRange [ ] ;
22032204 if ( hasDetachedComments ( pos ) ) {
22042205 // get comments without detached comments
22052206 leadingComments = getLeadingCommentsWithoutDetachedComments ( ) ;
22062207 }
22072208 else {
22082209 // get the leading comments from the node
2209- leadingComments = getLeadingComments ( currentSourceFile . text , pos ) ;
2210+ leadingComments = getLeadingCommentRanges ( currentSourceFile . text , pos ) ;
22102211 }
22112212 emitNewLineBeforeLeadingComments ( { pos : pos , end : pos } , leadingComments , writer ) ;
22122213 // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space
22132214 emitComments ( leadingComments , /*trailingSeparator*/ true , writer , writeComment ) ;
22142215 }
22152216
22162217 function emitDetachedCommentsAtPosition ( node : TextRange ) {
2217- var leadingComments = getLeadingComments ( currentSourceFile . text , node . pos ) ;
2218+ var leadingComments = getLeadingCommentRanges ( currentSourceFile . text , node . pos ) ;
22182219 if ( leadingComments ) {
2219- var detachedComments : Comment [ ] = [ ] ;
2220- var lastComment : Comment ;
2220+ var detachedComments : CommentRange [ ] = [ ] ;
2221+ var lastComment : CommentRange ;
22212222
22222223 forEach ( leadingComments , comment => {
22232224 if ( lastComment ) {
@@ -2261,7 +2262,7 @@ module ts {
22612262 function emitPinnedOrTripleSlashCommentsOfNode ( node : Node ) {
22622263 var pinnedComments = ts . filter ( getLeadingCommentsToEmit ( node ) , isPinnedOrTripleSlashComment ) ;
22632264
2264- function isPinnedOrTripleSlashComment ( comment : Comment ) {
2265+ function isPinnedOrTripleSlashComment ( comment : CommentRange ) {
22652266 if ( currentSourceFile . text . charCodeAt ( comment . pos + 1 ) === CharacterCodes . asterisk ) {
22662267 return currentSourceFile . text . charCodeAt ( comment . pos + 2 ) === CharacterCodes . exclamation ;
22672268 }
@@ -2300,7 +2301,7 @@ module ts {
23002301 }
23012302
23022303 function emitDeclarations ( jsFilePath : string , root ?: SourceFile ) {
2303- var writer = createTextWriter ( writeSymbol ) ;
2304+ var writer = createTextWriter ( trackSymbol ) ;
23042305 var write = writer . write ;
23052306 var writeLine = writer . writeLine ;
23062307 var increaseIndent = writer . increaseIndent ;
@@ -2328,7 +2329,7 @@ module ts {
23282329 var oldWriter = writer ;
23292330 forEach ( importDeclarations , aliasToWrite => {
23302331 var aliasEmitInfo = forEach ( aliasDeclarationEmitInfo , declEmitInfo => declEmitInfo . declaration === aliasToWrite ? declEmitInfo : undefined ) ;
2331- writer = createTextWriter ( writeSymbol ) ;
2332+ writer = createTextWriter ( trackSymbol ) ;
23322333 for ( var declarationIndent = aliasEmitInfo . indent ; declarationIndent ; declarationIndent -- ) {
23332334 writer . increaseIndent ( ) ;
23342335 }
@@ -2339,10 +2340,9 @@ module ts {
23392340 writer = oldWriter ;
23402341 }
23412342
2342- function writeSymbol ( symbol : Symbol , enclosingDeclaration ?: Node , meaning ?: SymbolFlags ) {
2343+ function trackSymbol ( symbol : Symbol , enclosingDeclaration ?: Node , meaning ?: SymbolFlags ) {
23432344 var symbolAccesibilityResult = resolver . isSymbolAccessible ( symbol , enclosingDeclaration , meaning ) ;
23442345 if ( symbolAccesibilityResult . accessibility === SymbolAccessibility . Accessible ) {
2345- resolver . writeSymbol ( symbol , enclosingDeclaration , meaning , writer ) ;
23462346
23472347 // write the aliases
23482348 if ( symbolAccesibilityResult && symbolAccesibilityResult . aliasesToMakeVisible ) {
0 commit comments