@@ -141,7 +141,7 @@ class ClassServer implements vsc.CompletionItemProvider {
141141 }
142142}
143143
144- function pushSymbols ( key : string , symbols : lst . SymbolInformation [ ] ) {
144+ function pushSymbols ( key : string , symbols : lst . SymbolInformation [ ] ) : void {
145145 let ci : vsc . CompletionItem [ ] = [ ] ;
146146 for ( let i = 0 ; i < symbols . length ; i ++ ) {
147147 if ( symbols [ i ] . kind !== 5 ) {
@@ -156,7 +156,7 @@ function pushSymbols(key: string, symbols: lst.SymbolInformation[]) {
156156 map [ key ] = ci ;
157157}
158158
159- function parse ( uri : vsc . Uri ) {
159+ function parse ( uri : vsc . Uri ) : void {
160160 fs . readFile ( uri . fsPath , 'utf8' , function ( err : any , data : string ) {
161161 if ( err ) {
162162 delete map [ uri . fsPath ] ;
@@ -168,45 +168,31 @@ function parse(uri: vsc.Uri) {
168168 } ) ;
169169}
170170
171- function parseResource ( resource : any ) : string {
172- let glob = ''
173- let count = 0 ;
174- for ( let key in resource . css ) {
175- for ( let item of resource . css [ key ] ) {
176- glob += item + ',' ;
177- count ++ ;
178- }
179- }
180- if ( count > 0 ) {
181- glob = glob . slice ( 0 , - 1 ) ;
182- }
183- if ( count > 1 ) {
184- glob = '{' + glob + '}' ;
185- }
186- return glob ;
187- }
188-
189171export function activate ( context : vsc . ExtensionContext ) {
190172
191173 if ( vsc . workspace . rootPath ) {
192174 let resourceJson = path . resolve ( vsc . workspace . rootPath , 'resource.json' ) ;
193175
194176 fs . readFile ( resourceJson , 'utf8' , function ( err : any , data : string ) {
195- let glob : string ;
177+ let glob = '**/*.css' ;
196178
197179 if ( err ) {
198- glob = '**/*.css' ;
180+ vsc . workspace . findFiles ( glob , '' ) . then ( function ( uris : vsc . Uri [ ] ) {
181+ for ( let i = 0 ; i < uris . length ; i ++ ) {
182+ parse ( uris [ i ] ) ;
183+ }
184+ } ) ;
199185 } else {
200- glob = parseResource ( JSON . parse ( data ) ) ;
201- }
186+ let resources = JSON . parse ( data ) ;
202187
203- vsc . workspace . findFiles ( glob , '' ) . then ( function ( uris : vsc . Uri [ ] ) {
204- for ( let i = 0 ; i < uris . length ; i ++ ) {
205- parse ( uris [ i ] ) ;
188+ for ( let key in resources . css ) {
189+ for ( let resource of resources . css [ key ] ) {
190+ parse ( vsc . Uri . file ( path . resolve ( vsc . workspace . rootPath , resource ) ) ) ;
191+ }
206192 }
207- } ) ;
193+ }
208194
209- let watcher = vsc . workspace . createFileSystemWatcher ( glob ) ;
195+ let watcher = vsc . workspace . createFileSystemWatcher ( glob ) ; // TODO
210196
211197 watcher . onDidCreate ( parse ) ;
212198 watcher . onDidChange ( parse ) ;
0 commit comments