11/// <reference path="harness.ts" />
22/// <reference path="..\compiler\commandLineParser.ts"/>
33namespace Utils {
4- export class VirtualFileSystemEntry < T > {
5- fileSystem : VirtualFileSystem < T > ;
4+ export class VirtualFileSystemEntry {
5+ fileSystem : VirtualFileSystem ;
66 name : string ;
77
8- constructor ( fileSystem : VirtualFileSystem < T > , name : string ) {
8+ constructor ( fileSystem : VirtualFileSystem , name : string ) {
99 this . fileSystem = fileSystem ;
1010 this . name = name ;
1111 }
@@ -15,15 +15,15 @@ namespace Utils {
1515 isFileSystem ( ) { return false ; }
1616 }
1717
18- export class VirtualFile < T > extends VirtualFileSystemEntry < T > {
19- content : T ;
18+ export class VirtualFile extends VirtualFileSystemEntry {
19+ content ?: Harness . LanguageService . ScriptInfo ;
2020 isFile ( ) { return true ; }
2121 }
2222
23- export abstract class VirtualFileSystemContainer < T > extends VirtualFileSystemEntry < T > {
24- abstract getFileSystemEntries ( ) : VirtualFileSystemEntry < T > [ ] ;
23+ export abstract class VirtualFileSystemContainer extends VirtualFileSystemEntry {
24+ abstract getFileSystemEntries ( ) : VirtualFileSystemEntry [ ] ;
2525
26- getFileSystemEntry ( name : string ) : VirtualFileSystemEntry < T > {
26+ getFileSystemEntry ( name : string ) : VirtualFileSystemEntry {
2727 for ( const entry of this . getFileSystemEntries ( ) ) {
2828 if ( this . fileSystem . sameName ( entry . name , name ) ) {
2929 return entry ;
@@ -32,57 +32,57 @@ namespace Utils {
3232 return undefined ;
3333 }
3434
35- getDirectories ( ) : VirtualDirectory < T > [ ] {
36- return < VirtualDirectory < T > [ ] > ts . filter ( this . getFileSystemEntries ( ) , entry => entry . isDirectory ( ) ) ;
35+ getDirectories ( ) : VirtualDirectory [ ] {
36+ return < VirtualDirectory [ ] > ts . filter ( this . getFileSystemEntries ( ) , entry => entry . isDirectory ( ) ) ;
3737 }
3838
39- getFiles ( ) : VirtualFile < T > [ ] {
40- return < VirtualFile < T > [ ] > ts . filter ( this . getFileSystemEntries ( ) , entry => entry . isFile ( ) ) ;
39+ getFiles ( ) : VirtualFile [ ] {
40+ return < VirtualFile [ ] > ts . filter ( this . getFileSystemEntries ( ) , entry => entry . isFile ( ) ) ;
4141 }
4242
43- getDirectory ( name : string ) : VirtualDirectory < T > {
43+ getDirectory ( name : string ) : VirtualDirectory {
4444 const entry = this . getFileSystemEntry ( name ) ;
45- return entry . isDirectory ( ) ? < VirtualDirectory < T > > entry : undefined ;
45+ return entry . isDirectory ( ) ? < VirtualDirectory > entry : undefined ;
4646 }
4747
48- getFile ( name : string ) : VirtualFile < T > {
48+ getFile ( name : string ) : VirtualFile {
4949 const entry = this . getFileSystemEntry ( name ) ;
50- return entry . isFile ( ) ? < VirtualFile < T > > entry : undefined ;
50+ return entry . isFile ( ) ? < VirtualFile > entry : undefined ;
5151 }
5252 }
5353
54- export class VirtualDirectory < T > extends VirtualFileSystemContainer < T > {
55- private entries : VirtualFileSystemEntry < T > [ ] = [ ] ;
54+ export class VirtualDirectory extends VirtualFileSystemContainer {
55+ private entries : VirtualFileSystemEntry [ ] = [ ] ;
5656
5757 isDirectory ( ) { return true ; }
5858
5959 getFileSystemEntries ( ) { return this . entries . slice ( ) ; }
6060
61- addDirectory ( name : string ) : VirtualDirectory < T > {
61+ addDirectory ( name : string ) : VirtualDirectory {
6262 const entry = this . getFileSystemEntry ( name ) ;
6363 if ( entry === undefined ) {
64- const directory = new VirtualDirectory < T > ( this . fileSystem , name ) ;
64+ const directory = new VirtualDirectory ( this . fileSystem , name ) ;
6565 this . entries . push ( directory ) ;
6666 return directory ;
6767 }
6868 else if ( entry . isDirectory ( ) ) {
69- return < VirtualDirectory < T > > entry ;
69+ return < VirtualDirectory > entry ;
7070 }
7171 else {
7272 return undefined ;
7373 }
7474 }
7575
76- addFile ( name : string , content ?: T ) : VirtualFile < T > {
76+ addFile ( name : string , content ?: Harness . LanguageService . ScriptInfo ) : VirtualFile {
7777 const entry = this . getFileSystemEntry ( name ) ;
7878 if ( entry === undefined ) {
79- const file = new VirtualFile < T > ( this . fileSystem , name ) ;
79+ const file = new VirtualFile ( this . fileSystem , name ) ;
8080 file . content = content ;
8181 this . entries . push ( file ) ;
8282 return file ;
8383 }
8484 else if ( entry . isFile ( ) ) {
85- const file = < VirtualFile < T > > entry ;
85+ const file = < VirtualFile > entry ;
8686 file . content = content ;
8787 return file ;
8888 }
@@ -92,16 +92,16 @@ namespace Utils {
9292 }
9393 }
9494
95- export class VirtualFileSystem < T > extends VirtualFileSystemContainer < T > {
96- private root : VirtualDirectory < T > ;
95+ export class VirtualFileSystem extends VirtualFileSystemContainer {
96+ private root : VirtualDirectory ;
9797
9898 currentDirectory : string ;
9999 useCaseSensitiveFileNames : boolean ;
100100
101101 constructor ( currentDirectory : string , useCaseSensitiveFileNames : boolean ) {
102102 super ( undefined , "" ) ;
103103 this . fileSystem = this ;
104- this . root = new VirtualDirectory < T > ( this , "" ) ;
104+ this . root = new VirtualDirectory ( this , "" ) ;
105105 this . currentDirectory = currentDirectory ;
106106 this . useCaseSensitiveFileNames = useCaseSensitiveFileNames ;
107107 }
@@ -111,9 +111,9 @@ namespace Utils {
111111 getFileSystemEntries ( ) { return this . root . getFileSystemEntries ( ) ; }
112112
113113 addDirectory ( path : string ) {
114- path = this . normalizePathRoot ( path ) ;
114+ path = ts . normalizePath ( path ) ;
115115 const components = ts . getNormalizedPathComponents ( path , this . currentDirectory ) ;
116- let directory : VirtualDirectory < T > = this . root ;
116+ let directory : VirtualDirectory = this . root ;
117117 for ( const component of components ) {
118118 directory = directory . addDirectory ( component ) ;
119119 if ( directory === undefined ) {
@@ -124,8 +124,8 @@ namespace Utils {
124124 return directory ;
125125 }
126126
127- addFile ( path : string , content ?: T ) {
128- const absolutePath = this . normalizePathRoot ( ts . getNormalizedAbsolutePath ( path , this . currentDirectory ) ) ;
127+ addFile ( path : string , content ?: Harness . LanguageService . ScriptInfo ) {
128+ const absolutePath = ts . normalizePath ( ts . getNormalizedAbsolutePath ( path , this . currentDirectory ) ) ;
129129 const fileName = ts . getBaseFileName ( path ) ;
130130 const directoryPath = ts . getDirectoryPath ( absolutePath ) ;
131131 const directory = this . addDirectory ( directoryPath ) ;
@@ -142,15 +142,15 @@ namespace Utils {
142142 }
143143
144144 traversePath ( path : string ) {
145- path = this . normalizePathRoot ( path ) ;
146- let directory : VirtualDirectory < T > = this . root ;
145+ path = ts . normalizePath ( path ) ;
146+ let directory : VirtualDirectory = this . root ;
147147 for ( const component of ts . getNormalizedPathComponents ( path , this . currentDirectory ) ) {
148148 const entry = directory . getFileSystemEntry ( component ) ;
149149 if ( entry === undefined ) {
150150 return undefined ;
151151 }
152152 else if ( entry . isDirectory ( ) ) {
153- directory = < VirtualDirectory < T > > entry ;
153+ directory = < VirtualDirectory > entry ;
154154 }
155155 else {
156156 return entry ;
@@ -168,7 +168,7 @@ namespace Utils {
168168 getAccessibleFileSystemEntries ( path : string ) {
169169 const entry = this . traversePath ( path ) ;
170170 if ( entry && entry . isDirectory ( ) ) {
171- const directory = < VirtualDirectory < T > > entry ;
171+ const directory = < VirtualDirectory > entry ;
172172 return {
173173 files : ts . map ( directory . getFiles ( ) , f => f . name ) ,
174174 directories : ts . map ( directory . getDirectories ( ) , d => d . name )
@@ -178,11 +178,11 @@ namespace Utils {
178178 }
179179
180180 getAllFileEntries ( ) {
181- const fileEntries : VirtualFile < T > [ ] = [ ] ;
181+ const fileEntries : VirtualFile [ ] = [ ] ;
182182 getFilesRecursive ( this . root , fileEntries ) ;
183183 return fileEntries ;
184184
185- function getFilesRecursive ( dir : VirtualDirectory < T > , result : VirtualFile < T > [ ] ) {
185+ function getFilesRecursive ( dir : VirtualDirectory , result : VirtualFile [ ] ) {
186186 const files = dir . getFiles ( ) ;
187187 const dirs = dir . getDirectories ( ) ;
188188 for ( const file of files ) {
@@ -193,17 +193,9 @@ namespace Utils {
193193 }
194194 }
195195 }
196-
197- normalizePathRoot ( path : string ) {
198- const components = ts . getNormalizedPathComponents ( path , this . currentDirectory ) ;
199-
200- // Toss the root component
201- components [ 0 ] = "" ;
202- return components . join ( ts . directorySeparator ) ;
203- }
204196 }
205197
206- export class MockParseConfigHost extends VirtualFileSystem < string > implements ts . ParseConfigHost {
198+ export class MockParseConfigHost extends VirtualFileSystem implements ts . ParseConfigHost {
207199 constructor ( currentDirectory : string , ignoreCase : boolean , files : string [ ] ) {
208200 super ( currentDirectory , ignoreCase ) ;
209201 for ( const file of files ) {
0 commit comments