@@ -4844,13 +4844,15 @@ module ts {
4844
4844
}
4845
4845
4846
4846
/// Syntactic features
4847
- function getCurrentSourceFile ( fileName : string ) : SourceFile {
4847
+ function getSourceFile ( fileName : string ) : SourceFile {
4848
4848
return syntaxTreeCache . getCurrentSourceFile ( fileName ) ;
4849
4849
}
4850
4850
4851
4851
function getNameOrDottedNameSpan ( fileName : string , startPos : number , endPos : number ) : TextSpan {
4852
+ var sourceFile = syntaxTreeCache . getCurrentSourceFile ( fileName ) ;
4853
+
4852
4854
// Get node at the location
4853
- var node = getTouchingPropertyName ( getCurrentSourceFile ( fileName ) , startPos ) ;
4855
+ var node = getTouchingPropertyName ( sourceFile , startPos ) ;
4854
4856
4855
4857
if ( ! node ) {
4856
4858
return ;
@@ -4904,11 +4906,15 @@ module ts {
4904
4906
4905
4907
function getBreakpointStatementAtPosition ( fileName : string , position : number ) {
4906
4908
// doesn't use compiler - no need to synchronize with host
4907
- return BreakpointResolver . spanInSourceFileAtLocation ( getCurrentSourceFile ( fileName ) , position ) ;
4909
+ var sourceFile = syntaxTreeCache . getCurrentSourceFile ( fileName ) ;
4910
+
4911
+ return BreakpointResolver . spanInSourceFileAtLocation ( sourceFile , position ) ;
4908
4912
}
4909
4913
4910
- function getNavigationBarItems ( fileName : string ) : NavigationBarItem [ ] {
4911
- return NavigationBar . getNavigationBarItems ( getCurrentSourceFile ( fileName ) ) ;
4914
+ function getNavigationBarItems ( fileName : string ) : NavigationBarItem [ ] {
4915
+ var sourceFile = syntaxTreeCache . getCurrentSourceFile ( fileName ) ;
4916
+
4917
+ return NavigationBar . getNavigationBarItems ( sourceFile ) ;
4912
4918
}
4913
4919
4914
4920
function getSemanticClassifications ( fileName : string , span : TextSpan ) : ClassifiedSpan [ ] {
@@ -4986,7 +4992,7 @@ module ts {
4986
4992
4987
4993
function getSyntacticClassifications ( fileName : string , span : TextSpan ) : ClassifiedSpan [ ] {
4988
4994
// doesn't use compiler - no need to synchronize with host
4989
- var sourceFile = getCurrentSourceFile ( fileName ) ;
4995
+ var sourceFile = syntaxTreeCache . getCurrentSourceFile ( fileName ) ;
4990
4996
4991
4997
// Make a scanner we can get trivia from.
4992
4998
var triviaScanner = createScanner ( ScriptTarget . Latest , /*skipTrivia:*/ false , sourceFile . text ) ;
@@ -5204,12 +5210,12 @@ module ts {
5204
5210
5205
5211
function getOutliningSpans ( fileName : string ) : OutliningSpan [ ] {
5206
5212
// doesn't use compiler - no need to synchronize with host
5207
- var sourceFile = getCurrentSourceFile ( fileName ) ;
5213
+ var sourceFile = syntaxTreeCache . getCurrentSourceFile ( fileName ) ;
5208
5214
return OutliningElementsCollector . collectElements ( sourceFile ) ;
5209
5215
}
5210
5216
5211
5217
function getBraceMatchingAtPosition ( fileName : string , position : number ) {
5212
- var sourceFile = getCurrentSourceFile ( fileName ) ;
5218
+ var sourceFile = syntaxTreeCache . getCurrentSourceFile ( fileName ) ;
5213
5219
var result : TextSpan [ ] = [ ] ;
5214
5220
5215
5221
var token = getTouchingToken ( sourceFile , position ) ;
@@ -5263,7 +5269,7 @@ module ts {
5263
5269
5264
5270
function getIndentationAtPosition ( fileName : string , position : number , editorOptions : EditorOptions ) {
5265
5271
var start = new Date ( ) . getTime ( ) ;
5266
- var sourceFile = getCurrentSourceFile ( fileName ) ;
5272
+ var sourceFile = syntaxTreeCache . getCurrentSourceFile ( fileName ) ;
5267
5273
log ( "getIndentationAtPosition: getCurrentSourceFile: " + ( new Date ( ) . getTime ( ) - start ) ) ;
5268
5274
5269
5275
var start = new Date ( ) . getTime ( ) ;
@@ -5275,17 +5281,17 @@ module ts {
5275
5281
}
5276
5282
5277
5283
function getFormattingEditsForRange ( fileName : string , start : number , end : number , options : FormatCodeOptions ) : TextChange [ ] {
5278
- var sourceFile = getCurrentSourceFile ( fileName ) ;
5284
+ var sourceFile = syntaxTreeCache . getCurrentSourceFile ( fileName ) ;
5279
5285
return formatting . formatSelection ( start , end , sourceFile , getRuleProvider ( options ) , options ) ;
5280
5286
}
5281
5287
5282
5288
function getFormattingEditsForDocument ( fileName : string , options : FormatCodeOptions ) : TextChange [ ] {
5283
- var sourceFile = getCurrentSourceFile ( fileName ) ;
5289
+ var sourceFile = syntaxTreeCache . getCurrentSourceFile ( fileName ) ;
5284
5290
return formatting . formatDocument ( sourceFile , getRuleProvider ( options ) , options ) ;
5285
5291
}
5286
5292
5287
5293
function getFormattingEditsAfterKeystroke ( fileName : string , position : number , key : string , options : FormatCodeOptions ) : TextChange [ ] {
5288
- var sourceFile = getCurrentSourceFile ( fileName ) ;
5294
+ var sourceFile = syntaxTreeCache . getCurrentSourceFile ( fileName ) ;
5289
5295
5290
5296
if ( key === "}" ) {
5291
5297
return formatting . formatOnClosingCurly ( position , sourceFile , getRuleProvider ( options ) , options ) ;
@@ -5539,7 +5545,7 @@ module ts {
5539
5545
getFormattingEditsForDocument,
5540
5546
getFormattingEditsAfterKeystroke,
5541
5547
getEmitOutput,
5542
- getSourceFile : getCurrentSourceFile ,
5548
+ getSourceFile,
5543
5549
getProgram
5544
5550
} ;
5545
5551
}
0 commit comments