Skip to content

Commit 0485520

Browse files
committed
Add classification and type to types
1 parent 0560f4f commit 0485520

File tree

6 files changed

+96
-4
lines changed

6 files changed

+96
-4
lines changed

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { DecodedBqrsChunk } from "../common/bqrs-cli-types";
2-
import { Call, ExternalApiUsage } from "./external-api-usage";
2+
import {
3+
Call,
4+
CallClassification,
5+
ExternalApiUsage,
6+
} from "./external-api-usage";
7+
import { ModeledMethodType } from "./modeled-method";
38

49
export function decodeBqrsToExternalApiUsages(
510
chunk: DecodedBqrsChunk,
@@ -11,6 +16,8 @@ export function decodeBqrsToExternalApiUsages(
1116
const signature = tuple[1] as string;
1217
const supported = (tuple[2] as string) === "true";
1318
const library = tuple[4] as string;
19+
const type = tuple[6] as ModeledMethodType;
20+
const classification = tuple[8] as CallClassification;
1421

1522
const [packageWithType, methodDeclaration] = signature.split("#");
1623

@@ -39,12 +46,16 @@ export function decodeBqrsToExternalApiUsages(
3946
methodName,
4047
methodParameters,
4148
supported,
49+
supportedType: type,
4250
usages: [],
4351
});
4452
}
4553

4654
const method = methodsByApiName.get(signature)!;
47-
method.usages.push(usage);
55+
method.usages.push({
56+
...usage,
57+
classification,
58+
});
4859
});
4960

5061
return Array.from(methodsByApiName.values());

extensions/ql-vscode/src/data-extensions-editor/external-api-usage.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
import { ResolvableLocationValue } from "../common/bqrs-cli-types";
2+
import { ModeledMethodType } from "./modeled-method";
23

34
export type Call = {
45
label: string;
56
url: ResolvableLocationValue;
67
};
78

9+
export enum CallClassification {
10+
Unknown = "unknown",
11+
Source = "source",
12+
Test = "test",
13+
Generated = "generated",
14+
}
15+
16+
export type Usage = Call & {
17+
classification: CallClassification;
18+
};
19+
820
export type ExternalApiUsage = {
921
/**
1022
* Contains the name of the library containing the method declaration, e.g. `sql2o-1.6.0.jar` or `System.Runtime.dll`
@@ -30,5 +42,6 @@ export type ExternalApiUsage = {
3042
* If so, there is no need for the user to model it themselves.
3143
*/
3244
supported: boolean;
33-
usages: Call[];
45+
supportedType: ModeledMethodType;
46+
usages: Usage[];
3447
};

extensions/ql-vscode/src/stories/data-extensions-editor/DataExtensionsEditor.stories.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ComponentMeta, ComponentStory } from "@storybook/react";
44

55
import { Mode } from "../../data-extensions-editor/shared/mode";
66
import { DataExtensionsEditor as DataExtensionsEditorComponent } from "../../view/data-extensions-editor/DataExtensionsEditor";
7+
import { CallClassification } from "../../data-extensions-editor/external-api-usage";
78

