@@ -7,6 +7,7 @@ import * as lst from 'vscode-languageserver-types';
77import * as css from 'vscode-css-languageservice' ;
88import * as fs from 'fs' ;
99import * as path from 'path' ;
10+ import * as https from 'https' ;
1011
1112let service = css . getCSSLanguageService ( ) ;
1213let map : { [ index : string ] : vsc . CompletionItem [ ] ; } = { } ;
@@ -121,6 +122,26 @@ function parse(uri: vsc.Uri): void {
121122 } ) ;
122123}
123124
125+ function parseRemote ( url : string ) {
126+ https . get ( url , res => {
127+ let styles = '' ;
128+ res . on ( 'data' , d => {
129+ styles += d . toString ( ) ;
130+ } ) . on ( 'end' , ( ) => {
131+ let doc = lst . TextDocument . create ( url , 'css' , 1 , styles ) ;
132+ let symbols = service . findDocumentSymbols ( doc , service . parseStylesheet ( doc ) ) ;
133+ pushSymbols ( url , symbols ) ;
134+ } ) ;
135+ } )
136+ }
137+
138+ function parseRemoteConfig ( ) {
139+ console . log ( 'parse remote' ) ;
140+ let remoteCssConfig = vsc . workspace . getConfiguration ( 'css' ) ;
141+ let urls = remoteCssConfig . get ( 'remoteStyleSheets' ) as string [ ] ;
142+ urls . forEach ( url => parseRemote ( url ) ) ;
143+ }
144+
124145export function activate ( context : vsc . ExtensionContext ) {
125146
126147 if ( vsc . workspace . rootPath ) {
@@ -133,6 +154,8 @@ export function activate(context: vsc.ExtensionContext) {
133154 }
134155 } ) ;
135156
157+ parseRemoteConfig ( ) ;
158+
136159 let watcher = vsc . workspace . createFileSystemWatcher ( glob ) ;
137160
138161 watcher . onDidCreate ( function ( uri : vsc . Uri ) {
@@ -172,6 +195,9 @@ export function activate(context: vsc.ExtensionContext) {
172195 context . subscriptions . push ( vsc . languages . setLanguageConfiguration ( 'jade' , { wordPattern : wp } ) ) ;
173196 context . subscriptions . push ( vsc . languages . setLanguageConfiguration ( 'handlebars' , { wordPattern : wp } ) ) ;
174197 context . subscriptions . push ( vsc . languages . setLanguageConfiguration ( 'php' , { wordPattern : wp } ) ) ;
198+ context . subscriptions . push ( vsc . workspace . onDidChangeConfiguration ( e => {
199+ parseRemoteConfig ( ) ;
200+ } ) ) ;
175201}
176202
177203export function deactivate ( ) {
0 commit comments