Skip to content

Remove unnecessary CLI feature checks #4075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions extensions/ql-vscode/src/codeql-cli/cli-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ interface VersionResult {
}

export interface CliFeatures {
featuresInVersionResult?: boolean;
mrvaPackCreate?: boolean;
generateSummarySymbolMap?: boolean;
queryServerRunQueries?: boolean;
}

Expand Down
15 changes: 4 additions & 11 deletions extensions/ql-vscode/src/codeql-cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1191,15 +1191,12 @@ export class CodeQLCliServer implements Disposable {
outputPath: string,
endSummaryPath: string,
): Promise<string> {
const supportsGenerateSummarySymbolMap =
await this.cliConstraints.supportsGenerateSummarySymbolMap();
const subcommandArgs = [
"--format=text",
`--end-summary=${endSummaryPath}`,
"--sourcemap",
...(supportsGenerateSummarySymbolMap
? ["--summary-symbol-map", "--minify-output"]
: []),
"--summary-symbol-map",
"--minify-output",
inputPath,
outputPath,
];
Expand Down Expand Up @@ -1910,11 +1907,7 @@ export class CliVersionConstraint {
/**/
}

async supportsMrvaPackCreate(): Promise<boolean> {
return (await this.cli.getFeatures()).mrvaPackCreate === true;
}

async supportsGenerateSummarySymbolMap(): Promise<boolean> {
return (await this.cli.getFeatures()).generateSummarySymbolMap === true;
async supportsQueryServerRunQueries(): Promise<boolean> {
return (await this.cli.getFeatures()).queryServerRunQueries === true;
}
}
103 changes: 0 additions & 103 deletions extensions/ql-vscode/src/log-insights/summary-parser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { createReadStream, writeFile } from "fs-extra";
import { LINE_ENDINGS, splitStreamAtSeparators } from "../common/split-stream";

/**
* Location information for a single pipeline invocation in the RA.
*/
Expand Down Expand Up @@ -32,103 +29,3 @@ interface PredicateSymbol {
export interface SummarySymbols {
predicates: Record<string, PredicateSymbol>;
}

// Tuple counts for Expr::Expr::getParent#dispred#f0820431#ff@76d6745o:
const NON_RECURSIVE_TUPLE_COUNT_REGEXP =
/^Evaluated relational algebra for predicate (?<predicateName>\S+) with tuple counts:$/;
// Tuple counts for Expr::Expr::getEnclosingStmt#f0820431#bf@923ddwj9 on iteration 0 running pipeline base:
const RECURSIVE_TUPLE_COUNT_REGEXP =
/^Evaluated relational algebra for predicate (?<predicateName>\S+) on iteration (?<iteration>\d+) running pipeline (?<pipeline>\S+) with tuple counts:$/;
const RETURN_REGEXP = /^\s*return /;

/**
* Parse a human-readable evaluation log summary to find the location of the RA for each pipeline
* run.
*
* TODO: Once we're more certain about the symbol format, we should have the CLI generate this as it
* generates the human-readabe summary to avoid having to rely on regular expression matching of the
* human-readable text.
*
* @param summaryPath The path to the summary file.
* @param symbolsPath The path to the symbols file to generate.
*/
export async function generateSummarySymbolsFile(
summaryPath: string,
symbolsPath: string,
): Promise<void> {
const symbols = await generateSummarySymbols(summaryPath);
await writeFile(symbolsPath, JSON.stringify(symbols));
}

/**
* Parse a human-readable evaluation log summary to find the location of the RA for each pipeline
* run.
*
* @param fileLocation The path to the summary file.
* @returns Symbol information for the summary file.
*/
async function generateSummarySymbols(
summaryPath: string,
): Promise<SummarySymbols> {
const stream = createReadStream(summaryPath, {
encoding: "utf-8",
});
try {
const lines = splitStreamAtSeparators(stream, LINE_ENDINGS);

const symbols: SummarySymbols = {
predicates: {},
};

let lineNumber = 0;
let raStartLine = 0;
let iteration = 0;
let predicateName: string | undefined = undefined;
let startLine = 0;
for await (const line of lines) {
if (predicateName === undefined) {
// Looking for the start of the predicate.
const nonRecursiveMatch = line.match(NON_RECURSIVE_TUPLE_COUNT_REGEXP);
if (nonRecursiveMatch) {
iteration = 0;
predicateName = nonRecursiveMatch.groups!.predicateName;
} else {
const recursiveMatch = line.match(RECURSIVE_TUPLE_COUNT_REGEXP);
if (recursiveMatch?.groups) {
predicateName = recursiveMatch.groups.predicateName;
iteration = parseInt(recursiveMatch.groups.iteration);
}
}
if (predicateName !== undefined) {
startLine = lineNumber;
raStartLine = lineNumber + 1;
}
} else {
const returnMatch = line.match(RETURN_REGEXP);
if (returnMatch) {
let symbol = symbols.predicates[predicateName];
if (symbol === undefined) {
symbol = {
iterations: {},
recursionSummaries: {},
};
symbols.predicates[predicateName] = symbol;
}
symbol.iterations[iteration] = {
startLine,
raStartLine,
raEndLine: lineNumber,
};

predicateName = undefined;
}
}

lineNumber++;
}

return symbols;
} finally {
stream.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class QueryServerClient extends DisposableObject {
* queries at once.
*/
async supportsRunQueriesMethod(): Promise<boolean> {
return (await this.cliServer.getFeatures()).queryServerRunQueries === true;
return await this.cliServer.cliConstraints.supportsQueryServerRunQueries();
}

/** Stops the query server by disposing of the current server process. */
Expand Down
10 changes: 0 additions & 10 deletions extensions/ql-vscode/src/run-queries-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import type {
import type { BaseLogger } from "./common/logging";
import { showAndLogWarningMessage } from "./common/logging";
import { extLogger } from "./common/logging/vscode";
import { generateSummarySymbolsFile } from "./log-insights/summary-parser";
import { getErrorMessage } from "./common/helpers-pure";
import { createHash } from "crypto";
import { QueryOutputDir } from "./local-queries/query-output-dir";
Expand Down Expand Up @@ -570,15 +569,6 @@ export async function generateEvalLogSummaries(

if (humanReadableSummary !== undefined) {
summarySymbols = outputDir.evalLogSummarySymbolsPath;
if (
!(await cliServer.cliConstraints.supportsGenerateSummarySymbolMap())
) {
// We're using an old CLI that cannot generate the summary symbols file while generating the
// human-readable log summary. As a fallback, create it by parsing the human-readable
// summary.
progress(progressUpdate(3, 3, "Generating summary symbols file"));
await generateSummarySymbolsFile(humanReadableSummary, summarySymbols);
}
}
}

Expand Down
Loading
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy