Draft PR showcasing how to use filtered queries in the extension.#2661
Draft PR showcasing how to use filtered queries in the extension.#2661starcke wants to merge 1 commit into
Conversation
| import { extLogger } from "../common/logging/vscode"; | ||
| import { dir } from "tmp-promise"; | ||
| import { writeFile, outputFile } from "fs-extra"; | ||
| import { autoPickExtensionsDirectory } from "./extensions-workspace-folder"; |
Check notice
Code scanning / CodeQL
Unused variable, import, function or class
| import { dir } from "tmp-promise"; | ||
| import { writeFile, outputFile } from "fs-extra"; | ||
| import { autoPickExtensionsDirectory } from "./extensions-workspace-folder"; | ||
| import { sign } from "crypto"; |
Check notice
Code scanning / CodeQL
Unused variable, import, function or class
aeisenberg
left a comment
There was a problem hiding this comment.
Nice. I think this is reasonable.
|
|
||
| if (useLlmGenerationV2()) { | ||
| // Generate a qlpack with a filter that only includes the usages we want to model. | ||
| const packDir = (await dir({ unsafeCleanup: true })).path; |
There was a problem hiding this comment.
This dir will be cleaned when vscode exits?
There was a problem hiding this comment.
We should make sure it does. I am working on the actual PR right now, this was mostly to a showcase to show how we could use the queries.
| const syntheticConfigPack = { | ||
| name: "codeql/automodel-filter", | ||
| version: "0.0.0", | ||
| library: true, | ||
| extensionTargets: { | ||
| [`codeql/${this.databaseItem.language}-all`]: "*", | ||
| }, | ||
| dataExtensions: ["filter.yml"], | ||
| }; |
| queryStorageDir: this.queryStorageDir, | ||
| databaseItem: this.databaseItem, | ||
| progress: (update) => progress({ ...update, maxStep }), | ||
| extraExtensionPacks: [packDir], |
There was a problem hiding this comment.
I was expecting to see the name of the extension pack here. I haven't looked at the entire implementation, so you may already be doing this properly. The --extension-packs argument must be the name (and optional version) of the extension/model pack you want to use. And this pack must be available either in the package cache or from addtional-packs or from the workspace.
There was a problem hiding this comment.
I refactored this slightly in my other PR. I moved package generation to auto-model-codeml-queries.ts. That means we can just do:
const additionalPacks = [...getOnDiskWorkspaceFolders(), filterPackDir];
const extensionPacks = Object.keys(
await cliServer.resolveQlpacks(additionalPacks, true),
);
and pass those directly to the run method:
const candidates = await runAutoModelQuery({
...
additionalPacks,
extensionPacks,
...
});
|
Closing in favor of #2670 |
This is draft/WIP example on how to use an
extensiblepredicate in the extraction queries, it showcases and relies on using the queries from github/codeql#13852.Checklist
ready-for-doc-reviewlabel there.