Skip to content

Commit a327fa4

Browse files
authored
Merge pull request #4075 from github/koesie10/remove-cli-constraints
Remove unnecessary CLI feature checks
2 parents 24f0a25 + adb7072 commit a327fa4

File tree

6 files changed

+21
-306
lines changed

6 files changed

+21
-306
lines changed

extensions/ql-vscode/src/codeql-cli/cli-version.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ interface VersionResult {
1010
}
1111

1212
export interface CliFeatures {
13-
featuresInVersionResult?: boolean;
14-
mrvaPackCreate?: boolean;
15-
generateSummarySymbolMap?: boolean;
1613
queryServerRunQueries?: boolean;
1714
}
1815

extensions/ql-vscode/src/codeql-cli/cli.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,15 +1191,12 @@ export class CodeQLCliServer implements Disposable {
11911191
outputPath: string,
11921192
endSummaryPath: string,
11931193
): Promise<string> {
1194-
const supportsGenerateSummarySymbolMap =
1195-
await this.cliConstraints.supportsGenerateSummarySymbolMap();
11961194
const subcommandArgs = [
11971195
"--format=text",
11981196
`--end-summary=${endSummaryPath}`,
11991197
"--sourcemap",
1200-
...(supportsGenerateSummarySymbolMap
1201-
? ["--summary-symbol-map", "--minify-output"]
1202-
: []),
1198+
"--summary-symbol-map",
1199+
"--minify-output",
12031200
inputPath,
12041201
outputPath,
12051202
];
@@ -1910,11 +1907,7 @@ export class CliVersionConstraint {
19101907
/**/
19111908
}
19121909

1913-
async supportsMrvaPackCreate(): Promise<boolean> {
1914-
return (await this.cli.getFeatures()).mrvaPackCreate === true;
1915-
}
1916-
1917-
async supportsGenerateSummarySymbolMap(): Promise<boolean> {
1918-
return (await this.cli.getFeatures()).generateSummarySymbolMap === true;
1910+
async supportsQueryServerRunQueries(): Promise<boolean> {
1911+
return (await this.cli.getFeatures()).queryServerRunQueries === true;
19191912
}
19201913
}
Lines changed: 0 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import { createReadStream, writeFile } from "fs-extra";
2-
import { LINE_ENDINGS, splitStreamAtSeparators } from "../common/split-stream";
3-
41
/**
52
* Location information for a single pipeline invocation in the RA.
63
*/
@@ -32,103 +29,3 @@ interface PredicateSymbol {
3229
export interface SummarySymbols {
3330
predicates: Record<string, PredicateSymbol>;
3431
}
35-
36-
// Tuple counts for Expr::Expr::getParent#dispred#f0820431#ff@76d6745o:
37-
const NON_RECURSIVE_TUPLE_COUNT_REGEXP =
38-
/^Evaluated relational algebra for predicate (?<predicateName>\S+) with tuple counts:$/;
39-
// Tuple counts for Expr::Expr::getEnclosingStmt#f0820431#bf@923ddwj9 on iteration 0 running pipeline base:
40-
const RECURSIVE_TUPLE_COUNT_REGEXP =
41-
/^Evaluated relational algebra for predicate (?<predicateName>\S+) on iteration (?<iteration>\d+) running pipeline (?<pipeline>\S+) with tuple counts:$/;
42-
const RETURN_REGEXP = /^\s*return /;
43-
44-
/**
45-
* Parse a human-readable evaluation log summary to find the location of the RA for each pipeline
46-
* run.
47-
*
48-
* TODO: Once we're more certain about the symbol format, we should have the CLI generate this as it
49-
* generates the human-readabe summary to avoid having to rely on regular expression matching of the
50-
* human-readable text.
51-
*
52-
* @param summaryPath The path to the summary file.
53-
* @param symbolsPath The path to the symbols file to generate.
54-
*/
55-
export async function generateSummarySymbolsFile(
56-
summaryPath: string,
57-
symbolsPath: string,
58-
): Promise<void> {
59-
const symbols = await generateSummarySymbols(summaryPath);
60-
await writeFile(symbolsPath, JSON.stringify(symbols));
61-
}
62-
63-
/**
64-
* Parse a human-readable evaluation log summary to find the location of the RA for each pipeline
65-
* run.
66-
*
67-
* @param fileLocation The path to the summary file.
68-
* @returns Symbol information for the summary file.
69-
*/
70-
async function generateSummarySymbols(
71-
summaryPath: string,
72-
): Promise<SummarySymbols> {
73-
const stream = createReadStream(summaryPath, {
74-
encoding: "utf-8",
75-
});
76-
try {
77-
const lines = splitStreamAtSeparators(stream, LINE_ENDINGS);
78-
79-
const symbols: SummarySymbols = {
80-
predicates: {},
81-
};
82-
83-
let lineNumber = 0;
84-
let raStartLine = 0;
85-
let iteration = 0;
86-
let predicateName: string | undefined = undefined;
87-
let startLine = 0;
88-
for await (const line of lines) {
89-
if (predicateName === undefined) {
90-
// Looking for the start of the predicate.
91-
const nonRecursiveMatch = line.match(NON_RECURSIVE_TUPLE_COUNT_REGEXP);
92-
if (nonRecursiveMatch) {
93-
iteration = 0;
94-
predicateName = nonRecursiveMatch.groups!.predicateName;
95-
} else {
96-
const recursiveMatch = line.match(RECURSIVE_TUPLE_COUNT_REGEXP);
97-
if (recursiveMatch?.groups) {
98-
predicateName = recursiveMatch.groups.predicateName;
99-
iteration = parseInt(recursiveMatch.groups.iteration);
100-
}
101-
}
102-
if (predicateName !== undefined) {
103-
startLine = lineNumber;
104-
raStartLine = lineNumber + 1;
105-
}
106-
} else {
107-
const returnMatch = line.match(RETURN_REGEXP);
108-
if (returnMatch) {
109-
let symbol = symbols.predicates[predicateName];
110-
if (symbol === undefined) {
111-
symbol = {
112-
iterations: {},
113-
recursionSummaries: {},
114-
};
115-
symbols.predicates[predicateName] = symbol;
116-
}
117-
symbol.iterations[iteration] = {
118-
startLine,
119-
raStartLine,
120-
raEndLine: lineNumber,
121-
};
122-
123-
predicateName = undefined;
124-
}
125-
}
126-
127-
lineNumber++;
128-
}
129-
130-
return symbols;
131-
} finally {
132-
stream.close();
133-
}
134-
}

extensions/ql-vscode/src/query-server/query-server-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export class QueryServerClient extends DisposableObject {
100100
* queries at once.
101101
*/
102102
async supportsRunQueriesMethod(): Promise<boolean> {
103-
return (await this.cliServer.getFeatures()).queryServerRunQueries === true;
103+
return await this.cliServer.cliConstraints.supportsQueryServerRunQueries();
104104
}
105105

106106
/** Stops the query server by disposing of the current server process. */

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import type {
2727
import type { BaseLogger } from "./common/logging";
2828
import { showAndLogWarningMessage } from "./common/logging";
2929
import { extLogger } from "./common/logging/vscode";
30-
import { generateSummarySymbolsFile } from "./log-insights/summary-parser";
3130
import { getErrorMessage } from "./common/helpers-pure";
3231
import { createHash } from "crypto";
3332
import { QueryOutputDir } from "./local-queries/query-output-dir";
@@ -570,15 +569,6 @@ export async function generateEvalLogSummaries(
570569

571570
if (humanReadableSummary !== undefined) {
572571
summarySymbols = outputDir.evalLogSummarySymbolsPath;
573-
if (
574-
!(await cliServer.cliConstraints.supportsGenerateSummarySymbolMap())
575-
) {
576-
// We're using an old CLI that cannot generate the summary symbols file while generating the
577-
// human-readable log summary. As a fallback, create it by parsing the human-readable
578-
// summary.
579-
progress(progressUpdate(3, 3, "Generating summary symbols file"));
580-
await generateSummarySymbolsFile(humanReadableSummary, summarySymbols);
581-
}
582572
}
583573
}
584574

0 commit comments

Comments
 (0)