Skip to content

Commit

Permalink
Merge pull request #3647 from d10c/d10c/bigint-quick-eval
Browse files Browse the repository at this point in the history
  • Loading branch information
d10c authored Oct 14, 2024
2 parents fb3c00b + c4eaf54 commit 9cc790e
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 3 deletions.
2 changes: 2 additions & 0 deletions extensions/ql-vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [UNRELEASED]

- Support result columns of type `QlBuiltins::BigInt` in quick evaluations. [#3647](https://github.com/github/vscode-codeql/pull/3647)

## 1.16.0 - 10 October 2024

- Increase the required version of VS Code to 1.90.0. [#3737](https://github.com/github/vscode-codeql/pull/3737)
Expand Down
7 changes: 5 additions & 2 deletions extensions/ql-vscode/src/common/bqrs-cli-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export namespace BqrsColumnKindCode {
export const BOOLEAN = "b";
export const DATE = "d";
export const ENTITY = "e";
export const BIGINT = "z";
}

export type BqrsColumnKind =
Expand All @@ -19,7 +20,8 @@ export type BqrsColumnKind =
| typeof BqrsColumnKindCode.STRING
| typeof BqrsColumnKindCode.BOOLEAN
| typeof BqrsColumnKindCode.DATE
| typeof BqrsColumnKindCode.ENTITY;
| typeof BqrsColumnKindCode.ENTITY
| typeof BqrsColumnKindCode.BIGINT;

export interface BqrsSchemaColumn {
name?: string;
Expand Down Expand Up @@ -79,7 +81,8 @@ export type BqrsKind =
| "Integer"
| "Boolean"
| "Date"
| "Entity";
| "Entity"
| "BigInt";

interface BqrsColumn {
name?: string;
Expand Down
2 changes: 2 additions & 0 deletions extensions/ql-vscode/src/common/bqrs-raw-results-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ function mapColumnKind(kind: BqrsColumnKind): ColumnKind {
return ColumnKind.Date;
case BqrsColumnKindCode.ENTITY:
return ColumnKind.Entity;
case BqrsColumnKindCode.BIGINT:
return ColumnKind.BigInt;
default:
assertNever(kind);
}
Expand Down
9 changes: 8 additions & 1 deletion extensions/ql-vscode/src/common/raw-result-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export enum ColumnKind {
Boolean = "boolean",
Date = "date",
Entity = "entity",
BigInt = "bigint",
}

export type Column = {
Expand Down Expand Up @@ -61,6 +62,11 @@ type CellValueNumber = {
value: number;
};

type CellValueBigInt = {
type: "number";
value: number;
};

type CellValueString = {
type: "string";
value: string;
Expand All @@ -75,7 +81,8 @@ export type CellValue =
| CellValueEntity
| CellValueNumber
| CellValueString
| CellValueBoolean;
| CellValueBoolean
| CellValueBigInt;

export type Row = CellValue[];

Expand Down
4 changes: 4 additions & 0 deletions extensions/ql-vscode/test/data/debugger/QuickEvalLib.qll
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ abstract class InterestingNumber extends TNumber
final int getValue() {
result = value
}

QlBuiltins::BigInt getBigIntValue() {
result = value.toBigInt()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,25 @@ describeWithCodeQL()("Debugger", () => {
});
});

it("should run a quick evaluation with a bigint-valued result column", async () => {
await withDebugController(appCommands, async (controller) => {
await selectForQuickEval(quickEvalLibPath, 20, 23, 20, 37);

await controller.startDebuggingSelection({
query: quickEvalQueryPath, // The query context. This query extends the abstract class.
});
await controller.expectLaunched();
const result = await controller.expectSucceeded();
expect(result.started.quickEvalContext).toBeDefined();
expect(result.started.quickEvalContext!.quickEvalText).toBe(
"getBigIntValue",
);
expect(result.results.queryTarget.quickEvalPosition).toBeDefined();
expect(await getResultCount(result.results.outputDir, cli)).toBe(8);
await controller.expectStopped();
});
});

it("should save dirty documents before launching a debug session", async () => {
await withDebugController(appCommands, async (controller) => {
const editor = await selectForQuickEval(quickEvalLibPath, 4, 15, 4, 32);
Expand Down

0 comments on commit 9cc790e

Please sign in to comment.