@@ -25,6 +25,14 @@ import {
2525} from './taskProviders' ;
2626import { isAbsolute } from 'path' ;
2727
28+ /**
29+ * Return type of the 'als-source-dirs' LSP request.
30+ */
31+ export type ALSSourceDirDescription = {
32+ name : string ;
33+ uri : string ;
34+ } ;
35+
2836/**
2937 * This class encapsulates all state that should be maintained throughout the
3038 * lifecyle of the extension. This includes e.g. the Ada and GPR LSP clients,
@@ -56,6 +64,7 @@ export class ExtensionState {
5664 */
5765 cachedProjectUri : vscode . Uri | undefined ;
5866 cachedObjectDir : string | undefined ;
67+ cachedSourceDirs : ALSSourceDirDescription [ ] | undefined ;
5968 cachedTargetPrefix : string | undefined ;
6069 cachedMains : string [ ] | undefined ;
6170 cachedExecutables : string [ ] | undefined ;
@@ -68,6 +77,7 @@ export class ExtensionState {
6877 private clearALSCache ( ) {
6978 this . cachedProjectUri = undefined ;
7079 this . cachedObjectDir = undefined ;
80+ this . cachedSourceDirs = undefined ;
7181 this . cachedTargetPrefix = undefined ;
7282 this . cachedMains = undefined ;
7383 this . cachedExecutables = undefined ;
@@ -381,6 +391,20 @@ export class ExtensionState {
381391 return this . cachedObjectDir ;
382392 }
383393
394+ /**
395+ *
396+ * @returns the list of source directorues defined in the project loaded by the ALS
397+ */
398+ public async getSourceDirs ( ) : Promise < ALSSourceDirDescription [ ] > {
399+ if ( this . cachedSourceDirs === undefined ) {
400+ this . cachedSourceDirs = ( await this . adaClient . sendRequest ( ExecuteCommandRequest . type , {
401+ command : 'als-source-dirs' ,
402+ } ) ) as ALSSourceDirDescription [ ] ;
403+ }
404+
405+ return this . cachedSourceDirs ;
406+ }
407+
384408 /**
385409 *
386410 * @returns the list of full paths of main sources defined in the project from the ALS
0 commit comments