Show labels for methods only classified in test and generated
This commit is contained in:
@@ -116,6 +116,17 @@ DataExtensionsEditor.args = {
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
{
|
||||
label: "println(...)",
|
||||
url: {
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/test/java/org/example/HelloControllerTest.java",
|
||||
startLine: 29,
|
||||
startColumn: 9,
|
||||
endLine: 29,
|
||||
endColumn: 49,
|
||||
},
|
||||
classification: CallClassification.Test,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -170,17 +181,30 @@ DataExtensionsEditor.args = {
|
||||
methodParameters: "(String)",
|
||||
supported: false,
|
||||
supportedType: "none",
|
||||
usages: Array(4).fill({
|
||||
label: "new Sql2o(...)",
|
||||
url: {
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 23,
|
||||
startColumn: 23,
|
||||
endLine: 23,
|
||||
endColumn: 36,
|
||||
usages: [
|
||||
...Array(4).fill({
|
||||
label: "new Sql2o(...)",
|
||||
url: {
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java",
|
||||
startLine: 23,
|
||||
startColumn: 23,
|
||||
endLine: 23,
|
||||
endColumn: 36,
|
||||
},
|
||||
classification: CallClassification.Test,
|
||||
}),
|
||||
{
|
||||
label: "new Sql2o(...)",
|
||||
url: {
|
||||
uri: "file:/home/runner/work/sql2o-example/sql2o-example/build/generated/java/org/example/HelloControllerGenerated.java",
|
||||
startLine: 23,
|
||||
startColumn: 23,
|
||||
endLine: 23,
|
||||
endColumn: 36,
|
||||
},
|
||||
classification: CallClassification.Generated,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
initialModeledMethods: {
|
||||
|
||||
@@ -3,13 +3,17 @@ import {
|
||||
VSCodeDataGridCell,
|
||||
VSCodeDataGridRow,
|
||||
VSCodeLink,
|
||||
VSCodeTag,
|
||||
} from "@vscode/webview-ui-toolkit/react";
|
||||
import * as React from "react";
|
||||
import { ChangeEvent, useCallback, useMemo } from "react";
|
||||
import styled from "styled-components";
|
||||
import { vscode } from "../vscode-api";
|
||||
|
||||
import { ExternalApiUsage } from "../../data-extensions-editor/external-api-usage";
|
||||
import {
|
||||
CallClassification,
|
||||
ExternalApiUsage,
|
||||
} from "../../data-extensions-editor/external-api-usage";
|
||||
import {
|
||||
ModeledMethod,
|
||||
ModeledMethodType,
|
||||
@@ -39,6 +43,12 @@ const ViewLink = styled(VSCodeLink)`
|
||||
white-space: nowrap;
|
||||
`;
|
||||
|
||||
const ClassificationsContainer = styled.div`
|
||||
display: inline-flex;
|
||||
flex-direction: row;
|
||||
gap: 0.5rem;
|
||||
`;
|
||||
|
||||
const modelTypeOptions: Array<{ value: ModeledMethodType; label: string }> = [
|
||||
{ value: "none", label: "Unmodeled" },
|
||||
{ value: "source", label: "Source" },
|
||||
@@ -194,6 +204,20 @@ function ModelableMethodRow(props: Props) {
|
||||
: undefined;
|
||||
const showKindCell = predicate?.supportedKinds;
|
||||
|
||||
const allUsageClassifications = useMemo(
|
||||
() =>
|
||||
new Set(
|
||||
externalApiUsage.usages.map((usage) => {
|
||||
return usage.classification;
|
||||
}),
|
||||
),
|
||||
[externalApiUsage.usages],
|
||||
);
|
||||
|
||||
const inSource = allUsageClassifications.has(CallClassification.Source);
|
||||
const inTest = allUsageClassifications.has(CallClassification.Test);
|
||||
const inGenerated = allUsageClassifications.has(CallClassification.Generated);
|
||||
|
||||
return (
|
||||
<VSCodeDataGridRow>
|
||||
<ApiOrMethodCell gridColumn={1}>
|
||||
@@ -205,6 +229,12 @@ function ModelableMethodRow(props: Props) {
|
||||
</UsagesButton>
|
||||
)}
|
||||
<ViewLink onClick={jumpToUsage}>View</ViewLink>
|
||||
{!inSource && (
|
||||
<ClassificationsContainer>
|
||||
{inTest && <VSCodeTag>Test</VSCodeTag>}
|
||||
{inGenerated && <VSCodeTag>Generated</VSCodeTag>}
|
||||
</ClassificationsContainer>
|
||||
)}
|
||||
</ApiOrMethodCell>
|
||||
<VSCodeDataGridCell gridColumn={2}>
|
||||
<Dropdown
|
||||
|
||||
Reference in New Issue
Block a user