Merge branch 'main' into koesie10/remove-ignore-source-archive-option

This commit is contained in:
Koen Vlaswinkel
2023-06-02 10:16:34 +02:00
committed by GitHub
5 changed files with 35 additions and 18 deletions

View File

@@ -116,13 +116,14 @@ export const extensiblePredicateDefinitions: Record<
neutral: {
extensiblePredicate: "neutralModel",
// extensible predicate neutralModel(
// string package, string type, string name, string signature, string provenance
// string package, string type, string name, string signature, string kind, string provenance
// );
generateMethodDefinition: (method) => [
method.externalApiUsage.packageName,
method.externalApiUsage.typeName,
method.externalApiUsage.methodName,
method.externalApiUsage.methodParameters,
method.modeledMethod.kind,
"manual",
],
readModeledMethod: (row) => ({
@@ -131,8 +132,9 @@ export const extensiblePredicateDefinitions: Record<
type: "neutral",
input: "",
output: "",
kind: "",
kind: row[4] as string,
},
}),
supportedKinds: ["summary", "source", "sink"],
},
};

View File

@@ -42,9 +42,14 @@ export function getAstCfgCommands({
const viewCfg = async () =>
withProgress(
async (progress, token) => {
const res = await cfgTemplateProvider.provideCfgUri(
window.activeTextEditor?.document,
);
const editor = window.activeTextEditor;
const res = !editor
? undefined
: await cfgTemplateProvider.provideCfgUri(
editor.document,
editor.selection.active.line + 1,
editor.selection.active.character + 1,
);
if (res) {
await localQueries.compileAndRunQuery(
QuickEvalType.None,

View File

@@ -24,7 +24,9 @@ import { QueryResultType } from "../../pure/new-messages";
import { fileRangeFromURI } from "./file-range-from-uri";
export const SELECT_QUERY_NAME = "#select";
export const TEMPLATE_NAME = "selectedSourceFile";
export const SELECTED_SOURCE_FILE = "selectedSourceFile";
export const SELECTED_SOURCE_LINE = "selectedSourceLine";
export const SELECTED_SOURCE_COLUMN = "selectedSourceColumn";
export interface FullLocationLink extends LocationLink {
originUri: Uri;
@@ -124,7 +126,7 @@ async function getLinksFromResults(
function createTemplates(path: string): Record<string, string> {
return {
[TEMPLATE_NAME]: path,
[SELECTED_SOURCE_FILE]: path,
};
}

View File

@@ -23,7 +23,9 @@ import { KeyType } from "./key-type";
import {
FullLocationLink,
getLocationsForUriString,
TEMPLATE_NAME,
SELECTED_SOURCE_FILE,
SELECTED_SOURCE_LINE,
SELECTED_SOURCE_COLUMN,
} from "./location-finder";
import {
qlpackOfDatabase,
@@ -253,7 +255,7 @@ export class TemplatePrintAstProvider {
const query = queries[0];
const templates: Record<string, string> = {
[TEMPLATE_NAME]: zippedArchive.pathWithinSourceArchive,
[SELECTED_SOURCE_FILE]: zippedArchive.pathWithinSourceArchive,
};
const results = await runContextualQuery(
@@ -284,15 +286,17 @@ export class TemplatePrintCfgProvider {
}
async provideCfgUri(
document?: TextDocument,
document: TextDocument,
line: number,
character: number,
): Promise<[Uri, Record<string, string>] | undefined> {
if (!document) {
return;
}
return this.shouldUseCache()
? await this.cache.get(document.uri.toString())
: await this.getCfgUri(document.uri.toString());
? await this.cache.get(
`${document.uri.toString()}#${line}:${character}`,
line,
character,
)
: await this.getCfgUri(document.uri.toString(), line, character);
}
private shouldUseCache() {
@@ -301,6 +305,8 @@ export class TemplatePrintCfgProvider {
private async getCfgUri(
uriString: string,
line: number,
character: number,
): Promise<[Uri, Record<string, string>]> {
const uri = Uri.parse(uriString, true);
if (uri.scheme !== zipArchiveScheme) {
@@ -342,7 +348,9 @@ export class TemplatePrintCfgProvider {
const queryUri = Uri.file(queries[0]);
const templates: Record<string, string> = {
[TEMPLATE_NAME]: zippedArchive.pathWithinSourceArchive,
[SELECTED_SOURCE_FILE]: zippedArchive.pathWithinSourceArchive,
[SELECTED_SOURCE_LINE]: line.toString(),
[SELECTED_SOURCE_COLUMN]: character.toString(),
};
return [queryUri, templates];

View File

@@ -1,5 +1,5 @@
[
"v2.13.1",
"v2.13.3",
"v2.12.7",
"v2.11.6",
"v2.7.6",