Skip to content

Commit 55d1f14

Browse files
committed
Add library to data extensions editor
This adds a new library column to the data extensions editor containing the JAR or DLL file the method is defined in. This will be used to group methods by library in the future. For now, it just shows in a column.
1 parent 0f9d127 commit 55d1f14

11 files changed

Lines changed: 46 additions & 14 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export function decodeBqrsToExternalApiUsages(
1010
const usage = tuple[0] as Call;
1111
const signature = tuple[1] as string;
1212
const supported = (tuple[2] as string) === "true";
13+
const library = tuple[4] as string;
1314

1415
const [packageWithType, methodDeclaration] = signature.split("#");
1516

@@ -31,6 +32,7 @@ export function decodeBqrsToExternalApiUsages(
3132

3233
if (!methodsByApiName.has(signature)) {
3334
methodsByApiName.set(signature, {
35+
library,
3436
signature,
3537
packageName,
3638
typeName,

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ export type Call = {
66
};
77

88
export type ExternalApiUsage = {
9+
/**
10+
* Contains the name of the library containing the method declaration, e.g. `sql2o-1.6.0.jar` or `System.Runtime.dll`
11+
*/
12+
library: string;
913
/**
1014
* Contains the full method signature, e.g. `org.sql2o.Connection#createQuery(String)`
1115
*/

extensions/ql-vscode/src/data-extensions-editor/queries/csharp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ where
2626
apiName = api.getApiName() and
2727
supported = isSupported(api) and
2828
usage = aUsage(api)
29-
select usage, apiName, supported.toString(), "supported"
29+
select usage, apiName, supported.toString(), "supported", api.getFile().getBaseName(), "library"
3030
`,
3131
dependencies: {
3232
"ExternalApi.qll": `/** Provides classes and predicates related to handling APIs from external libraries. */

extensions/ql-vscode/src/data-extensions-editor/queries/java.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ where
2828
apiName = api.getApiName() and
2929
supported = isSupported(api) and
3030
usage = aUsage(api)
31-
select usage, apiName, supported.toString(), "supported"
31+
select usage, apiName, supported.toString(), "supported", api.jarContainer(), "jar"
3232
`,
3333
dependencies: {
3434
"ExternalApi.qll": `/** Provides classes and predicates related to handling APIs from external libraries. */

extensions/ql-vscode/src/data-extensions-editor/queries/query.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export type Query = {
77
* - apiName: the name of the external API. This is a string.
88
* - supported: whether the external API is supported by the extension. This should be a string representation of a boolean to satify the result pattern for a problem query.
99
* - "supported": a string literal. This is required to make the query a valid problem query.
10+
* - libraryName: the name of the library that contains the external API. This is a string and usually the basename of a file.
11+
* - "library": a string literal. This is required to make the query a valid problem query.
1012
*/
1113
mainQuery: string;
1214
dependencies?: {

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ DataExtensionsEditor.args = {
3434
},
3535
initialExternalApiUsages: [
3636
{
37+
library: "sql2o-1.6.0.jar",
3738
signature: "org.sql2o.Connection#createQuery(String)",
3839
packageName: "org.sql2o",
3940
typeName: "Connection",
@@ -64,6 +65,7 @@ DataExtensionsEditor.args = {
6465
],
6566
},
6667
{
68+
library: "sql2o-1.6.0.jar",
6769
signature: "org.sql2o.Query#executeScalar(Class)",
6870
packageName: "org.sql2o",
6971
typeName: "Query",
@@ -94,6 +96,7 @@ DataExtensionsEditor.args = {
9496
],
9597
},
9698
{
99+
library: "sql2o-1.6.0.jar",
97100
signature: "org.sql2o.Sql2o#open()",
98101
packageName: "org.sql2o",
99102
typeName: "Sql2o",
@@ -124,6 +127,7 @@ DataExtensionsEditor.args = {
124127
],
125128
},
126129
{
130+
library: "rt.jar",
127131
signature: "java.io.PrintStream#println(String)",
128132
packageName: "java.io",
129133
typeName: "PrintStream",
@@ -144,6 +148,7 @@ DataExtensionsEditor.args = {
144148
],
145149
},
146150
{
151+
library: "spring-boot-3.0.2.jar",
147152
signature:
148153
"org.springframework.boot.SpringApplication#run(Class,String[])",
149154
packageName: "org.springframework.boot",
@@ -165,6 +170,7 @@ DataExtensionsEditor.args = {
165170
],
166171
},
167172
{
173+
library: "sql2o-1.6.0.jar",
168174
signature: "org.sql2o.Sql2o#Sql2o(String,String,String)",
169175
packageName: "org.sql2o",
170176
typeName: "Sql2o",
@@ -185,6 +191,7 @@ DataExtensionsEditor.args = {
185191
],
186192
},
187193
{
194+
library: "sql2o-1.6.0.jar",
188195
signature: "org.sql2o.Sql2o#Sql2o(String)",
189196
packageName: "org.sql2o",
190197
typeName: "Sql2o",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const Template: ComponentStory<typeof MethodRowComponent> = (args) => (
1616
export const MethodRow = Template.bind({});
1717
MethodRow.args = {
1818
externalApiUsage: {
19+
library: "sql2o-1.6.0.jar",
1920
signature: "org.sql2o.Sql2o#open()",
2021
packageName: "org.sql2o",
2122
typeName: "Sql2o",

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,24 +235,27 @@ export function DataExtensionsEditor({
235235
<VSCodeDataGrid>
236236
<VSCodeDataGridRow rowType="header">
237237
<VSCodeDataGridCell cellType="columnheader" gridColumn={1}>
238-
Type
238+
Library
239239
</VSCodeDataGridCell>
240240
<VSCodeDataGridCell cellType="columnheader" gridColumn={2}>
241-
Method
241+
Type
242242
</VSCodeDataGridCell>
243243
<VSCodeDataGridCell cellType="columnheader" gridColumn={3}>
244-
Usages
244+
Method
245245
</VSCodeDataGridCell>
246246
<VSCodeDataGridCell cellType="columnheader" gridColumn={4}>
247-
Model type
247+
Usages
248248
</VSCodeDataGridCell>
249249
<VSCodeDataGridCell cellType="columnheader" gridColumn={5}>
250-
Input
250+
Model type
251251
</VSCodeDataGridCell>
252252
<VSCodeDataGridCell cellType="columnheader" gridColumn={6}>
253-
Output
253+
Input
254254
</VSCodeDataGridCell>
255255
<VSCodeDataGridCell cellType="columnheader" gridColumn={7}>
256+
Output
257+
</VSCodeDataGridCell>
258+
<VSCodeDataGridCell cellType="columnheader" gridColumn={8}>
256259
Kind
257260
</VSCodeDataGridCell>
258261
</VSCodeDataGridRow>

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,17 @@ export const MethodRow = ({
149149
return (
150150
<VSCodeDataGridRow>
151151
<VSCodeDataGridCell gridColumn={1}>
152+
{externalApiUsage.library}
153+
</VSCodeDataGridCell>
154+
<VSCodeDataGridCell gridColumn={2}>
152155
<SupportSpan
153156
supported={externalApiUsage.supported}
154157
modeled={modeledMethod}
155158
>
156159
{externalApiUsage.packageName}.{externalApiUsage.typeName}
157160
</SupportSpan>
158161
</VSCodeDataGridCell>
159-
<VSCodeDataGridCell gridColumn={2}>
162+
<VSCodeDataGridCell gridColumn={3}>
160163
<SupportSpan
161164
supported={externalApiUsage.supported}
162165
modeled={modeledMethod}
@@ -165,12 +168,12 @@ export const MethodRow = ({
165168
{externalApiUsage.methodParameters}
166169
</SupportSpan>
167170
</VSCodeDataGridCell>
168-
<VSCodeDataGridCell gridColumn={3}>
171+
<VSCodeDataGridCell gridColumn={4}>
169172
<UsagesButton onClick={jumpToUsage}>
170173
{externalApiUsage.usages.length}
171174
</UsagesButton>
172175
</VSCodeDataGridCell>
173-
<VSCodeDataGridCell gridColumn={4}>
176+
<VSCodeDataGridCell gridColumn={5}>
174177
{(!externalApiUsage.supported ||
175178
(modeledMethod && modeledMethod?.type !== "none")) && (
176179
<Dropdown
@@ -185,7 +188,7 @@ export const MethodRow = ({
185188
</Dropdown>
186189
)}
187190
</VSCodeDataGridCell>
188-
<VSCodeDataGridCell gridColumn={5}>
191+
<VSCodeDataGridCell gridColumn={6}>
189192
{modeledMethod?.type &&
190193
["sink", "summary"].includes(modeledMethod?.type) && (
191194
<Dropdown value={modeledMethod?.input} onInput={handleInputInput}>
@@ -198,7 +201,7 @@ export const MethodRow = ({
198201
</Dropdown>
199202
)}
200203
</VSCodeDataGridCell>
201-
<VSCodeDataGridCell gridColumn={6}>
204+
<VSCodeDataGridCell gridColumn={7}>
202205
{modeledMethod?.type &&
203206
["source", "summary"].includes(modeledMethod?.type) && (
204207
<Dropdown value={modeledMethod?.output} onInput={handleOutputInput}>
@@ -212,7 +215,7 @@ export const MethodRow = ({
212215
</Dropdown>
213216
)}
214217
</VSCodeDataGridCell>
215-
<VSCodeDataGridCell gridColumn={7}>
218+
<VSCodeDataGridCell gridColumn={8}>
216219
{predicate?.supportedKinds && (
217220
<KindInput
218221
kinds={predicate.supportedKinds}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
describe("createAutoModelRequest", () => {
1414
const externalApiUsages: ExternalApiUsage[] = [
1515
{
16+
library: "spring-boot-3.0.2.jar",
1617
signature:
1718
"org.springframework.boot.SpringApplication#run(Class,String[])",
1819
packageName: "org.springframework.boot",
@@ -34,6 +35,7 @@ describe("createAutoModelRequest", () => {
3435
],
3536
},
3637
{
38+
library: "sql2o-1.6.0.jar",
3739
signature: "org.sql2o.Connection#createQuery(String)",
3840
packageName: "org.sql2o",
3941
typeName: "Connection",
@@ -64,6 +66,7 @@ describe("createAutoModelRequest", () => {
6466
],
6567
},
6668
{
69+
library: "sql2o-1.6.0.jar",
6770
signature: "org.sql2o.Query#executeScalar(Class)",
6871
packageName: "org.sql2o",
6972
typeName: "Query",
@@ -94,6 +97,7 @@ describe("createAutoModelRequest", () => {
9497
],
9598
},
9699
{
100+
library: "sql2o-1.6.0.jar",
97101
signature: "org.sql2o.Sql2o#open()",
98102
packageName: "org.sql2o",
99103
typeName: "Sql2o",
@@ -124,6 +128,7 @@ describe("createAutoModelRequest", () => {
124128
],
125129
},
126130
{
131+
library: "rt.jar",
127132
signature: "java.io.PrintStream#println(String)",
128133
packageName: "java.io",
129134
typeName: "PrintStream",
@@ -144,6 +149,7 @@ describe("createAutoModelRequest", () => {
144149
],
145150
},
146151
{
152+
library: "sql2o-1.6.0.jar",
147153
signature: "org.sql2o.Sql2o#Sql2o(String,String,String)",
148154
packageName: "org.sql2o",
149155
typeName: "Sql2o",
@@ -164,6 +170,7 @@ describe("createAutoModelRequest", () => {
164170
],
165171
},
166172
{
173+
library: "sql2o-1.6.0.jar",
167174
signature: "org.sql2o.Sql2o#Sql2o(String)",
168175
packageName: "org.sql2o",
169176
typeName: "Sql2o",
@@ -184,6 +191,7 @@ describe("createAutoModelRequest", () => {
184191
],
185192
},
186193
{
194+
library: "test.jar",
187195
signature: "org.test.MyClass#test()",
188196
packageName: "org.test",
189197
typeName: "MyClass",

0 commit comments

Comments
 (0)