Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions extensions/ql-vscode/src/data-extensions-editor/bqrs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export function decodeBqrsToExternalApiUsages(
const usage = tuple[0] as Call;
const signature = tuple[1] as string;
const supported = (tuple[2] as string) === "true";
const library = tuple[4] as string;

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

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

if (!methodsByApiName.has(signature)) {
methodsByApiName.set(signature, {
library,
signature,
packageName,
typeName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ export type Call = {
};

export type ExternalApiUsage = {
/**
* Contains the name of the library containing the method declaration, e.g. `sql2o-1.6.0.jar` or `System.Runtime.dll`
*/
library: string;
/**
* Contains the full method signature, e.g. `org.sql2o.Connection#createQuery(String)`
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ where
apiName = api.getApiName() and
supported = isSupported(api) and
usage = aUsage(api)
select usage, apiName, supported.toString(), "supported"
select usage, apiName, supported.toString(), "supported", api.getFile().getBaseName(), "library"
`,
dependencies: {
"ExternalApi.qll": `/** Provides classes and predicates related to handling APIs from external libraries. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ where
apiName = api.getApiName() and
supported = isSupported(api) and
usage = aUsage(api)
select usage, apiName, supported.toString(), "supported"
select usage, apiName, supported.toString(), "supported", api.jarContainer(), "library"
`,
dependencies: {
"ExternalApi.qll": `/** Provides classes and predicates related to handling APIs from external libraries. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export type Query = {
* - apiName: the name of the external API. This is a string.
* - 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.
* - "supported": a string literal. This is required to make the query a valid problem query.
* - libraryName: the name of the library that contains the external API. This is a string and usually the basename of a file.
* - "library": a string literal. This is required to make the query a valid problem query.
*/
mainQuery: string;
dependencies?: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ DataExtensionsEditor.args = {
},
initialExternalApiUsages: [
{
library: "sql2o-1.6.0.jar",
signature: "org.sql2o.Connection#createQuery(String)",
packageName: "org.sql2o",
typeName: "Connection",
Expand Down Expand Up @@ -64,6 +65,7 @@ DataExtensionsEditor.args = {
],
},
{
library: "sql2o-1.6.0.jar",
signature: "org.sql2o.Query#executeScalar(Class)",
packageName: "org.sql2o",
typeName: "Query",
Expand Down Expand Up @@ -94,6 +96,7 @@ DataExtensionsEditor.args = {
],
},
{
library: "sql2o-1.6.0.jar",
signature: "org.sql2o.Sql2o#open()",
packageName: "org.sql2o",
typeName: "Sql2o",
Expand Down Expand Up @@ -124,6 +127,7 @@ DataExtensionsEditor.args = {
],
},
{
library: "rt.jar",
signature: "java.io.PrintStream#println(String)",
packageName: "java.io",
typeName: "PrintStream",
Expand All @@ -144,6 +148,7 @@ DataExtensionsEditor.args = {
],
},
{
library: "spring-boot-3.0.2.jar",
signature:
"org.springframework.boot.SpringApplication#run(Class,String[])",
packageName: "org.springframework.boot",
Expand All @@ -165,6 +170,7 @@ DataExtensionsEditor.args = {
],
},
{
library: "sql2o-1.6.0.jar",
signature: "org.sql2o.Sql2o#Sql2o(String,String,String)",
packageName: "org.sql2o",
typeName: "Sql2o",
Expand All @@ -185,6 +191,7 @@ DataExtensionsEditor.args = {
],
},
{
library: "sql2o-1.6.0.jar",
signature: "org.sql2o.Sql2o#Sql2o(String)",
packageName: "org.sql2o",
typeName: "Sql2o",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const Template: ComponentStory<typeof MethodRowComponent> = (args) => (
export const MethodRow = Template.bind({});
MethodRow.args = {
externalApiUsage: {
library: "sql2o-1.6.0.jar",
signature: "org.sql2o.Sql2o#open()",
packageName: "org.sql2o",
typeName: "Sql2o",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,24 +235,27 @@ export function DataExtensionsEditor({
<VSCodeDataGrid>
<VSCodeDataGridRow rowType="header">
<VSCodeDataGridCell cellType="columnheader" gridColumn={1}>
Type
Library
</VSCodeDataGridCell>
<VSCodeDataGridCell cellType="columnheader" gridColumn={2}>
Method
Type
</VSCodeDataGridCell>
<VSCodeDataGridCell cellType="columnheader" gridColumn={3}>
Usages
Method
</VSCodeDataGridCell>
<VSCodeDataGridCell cellType="columnheader" gridColumn={4}>
Model type
Usages
</VSCodeDataGridCell>
<VSCodeDataGridCell cellType="columnheader" gridColumn={5}>
Input
Model type
</VSCodeDataGridCell>
<VSCodeDataGridCell cellType="columnheader" gridColumn={6}>
Output
Input
</VSCodeDataGridCell>
<VSCodeDataGridCell cellType="columnheader" gridColumn={7}>
Output
</VSCodeDataGridCell>
<VSCodeDataGridCell cellType="columnheader" gridColumn={8}>
Kind
</VSCodeDataGridCell>
</VSCodeDataGridRow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,17 @@ export const MethodRow = ({
return (
<VSCodeDataGridRow>
<VSCodeDataGridCell gridColumn={1}>
{externalApiUsage.library}
</VSCodeDataGridCell>
<VSCodeDataGridCell gridColumn={2}>
<SupportSpan
supported={externalApiUsage.supported}
modeled={modeledMethod}
>
{externalApiUsage.packageName}.{externalApiUsage.typeName}
</SupportSpan>
</VSCodeDataGridCell>
<VSCodeDataGridCell gridColumn={2}>
<VSCodeDataGridCell gridColumn={3}>
<SupportSpan
supported={externalApiUsage.supported}
modeled={modeledMethod}
Expand All @@ -165,12 +168,12 @@ export const MethodRow = ({
{externalApiUsage.methodParameters}
</SupportSpan>
</VSCodeDataGridCell>
<VSCodeDataGridCell gridColumn={3}>
<VSCodeDataGridCell gridColumn={4}>
<UsagesButton onClick={jumpToUsage}>
{externalApiUsage.usages.length}
</UsagesButton>
</VSCodeDataGridCell>
<VSCodeDataGridCell gridColumn={4}>
<VSCodeDataGridCell gridColumn={5}>
{(!externalApiUsage.supported ||
(modeledMethod && modeledMethod?.type !== "none")) && (
<Dropdown
Expand All @@ -185,7 +188,7 @@ export const MethodRow = ({
</Dropdown>
)}
</VSCodeDataGridCell>
<VSCodeDataGridCell gridColumn={5}>
<VSCodeDataGridCell gridColumn={6}>
{modeledMethod?.type &&
["sink", "summary"].includes(modeledMethod?.type) && (
<Dropdown value={modeledMethod?.input} onInput={handleInputInput}>
Expand All @@ -198,7 +201,7 @@ export const MethodRow = ({
</Dropdown>
)}
</VSCodeDataGridCell>
<VSCodeDataGridCell gridColumn={6}>
<VSCodeDataGridCell gridColumn={7}>
{modeledMethod?.type &&
["source", "summary"].includes(modeledMethod?.type) && (
<Dropdown value={modeledMethod?.output} onInput={handleOutputInput}>
Expand All @@ -212,7 +215,7 @@ export const MethodRow = ({
</Dropdown>
)}
</VSCodeDataGridCell>
<VSCodeDataGridCell gridColumn={7}>
<VSCodeDataGridCell gridColumn={8}>
{predicate?.supportedKinds && (
<KindInput
kinds={predicate.supportedKinds}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
describe("createAutoModelRequest", () => {
const externalApiUsages: ExternalApiUsage[] = [
{
library: "spring-boot-3.0.2.jar",
signature:
"org.springframework.boot.SpringApplication#run(Class,String[])",
packageName: "org.springframework.boot",
Expand All @@ -34,6 +35,7 @@ describe("createAutoModelRequest", () => {
],
},
{
library: "sql2o-1.6.0.jar",
signature: "org.sql2o.Connection#createQuery(String)",
packageName: "org.sql2o",
typeName: "Connection",
Expand Down Expand Up @@ -64,6 +66,7 @@ describe("createAutoModelRequest", () => {
],
},
{
library: "sql2o-1.6.0.jar",
signature: "org.sql2o.Query#executeScalar(Class)",
packageName: "org.sql2o",
typeName: "Query",
Expand Down Expand Up @@ -94,6 +97,7 @@ describe("createAutoModelRequest", () => {
],
},
{
library: "sql2o-1.6.0.jar",
signature: "org.sql2o.Sql2o#open()",
packageName: "org.sql2o",
typeName: "Sql2o",
Expand Down Expand Up @@ -124,6 +128,7 @@ describe("createAutoModelRequest", () => {
],
},
{
library: "rt.jar",
signature: "java.io.PrintStream#println(String)",
packageName: "java.io",
typeName: "PrintStream",
Expand All @@ -144,6 +149,7 @@ describe("createAutoModelRequest", () => {
],
},
{
library: "sql2o-1.6.0.jar",
signature: "org.sql2o.Sql2o#Sql2o(String,String,String)",
packageName: "org.sql2o",
typeName: "Sql2o",
Expand All @@ -164,6 +170,7 @@ describe("createAutoModelRequest", () => {
],
},
{
library: "sql2o-1.6.0.jar",
signature: "org.sql2o.Sql2o#Sql2o(String)",
packageName: "org.sql2o",
typeName: "Sql2o",
Expand All @@ -184,6 +191,7 @@ describe("createAutoModelRequest", () => {
],
},
{
library: "test.jar",
signature: "org.test.MyClass#test()",
packageName: "org.test",
typeName: "MyClass",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ describe("createDataExtensionYaml", () => {
"java",
[
{
library: "sql2o-1.6.0.jar",
signature: "org.sql2o.Connection#createQuery(String)",
packageName: "org.sql2o",
typeName: "Connection",
Expand Down Expand Up @@ -39,6 +40,7 @@ describe("createDataExtensionYaml", () => {
],
},
{
library: "sql2o-1.6.0.jar",
signature: "org.sql2o.Query#executeScalar(Class)",
packageName: "org.sql2o",
typeName: "Query",
Expand Down