Skip to content

Commit 331d39a

Browse files
committed
Cache BQRS schemas in compare view
1 parent b6ba0bb commit 331d39a

File tree

2 files changed

+24
-25
lines changed

2 files changed

+24
-25
lines changed

extensions/ql-vscode/src/compare/compare-view.ts

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ import { findResultSetNames } from "./result-set-names";
3030

3131
interface ComparePair {
3232
from: CompletedLocalQueryInfo;
33+
fromSchemas: BQRSInfo;
3334
to: CompletedLocalQueryInfo;
35+
toSchemas: BQRSInfo;
3436
}
3537

3638
export class CompareView extends AbstractWebview<
@@ -57,7 +59,19 @@ export class CompareView extends AbstractWebview<
5759
to: CompletedLocalQueryInfo,
5860
selectedResultSetName?: string,
5961
) {
60-
this.comparePair = { from, to };
62+
const fromSchemas = await this.cliServer.bqrsInfo(
63+
from.completedQuery.query.resultsPaths.resultsPath,
64+
);
65+
const toSchemas = await this.cliServer.bqrsInfo(
66+
to.completedQuery.query.resultsPaths.resultsPath,
67+
);
68+
69+
this.comparePair = {
70+
from,
71+
fromSchemas,
72+
to,
73+
toSchemas,
74+
};
6175

6276
await this.showResultsInternal(selectedResultSetName);
6377
}
@@ -78,7 +92,10 @@ export class CompareView extends AbstractWebview<
7892
currentResultSetName,
7993
fromResultSet,
8094
toResultSet,
81-
] = await this.findCommonResultSetNames(from, to, selectedResultSetName);
95+
] = await this.findCommonResultSetNames(
96+
this.comparePair,
97+
selectedResultSetName,
98+
);
8299
if (currentResultSetName) {
83100
let rows: QueryCompareResult | undefined;
84101
let message: string | undefined;
@@ -178,23 +195,15 @@ export class CompareView extends AbstractWebview<
178195
}
179196

180197
private async findCommonResultSetNames(
181-
from: CompletedLocalQueryInfo,
182-
to: CompletedLocalQueryInfo,
198+
{ from, fromSchemas, to, toSchemas }: ComparePair,
183199
selectedResultSetName: string | undefined,
184200
): Promise<[string[], string, RawResultSet, RawResultSet]> {
185201
const {
186202
commonResultSetNames,
187203
currentResultSetDisplayName,
188-
fromSchemas,
189204
fromResultSetName,
190-
toSchemas,
191205
toResultSetName,
192-
} = await findResultSetNames(
193-
this.cliServer,
194-
from,
195-
to,
196-
selectedResultSetName,
197-
);
206+
} = await findResultSetNames(fromSchemas, toSchemas, selectedResultSetName);
198207

199208
const fromResultSet = await this.getResultSet(
200209
fromSchemas,

extensions/ql-vscode/src/compare/result-set-names.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
1-
import { CompletedLocalQueryInfo } from "../query-results";
2-
import { CodeQLCliServer } from "../codeql-cli/cli";
1+
import { BQRSInfo } from "../common/bqrs-cli-types";
32

43
export async function findResultSetNames(
5-
cliServer: CodeQLCliServer,
6-
from: CompletedLocalQueryInfo,
7-
to: CompletedLocalQueryInfo,
4+
fromSchemas: BQRSInfo,
5+
toSchemas: BQRSInfo,
86
selectedResultSetName: string | undefined,
97
) {
10-
const fromSchemas = await cliServer.bqrsInfo(
11-
from.completedQuery.query.resultsPaths.resultsPath,
12-
);
13-
const toSchemas = await cliServer.bqrsInfo(
14-
to.completedQuery.query.resultsPaths.resultsPath,
15-
);
168
const fromSchemaNames = fromSchemas["result-sets"].map(
179
(schema) => schema.name,
1810
);
@@ -47,9 +39,7 @@ export async function findResultSetNames(
4739
currentResultSetDisplayName:
4840
currentResultSetName ||
4941
`${defaultFromResultSetName} <-> ${defaultToResultSetName}`,
50-
fromSchemas,
5142
fromResultSetName,
52-
toSchemas,
5343
toResultSetName,
5444
};
5545
}

0 commit comments

Comments
 (0)