|
| 1 | +/** |
| 2 | + * TODO: Types in this file are deprecated, and uses of them should be |
| 3 | + * migrated to the analogous types in bqrs-cli-types. |
| 4 | + */ |
| 5 | + |
| 6 | +export enum LocationStyle { |
| 7 | + None = 0, |
| 8 | + String, |
| 9 | + FivePart, |
| 10 | + /** Does not occur in BQRS files. Used only to distinguish whole-file locations in client code. */ |
| 11 | + WholeFile |
| 12 | +} |
| 13 | + |
| 14 | +/** |
| 15 | + * A primitive type (any type other than an element). |
| 16 | + */ |
| 17 | +export type PrimitiveTypeKind = 's' | 'b' | 'i' | 'f' | 'd' | 'u'; |
| 18 | + |
| 19 | +/** |
| 20 | + * A kind of type that a column may have. |
| 21 | + */ |
| 22 | +export type ColumnTypeKind = PrimitiveTypeKind | 'e'; |
| 23 | + |
| 24 | +/** |
| 25 | + * A column type that is a primitive type. |
| 26 | + */ |
| 27 | +export interface PrimitiveColumnType { |
| 28 | + type: PrimitiveTypeKind; |
| 29 | +} |
| 30 | + |
| 31 | +/** |
| 32 | + * A column type that is an element type. |
| 33 | + */ |
| 34 | +export interface ElementColumnType { |
| 35 | + type: 'e'; |
| 36 | + primitiveType: PrimitiveTypeKind; |
| 37 | + locationStyle: LocationStyle; |
| 38 | + hasLabel: boolean; |
| 39 | +} |
| 40 | + |
| 41 | +/** |
| 42 | + * The type of a column. |
| 43 | + */ |
| 44 | +export type ColumnType = PrimitiveColumnType | ElementColumnType; |
| 45 | + |
| 46 | +/** |
| 47 | + * The schema describing a single column in a `ResultSet`. |
| 48 | + */ |
| 49 | +export interface ColumnSchema { |
| 50 | + readonly name: string; |
| 51 | + readonly type: ColumnType; |
| 52 | +} |
| 53 | + |
| 54 | +/** |
| 55 | + * The schema of a single `ResultSet` in a BQRS file. |
| 56 | + */ |
| 57 | +export interface ResultSetSchema { |
| 58 | + readonly version: number; |
| 59 | + readonly name: string; |
| 60 | + readonly tupleCount: number; |
| 61 | + readonly columns: readonly ColumnSchema[]; |
| 62 | +} |
| 63 | + |
| 64 | +/** |
| 65 | + * The schema describing the contents of a BQRS file. |
| 66 | + */ |
| 67 | +export interface ResultSetsSchema { |
| 68 | + readonly version: number; |
| 69 | + readonly stringPoolSize: number; |
| 70 | + readonly resultSets: readonly ResultSetSchema[]; |
| 71 | +} |
| 72 | + |
| 73 | +// See https://help.semmle.com/QL/learn-ql/ql/locations.html for how these are used. |
| 74 | +export interface FivePartLocation { |
| 75 | + t: LocationStyle.FivePart; |
| 76 | + file: string; |
| 77 | + lineStart: number; |
| 78 | + colStart: number; |
| 79 | + lineEnd: number; |
| 80 | + colEnd: number; |
| 81 | +} |
| 82 | + |
| 83 | +export interface StringLocation { |
| 84 | + t: LocationStyle.String; |
| 85 | + loc: string; |
| 86 | +} |
| 87 | + |
| 88 | +/** |
| 89 | + * A location representing an entire filesystem resource. |
| 90 | + * This is usually derived from a `StringLocation` with the entire filesystem URL. |
| 91 | + */ |
| 92 | +export interface WholeFileLocation { |
| 93 | + t: LocationStyle.WholeFile; |
| 94 | + file: string; |
| 95 | +} |
| 96 | + |
| 97 | +export type RawLocationValue = FivePartLocation | StringLocation; |
| 98 | + |
| 99 | +export type LocationValue = RawLocationValue | WholeFileLocation; |
| 100 | + |
| 101 | +/** A location that may be resolved to a source code element. */ |
| 102 | +export type ResolvableLocationValue = FivePartLocation | WholeFileLocation; |
0 commit comments