@@ -25,6 +25,19 @@ export class ServiceProvider {
25
25
Map < string , ServiceReturnType < ServiceType > >
26
26
> = new Map ( ) ;
27
27
28
+ /**
29
+ * Checks if the service is available to be created and returned from the {@link getService} method.
30
+ * Specifically, this method checks if there even is a command associated with the specified
31
+ * @{link ServiceType} registered within VS Code.
32
+ * @param type - The type of the service.
33
+ * @returns The value true if the service is available and false otherwise.
34
+ */
35
+ static async isServiceAvailable < T extends ServiceType > (
36
+ type : T
37
+ ) : Promise < boolean > {
38
+ return ( await this . getCommands ( ) ) . includes ( this . getCommandString ( type ) ) ;
39
+ }
40
+
28
41
/**
29
42
* Retrieves a service instance of the specified type and instance name.
30
43
* If the service instance does not exist, it will be created.
@@ -99,7 +112,7 @@ export class ServiceProvider {
99
112
}
100
113
101
114
/**
102
- * Checks if a service of the specified type exists.
115
+ * Checks if a service of the specified type exists yet within the cache of the ServiceProvider .
103
116
* @param type - The type of the service.
104
117
* @returns True if the service exists, false otherwise.
105
118
*/
@@ -108,7 +121,7 @@ export class ServiceProvider {
108
121
}
109
122
110
123
/**
111
- * Checks if a service instance of the specified type and instance name exists.
124
+ * Checks if a service instance of the specified type and instance name exists yet within the cache of the ServiceProvider .
112
125
* @param type - The type of the service.
113
126
* @param instanceName - The name of the service instance.
114
127
* @returns True if the service instance exists, false otherwise.
0 commit comments