Skip to content

Commit

Permalink
In memory file system (#801)
Browse files Browse the repository at this point in the history
If we want to enable users to click a link and land on vscode.dev with
code passed in the URL, we'll need some type of in memory file system
for it. This is an outline for that. For now, I've wired it in with a
simple command to open all our sample algorithms in a kind of sandbox
(so you can play around with them, change, debug, etc. all without being
backed by files on a disk or a repo. Any changes are lost when you close
it).

It does look like you're expected to vendor in your own in-memory file
system implementation, even though this is a common feature. (I'm
discussing with the VS Code team to confirm, and have the question at
https://stackoverflow.com/questions/77312576/in-memory-file-system-for-vs-code-extension
). I'll update if there's a simpler approach.
  • Loading branch information
billti authored Oct 25, 2023
1 parent 70b107c commit c6949ea
Show file tree
Hide file tree
Showing 12 changed files with 517 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* text eol=lf
*.png binary
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ __pycache__/
.DS_Store
.vscode/*
.vscode-test-web/
*.pem
!.vscode/*.shared.json
!.vscode/extensions.json
/fuzz/target
Expand Down
87 changes: 86 additions & 1 deletion vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
"description": "Q# Language Support",
"version": "0.0.0",
"publisher": "quantum",
"icon": "resources/qdk.png",
"galleryBanner": {
"color": "#252526",
"theme": "dark"
},
"type": "commonjs",
"engines": {
"vscode": "^1.77.0"
Expand All @@ -18,9 +23,75 @@
"onNotebook:jupyter-notebook",
"onDebug",
"onDebugResolve:qsharp",
"onDebugDynamicConfigurations:qsharp"
"onDebugDynamicConfigurations:qsharp",
"onFileSystem:qsharp-vfs"
],
"contributes": {
"walkthroughs": [
{
"id": "qsharp-vscode.welcome",
"title": "The Azure Quantum Development Kit",
"description": "Getting started with the Azure Quantum Development Kit in VS Code",
"steps": [
{
"id": "qsharp-vscode.welcome.editor",
"title": "Welcome to the Azure Quantum Development Kit",
"description": "The Azure Quantum Development Kit (QDK) is an open-source SDK that you can use to write quantum programs and execute them on quantum hardware. This walkthrough will show you how to get started with the Azure Quantum Development Kit in VS Code.\n\nThe QDK gives you rich editor support for writing quantum programs in the Q# language, such as error checking, signature help, completion lists, safely renaming identifiers, and much more.",
"media": {
"image": "resources/intellisense.png",
"altText": "Intellisense"
}
},
{
"id": "qsharp-vscode.welcome.debug",
"title": "Debug Q# code",
"description": "With your Q# code open in the editor, use the F5 shortcut or the top right icons in the code edtior to run or debug the code.",
"media": {
"image": "resources/debug.png",
"altText": "Debug"
}
},
{
"id": "qsharp-vscode.welcome.simulator",
"title": "Run quantum simulations",
"description": "You can run quantum simulations directly in VS Code and see the program output in the integrated terminal.",
"media": {
"image": "resources/console.png",
"altText": "Console"
}
},
{
"id": "qsharp-vscode.welcome.submit",
"title": "Run on Azure Quantum",
"description": "If you have an Azure subscription, you can connect to your Azure Quantum workspace and submit your Q# program directly to quantum hardware",
"media": {
"image": "resources/submit.png",
"altText": "Submit to Azure"
}
},
{
"id": "qsharp-vscode.welcome.starters",
"title": "Starting points",
"description": "Expore Q# safely by opening files in the [Q# playground](command:qsharp-vscode.openPlayground), or work in Python by [creating a Jupyter Notebook](command:qsharp-vscode.createNotebook) from a template",
"media": {
"image": "resources/notebook.png",
"altText": "Jupyter Notebooks"
}
}
]
}
],
"webOpener": {
"scheme": "qsharp-vfs",
"runCommands": [
{
"command": "qsharp-vscode.webOpener",
"args": [
"$url"
]
}
]
},
"configuration": {
"title": "Q#",
"properties": {
Expand Down Expand Up @@ -88,6 +159,10 @@
{
"command": "qsharp-vscode.setTargetProfile",
"when": "resourceLangId == qsharp"
},
{
"command": "qsharp-vscode.webOpener",
"when": "false"
}
],
"view/title": [
Expand Down Expand Up @@ -143,6 +218,11 @@
}
],
"commands": [
{
"command": "qsharp-vscode.webOpener",
"title": "Internal web opener",
"category": "Q#"
},
{
"command": "qsharp-vscode.debugEditorContents",
"title": "Debug Q# file",
Expand Down Expand Up @@ -212,6 +292,11 @@
"command": "qsharp-vscode.createNotebook",
"category": "Q#",
"title": "Create an Azure Quantum notebook"
},
{
"command": "qsharp-vscode.openPlayground",
"category": "Q#",
"title": "Open Q# playground"
}
],
"breakpoints": [
Expand Down
Binary file added vscode/resources/console.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vscode/resources/debug.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vscode/resources/intellisense.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vscode/resources/notebook.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vscode/resources/qdk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions vscode/resources/qdk.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vscode/resources/submit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { initCodegen } from "./qirGeneration.js";
import { activateTargetProfileStatusBarItem } from "./statusbar.js";
import { createSignatureHelpProvider } from "./signature.js";
import { createRenameProvider } from "./rename.js";
import { initFileSystem } from "./memfs.js";

export async function activate(context: vscode.ExtensionContext) {
initializeLogger();
Expand Down Expand Up @@ -57,6 +58,7 @@ export async function activate(context: vscode.ExtensionContext) {
initCodegen(context);
activateDebugger(context);
registerCreateNotebookCommand(context);
initFileSystem(context);

log.info("Q# extension activated.");
}
Expand Down
Loading

0 comments on commit c6949ea

Please sign in to comment.