Skip to content

Commit 082c5e4

Browse files
committed
Prefix BQRS types with Bqrs
1 parent 439cfcc commit 082c5e4

13 files changed

Lines changed: 89 additions & 81 deletions

File tree

extensions/ql-vscode/src/codeql-cli/cli.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { promisify } from "util";
1111
import { CancellationToken, Disposable, Uri } from "vscode";
1212

1313
import {
14-
BQRSInfo,
14+
BqrsInfo,
1515
DecodedBqrs,
1616
DecodedBqrsChunk,
1717
} from "../common/bqrs-cli-types";
@@ -928,11 +928,11 @@ export class CodeQLCliServer implements Disposable {
928928
* @param bqrsPath The path to the bqrs.
929929
* @param pageSize The page size to precompute offsets into the binary file for.
930930
*/
931-
async bqrsInfo(bqrsPath: string, pageSize?: number): Promise<BQRSInfo> {
931+
async bqrsInfo(bqrsPath: string, pageSize?: number): Promise<BqrsInfo> {
932932
const subcommandArgs = (
933933
pageSize ? ["--paginate-rows", pageSize.toString()] : []
934934
).concat(bqrsPath);
935-
return await this.runJsonCodeQlCliCommand<BQRSInfo>(
935+
return await this.runJsonCodeQlCliCommand<BqrsInfo>(
936936
["bqrs", "info"],
937937
subcommandArgs,
938938
"Reading bqrs header",

extensions/ql-vscode/src/common/bqrs-cli-types.ts

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* the "for the sake of extensibility" comment in messages.ts.
55
*/
66
// eslint-disable-next-line @typescript-eslint/no-namespace
7-
export namespace ColumnKindCode {
7+
export namespace BqrsColumnKindCode {
88
export const FLOAT = "f";
99
export const INTEGER = "i";
1010
export const STRING = "s";
@@ -13,70 +13,70 @@ export namespace ColumnKindCode {
1313
export const ENTITY = "e";
1414
}
1515

16-
export type ColumnKind =
17-
| typeof ColumnKindCode.FLOAT
18-
| typeof ColumnKindCode.INTEGER
19-
| typeof ColumnKindCode.STRING
20-
| typeof ColumnKindCode.BOOLEAN
21-
| typeof ColumnKindCode.DATE
22-
| typeof ColumnKindCode.ENTITY;
16+
export type BqrsColumnKind =
17+
| typeof BqrsColumnKindCode.FLOAT
18+
| typeof BqrsColumnKindCode.INTEGER
19+
| typeof BqrsColumnKindCode.STRING
20+
| typeof BqrsColumnKindCode.BOOLEAN
21+
| typeof BqrsColumnKindCode.DATE
22+
| typeof BqrsColumnKindCode.ENTITY;
2323

24-
interface Column {
24+
interface BqrsSchemaColumn {
2525
name?: string;
26-
kind: ColumnKind;
26+
kind: BqrsColumnKind;
2727
}
2828

29-
export interface ResultSetSchema {
29+
export interface BqrsResultSetSchema {
3030
name: string;
3131
rows: number;
32-
columns: Column[];
33-
pagination?: PaginationInfo;
32+
columns: BqrsSchemaColumn[];
33+
pagination?: BqrsPaginationInfo;
3434
}
3535

36-
interface PaginationInfo {
36+
interface BqrsPaginationInfo {
3737
"step-size": number;
3838
offsets: number[];
3939
}
4040

41-
export interface BQRSInfo {
42-
"result-sets": ResultSetSchema[];
41+
export interface BqrsInfo {
42+
"result-sets": BqrsResultSetSchema[];
4343
}
4444

4545
export type BqrsId = number;
4646

47-
export interface EntityValue {
48-
url?: UrlValue;
47+
export interface BqrsEntityValue {
48+
url?: BqrsUrlValue;
4949
label?: string;
5050
id?: BqrsId;
5151
}
5252

53-
export interface LineColumnLocation {
53+
export interface BqrsLineColumnLocation {
5454
uri: string;
5555
startLine: number;
5656
startColumn: number;
5757
endLine: number;
5858
endColumn: number;
5959
}
6060

61-
export interface WholeFileLocation {
61+
export interface BqrsWholeFileLocation {
6262
uri: string;
6363
startLine: never;
6464
startColumn: never;
6565
endLine: never;
6666
endColumn: never;
6767
}
6868

69-
type ResolvableLocationValue = WholeFileLocation | LineColumnLocation;
69+
export type BqrsUrlValue =
70+
| BqrsWholeFileLocation
71+
| BqrsLineColumnLocation
72+
| string;
7073

71-
export type UrlValue = ResolvableLocationValue | string;
72-
73-
export type CellValue = EntityValue | number | string | boolean;
74+
export type BqrsCellValue = BqrsEntityValue | number | string | boolean;
7475

7576
export type BqrsKind =
7677
| "String"
7778
| "Float"
7879
| "Integer"
79-
| "String"
8080
| "Boolean"
8181
| "Date"
8282
| "Entity";
@@ -85,8 +85,9 @@ interface BqrsColumn {
8585
name?: string;
8686
kind: BqrsKind;
8787
}
88+
8889
export interface DecodedBqrsChunk {
89-
tuples: CellValue[][];
90+
tuples: BqrsCellValue[][];
9091
next?: number;
9192
columns: BqrsColumn[];
9293
}

extensions/ql-vscode/src/common/bqrs-result.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import {
2-
CellValue as BqrsCellValue,
3-
ColumnKind as BqrsColumnKind,
4-
ColumnKindCode,
2+
BqrsCellValue as BqrsCellValue,
3+
BqrsColumnKind as BqrsColumnKind,
4+
BqrsColumnKindCode,
55
DecodedBqrsChunk,
6-
EntityValue as BqrsEntityValue,
7-
LineColumnLocation,
8-
ResultSetSchema,
9-
UrlValue as BqrsUrlValue,
10-
WholeFileLocation,
6+
BqrsEntityValue as BqrsEntityValue,
7+
BqrsLineColumnLocation,
8+
BqrsResultSetSchema,
9+
BqrsUrlValue as BqrsUrlValue,
10+
BqrsWholeFileLocation,
1111
} from "./bqrs-cli-types";
1212
import {
1313
CellValue,
@@ -23,7 +23,7 @@ import { assertNever } from "./helpers-pure";
2323
import { isEmptyPath } from "./bqrs-utils";
2424

2525
export function bqrsToResultSet(
26-
schema: ResultSetSchema,
26+
schema: BqrsResultSetSchema,
2727
chunk: DecodedBqrsChunk,
2828
): RawResultSet {
2929
const name = schema.name;
@@ -52,17 +52,17 @@ export function bqrsToResultSet(
5252

5353
function mapColumnKind(kind: BqrsColumnKind): ColumnKind {
5454
switch (kind) {
55-
case ColumnKindCode.STRING:
55+
case BqrsColumnKindCode.STRING:
5656
return ColumnKind.String;
57-
case ColumnKindCode.FLOAT:
57+
case BqrsColumnKindCode.FLOAT:
5858
return ColumnKind.Float;
59-
case ColumnKindCode.INTEGER:
59+
case BqrsColumnKindCode.INTEGER:
6060
return ColumnKind.Integer;
61-
case ColumnKindCode.BOOLEAN:
61+
case BqrsColumnKindCode.BOOLEAN:
6262
return ColumnKind.Boolean;
63-
case ColumnKindCode.DATE:
63+
case BqrsColumnKindCode.DATE:
6464
return ColumnKind.Date;
65-
case ColumnKindCode.ENTITY:
65+
case BqrsColumnKindCode.ENTITY:
6666
return ColumnKind.Entity;
6767
default:
6868
assertNever(kind);
@@ -136,7 +136,7 @@ export function mapUrlValue(urlValue: BqrsUrlValue): UrlValue | undefined {
136136
return undefined;
137137
}
138138

139-
function isLineColumnLoc(loc: BqrsUrlValue): loc is LineColumnLocation {
139+
function isLineColumnLoc(loc: BqrsUrlValue): loc is BqrsLineColumnLocation {
140140
return (
141141
typeof loc !== "string" &&
142142
!isEmptyPath(loc.uri) &&
@@ -147,7 +147,7 @@ function isLineColumnLoc(loc: BqrsUrlValue): loc is LineColumnLocation {
147147
);
148148
}
149149

150-
function isWholeFileLoc(loc: BqrsUrlValue): loc is WholeFileLocation {
150+
function isWholeFileLoc(loc: BqrsUrlValue): loc is BqrsWholeFileLocation {
151151
return (
152152
typeof loc !== "string" && !isEmptyPath(loc.uri) && !isLineColumnLoc(loc)
153153
);

extensions/ql-vscode/src/compare/compare-view.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { extLogger } from "../common/logging/vscode";
1010
import { CodeQLCliServer } from "../codeql-cli/cli";
1111
import { DatabaseManager } from "../databases/local-databases";
1212
import { jumpToLocation } from "../databases/local-databases/locations";
13-
import { BQRSInfo } from "../common/bqrs-cli-types";
13+
import { BqrsInfo } from "../common/bqrs-cli-types";
1414
import resultsDiff from "./resultsDiff";
1515
import { CompletedLocalQueryInfo } from "../query-results";
1616
import { assertNever, getErrorMessage } from "../common/helpers-pure";
@@ -232,7 +232,7 @@ export class CompareView extends AbstractWebview<
232232
}
233233

234234
private async getResultSet(
235-
bqrsInfo: BQRSInfo,
235+
bqrsInfo: BqrsInfo,
236236
resultSetName: string,
237237
resultsPath: string,
238238
): Promise<RawResultSet> {

extensions/ql-vscode/src/language-support/ast-viewer/ast-builder.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { CodeQLCliServer } from "../../codeql-cli/cli";
22
import {
33
DecodedBqrsChunk,
44
BqrsId,
5-
EntityValue,
5+
BqrsEntityValue,
66
} from "../../common/bqrs-cli-types";
77
import { DatabaseItem } from "../../databases/local-databases";
88
import { ChildAstItem, AstItem } from "./ast-viewer";
@@ -56,8 +56,8 @@ export class AstBuilder {
5656
// Build up the parent-child relationships
5757
edgeTuples.tuples.forEach((tuple) => {
5858
const [source, target, tupleType, value] = tuple as [
59-
EntityValue,
60-
EntityValue,
59+
BqrsEntityValue,
60+
BqrsEntityValue,
6161
string,
6262
string,
6363
];
@@ -91,7 +91,11 @@ export class AstBuilder {
9191

9292
// populate parents and children
9393
nodeTuples.tuples.forEach((tuple) => {
94-
const [entity, tupleType, value] = tuple as [EntityValue, string, string];
94+
const [entity, tupleType, value] = tuple as [
95+
BqrsEntityValue,
96+
string,
97+
string,
98+
];
9599
const id = entity.id!;
96100

97101
switch (tupleType) {

extensions/ql-vscode/src/language-support/contextual/file-range-from-uri.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
import * as vscode from "vscode";
22

3-
import { UrlValue, LineColumnLocation } from "../../common/bqrs-cli-types";
3+
import {
4+
BqrsUrlValue,
5+
BqrsLineColumnLocation,
6+
} from "../../common/bqrs-cli-types";
47
import { isEmptyPath } from "../../common/bqrs-utils";
58
import { DatabaseItem } from "../../databases/local-databases";
69

710
export function fileRangeFromURI(
8-
uri: UrlValue | undefined,
11+
uri: BqrsUrlValue | undefined,
912
db: DatabaseItem,
1013
): vscode.Location | undefined {
1114
if (!uri || typeof uri === "string") {
1215
return undefined;
1316
} else if ("startOffset" in uri) {
1417
return undefined;
1518
} else {
16-
const loc = uri as LineColumnLocation;
19+
const loc = uri as BqrsLineColumnLocation;
1720
if (isEmptyPath(loc.uri)) {
1821
return undefined;
1922
}

extensions/ql-vscode/src/language-support/contextual/location-finder.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import {
33
encodeArchiveBasePath,
44
} from "../../common/vscode/archive-filesystem-provider";
55
import {
6-
ColumnKindCode,
7-
EntityValue,
8-
ResultSetSchema,
6+
BqrsColumnKindCode,
7+
BqrsEntityValue,
8+
BqrsResultSetSchema,
99
} from "../../common/bqrs-cli-types";
1010
import { CodeQLCliServer } from "../../codeql-cli/cli";
1111
import { DatabaseItem, DatabaseManager } from "../../databases/local-databases";
@@ -105,7 +105,7 @@ async function getLinksFromResults(
105105
// TODO: Page this
106106
const allTuples = await cli.bqrsDecode(bqrsPath, SELECT_QUERY_NAME);
107107
for (const tuple of allTuples.tuples) {
108-
const [src, dest] = tuple as [EntityValue, EntityValue];
108+
const [src, dest] = tuple as [BqrsEntityValue, BqrsEntityValue];
109109
const srcFile = src.url && fileRangeFromURI(src.url, db);
110110
const destFile = dest.url && fileRangeFromURI(dest.url, db);
111111
if (
@@ -131,12 +131,12 @@ function createTemplates(path: string): Record<string, string> {
131131
};
132132
}
133133

134-
function isValidSelect(selectInfo: ResultSetSchema | undefined) {
134+
function isValidSelect(selectInfo: BqrsResultSetSchema | undefined) {
135135
return (
136136
selectInfo &&
137137
selectInfo.columns.length === 3 &&
138-
selectInfo.columns[0].kind === ColumnKindCode.ENTITY &&
139-
selectInfo.columns[1].kind === ColumnKindCode.ENTITY &&
140-
selectInfo.columns[2].kind === ColumnKindCode.STRING
138+
selectInfo.columns[0].kind === BqrsColumnKindCode.ENTITY &&
139+
selectInfo.columns[1].kind === BqrsColumnKindCode.ENTITY &&
140+
selectInfo.columns[2].kind === BqrsColumnKindCode.STRING
141141
);
142142
}

extensions/ql-vscode/src/local-queries/results-view.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ import { ResultsViewCommands } from "../common/commands";
7373
import { App } from "../common/app";
7474
import { Disposable } from "../common/disposable-object";
7575
import { RawResultSet } from "../common/raw-result-types";
76-
import { ResultSetSchema } from "../common/bqrs-cli-types";
76+
import { BqrsResultSetSchema } from "../common/bqrs-cli-types";
7777

7878
/**
7979
* results-view.ts
@@ -599,7 +599,7 @@ export class ResultsView extends AbstractWebview<
599599
private async getResultSetSchemas(
600600
completedQuery: CompletedQueryInfo,
601601
selectedTable = "",
602-
): Promise<ResultSetSchema[]> {
602+
): Promise<BqrsResultSetSchema[]> {
603603
const resultsPath = completedQuery.getResultsPath(selectedTable);
604604
const schemas = await this.cliServer.bqrsInfo(
605605
resultsPath,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DecodedBqrsChunk, EntityValue } from "../common/bqrs-cli-types";
1+
import { DecodedBqrsChunk, BqrsEntityValue } from "../common/bqrs-cli-types";
22
import { CallClassification, Method, Usage } from "./method";
33
import { ModeledMethodType } from "./modeled-method";
44
import { parseLibraryFilename } from "./library";
@@ -19,7 +19,7 @@ export function decodeBqrsToMethods(
1919
const definition = getModelsAsDataLanguage(language);
2020

2121
chunk?.tuples.forEach((tuple) => {
22-
let usageEntityValue: EntityValue;
22+
let usageEntityValue: BqrsEntityValue;
2323
let packageName: string;
2424
let typeName: string;
2525
let methodName: string;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { CallClassification } from "../method";
22
import { ModeledMethodType } from "../modeled-method";
3-
import { EntityValue } from "../../common/bqrs-cli-types";
3+
import { BqrsEntityValue } from "../../common/bqrs-cli-types";
44

55
export type Query = {
66
/**
@@ -40,7 +40,7 @@ export type Query = {
4040
};
4141

4242
export type ApplicationModeTuple = [
43-
EntityValue,
43+
BqrsEntityValue,
4444
string,
4545
string,
4646
string,
@@ -53,7 +53,7 @@ export type ApplicationModeTuple = [
5353
];
5454

5555
export type FrameworkModeTuple = [
56-
EntityValue,
56+
BqrsEntityValue,
5757
string,
5858
string,
5959
string,

0 commit comments

Comments
 (0)