Merge pull request #1971 from github/elena/rename-splat-slurp
Rename `splat/slurp` to `serialize/deserialize`
This commit is contained in:
@@ -36,7 +36,7 @@ import { QueryEvaluationInfo, QueryWithResults } from "../run-queries-shared";
|
||||
export class QueryInProgress {
|
||||
public queryEvalInfo: QueryEvaluationInfo;
|
||||
/**
|
||||
* Note that in the {@link slurpQueryHistory} method, we create a QueryEvaluationInfo instance
|
||||
* Note that in the {@link deserializeQueryHistory} method, we create a QueryEvaluationInfo instance
|
||||
* by explicitly setting the prototype in order to avoid calling this constructor.
|
||||
*/
|
||||
constructor(
|
||||
|
||||
@@ -47,7 +47,10 @@ import {
|
||||
QueryStatus,
|
||||
variantAnalysisStatusToQueryStatus,
|
||||
} from "./query-status";
|
||||
import { slurpQueryHistory, splatQueryHistory } from "./query-serialization";
|
||||
import {
|
||||
deserializeQueryHistory,
|
||||
serializeQueryHistory,
|
||||
} from "./query-serialization";
|
||||
import { pathExists } from "fs-extra";
|
||||
import { CliVersionConstraint } from "./cli";
|
||||
import { HistoryItemLabelProvider } from "./history-item-label-provider";
|
||||
@@ -787,7 +790,9 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
void extLogger.log(
|
||||
`Reading cached query history from '${this.queryMetadataStorageLocation}'.`,
|
||||
);
|
||||
const history = await slurpQueryHistory(this.queryMetadataStorageLocation);
|
||||
const history = await deserializeQueryHistory(
|
||||
this.queryMetadataStorageLocation,
|
||||
);
|
||||
this.treeDataProvider.allHistory = history;
|
||||
await Promise.all(
|
||||
this.treeDataProvider.allHistory.map(async (item) => {
|
||||
@@ -808,7 +813,7 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
}
|
||||
|
||||
async writeQueryHistory(): Promise<void> {
|
||||
await splatQueryHistory(
|
||||
await serializeQueryHistory(
|
||||
this.treeDataProvider.allHistory,
|
||||
this.queryMetadataStorageLocation,
|
||||
);
|
||||
|
||||
@@ -75,7 +75,7 @@ export class CompletedQueryInfo implements QueryWithResults {
|
||||
interpretedResultsSortState: InterpretedResultsSortState | undefined;
|
||||
|
||||
/**
|
||||
* Note that in the {@link slurpQueryHistory} method, we create a CompletedQueryInfo instance
|
||||
* Note that in the {@link deserializeQueryHistory} method, we create a CompletedQueryInfo instance
|
||||
* by explicitly setting the prototype in order to avoid calling this constructor.
|
||||
*/
|
||||
constructor(evaluation: QueryWithResults) {
|
||||
@@ -233,7 +233,7 @@ export class LocalQueryInfo {
|
||||
public evalLogSummarySymbolsLocation: string | undefined;
|
||||
|
||||
/**
|
||||
* Note that in the {@link slurpQueryHistory} method, we create a FullQueryInfo instance
|
||||
* Note that in the {@link deserializeQueryHistory} method, we create a FullQueryInfo instance
|
||||
* by explicitly setting the prototype in order to avoid calling this constructor.
|
||||
*/
|
||||
constructor(
|
||||
|
||||
@@ -13,7 +13,7 @@ import { QueryStatus } from "./query-status";
|
||||
import { QueryEvaluationInfo } from "./run-queries-shared";
|
||||
import { QueryResultType } from "./pure/legacy-messages";
|
||||
|
||||
export async function slurpQueryHistory(
|
||||
export async function deserializeQueryHistory(
|
||||
fsPath: string,
|
||||
): Promise<QueryHistoryInfo[]> {
|
||||
try {
|
||||
@@ -48,7 +48,7 @@ export async function slurpQueryHistory(
|
||||
q.completedQuery.query,
|
||||
QueryEvaluationInfo.prototype,
|
||||
);
|
||||
// slurped queries do not need to be disposed
|
||||
// deserialized queries do not need to be disposed
|
||||
q.completedQuery.dispose = () => {
|
||||
/**/
|
||||
};
|
||||
@@ -83,7 +83,7 @@ export async function slurpQueryHistory(
|
||||
// queries aged out.
|
||||
return asyncFilter(parsedQueries, async (q) => {
|
||||
if (q.t === "remote" || q.t === "variant-analysis") {
|
||||
// the slurper doesn't know where the remote queries are stored
|
||||
// the deserializer doesn't know where the remote queries are stored
|
||||
// so we need to assume here that they exist. Later, we check to
|
||||
// see if they exist on disk.
|
||||
return true;
|
||||
@@ -112,7 +112,7 @@ export async function slurpQueryHistory(
|
||||
* @param queries the list of queries to save.
|
||||
* @param fsPath the path to save the queries to.
|
||||
*/
|
||||
export async function splatQueryHistory(
|
||||
export async function serializeQueryHistory(
|
||||
queries: QueryHistoryInfo[],
|
||||
fsPath: string,
|
||||
): Promise<void> {
|
||||
|
||||
@@ -68,7 +68,7 @@ function findQueryEvalLogEndSummaryFile(resultPath: string): string {
|
||||
|
||||
export class QueryEvaluationInfo {
|
||||
/**
|
||||
* Note that in the {@link slurpQueryHistory} method, we create a QueryEvaluationInfo instance
|
||||
* Note that in the {@link deserializeQueryHistory} method, we create a QueryEvaluationInfo instance
|
||||
* by explicitly setting the prototype in order to avoid calling this constructor.
|
||||
*/
|
||||
constructor(
|
||||
|
||||
@@ -22,8 +22,8 @@ import { CodeQLCliServer, SourceInfo } from "../../../src/cli";
|
||||
import { CancellationTokenSource, Uri } from "vscode";
|
||||
import { tmpDir } from "../../../src/helpers";
|
||||
import {
|
||||
slurpQueryHistory,
|
||||
splatQueryHistory,
|
||||
deserializeQueryHistory,
|
||||
serializeQueryHistory,
|
||||
} from "../../../src/query-serialization";
|
||||
import {
|
||||
formatLegacyMessage,
|
||||
@@ -438,7 +438,7 @@ describe("query-results", () => {
|
||||
);
|
||||
});
|
||||
|
||||
describe("splat and slurp", () => {
|
||||
describe("serialize and deserialize", () => {
|
||||
let infoSuccessRaw: LocalQueryInfo;
|
||||
let infoSuccessInterpreted: LocalQueryInfo;
|
||||
let infoEarlyFailure: LocalQueryInfo;
|
||||
@@ -488,7 +488,7 @@ describe("query-results", () => {
|
||||
];
|
||||
});
|
||||
|
||||
it("should splat and slurp query history", async () => {
|
||||
it("should serialize and deserialize query history", async () => {
|
||||
// the expected results only contains the history with completed queries
|
||||
const expectedHistory = [
|
||||
infoSuccessRaw,
|
||||
@@ -498,9 +498,9 @@ describe("query-results", () => {
|
||||
|
||||
const allHistoryPath = join(tmpDir.name, "workspace-query-history.json");
|
||||
|
||||
// splat and slurp
|
||||
await splatQueryHistory(allHistory, allHistoryPath);
|
||||
const allHistoryActual = await slurpQueryHistory(allHistoryPath);
|
||||
// serialize and deserialize
|
||||
await serializeQueryHistory(allHistory, allHistoryPath);
|
||||
const allHistoryActual = await deserializeQueryHistory(allHistoryPath);
|
||||
|
||||
// the dispose methods will be different. Ignore them.
|
||||
allHistoryActual.forEach((info) => {
|
||||
@@ -508,7 +508,7 @@ describe("query-results", () => {
|
||||
const completedQuery = info.completedQuery;
|
||||
(completedQuery as any).dispose = undefined;
|
||||
|
||||
// these fields should be missing on the slurped value
|
||||
// these fields should be missing on the deserialized value
|
||||
// but they are undefined on the original value
|
||||
if (!("logFileLocation" in completedQuery)) {
|
||||
(completedQuery as any).logFileLocation = undefined;
|
||||
@@ -543,7 +543,7 @@ describe("query-results", () => {
|
||||
"utf8",
|
||||
);
|
||||
|
||||
const allHistoryActual = await slurpQueryHistory(badPath);
|
||||
const allHistoryActual = await deserializeQueryHistory(badPath);
|
||||
// version number is invalid. Should return an empty array.
|
||||
expect(allHistoryActual).toEqual([]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user