@@ -57,6 +57,12 @@ module ts {
5757 getNewLine ?( ) : string ;
5858 }
5959
60+ /** Public interface of the the of a config service shim instance.*/
61+ export interface CoreServicesShimHost extends Logger {
62+ /** Returns a JSON-encoded value of the type: string[] */
63+ readDirectory ( rootDir : string , extension : string ) : string ;
64+ }
65+
6066 ///
6167 /// Pre-processing
6268 ///
@@ -77,7 +83,7 @@ module ts {
7783 export interface Shim {
7884 dispose ( dummy : any ) : void ;
7985 }
80-
86+
8187 export interface LanguageServiceShim extends Shim {
8288 languageService : LanguageService ;
8389
@@ -188,6 +194,7 @@ module ts {
188194
189195 export interface CoreServicesShim extends Shim {
190196 getPreProcessedFileInfo ( fileName : string , sourceText : IScriptSnapshot ) : string ;
197+ getTSConfigFileInfo ( fileName : string , sourceText : IScriptSnapshot ) : string ;
191198 getDefaultCompilationSettings ( ) : string ;
192199 }
193200
@@ -302,6 +309,17 @@ module ts {
302309 }
303310 }
304311 }
312+
313+ export class CoreServicesShimHostAdapter implements ParseConfigHost {
314+
315+ constructor ( private shimHost : CoreServicesShimHost ) {
316+ }
317+
318+ public readDirectory ( rootDir : string , extension : string ) : string [ ] {
319+ var encoded = this . shimHost . readDirectory ( rootDir , extension ) ;
320+ return JSON . parse ( encoded ) ;
321+ }
322+ }
305323
306324 function simpleForwardCall ( logger : Logger , actionDescription : string , action : ( ) => any ) : any {
307325 logger . log ( actionDescription ) ;
@@ -741,7 +759,8 @@ module ts {
741759 }
742760
743761 class CoreServicesShimObject extends ShimBase implements CoreServicesShim {
744- constructor ( factory : ShimFactory , public logger : Logger ) {
762+
763+ constructor ( factory : ShimFactory , public logger : Logger , private host : CoreServicesShimHostAdapter ) {
745764 super ( factory ) ;
746765 }
747766
@@ -779,6 +798,25 @@ module ts {
779798 } ) ;
780799 }
781800
801+ public getTSConfigFileInfo ( fileName : string , sourceTextSnapshot : IScriptSnapshot ) : string {
802+ return this . forwardJSONCall (
803+ "getTSConfigFileInfo('" + fileName + "')" ,
804+ ( ) => {
805+ var text = sourceTextSnapshot . getText ( 0 , sourceTextSnapshot . getLength ( ) ) ;
806+ var json = / \S / . test ( text ) ? JSON . parse ( text ) : { } ;
807+
808+ var configFile = parseConfigFile ( json , this . host , getDirectoryPath ( normalizeSlashes ( fileName ) ) ) ;
809+
810+ var realErrors = realizeDiagnostics ( configFile . errors , '\r\n' ) ;
811+
812+ return {
813+ options : configFile . options ,
814+ files : configFile . fileNames ,
815+ errors : realErrors
816+ } ;
817+ } ) ;
818+ }
819+
782820 public getDefaultCompilationSettings ( ) : string {
783821 return this . forwardJSONCall (
784822 "getDefaultCompilationSettings()" ,
@@ -821,12 +859,13 @@ module ts {
821859 }
822860 }
823861
824- public createCoreServicesShim ( logger : Logger ) : CoreServicesShim {
862+ public createCoreServicesShim ( host : CoreServicesShimHost ) : CoreServicesShim {
825863 try {
826- return new CoreServicesShimObject ( this , logger ) ;
864+ var adapter = new CoreServicesShimHostAdapter ( host ) ;
865+ return new CoreServicesShimObject ( this , < Logger > host , adapter ) ;
827866 }
828867 catch ( err ) {
829- logInternalError ( logger , err ) ;
868+ logInternalError ( < Logger > host , err ) ;
830869 throw err ;
831870 }
832871 }
0 commit comments