Skip to content

Commit f115412

Browse files
authored
Merge branch 'main' into koesie10/remove-ignore-source-archive-option
2 parents 0e47709 + 26d27f8 commit f115412

File tree

5 files changed

+35
-18
lines changed

5 files changed

+35
-18
lines changed

extensions/ql-vscode/src/data-extensions-editor/predicates.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,14 @@ export const extensiblePredicateDefinitions: Record<
116116
neutral: {
117117
extensiblePredicate: "neutralModel",
118118
// extensible predicate neutralModel(
119-
// string package, string type, string name, string signature, string provenance
119+
// string package, string type, string name, string signature, string kind, string provenance
120120
// );
121121
generateMethodDefinition: (method) => [
122122
method.externalApiUsage.packageName,
123123
method.externalApiUsage.typeName,
124124
method.externalApiUsage.methodName,
125125
method.externalApiUsage.methodParameters,
126+
method.modeledMethod.kind,
126127
"manual",
127128
],
128129
readModeledMethod: (row) => ({
@@ -131,8 +132,9 @@ export const extensiblePredicateDefinitions: Record<
131132
type: "neutral",
132133
input: "",
133134
output: "",
134-
kind: "",
135+
kind: row[4] as string,
135136
},
136137
}),
138+
supportedKinds: ["summary", "source", "sink"],
137139
},
138140
};

extensions/ql-vscode/src/language-support/ast-viewer/ast-cfg-commands.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,14 @@ export function getAstCfgCommands({
4242
const viewCfg = async () =>
4343
withProgress(
4444
async (progress, token) => {
45-
const res = await cfgTemplateProvider.provideCfgUri(
46-
window.activeTextEditor?.document,
47-
);
45+
const editor = window.activeTextEditor;
46+
const res = !editor
47+
? undefined
48+
: await cfgTemplateProvider.provideCfgUri(
49+
editor.document,
50+
editor.selection.active.line + 1,
51+
editor.selection.active.character + 1,
52+
);
4853
if (res) {
4954
await localQueries.compileAndRunQuery(
5055
QuickEvalType.None,

extensions/ql-vscode/src/language-support/contextual/location-finder.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ import { QueryResultType } from "../../pure/new-messages";
2424
import { fileRangeFromURI } from "./file-range-from-uri";
2525

2626
export const SELECT_QUERY_NAME = "#select";
27-
export const TEMPLATE_NAME = "selectedSourceFile";
27+
export const SELECTED_SOURCE_FILE = "selectedSourceFile";
28+
export const SELECTED_SOURCE_LINE = "selectedSourceLine";
29+
export const SELECTED_SOURCE_COLUMN = "selectedSourceColumn";
2830

2931
export interface FullLocationLink extends LocationLink {
3032
originUri: Uri;
@@ -124,7 +126,7 @@ async function getLinksFromResults(
124126

125127
function createTemplates(path: string): Record<string, string> {
126128
return {
127-
[TEMPLATE_NAME]: path,
129+
[SELECTED_SOURCE_FILE]: path,
128130
};
129131
}
130132

extensions/ql-vscode/src/language-support/contextual/template-provider.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ import { KeyType } from "./key-type";
2323
import {
2424
FullLocationLink,
2525
getLocationsForUriString,
26-
TEMPLATE_NAME,
26+
SELECTED_SOURCE_FILE,
27+
SELECTED_SOURCE_LINE,
28+
SELECTED_SOURCE_COLUMN,
2729
} from "./location-finder";
2830
import {
2931
qlpackOfDatabase,
@@ -253,7 +255,7 @@ export class TemplatePrintAstProvider {
253255

254256
const query = queries[0];
255257
const templates: Record<string, string> = {
256-
[TEMPLATE_NAME]: zippedArchive.pathWithinSourceArchive,
258+
[SELECTED_SOURCE_FILE]: zippedArchive.pathWithinSourceArchive,
257259
};
258260

259261
const results = await runContextualQuery(
@@ -284,15 +286,17 @@ export class TemplatePrintCfgProvider {
284286
}
285287

286288
async provideCfgUri(
287-
document?: TextDocument,
289+
document: TextDocument,
290+
line: number,
291+
character: number,
288292
): Promise<[Uri, Record<string, string>] | undefined> {
289-
if (!document) {
290-
return;
291-
}
292-
293293
return this.shouldUseCache()
294-
? await this.cache.get(document.uri.toString())
295-
: await this.getCfgUri(document.uri.toString());
294+
? await this.cache.get(
295+
`${document.uri.toString()}#${line}:${character}`,
296+
line,
297+
character,
298+
)
299+
: await this.getCfgUri(document.uri.toString(), line, character);
296300
}
297301

298302
private shouldUseCache() {
@@ -301,6 +305,8 @@ export class TemplatePrintCfgProvider {
301305

302306
private async getCfgUri(
303307
uriString: string,
308+
line: number,
309+
character: number,
304310
): Promise<[Uri, Record<string, string>]> {
305311
const uri = Uri.parse(uriString, true);
306312
if (uri.scheme !== zipArchiveScheme) {
@@ -342,7 +348,9 @@ export class TemplatePrintCfgProvider {
342348
const queryUri = Uri.file(queries[0]);
343349

344350
const templates: Record<string, string> = {
345-
[TEMPLATE_NAME]: zippedArchive.pathWithinSourceArchive,
351+
[SELECTED_SOURCE_FILE]: zippedArchive.pathWithinSourceArchive,
352+
[SELECTED_SOURCE_LINE]: line.toString(),
353+
[SELECTED_SOURCE_COLUMN]: character.toString(),
346354
};
347355

348356
return [queryUri, templates];

extensions/ql-vscode/supported_cli_versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[
2-
"v2.13.1",
2+
"v2.13.3",
33
"v2.12.7",
44
"v2.11.6",
55
"v2.7.6",

0 commit comments

Comments
 (0)