Skip to content

Commit 841efbf

Browse files
authored
Add AccessPathSuggestions to "models as data" model (#3295)
1 parent 8c679ab commit 841efbf

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

extensions/ql-vscode/src/model-editor/languages/models-as-data.ts

+18-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ import type {
1010
import type { DataTuple } from "../model-extension-file";
1111
import type { Mode } from "../shared/mode";
1212
import type { QueryConstraints } from "../../local-queries/query-constraints";
13-
import type { DecodedBqrs } from "../../common/bqrs-cli-types";
13+
import type {
14+
DecodedBqrs,
15+
DecodedBqrsChunk,
16+
} from "../../common/bqrs-cli-types";
1417
import type { BaseLogger } from "../../common/logging";
18+
import type { AccessPathSuggestionRow } from "../suggestions";
1519

1620
type GenerateMethodDefinition<T> = (method: T) => DataTuple[];
1721
type ReadModeledMethod = (row: DataTuple[]) => ModeledMethod;
@@ -39,6 +43,18 @@ type ModelsAsDataLanguageModelGeneration = {
3943
) => ModeledMethod[];
4044
};
4145

46+
type ModelsAsDataLanguageAccessPathSuggestions = {
47+
parseResults: (
48+
// The results of a single predicate of the query.
49+
bqrs: DecodedBqrsChunk,
50+
// The language-specific predicate that was used to generate the results. This is passed to allow
51+
// sharing of code between different languages.
52+
modelsAsDataLanguage: ModelsAsDataLanguage,
53+
// The logger to use for logging.
54+
logger: BaseLogger,
55+
) => AccessPathSuggestionRow[];
56+
};
57+
4258
export type ModelsAsDataLanguagePredicates = {
4359
source?: ModelsAsDataLanguagePredicate<SourceModeledMethod>;
4460
sink?: ModelsAsDataLanguagePredicate<SinkModeledMethod>;
@@ -61,6 +77,7 @@ export type ModelsAsDataLanguage = {
6177
createMethodSignature: (method: MethodDefinition) => string;
6278
predicates: ModelsAsDataLanguagePredicates;
6379
modelGeneration?: ModelsAsDataLanguageModelGeneration;
80+
accessPathSuggestions?: ModelsAsDataLanguageAccessPathSuggestions;
6481
/**
6582
* Returns the list of valid arguments that can be selected for the given method.
6683
* @param method The method to get the valid arguments for.

0 commit comments

Comments
 (0)