Skip to content

Commit 80f588c

Browse files
Merge pull request #1971 from github/elena/rename-splat-slurp
Rename `splat/slurp` to `serialize/deserialize`
2 parents 4cb3c4c + 57b6c9b commit 80f588c

6 files changed

Lines changed: 25 additions & 20 deletions

File tree

extensions/ql-vscode/src/legacy-query-server/run-queries.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { QueryEvaluationInfo, QueryWithResults } from "../run-queries-shared";
3636
export class QueryInProgress {
3737
public queryEvalInfo: QueryEvaluationInfo;
3838
/**
39-
* Note that in the {@link slurpQueryHistory} method, we create a QueryEvaluationInfo instance
39+
* Note that in the {@link deserializeQueryHistory} method, we create a QueryEvaluationInfo instance
4040
* by explicitly setting the prototype in order to avoid calling this constructor.
4141
*/
4242
constructor(

extensions/ql-vscode/src/query-history.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ import {
4747
QueryStatus,
4848
variantAnalysisStatusToQueryStatus,
4949
} from "./query-status";
50-
import { slurpQueryHistory, splatQueryHistory } from "./query-serialization";
50+
import {
51+
deserializeQueryHistory,
52+
serializeQueryHistory,
53+
} from "./query-serialization";
5154
import { pathExists } from "fs-extra";
5255
import { CliVersionConstraint } from "./cli";
5356
import { HistoryItemLabelProvider } from "./history-item-label-provider";
@@ -787,7 +790,9 @@ export class QueryHistoryManager extends DisposableObject {
787790
void extLogger.log(
788791
`Reading cached query history from '${this.queryMetadataStorageLocation}'.`,
789792
);
790-
const history = await slurpQueryHistory(this.queryMetadataStorageLocation);
793+
const history = await deserializeQueryHistory(
794+
this.queryMetadataStorageLocation,
795+
);
791796
this.treeDataProvider.allHistory = history;
792797
await Promise.all(
793798
this.treeDataProvider.allHistory.map(async (item) => {
@@ -808,7 +813,7 @@ export class QueryHistoryManager extends DisposableObject {
808813
}
809814

810815
async writeQueryHistory(): Promise<void> {
811-
await splatQueryHistory(
816+
await serializeQueryHistory(
812817
this.treeDataProvider.allHistory,
813818
this.queryMetadataStorageLocation,
814819
);

extensions/ql-vscode/src/query-results.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class CompletedQueryInfo implements QueryWithResults {
7575
interpretedResultsSortState: InterpretedResultsSortState | undefined;
7676

7777
/**
78-
* Note that in the {@link slurpQueryHistory} method, we create a CompletedQueryInfo instance
78+
* Note that in the {@link deserializeQueryHistory} method, we create a CompletedQueryInfo instance
7979
* by explicitly setting the prototype in order to avoid calling this constructor.
8080
*/
8181
constructor(evaluation: QueryWithResults) {
@@ -233,7 +233,7 @@ export class LocalQueryInfo {
233233
public evalLogSummarySymbolsLocation: string | undefined;
234234

235235
/**
236-
* Note that in the {@link slurpQueryHistory} method, we create a FullQueryInfo instance
236+
* Note that in the {@link deserializeQueryHistory} method, we create a FullQueryInfo instance
237237
* by explicitly setting the prototype in order to avoid calling this constructor.
238238
*/
239239
constructor(

extensions/ql-vscode/src/query-serialization.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { QueryStatus } from "./query-status";
1313
import { QueryEvaluationInfo } from "./run-queries-shared";
1414
import { QueryResultType } from "./pure/legacy-messages";
1515

16-
export async function slurpQueryHistory(
16+
export async function deserializeQueryHistory(
1717
fsPath: string,
1818
): Promise<QueryHistoryInfo[]> {
1919
try {
@@ -48,7 +48,7 @@ export async function slurpQueryHistory(
4848
q.completedQuery.query,
4949
QueryEvaluationInfo.prototype,
5050
);
51-
// slurped queries do not need to be disposed
51+
// deserialized queries do not need to be disposed
5252
q.completedQuery.dispose = () => {
5353
/**/
5454
};
@@ -83,7 +83,7 @@ export async function slurpQueryHistory(
8383
// queries aged out.
8484
return asyncFilter(parsedQueries, async (q) => {
8585
if (q.t === "remote" || q.t === "variant-analysis") {
86-
// the slurper doesn't know where the remote queries are stored
86+
// the deserializer doesn't know where the remote queries are stored
8787
// so we need to assume here that they exist. Later, we check to
8888
// see if they exist on disk.
8989
return true;
@@ -112,7 +112,7 @@ export async function slurpQueryHistory(
112112
* @param queries the list of queries to save.
113113
* @param fsPath the path to save the queries to.
114114
*/
115-
export async function splatQueryHistory(
115+
export async function serializeQueryHistory(
116116
queries: QueryHistoryInfo[],
117117
fsPath: string,
118118
): Promise<void> {

extensions/ql-vscode/src/run-queries-shared.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function findQueryEvalLogEndSummaryFile(resultPath: string): string {
6868

6969
export class QueryEvaluationInfo {
7070
/**
71-
* Note that in the {@link slurpQueryHistory} method, we create a QueryEvaluationInfo instance
71+
* Note that in the {@link deserializeQueryHistory} method, we create a QueryEvaluationInfo instance
7272
* by explicitly setting the prototype in order to avoid calling this constructor.
7373
*/
7474
constructor(

extensions/ql-vscode/test/vscode-tests/no-workspace/query-results.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import { CodeQLCliServer, SourceInfo } from "../../../src/cli";
2222
import { CancellationTokenSource, Uri } from "vscode";
2323
import { tmpDir } from "../../../src/helpers";
2424
import {
25-
slurpQueryHistory,
26-
splatQueryHistory,
25+
deserializeQueryHistory,
26+
serializeQueryHistory,
2727
} from "../../../src/query-serialization";
2828
import {
2929
formatLegacyMessage,
@@ -438,7 +438,7 @@ describe("query-results", () => {
438438
);
439439
});
440440

441-
describe("splat and slurp", () => {
441+
describe("serialize and deserialize", () => {
442442
let infoSuccessRaw: LocalQueryInfo;
443443
let infoSuccessInterpreted: LocalQueryInfo;
444444
let infoEarlyFailure: LocalQueryInfo;
@@ -488,7 +488,7 @@ describe("query-results", () => {
488488
];
489489
});
490490

491-
it("should splat and slurp query history", async () => {
491+
it("should serialize and deserialize query history", async () => {
492492
// the expected results only contains the history with completed queries
493493
const expectedHistory = [
494494
infoSuccessRaw,
@@ -498,17 +498,17 @@ describe("query-results", () => {
498498

499499
const allHistoryPath = join(tmpDir.name, "workspace-query-history.json");
500500

501-
// splat and slurp
502-
await splatQueryHistory(allHistory, allHistoryPath);
503-
const allHistoryActual = await slurpQueryHistory(allHistoryPath);
501+
// serialize and deserialize
502+
await serializeQueryHistory(allHistory, allHistoryPath);
503+
const allHistoryActual = await deserializeQueryHistory(allHistoryPath);
504504

505505
// the dispose methods will be different. Ignore them.
506506
allHistoryActual.forEach((info) => {
507507
if (info.t === "local" && info.completedQuery) {
508508
const completedQuery = info.completedQuery;
509509
(completedQuery as any).dispose = undefined;
510510

511-
// these fields should be missing on the slurped value
511+
// these fields should be missing on the deserialized value
512512
// but they are undefined on the original value
513513
if (!("logFileLocation" in completedQuery)) {
514514
(completedQuery as any).logFileLocation = undefined;
@@ -543,7 +543,7 @@ describe("query-results", () => {
543543
"utf8",
544544
);
545545

546-
const allHistoryActual = await slurpQueryHistory(badPath);
546+
const allHistoryActual = await deserializeQueryHistory(badPath);
547547
// version number is invalid. Should return an empty array.
548548
expect(allHistoryActual).toEqual([]);
549549
});

0 commit comments

Comments
 (0)