89
export default {
910
title: "Data Extensions Editor/Data Extensions Editor",
@@ -39,6 +40,7 @@ DataExtensionsEditor.args = {
3940
methodName: "createQuery",
4041
methodParameters: "(String)",
4142
supported: true,
43+
supportedType: "summary",
4244
usages: Array(10).fill({
4345
label: "createQuery(...)",
4446
url: {
@@ -48,6 +50,7 @@ DataExtensionsEditor.args = {
4850
endLine: 15,
4951
endColumn: 56,
5052
},
53+
classification: CallClassification.Source,
5154
}),
5255
},
5356
{
@@ -58,6 +61,7 @@ DataExtensionsEditor.args = {
5861
methodName: "executeScalar",
5962
methodParameters: "(Class)",
6063
supported: true,
64+
supportedType: "neutral",
6165
usages: Array(2).fill({
6266
label: "executeScalar(...)",
6367
url: {
@@ -67,6 +71,7 @@ DataExtensionsEditor.args = {
6771
endLine: 15,
6872
endColumn: 85,
6973
},
74+
classification: CallClassification.Source,
7075
}),
7176
},
7277
{
@@ -77,6 +82,7 @@ DataExtensionsEditor.args = {
7782
methodName: "open",
7883
methodParameters: "()",
7984
supported: false,
85+
supportedType: "none",
8086
usages: Array(28).fill({
8187
label: "open(...)",
8288
url: {
@@ -86,6 +92,7 @@ DataExtensionsEditor.args = {
8692
endLine: 14,
8793
endColumn: 35,
8894
},
95+
classification: CallClassification.Source,
8996
}),
9097
},
9198
{
@@ -96,6 +103,7 @@ DataExtensionsEditor.args = {
96103
methodName: "println",
97104
methodParameters: "(String)",
98105
supported: true,
106+
supportedType: "summary",
99107
usages: [
100108
{
101109
label: "println(...)",
@@ -106,6 +114,7 @@ DataExtensionsEditor.args = {
106114
endLine: 29,
107115
endColumn: 49,
108116
},
117+
classification: CallClassification.Source,
109118
},
110119
],
111120
},
@@ -118,6 +127,7 @@ DataExtensionsEditor.args = {
118127
methodName: "run",
119128
methodParameters: "(Class,String[])",
120129
supported: false,
130+
supportedType: "none",
121131
usages: Array(7).fill({
122132
label: "run(...)",
123133
url: {
@@ -127,6 +137,7 @@ DataExtensionsEditor.args = {
127137
endLine: 9,
128138
endColumn: 66,
129139
},
140+
classification: CallClassification.Source,
130141
}),
131142
},
132143
{
@@ -137,6 +148,7 @@ DataExtensionsEditor.args = {
137148
methodName: "Sql2o",
138149
methodParameters: "(String,String,String)",
139150
supported: false,
151+
supportedType: "none",
140152
usages: Array(106).fill({
141153
label: "new Sql2o(...)",
142154
url: {
@@ -145,6 +157,7 @@ DataExtensionsEditor.args = {
145157
startColumn: 33,
146158
endLine: 10,
147159
endColumn: 88,
160+
classification: CallClassification.Source,
148161
},
149162
}),
150163
},
@@ -156,6 +169,7 @@ DataExtensionsEditor.args = {
156169
methodName: "Sql2o",
157170
methodParameters: "(String)",
158171
supported: false,
172+
supportedType: "none",
159173
usages: Array(4).fill({
160174
label: "new Sql2o(...)",
161175
url: {
@@ -165,6 +179,7 @@ DataExtensionsEditor.args = {
165179
endLine: 23,
166180
endColumn: 36,
167181
},
182+
classification: CallClassification.Source,
168183
}),
169184
},
170185
],

extensions/ql-vscode/src/stories/data-extensions-editor/MethodRow.stories.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as React from "react";
33
import { ComponentMeta, ComponentStory } from "@storybook/react";
44

55
import { MethodRow as MethodRowComponent } from "../../view/data-extensions-editor/MethodRow";
6+
import { CallClassification } from "../../data-extensions-editor/external-api-usage";
67

78
export default {
89
title: "Data Extensions Editor/Method Row",
@@ -23,6 +24,7 @@ MethodRow.args = {
2324
methodName: "open",
2425
methodParameters: "()",
2526
supported: true,
27+
supportedType: "summary",
2628
usages: [
2729
{
2830
label: "open(...)",
@@ -33,6 +35,7 @@ MethodRow.args = {
3335
endLine: 14,
3436
endColumn: 35,
3537
},
38+
classification: CallClassification.Source,
3639
},
3740
{
3841
label: "open(...)",
@@ -43,6 +46,7 @@ MethodRow.args = {
4346
endLine: 25,
4447
endColumn: 35,
4548
},
49+
classification: CallClassification.Source,
4650
},
4751
],
4852
},

extensions/ql-vscode/test/unit-tests/data-extensions-editor/auto-model.test.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import {
33
createAutoModelRequest,
44
parsePredictedClassifications,
55
} from "../../../src/data-extensions-editor/auto-model";
6-
import { ExternalApiUsage } from "../../../src/data-extensions-editor/external-api-usage";
6+
import {
7+
CallClassification,
8+
ExternalApiUsage,
9+
} from "../../../src/data-extensions-editor/external-api-usage";
710
import { ModeledMethod } from "../../../src/data-extensions-editor/modeled-method";
811
import {
912
ClassificationType,
@@ -22,6 +25,7 @@ describe("createAutoModelRequest", () => {
2225
methodName: "run",
2326
methodParameters: "(Class,String[])",
2427
supported: false,
28+
supportedType: "none",
2529
usages: [
2630
{
2731
label: "run(...)",
@@ -32,6 +36,7 @@ describe("createAutoModelRequest", () => {
3236
endLine: 9,
3337
endColumn: 66,
3438
},
39+
classification: CallClassification.Source,
3540
},
3641
],
3742
},
@@ -43,6 +48,7 @@ describe("createAutoModelRequest", () => {
4348
methodName: "createQuery",
4449
methodParameters: "(String)",
4550
supported: false,
51+
supportedType: "none",
4652
usages: [
4753
{
4854
label: "createQuery(...)",
@@ -53,6 +59,7 @@ describe("createAutoModelRequest", () => {
5359
endLine: 15,
5460
endColumn: 56,
5561
},
62+
classification: CallClassification.Source,
5663
},
5764
{
5865
label: "createQuery(...)",
@@ -63,6 +70,7 @@ describe("createAutoModelRequest", () => {
6370
endLine: 26,
6471
endColumn: 39,
6572
},
73+
classification: CallClassification.Source,
6674
},
6775
],
6876
},
@@ -74,6 +82,7 @@ describe("createAutoModelRequest", () => {
7482
methodName: "executeScalar",
7583
methodParameters: "(Class)",
7684
supported: false,
85+
supportedType: "none",
7786
usages: [
7887
{
7988
label: "executeScalar(...)",
@@ -84,6 +93,7 @@ describe("createAutoModelRequest", () => {
8493
endLine: 15,
8594
endColumn: 85,
8695
},
96+
classification: CallClassification.Source,
8797
},
8898
{
8999
label: "executeScalar(...)",
@@ -94,6 +104,7 @@ describe("createAutoModelRequest", () => {
94104
endLine: 26,
95105
endColumn: 68,
96106
},
107+
classification: CallClassification.Source,
97108
},
98109
],
99110
},
@@ -105,6 +116,7 @@ describe("createAutoModelRequest", () => {
105116
methodName: "open",
106117
methodParameters: "()",
107118
supported: false,
119+
supportedType: "none",
108120
usages: [
109121
{
110122
label: "open(...)",
@@ -115,6 +127,7 @@ describe("createAutoModelRequest", () => {
115127
endLine: 14,
116128
endColumn: 35,
117129
},
130+
classification: CallClassification.Source,
118131
},
119132
{
120133
label: "open(...)",
@@ -125,6 +138,7 @@ describe("createAutoModelRequest", () => {
125138
endLine: 25,
126139
endColumn: 35,
127140
},
141+
classification: CallClassification.Source,
128142
},
129143
],
130144
},
@@ -136,6 +150,7 @@ describe("createAutoModelRequest", () => {
136150
methodName: "println",
137151
methodParameters: "(String)",
138152
supported: false,
153+
supportedType: "none",
139154
usages: [
140155
{
141156
label: "println(...)",
@@ -146,6 +161,7 @@ describe("createAutoModelRequest", () => {
146161
endLine: 29,
147162
endColumn: 49,
148163
},
164+
classification: CallClassification.Source,
149165
},
150166
],
151167
},
@@ -157,6 +173,7 @@ describe("createAutoModelRequest", () => {
157173
methodName: "Sql2o",
158174
methodParameters: "(String,String,String)",
159175
supported: false,
176+
supportedType: "none",
160177
usages: [
161178
{
162179
label: "new Sql2o(...)",
@@ -167,6 +184,7 @@ describe("createAutoModelRequest", () => {
167184
endLine: 10,
168185
endColumn: 88,
169186
},
187+
classification: CallClassification.Source,
170188
},
171189
],
172190
},
@@ -178,6 +196,7 @@ describe("createAutoModelRequest", () => {
178196
methodName: "Sql2o",
179197
methodParameters: "(String)",
180198
supported: false,
199+
supportedType: "none",
181200
usages: [
182201
{
183202
label: "new Sql2o(...)",
@@ -188,6 +207,7 @@ describe("createAutoModelRequest", () => {
188207
endLine: 23,
189208
endColumn: 36,
190209
},
210+
classification: CallClassification.Source,
191211
},
192212
],
193213
},
@@ -199,6 +219,7 @@ describe("createAutoModelRequest", () => {
199219
methodName: "test",
200220
methodParameters: "()",
201221
supported: true,
222+
supportedType: "neutral",
202223
usages: [
203224
{
204225
label: "abc.test(...)",
@@ -209,6 +230,7 @@ describe("createAutoModelRequest", () => {
209230
endLine: 23,
210231
endColumn: 36,
211232
},
233+
classification: CallClassification.Source,
212234
},
213235
],
214236
},

0 commit comments

Comments
 (0)