@@ -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,25 @@ 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+ let remoteCssConfig = vsc . workspace . getConfiguration ( 'css' ) ;
140+ let urls = remoteCssConfig . get ( 'remoteStyleSheets' ) as string [ ] ;
141+ urls . forEach ( url => parseRemote ( url ) ) ;
142+ }
143+
124144export function activate ( context : vsc . ExtensionContext ) {
125145
126146 if ( vsc . workspace . rootPath ) {
@@ -133,6 +153,8 @@ export function activate(context: vsc.ExtensionContext) {
133153 }
134154 } ) ;
135155
156+ parseRemoteConfig ( ) ;
157+
136158 let watcher = vsc . workspace . createFileSystemWatcher ( glob ) ;
137159
138160 watcher . onDidCreate ( function ( uri : vsc . Uri ) {
@@ -172,6 +194,9 @@ export function activate(context: vsc.ExtensionContext) {
172194 context . subscriptions . push ( vsc . languages . setLanguageConfiguration ( 'jade' , { wordPattern : wp } ) ) ;
173195 context . subscriptions . push ( vsc . languages . setLanguageConfiguration ( 'handlebars' , { wordPattern : wp } ) ) ;
174196 context . subscriptions . push ( vsc . languages . setLanguageConfiguration ( 'php' , { wordPattern : wp } ) ) ;
197+ context . subscriptions . push ( vsc . workspace . onDidChangeConfiguration ( e => {
198+ parseRemoteConfig ( ) ;
199+ } ) ) ;
175200}
176201
177202export function deactivate ( ) {
0 commit comments