@@ -841,16 +841,10 @@ module ts {
841841 }
842842 }
843843
844- export interface Logger {
845- log ( s : string ) : void ;
846- trace ( s : string ) : void ;
847- error ( s : string ) : void ;
848- }
849-
850844 //
851845 // Public interface of the host of a language service instance.
852846 //
853- export interface LanguageServiceHost extends Logger {
847+ export interface LanguageServiceHost {
854848 getCompilationSettings ( ) : CompilerOptions ;
855849 getScriptFileNames ( ) : string [ ] ;
856850 getScriptVersion ( fileName : string ) : string ;
@@ -860,6 +854,9 @@ module ts {
860854 getCancellationToken ?( ) : CancellationToken ;
861855 getCurrentDirectory ( ) : string ;
862856 getDefaultLibFilename ( options : CompilerOptions ) : string ;
857+ log ? ( s : string ) : void ;
858+ trace ? ( s : string ) : void ;
859+ error ? ( s : string ) : void ;
863860 }
864861
865862 //
@@ -1492,11 +1489,17 @@ module ts {
14921489 constructor ( private host : LanguageServiceHost ) {
14931490 }
14941491
1492+ private log ( message : string ) {
1493+ if ( this . host . log ) {
1494+ this . host . log ( message ) ;
1495+ }
1496+ }
1497+
14951498 private initialize ( filename : string ) {
14961499 // ensure that both source file and syntax tree are either initialized or not initialized
14971500 var start = new Date ( ) . getTime ( ) ;
14981501 this . hostCache = new HostCache ( this . host ) ;
1499- this . host . log ( "SyntaxTreeCache.Initialize: new HostCache: " + ( new Date ( ) . getTime ( ) - start ) ) ;
1502+ this . log ( "SyntaxTreeCache.Initialize: new HostCache: " + ( new Date ( ) . getTime ( ) - start ) ) ;
15001503
15011504 var version = this . hostCache . getVersion ( filename ) ;
15021505 var sourceFile : SourceFile ;
@@ -1506,7 +1509,7 @@ module ts {
15061509
15071510 var start = new Date ( ) . getTime ( ) ;
15081511 sourceFile = createLanguageServiceSourceFile ( filename , scriptSnapshot , ScriptTarget . Latest , version , /*isOpen*/ true , /*setNodeParents;*/ true ) ;
1509- this . host . log ( "SyntaxTreeCache.Initialize: createSourceFile: " + ( new Date ( ) . getTime ( ) - start ) ) ;
1512+ this . log ( "SyntaxTreeCache.Initialize: createSourceFile: " + ( new Date ( ) . getTime ( ) - start ) ) ;
15101513 }
15111514 else if ( this . currentFileVersion !== version ) {
15121515 var scriptSnapshot = this . hostCache . getScriptSnapshot ( filename ) ;
@@ -1515,7 +1518,7 @@ module ts {
15151518
15161519 var start = new Date ( ) . getTime ( ) ;
15171520 sourceFile = updateLanguageServiceSourceFile ( this . currentSourceFile , scriptSnapshot , version , /*isOpen*/ true , editRange ) ;
1518- this . host . log ( "SyntaxTreeCache.Initialize: updateSourceFile: " + ( new Date ( ) . getTime ( ) - start ) ) ;
1521+ this . log ( "SyntaxTreeCache.Initialize: updateSourceFile: " + ( new Date ( ) . getTime ( ) - start ) ) ;
15191522 }
15201523
15211524 if ( sourceFile ) {
@@ -1931,6 +1934,12 @@ module ts {
19311934 localizedDiagnosticMessages = host . getLocalizedDiagnosticMessages ( ) ;
19321935 }
19331936
1937+ function log ( message : string ) {
1938+ if ( host . log ) {
1939+ host . log ( message ) ;
1940+ }
1941+ }
1942+
19341943 function getCanonicalFileName ( filename : string ) {
19351944 return useCaseSensitivefilenames ? filename : filename . toLowerCase ( ) ;
19361945 }
@@ -1946,7 +1955,7 @@ module ts {
19461955 function getRuleProvider ( options : FormatCodeOptions ) {
19471956 // Ensure rules are initialized and up to date wrt to formatting options
19481957 if ( ! ruleProvider ) {
1949- ruleProvider = new formatting . RulesProvider ( host ) ;
1958+ ruleProvider = new formatting . RulesProvider ( ) ;
19501959 }
19511960
19521961 ruleProvider . ensureUpToDate ( options ) ;
@@ -2199,35 +2208,35 @@ module ts {
21992208
22002209 var start = new Date ( ) . getTime ( ) ;
22012210 var currentToken = getTokenAtPosition ( sourceFile , position ) ;
2202- host . log ( "getCompletionsAtPosition: Get current token: " + ( new Date ( ) . getTime ( ) - start ) ) ;
2211+ log ( "getCompletionsAtPosition: Get current token: " + ( new Date ( ) . getTime ( ) - start ) ) ;
22032212
22042213 var start = new Date ( ) . getTime ( ) ;
22052214 // Completion not allowed inside comments, bail out if this is the case
22062215 var insideComment = isInsideComment ( sourceFile , currentToken , position ) ;
2207- host . log ( "getCompletionsAtPosition: Is inside comment: " + ( new Date ( ) . getTime ( ) - start ) ) ;
2216+ log ( "getCompletionsAtPosition: Is inside comment: " + ( new Date ( ) . getTime ( ) - start ) ) ;
22082217
22092218 if ( insideComment ) {
2210- host . log ( "Returning an empty list because completion was inside a comment." ) ;
2219+ log ( "Returning an empty list because completion was inside a comment." ) ;
22112220 return undefined ;
22122221 }
22132222
22142223 // The decision to provide completion depends on the previous token, so find it
22152224 // Note: previousToken can be undefined if we are the beginning of the file
22162225 var start = new Date ( ) . getTime ( ) ;
22172226 var previousToken = findPrecedingToken ( position , sourceFile ) ;
2218- host . log ( "getCompletionsAtPosition: Get previous token 1: " + ( new Date ( ) . getTime ( ) - start ) ) ;
2227+ log ( "getCompletionsAtPosition: Get previous token 1: " + ( new Date ( ) . getTime ( ) - start ) ) ;
22192228
22202229 // The caret is at the end of an identifier; this is a partial identifier that we want to complete: e.g. a.toS|
22212230 // Skip this partial identifier to the previous token
22222231 if ( previousToken && position <= previousToken . end && previousToken . kind === SyntaxKind . Identifier ) {
22232232 var start = new Date ( ) . getTime ( ) ;
22242233 previousToken = findPrecedingToken ( previousToken . pos , sourceFile ) ;
2225- host . log ( "getCompletionsAtPosition: Get previous token 2: " + ( new Date ( ) . getTime ( ) - start ) ) ;
2234+ log ( "getCompletionsAtPosition: Get previous token 2: " + ( new Date ( ) . getTime ( ) - start ) ) ;
22262235 }
22272236
22282237 // Check if this is a valid completion location
22292238 if ( previousToken && isCompletionListBlocker ( previousToken ) ) {
2230- host . log ( "Returning an empty list because completion was requested in an invalid position." ) ;
2239+ log ( "Returning an empty list because completion was requested in an invalid position." ) ;
22312240 return undefined ;
22322241 }
22332242
@@ -2256,7 +2265,7 @@ module ts {
22562265 symbols : { } ,
22572266 typeChecker : typeInfoResolver
22582267 } ;
2259- host . log ( "getCompletionsAtPosition: Syntactic work: " + ( new Date ( ) . getTime ( ) - syntacticStart ) ) ;
2268+ log ( "getCompletionsAtPosition: Syntactic work: " + ( new Date ( ) . getTime ( ) - syntacticStart ) ) ;
22602269
22612270 var location = getTouchingPropertyName ( sourceFile , position ) ;
22622271 // Populate the completion list
@@ -2330,7 +2339,7 @@ module ts {
23302339 if ( ! isMemberCompletion ) {
23312340 Array . prototype . push . apply ( activeCompletionSession . entries , keywordCompletions ) ;
23322341 }
2333- host . log ( "getCompletionsAtPosition: Semantic work: " + ( new Date ( ) . getTime ( ) - semanticStart ) ) ;
2342+ log ( "getCompletionsAtPosition: Semantic work: " + ( new Date ( ) . getTime ( ) - semanticStart ) ) ;
23342343
23352344 return {
23362345 isMemberCompletion,
@@ -2349,15 +2358,15 @@ module ts {
23492358 }
23502359 }
23512360 } ) ;
2352- host . log ( "getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + ( new Date ( ) . getTime ( ) - start ) ) ;
2361+ log ( "getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + ( new Date ( ) . getTime ( ) - start ) ) ;
23532362 }
23542363
23552364 function isCompletionListBlocker ( previousToken : Node ) : boolean {
23562365 var start = new Date ( ) . getTime ( ) ;
23572366 var result = isInStringOrRegularExpressionOrTemplateLiteral ( previousToken ) ||
23582367 isIdentifierDefinitionLocation ( previousToken ) ||
23592368 isRightOfIllegalDot ( previousToken ) ;
2360- host . log ( "getCompletionsAtPosition: isCompletionListBlocker: " + ( new Date ( ) . getTime ( ) - start ) ) ;
2369+ log ( "getCompletionsAtPosition: isCompletionListBlocker: " + ( new Date ( ) . getTime ( ) - start ) ) ;
23612370 return result ;
23622371 }
23632372
@@ -5139,12 +5148,12 @@ module ts {
51395148
51405149 var start = new Date ( ) . getTime ( ) ;
51415150 var sourceFile = getCurrentSourceFile ( filename ) ;
5142- host . log ( "getIndentationAtPosition: getCurrentSourceFile: " + ( new Date ( ) . getTime ( ) - start ) ) ;
5151+ log ( "getIndentationAtPosition: getCurrentSourceFile: " + ( new Date ( ) . getTime ( ) - start ) ) ;
51435152
51445153 var start = new Date ( ) . getTime ( ) ;
51455154
51465155 var result = formatting . SmartIndenter . getIndentation ( position , sourceFile , editorOptions ) ;
5147- host . log ( "getIndentationAtPosition: computeIndentation : " + ( new Date ( ) . getTime ( ) - start ) ) ;
5156+ log ( "getIndentationAtPosition: computeIndentation : " + ( new Date ( ) . getTime ( ) - start ) ) ;
51485157
51495158 return result ;
51505159 }
@@ -5417,7 +5426,7 @@ module ts {
54175426 }
54185427
54195428 /// Classifier
5420- export function createClassifier ( host : Logger ) : Classifier {
5429+ export function createClassifier ( ) : Classifier {
54215430 var scanner = createScanner ( ScriptTarget . Latest , /*skipTrivia*/ false ) ;
54225431
54235432 /// We do not have a full parser support to know when we should parse a regex or not
0 commit comments