Skip to content
Open
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
61 changes: 31 additions & 30 deletions src/debugger/godot4/variables/debugger_variables.test.ts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lines being changed here should probably be removed entirely rather than commented out (since you can find them back using version control).

Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,18 @@ async function waitForBreakpoint(
ctx?: Mocha.Context,
): Promise<void> {
const t0 = performance.now();
console.log(
fmt(
`Waiting for breakpoint ${breakpoint.location.uri.path}:${breakpoint.location.range.start.line}, enabled: ${breakpoint.enabled}`,
),
);
// console.log(
// fmt(
// `Waiting for breakpoint ${breakpoint.location.uri.path}:${breakpoint.location.range.start.line}, enabled: ${breakpoint.enabled}`,
// ),
// );
const res = await waitForActiveStackItemChange(timeoutMs);
const t1 = performance.now();
console.log(
fmt(
`Waiting for breakpoint completed ${breakpoint.location.uri.path}:${breakpoint.location.range.start.line}, enabled: ${breakpoint.enabled}, took ${t1 - t0}ms`,
),
);
// console.log(
// fmt(
// `Waiting for breakpoint completed ${breakpoint.location.uri.path}:${breakpoint.location.range.start.line}, enabled: ${breakpoint.enabled}, took ${t1 - t0}ms`,
// ),
// );
const stackFrames = await getStackFrames();
if (
stackFrames[0].source.path !== breakpoint.location.uri.fsPath ||
Expand Down Expand Up @@ -202,10 +202,10 @@ async function startDebugging(
scene: scene,
additional_options: "--headless",
};
console.log(fmt(`Starting debugger for scene ${scene}`));
// console.log(fmt(`Starting debugger for scene ${scene}`));
const res = await vscode.debug.startDebugging(vscode.workspace.workspaceFolders?.[0], debugConfig);
const t1 = performance.now();
console.log(fmt(`Starting debugger for scene ${scene} completed, took ${t1 - t0}ms`));
// console.log(fmt(`Starting debugger for scene ${scene} completed, took ${t1 - t0}ms`));
if (!res) {
throw new Error(`Failed to start debugging for scene ${scene}`);
}
Expand All @@ -220,10 +220,11 @@ suite("DAP Integration Tests - Variable Scopes", () => {

suiteSetup(async function () {
this.timeout(20000); // enough time to do `godot --import`
console.log("Environment Variables:");
for (const [key, value] of Object.entries(process.env)) {
console.log(`${key}: ${value}`);
}
// TODO: maybe dump environment variables to file?
// console.log("Environment Variables:");
// for (const [key, value] of Object.entries(process.env)) {
// console.log(`${key}: ${value}`);
// }

// init the godot project by importing it in godot engine:
const config = vscode.workspace.getConfiguration("godotTools");
Expand All @@ -232,21 +233,21 @@ suite("DAP Integration Tests - Variable Scopes", () => {
const godot4_path = clean_godot_path(config.get<string>("editorPath.godot4"));

// get the path for currently opened project in vscode test instance:
console.log("Executing", [godot4_path, "--headless", "--import", workspaceFolder]);
// console.log("Executing", [godot4_path, "--headless", "--import", workspaceFolder]);
const exec_res = await execFileAsync(godot4_path, ["--headless", "--import", workspaceFolder], {
shell: true,
cwd: workspaceFolder,
});
if (exec_res.stderr !== "") {
// TODO: was preventing tests from running
// throw new Error(exec_res.stderr);
console.log(exec_res.stderr);
// console.log(exec_res.stderr);
}
console.log(exec_res.stdout);
// console.log(exec_res.stdout);
});

setup(async function () {
console.log(`➤ Test '${this?.currentTest.title}' starting`);
// console.log(`➤ Test '${this?.currentTest.title}' starting`);
await vscode.commands.executeCommand("workbench.action.closeAllEditors");
if (vscode.debug.breakpoints) {
await vscode.debug.removeBreakpoints(vscode.debug.breakpoints);
Expand All @@ -259,13 +260,13 @@ suite("DAP Integration Tests - Variable Scopes", () => {
this.timeout(3000);
await sleep(1000);
if (vscode.debug.activeDebugSession !== undefined) {
console.log("Closing debug session");
// console.log("Closing debug session");
await vscode.debug.stopDebugging();
await sleep(1000);
}
console.log(
`⬛ Test '${this.currentTest.title}' result: ${this.currentTest.state}, duration: ${performance.now() - this.testStart}ms`,
);
// console.log(
// `⬛ Test '${this.currentTest.title}' result: ${this.currentTest.state}, duration: ${performance.now() - this.testStart}ms`,
// );
});

test("should return correct scopes", async () => {
Expand All @@ -279,7 +280,7 @@ suite("DAP Integration Tests - Variable Scopes", () => {
await waitForBreakpoint(breakpoint, 2000);

// TODO: current DAP needs a delay before it will return variables
console.log("Sleeping for 2 seconds");
// console.log("Sleeping for 2 seconds");
await sleep(2000);

// corresponds to file://./debug_session.ts async scopesRequest
Expand Down Expand Up @@ -334,7 +335,7 @@ suite("DAP Integration Tests - Variable Scopes", () => {
await waitForBreakpoint(breakpoint, 2000);

// TODO: current DAP needs a delay before it will return variables
console.log("Sleeping for 2 seconds");
// console.log("Sleeping for 2 seconds");
await sleep(2000);

const variables = await getVariablesForScope(VariableScope.Globals);
Expand All @@ -351,7 +352,7 @@ suite("DAP Integration Tests - Variable Scopes", () => {
await waitForBreakpoint(breakpoint, 2000);

// TODO: current DAP needs a delay before it will return variables
console.log("Sleeping for 2 seconds");
// console.log("Sleeping for 2 seconds");
await sleep(2000);

const variables = await getVariablesForScope(VariableScope.Locals);
Expand All @@ -370,7 +371,7 @@ suite("DAP Integration Tests - Variable Scopes", () => {
await waitForBreakpoint(breakpoint, 2000);

// TODO: current DAP needs a delay before it will return variables
console.log("Sleeping for 2 seconds");
// console.log("Sleeping for 2 seconds");
await sleep(2000);

const variables = await getVariablesForScope(VariableScope.Members);
Expand All @@ -392,7 +393,7 @@ suite("DAP Integration Tests - Variable Scopes", () => {
await waitForBreakpoint(breakpoint, 2000);

// TODO: current DAP needs a delay before it will return variables
console.log("Sleeping for 2 seconds");
// console.log("Sleeping for 2 seconds");
await sleep(2000);

const variables = await getVariablesForScope(VariableScope.Locals);
Expand Down Expand Up @@ -433,7 +434,7 @@ suite("DAP Integration Tests - Variable Scopes", () => {
await waitForBreakpoint(breakpoint, 2000);

// TODO: current DAP needs a delay before it will return variables
console.log("Sleeping for 2 seconds");
// console.log("Sleeping for 2 seconds");
await sleep(2000);

const memberVariables = await getVariablesForScope(VariableScope.Members);
Expand Down
Empty file.
Empty file.
6 changes: 6 additions & 0 deletions src/formatter/snapshots/indices.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# --- IN ---
var some_array = [1, 2, 3]

func f():
some_array[-1] = 0
print(some_array[-1])
14 changes: 14 additions & 0 deletions src/formatter/snapshots/keywords.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
var c = 0

func f():
super()

const a = preload("res://a.gd")
const b = load("res://b.gd")

Expand All @@ -15,3 +17,15 @@ func f():
self.c = 1
print(self.c + 2)
print(func() return self.c + 2)

var list = [self]
var list2 = [self, self]

var dict = {self: self}
print(dict[self])

print(self)
print(self, self)

[].append(self)
var a = self['1']
7 changes: 6 additions & 1 deletion src/formatter/textmate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const wasmBin = fs.readFileSync(wasmPath).buffer;

// Create a registry that can create a grammar from a scope name.
const registry = new vsctm.Registry({
onigLib: oniguruma.loadWASM(wasmBin).then(() => {
onigLib: oniguruma.loadWASM(wasmBin as unknown as oniguruma.IOptions).then(() => {
return {
createOnigScanner(patterns) {
return new oniguruma.OnigScanner(patterns);
Expand Down Expand Up @@ -109,6 +109,11 @@ function parse_token(token: Token) {
if (token.value === "preload") {
return;
}
// "self" and "super" are highlighted as keywords but behaves like an identifier
if (token.value === "self" || token.value === "super") {
token.type = "variable";
return;
}
if (token.scopes.includes("keyword.language.gdscript")) {
token.type = "keyword";
return;
Expand Down
Loading