@@ -278,10 +278,16 @@ export class WorkspaceD extends EventEmitter implements
278278 return this . request ( { cmd : "dub" , subcmd : "list:configurations" } ) ;
279279 }
280280
281+ getConfiguration ( ) : Thenable < string > {
282+ return this . request ( { cmd : "dub" , subcmd : "get:configuration" } ) ;
283+ }
284+
281285 setConfiguration ( config : string ) {
282286 this . request ( { cmd : "dub" , subcmd : "set:configuration" , configuration : config } ) . then ( ( success ) => {
283- if ( success )
287+ if ( success ) {
284288 this . request ( { cmd : "dub" , subcmd : "list:import" } ) . then ( console . log ) ;
289+ this . emit ( "configuration-change" , config ) ;
290+ }
285291 else
286292 vscode . window . showInformationMessage ( "No import paths available for this project. Autocompletion could be broken!" , "Switch Configuration" ) . then ( ( s ) => {
287293 if ( s == "Switch Configuration" ) {
@@ -291,6 +297,29 @@ export class WorkspaceD extends EventEmitter implements
291297 } ) ;
292298 }
293299
300+ listBuildTypes ( ) : Thenable < string [ ] > {
301+ return this . request ( { cmd : "dub" , subcmd : "list:build-types" } ) ;
302+ }
303+
304+ getBuildType ( ) : Thenable < string > {
305+ return this . request ( { cmd : "dub" , subcmd : "get:build-type" } ) ;
306+ }
307+
308+ setBuildType ( config : string ) {
309+ this . request ( { cmd : "dub" , subcmd : "set:build-type" , "build-type" : config } ) . then ( ( success ) => {
310+ if ( success ) {
311+ this . request ( { cmd : "dub" , subcmd : "list:import" } ) . then ( console . log ) ;
312+ this . emit ( "build-type-change" , config ) ;
313+ }
314+ else
315+ vscode . window . showInformationMessage ( "No import paths available for this build type. Autocompletion could be broken!" , "Switch Build Type" ) . then ( ( s ) => {
316+ if ( s == "Switch Build Type" ) {
317+ vscode . commands . executeCommand ( "code-d.switchBuildType" ) ;
318+ }
319+ } ) ;
320+ } ) ;
321+ }
322+
294323 killServer ( ) : Thenable < any > {
295324 if ( ! this . dcdReady )
296325 return new Promise ( ( resolve , reject ) => { reject ( ) ; } ) ;
@@ -338,6 +367,7 @@ export class WorkspaceD extends EventEmitter implements
338367 this . request ( { cmd : "load" , components : [ "dub" ] , dir : this . projectRoot } ) . then ( ( data ) => {
339368 console . log ( "dub is ready" ) ;
340369 self . dubReady = true ;
370+ self . emit ( "dub-ready" ) ;
341371 self . setupDCD ( ) ;
342372 self . setupDScanner ( ) ;
343373 self . setupDfmt ( ) ;
@@ -357,6 +387,7 @@ export class WorkspaceD extends EventEmitter implements
357387 let self = this ;
358388 this . request ( { cmd : "load" , components : [ "dscanner" ] , dir : this . projectRoot , dscannerPath : config ( ) . get ( "dscannerPath" , "dscanner" ) } ) . then ( ( data ) => {
359389 console . log ( "DScanner is ready" ) ;
390+ self . emit ( "dscanner-ready" ) ;
360391 self . dscannerReady = true ;
361392 } ) ;
362393 }
@@ -381,6 +412,7 @@ export class WorkspaceD extends EventEmitter implements
381412 let self = this ;
382413 this . request ( { cmd : "load" , components : [ "dfmt" ] , dir : this . projectRoot , dfmtPath : config ( ) . get ( "dfmtPath" , "dfmt" ) } ) . then ( ( data ) => {
383414 console . log ( "Dfmt is ready" ) ;
415+ self . emit ( "dfmt-ready" ) ;
384416 self . dfmtReady = true ;
385417 } ) ;
386418 }
@@ -413,6 +445,7 @@ export class WorkspaceD extends EventEmitter implements
413445 this . request ( { cmd : "dcd" , subcmd : "setup-server" } ) . then ( ( data ) => {
414446 this . request ( { cmd : "dcd" , subcmd : "add-imports" , imports : [ "/usr/include/dmd/druntime/import" , "/usr/include/dmd/phobos" ] } ) . then ( ( data ) => {
415447 console . log ( "DCD is ready" ) ;
448+ this . emit ( "dcd-ready" ) ;
416449 this . dcdReady = true ;
417450 } , ( err ) => {
418451 vscode . window . showErrorMessage ( "Could not initialize DCD. See console for details!" ) ;
0 commit comments