@@ -10,9 +10,18 @@ import { SarifLocation } from "./SarifLocation";
10
10
11
11
/** The definition of a taxon for a data extension model row. */
12
12
interface ModelTaxon {
13
+ kind : "model" ;
13
14
location : SarifLogLocation ;
14
15
}
15
16
17
+ /** A taxon for a built-in model, such as `AdditionalFlowStep`. */
18
+ interface BuiltInTaxon {
19
+ kind : "string" ;
20
+ text : string ;
21
+ }
22
+
23
+ type TaxonDefinition = ModelTaxon | BuiltInTaxon ;
24
+
16
25
/** Resolve an `ArtifactLocation` that might contain a relative reference instead of an absolute
17
26
* URI.
18
27
*/
@@ -49,12 +58,33 @@ function getLocalPackUri(extension: ToolComponent): URL | undefined {
49
58
return new URL ( localPackLocation . uri ) ;
50
59
}
51
60
52
- /** Resolve a `ReportingDescriptorReference` to the `ReportingDescriptor` for the taxon that it
53
- * refers to .
61
+ /** Resolve a `ReportingDescriptorReference` to the built-in taxon it refers to, or `undefined` if
62
+ * it is not a built-in taxon .
54
63
*/
55
- function resolveTaxonDefinition (
56
- run : Run ,
64
+ function resolveBuiltInTaxon (
57
65
taxonRef : ReportingDescriptorReference ,
66
+ ) : BuiltInTaxon | undefined {
67
+ if (
68
+ taxonRef . id !== undefined &&
69
+ taxonRef . index === undefined &&
70
+ taxonRef . toolComponent === undefined
71
+ ) {
72
+ return {
73
+ kind : "string" ,
74
+ text : taxonRef . id ,
75
+ } ;
76
+ } else {
77
+ return undefined ;
78
+ }
79
+ }
80
+
81
+ /**
82
+ * Resolve a `ReportingDescriptorReference` to the MaD taxon definition it refers to, or
83
+ * `undefined` if it does not refer to a MaD model.
84
+ */
85
+ function resolveModelTaxon (
86
+ taxonRef : ReportingDescriptorReference ,
87
+ run : Run ,
58
88
) : ModelTaxon | undefined {
59
89
const extensions = run . tool . extensions ;
60
90
if ( extensions === undefined ) {
@@ -101,6 +131,7 @@ function resolveTaxonDefinition(
101
131
}
102
132
103
133
return {
134
+ kind : "model" ,
104
135
location : {
105
136
physicalLocation : {
106
137
...location ,
@@ -113,6 +144,14 @@ function resolveTaxonDefinition(
113
144
} ;
114
145
}
115
146
147
+ /** Resolve a `ReportingDescriptorReference` to the taxon definition it refers to. */
148
+ function resolveTaxonDefinition (
149
+ run : Run ,
150
+ taxonRef : ReportingDescriptorReference ,
151
+ ) : TaxonDefinition | undefined {
152
+ return resolveModelTaxon ( taxonRef , run ) ?? resolveBuiltInTaxon ( taxonRef ) ;
153
+ }
154
+
116
155
interface Props {
117
156
taxa : ReportingDescriptorReference [ ] | undefined ;
118
157
run : Run | undefined ;
@@ -148,8 +187,9 @@ export function TaxaLocations({
148
187
< div key = { index } >
149
188
{ `(${ role } ) ` }
150
189
< SarifLocation
151
- loc = { taxonDef . location }
190
+ loc = { taxonDef . kind === "model" ? taxonDef . location : undefined }
152
191
databaseUri = { undefined }
192
+ text = { taxonDef . kind === "string" ? taxonDef . text : undefined }
153
193
sourceLocationPrefix = ""
154
194
onClick = { onClick }
155
195
/>
0 commit comments