File tree Expand file tree Collapse file tree 5 files changed +72
-0
lines changed Expand file tree Collapse file tree 5 files changed +72
-0
lines changed Original file line number Diff line number Diff line change 790
790
"command" : " codeQL.trimCache" ,
791
791
"title" : " CodeQL: Trim Cache"
792
792
},
793
+ {
794
+ "command" : " codeQL.trimOverlayBaseCache" ,
795
+ "title" : " CodeQL: Trim Overlay Base Cache"
796
+ },
793
797
{
794
798
"command" : " codeQL.installPackDependencies" ,
795
799
"title" : " CodeQL: Install Pack Dependencies"
1817
1821
},
1818
1822
{
1819
1823
"command" : " codeQL.trimCache"
1824
+ },
1825
+ {
1826
+ "command" : " codeQL.trimOverlayBaseCache" ,
1827
+ "when" : " codeQL.cliFeatures.queryServerTrimCacheWithMode"
1820
1828
}
1821
1829
],
1822
1830
"editor/context" : [
Original file line number Diff line number Diff line change @@ -221,6 +221,7 @@ export type LocalDatabasesCommands = {
221
221
"codeQL.upgradeCurrentDatabase" : ( ) => Promise < void > ;
222
222
"codeQL.clearCache" : ( ) => Promise < void > ;
223
223
"codeQL.trimCache" : ( ) => Promise < void > ;
224
+ "codeQL.trimOverlayBaseCache" : ( ) => Promise < void > ;
224
225
225
226
// Explorer context menu
226
227
"codeQL.setCurrentDatabase" : ( uri : Uri ) => Promise < void > ;
Original file line number Diff line number Diff line change @@ -284,6 +284,7 @@ export class DatabaseUI extends DisposableObject {
284
284
this . handleUpgradeCurrentDatabase . bind ( this ) ,
285
285
"codeQL.clearCache" : this . handleClearCache . bind ( this ) ,
286
286
"codeQL.trimCache" : this . handleTrimCache . bind ( this ) ,
287
+ "codeQL.trimOverlayBaseCache" : this . handleTrimOverlayBaseCache . bind ( this ) ,
287
288
"codeQLDatabases.chooseDatabaseFolder" :
288
289
this . handleChooseDatabaseFolder . bind ( this ) ,
289
290
"codeQLDatabases.chooseDatabaseArchive" :
@@ -688,6 +689,25 @@ export class DatabaseUI extends DisposableObject {
688
689
) ;
689
690
}
690
691
692
+ private async handleTrimOverlayBaseCache ( ) : Promise < void > {
693
+ return withProgress (
694
+ async ( ) => {
695
+ if (
696
+ this . queryServer !== undefined &&
697
+ this . databaseManager . currentDatabaseItem !== undefined
698
+ ) {
699
+ await this . queryServer . trimCacheWithModeInDatabase (
700
+ this . databaseManager . currentDatabaseItem ,
701
+ "overlay" ,
702
+ ) ;
703
+ }
704
+ } ,
705
+ {
706
+ title : "Removing all overlay-dependent data from cache" ,
707
+ } ,
708
+ ) ;
709
+ }
710
+
691
711
private async handleGetCurrentDatabase ( ) : Promise < string | undefined > {
692
712
const dbItem = await this . getDatabaseItemInternal ( undefined ) ;
693
713
return dbItem ?. databaseUri . fsPath ;
Original file line number Diff line number Diff line change @@ -42,6 +42,22 @@ export interface TrimCacheParams {
42
42
db : string ;
43
43
}
44
44
45
+ /**
46
+ * Parameters for trimming the cache of a dataset with a specific mode.
47
+ */
48
+ export interface TrimCacheWithModeParams {
49
+ /**
50
+ * The dataset that we want to trim the cache of.
51
+ */
52
+ db : string ;
53
+ /**
54
+ * The cache cleanup mode to use.
55
+ */
56
+ mode : ClearCacheMode ;
57
+ }
58
+
59
+ export type ClearCacheMode = "clear" | "trim" | "fit" | "overlay" ;
60
+
45
61
/**
46
62
* The result of trimming or clearing the cache.
47
63
*/
@@ -193,6 +209,14 @@ export const trimCache = new RequestType<
193
209
ClearCacheResult ,
194
210
void
195
211
> ( "evaluation/trimCache" ) ;
212
+ /**
213
+ * Trim the cache of a dataset with a specific mode.
214
+ */
215
+ export const trimCacheWithMode = new RequestType <
216
+ WithProgressId < TrimCacheWithModeParams > ,
217
+ ClearCacheResult ,
218
+ void
219
+ > ( "evaluation/trimCacheWithMode" ) ;
196
220
197
221
/**
198
222
* Clear the pack cache
Original file line number Diff line number Diff line change @@ -6,17 +6,20 @@ import { UserCancellationException } from "../common/vscode/progress";
6
6
import type { DatabaseItem } from "../databases/local-databases/database-item" ;
7
7
import { QueryOutputDir } from "../local-queries/query-output-dir" ;
8
8
import type {
9
+ ClearCacheMode ,
9
10
ClearCacheParams ,
10
11
Position ,
11
12
QueryResultType ,
12
13
TrimCacheParams ,
14
+ TrimCacheWithModeParams ,
13
15
} from "./messages" ;
14
16
import {
15
17
clearCache ,
16
18
clearPackCache ,
17
19
deregisterDatabases ,
18
20
registerDatabases ,
19
21
trimCache ,
22
+ trimCacheWithMode ,
20
23
upgradeDatabase ,
21
24
} from "./messages" ;
22
25
import type { BaseLogger , Logger } from "../common/logging" ;
@@ -142,6 +145,22 @@ export class QueryRunner {
142
145
await this . qs . sendRequest ( trimCache , params ) ;
143
146
}
144
147
148
+ async trimCacheWithModeInDatabase (
149
+ dbItem : DatabaseItem ,
150
+ mode : ClearCacheMode ,
151
+ ) : Promise < void > {
152
+ if ( dbItem . contents === undefined ) {
153
+ throw new Error ( "Can't clean the cache in an invalid database." ) ;
154
+ }
155
+
156
+ const db = dbItem . databaseUri . fsPath ;
157
+ const params : TrimCacheWithModeParams = {
158
+ db,
159
+ mode,
160
+ } ;
161
+ await this . qs . sendRequest ( trimCacheWithMode , params ) ;
162
+ }
163
+
145
164
public async compileAndRunQueryAgainstDatabaseCore (
146
165
dbPath : string ,
147
166
queries : CoreQueryTarget [ ] ,
You can’t perform that action at this time.
0 commit comments