Skip to content

Commit

Permalink
Tidy up uses of QueryPackDetail object fields (#3276)
Browse files Browse the repository at this point in the history
  • Loading branch information
charisk authored Jan 25, 2024
1 parent 594f422 commit 2f66be3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
21 changes: 9 additions & 12 deletions extensions/ql-vscode/src/variant-analysis/run-remote-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ async function generateQueryPack(
qlPackDetails: QlPackDetails,
tmpDir: RemoteQueryTempDir,
): Promise<string> {
const originalPackRoot = qlPackDetails.qlPackRootPath;
const workspaceFolders = getOnDiskWorkspaceFolders();
const extensionPacks = await getExtensionPacksToInject(
cliServer,
Expand Down Expand Up @@ -93,7 +92,7 @@ async function generateQueryPack(
needsInstall = true;
} else {
// The CLI supports creating a MRVA query pack directly from the source pack.
queryPackDir = originalPackRoot;
queryPackDir = qlPackDetails.qlPackRootPath;
// We expect any dependencies to be available already.
needsInstall = false;
}
Expand Down Expand Up @@ -135,7 +134,7 @@ async function generateQueryPack(
if (await cliServer.cliConstraints.usesGlobalCompilationCache()) {
precompilationOpts = ["--qlx"];
} else {
const cache = join(originalPackRoot, ".cache");
const cache = join(qlPackDetails.qlPackRootPath, ".cache");
precompilationOpts = [
"--qlx",
"--no-default-compilation-cache",
Expand Down Expand Up @@ -195,9 +194,6 @@ async function copyExistingQueryPack(
qlPackDetails: QlPackDetails,
queryPackDir: string,
) {
const originalPackRoot = qlPackDetails.qlPackRootPath;
const queryFiles = qlPackDetails.queryFiles;

const toCopy = await cliServer.packPacklist(
qlPackDetails.qlPackRootPath,
false,
Expand All @@ -209,27 +205,28 @@ async function copyExistingQueryPack(
if (
await cliServer.cliConstraints.supportsGenerateExtensiblePredicateMetadata()
) {
const metadata =
await cliServer.generateExtensiblePredicateMetadata(originalPackRoot);
const metadata = await cliServer.generateExtensiblePredicateMetadata(
qlPackDetails.qlPackRootPath,
);
metadata.extensible_predicates.forEach((predicate) => {
if (predicate.path.endsWith(".ql")) {
toCopy.push(join(originalPackRoot, predicate.path));
toCopy.push(join(qlPackDetails.qlPackRootPath, predicate.path));
}
});
}

[
// also copy the lock file (either new name or old name) and the query file itself. These are not included in the packlist.
...QLPACK_LOCK_FILENAMES.map((f) => join(originalPackRoot, f)),
...queryFiles,
...QLPACK_LOCK_FILENAMES.map((f) => join(qlPackDetails.qlPackRootPath, f)),
...qlPackDetails.queryFiles,
].forEach((absolutePath) => {
if (absolutePath) {
toCopy.push(absolutePath);
}
});

let copiedCount = 0;
await copy(originalPackRoot, queryPackDir, {
await copy(qlPackDetails.qlPackRootPath, queryPackDir, {
filter: (file: string) =>
// copy file if it is in the packlist, or it is a parent directory of a file in the packlist
!!toCopy.find((f) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,11 +389,12 @@ export class VariantAnalysisManager
firstQueryFile,
);
const queryName = getQueryName(queryMetadata, firstQueryFile);
const language = qlPackDetails.language;
const variantAnalysisLanguage = parseVariantAnalysisQueryLanguage(language);
const variantAnalysisLanguage = parseVariantAnalysisQueryLanguage(
qlPackDetails.language,
);
if (variantAnalysisLanguage === undefined) {
throw new UserCancellationException(
`Found unsupported language: ${language}`,
`Found unsupported language: ${qlPackDetails.language}`,
);
}

Expand Down

0 comments on commit 2f66be3

Please sign in to comment.