Skip to content

Commit

Permalink
Add 'generate debug output' command
Browse files Browse the repository at this point in the history
  • Loading branch information
desplesda committed Aug 20, 2023
1 parent c3378fb commit 6dfee5a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@
"command": "yarnspinner.graph",
"category": "Yarn Spinner",
"title": "Export Dialogue as Graph..."
},
{
"command": "yarnspinner.generateDebugOutput",
"category": "Yarn Spinner",
"title": "Generate Debug Output",
"enablement": "config.yarnspinner.enableExperimentalFeatures"
}
],
"languages": [
Expand Down
27 changes: 27 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,17 @@ async function launchLanguageServer(context: vscode.ExtensionContext, configs: v
vscode.window.showErrorMessage("Error in the language server: " + error.toString());
});
}));

context.subscriptions.push(vscode.commands.registerCommand("yarnspinner.generateDebugOutput", () => {
getDebugOutput(client).then((debugOutput) => {
for (const item of debugOutput) {

var outputFile = vscode.Uri.parse(item.sourceProjectUri + ".debuginfo.json");

fs.writeFile(outputFile.fsPath, JSON.stringify(item), () => { });
}
});
}));
}

async function compileWorkspace(client: languageClient.LanguageClient): Promise<YarnData | null> {
Expand All @@ -504,6 +515,22 @@ async function compileWorkspace(client: languageClient.LanguageClient): Promise<
return yarnData;
}

type DebugOutputResponse = {
sourceProjectUri: languageClient.DocumentUri
variables: any[]
}[]

async function getDebugOutput(client: languageClient.LanguageClient): Promise<DebugOutputResponse> {
const params: languageClient.ExecuteCommandParams = {
command: "yarnspinner.generateDebugOutput",
arguments: [],
};

let result: DebugOutputResponse = await client.sendRequest(languageClient.ExecuteCommandRequest.type, params);

return result;
}

export function getDefaultUri(): vscode.Uri {
// Are any workspaces open?
if (vscode.workspace.workspaceFolders) {
Expand Down

0 comments on commit 6dfee5a

Please sign in to comment.