Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Enable BigInt results in Quick Evals #3647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading