Skip to content

Commit 6489ccf

Browse files
committed
Revamp the VS Code walkthrough
Closes eng/ide/ada_language_server#1406
1 parent 4aecf73 commit 6489ccf

File tree

11 files changed

+244
-66
lines changed

11 files changed

+244
-66
lines changed

integration/vscode/ada/media/build.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Several VS Code tasks are provided to work with Ada & SPARK projects.
2+
You can find them by using the [`Tasks: Run Task`](command:workbench.action.tasks.runTask) command and selecting the `ada` or `spark` task groups.
3+
4+
Use the [`ada: Build current project`](command:workbench.action.tasks.runTask?%22ada%3A%20Build%20current%20project%22) task to build your project.
5+
6+
If you would like to customize a task, for example by providing additional command line arguments, you can use the gear icon on the right-hand side of a task and edit it in your workspace's `tasks.json` file.

integration/vscode/ada/media/edit.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
When writing Ada or SPARK in VS Code you can benefit from the following features:
2+
3+
- Syntax highlighting
4+
- Outline
5+
- Pop-up documentation when hovering on symbols
6+
- Code completion proposals
7+
- Navigation to definitions
8+
- Find all references to an entity
9+
- Find all calls to a subprogram
10+
- Call hierarchy
11+
- Refactoring
12+
13+
and [more](https://github.com/AdaCore/ada_language_server?tab=readme-ov-file#vs-code-extension)...

integration/vscode/ada/media/empty.md

Whitespace-only changes.
Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,18 @@
1-
# 🔨 Build a project
1+
If your project defines a `Main` entry point, you can launch or debug it as follows.
22

3-
Use "auto-detected tasks" (i.e: `gnat` tasks in the `Run Task` dialog) to
4-
* ⚙ Build the whole project
5-
* ✅ Check errors in the current file
6-
* 🔎 Launch `gnatprove` to verify your SPARK code, if any (you can find the tool [here](https://github.com/alire-project/GNAT-FSF-builds/releases))
3+
# 🚀 Launch
74

8-
## 🚀 Launch
5+
- The [`Tasks: Run Task`](command:toSide:workbench.action.tasks.runTask) command offers tasks called `ada: Run main - ...` and `ada: Build and run main - ...`. The former run the main executable while the latter conveniently builds the project and runs the executable at once.
6+
- A Run button is displayed right above the declaration of the main subprogram. It's a shortcut to the `ada: Build and run main - ...` task.
97

10-
Open a new terminal to launch your executable once it has been built.
8+
To provide command line argument to your executable, use the gear icon at the right-hand side of the task to customize arguments in the `tasks.json` file.
119

12-
## 🐞 Debug
10+
Alternatively, open a new terminal and launch the executable manually with the desired command line arguments.
1311

14-
The [ms-vscode.cpptools](https://github.com/microsoft/vscode-cpptools) extension
15-
is automatically installed along with this extension, allowing to use its
16-
integration for GDB to debug Ada code.
12+
# 🐞 Debug
1713

18-
The extension provides default debug configurations for all the mains of your
19-
project. You can debug the executable of your choice by opening the
20-
`Run and Debug` panel and then by clicking on the `Run and Debug` button.
21-
You can also run directly the `Debug: Start Debugging` command instead of using the UI. In some circumstances the UI may offer a selection of languages, in which case select `Ada`.
22-
The extension will then propose you to select the main you want to debug if your project contains several mains.
14+
Ada debugging leverages the integration of GDB through the [Microsoft C/C++](command:toSide:extension.open?%22ms-vscode.cpptools%22) VS Code extension.
2315

24-
If you want to customize GDB's behavior or if you need to add custom arguments, you
25-
will have to create a `launch.json` file: this can be done through the
26-
`create a launch.json file` link button in the `Run and Debug` panel or directly via
27-
the `Debug: Add Configuration` command.
16+
You can start debugging by running the [`Debug: Start Debugging`](command:toSide:ada.walkthroughStartDebugging) command and selecting `Ada` if multiple languages are offered.
17+
18+
If you would like to provide command line arguments to the debugged program or customize GDB's behavior, use the [`Debug: Add Configuration`](command:toSide:debug.addConfiguration) command to create a `launch.json` where you can customize these aspects.
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
# ☀ Welcome to Ada!
1+
📖 Take a look at the following tutorials and demos from our [wiki](https://github.com/AdaCore/ada_language_server/wiki) to learn more about Ada & SPARK development in VS Code:
22

3-
Take a few minutes to learn about the features provided by the Ada extension.
4-
5-
Use this extension to develop in Ada/SPARK in VS Code.
6-
7-
📖 Take a look at our [WiKi site](https://github.com/AdaCore/ada_language_server/wiki) with tutorials and demos:
83
* [Tutorial: Using Ada in VS Code](https://github.com/AdaCore/ada_language_server/wiki/Getting-Started)
94
* [Auto detection Tasks video](https://github.com/AdaCore/ada_language_server/wiki/auto_detected_tasks.mp4)
105
* [Custom colors in VS Code](https://github.com/AdaCore/ada_language_server/wiki/Custom-colors-in-VS-Code)
116
* [Working in a Docker container](https://github.com/AdaCore/ada_language_server/tree/master/integration/vscode/Code%20Samples/docker)
127
* [Working on a remote machine](https://github.com/AdaCore/ada_language_server/wiki/Working-on-a-remote-machine)
13-
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
A GPR project file allows you to specify the directories containing your source files, the compilation options used to build your project and many more aspects of your project's lifecycle.
2+
3+
If you don't already have a project file, click the button on the left to get started with a Hello World example!
4+
5+
If you only have one `.gpr` file at the root of your workspace, the Ada & SPARK extension will automatically use it.
6+
However we recommend configuring the main project file explicitly in the workspace setting [ada.projectFile](command:toSide:workbench.action.openWorkspaceSettings?%22ada.projectFile%22).
7+
8+
📖 Learn more about project files in the [GPRbuild and GPR Companion Tools User’s Guide](https://docs.adacore.com/live/wave/gprbuild/html/gprbuild_ug/gprbuild_ug.html).
Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
1-
# Configure the extension
1+
You can customize the Ada & SPARK experience to your liking in the [settings](command:toSide:workbench.action.openWorkspaceSettings?%22%40ext%3Aadacore.ada%22).
22

3-
☝ Make sure to configure the active `*.gpr` project file, otherwise
4-
the extension will use the first project file found in the root project
5-
folder.
3+
📖 More information about the available settings is available [here](https://github.com/AdaCore/ada_language_server/blob/master/doc/settings.md).
64

7-
⚙ You can change settings per workspace or per user: generally we recommend to
8-
change the project file settings in the desired workspace, since project files
9-
are usually workspace-specific.
10-
11-
📋 [List of Ada settings](https://github.com/AdaCore/ada_language_server/blob/master/doc/settings.md)
12-
13-
## ⌨ Find or change key shortcuts
14-
15-
* `alt+O` to go from `.ads` to `.adb` and back
16-
* `alt+shift+B` to paste a "subprogram box"
5+
A number of [keyboard shortcuts](command:toSide:workbench.action.openGlobalKeybindings?%22%40source%3Aextension%20Ada%20%26%20SPARK%22) are also provided for quick actions.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Ada and SPARK are compiled languages which means that a compiler is needed to translate the source code into a program that can be executed.
2+
3+
We recommend installing the GNAT compiler for Ada from [these channels](https://github.com/AdaCore/ada_language_server/tree/master/integration/vscode/ada#getting-additional-tools) and [configuring it in your environment](https://github.com/AdaCore/ada_language_server/tree/master/integration/vscode/ada#environment-setup).

integration/vscode/ada/package.json

Lines changed: 55 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -840,44 +840,58 @@
840840
},
841841
"walkthroughs": [
842842
{
843-
"id": "als-get-stated",
844-
"title": "Ada in VS Code",
845-
"description": "Introduction to Ada in VS Code support",
843+
"id": "als-get-started",
844+
"title": "Get Started with Ada & SPARK",
845+
"description": "A brief introduction of Ada & SPARK support in VS Code",
846846
"steps": [
847847
{
848-
"id": "als-get-stated-welcome",
849-
"title": "Welcome to Ada extension!",
850-
"description": "This short walkthrough introduces the Ada extension.",
848+
"id": "als-get-started-install-toolchain",
849+
"title": "Install development tools",
850+
"description": "Install an Ada compiler to execute your source code.\n[Install a Compiler](https://github.com/AdaCore/ada_language_server/tree/master/integration/vscode/ada#getting-additional-tools)",
851851
"media": {
852-
"markdown": "media/welcome.md"
852+
"markdown": "media/toolchain.md"
853853
}
854854
},
855855
{
856-
"id": "als-get-stated-setting",
857-
"title": "Set a project file",
858-
"description": "Set the active project file in the ``ada.projectFile`` setting.\n [Open Settings](command:workbench.action.openSettings)",
856+
"id": "als-get-started-open-workspace",
857+
"title": "Open a VS Code workspace",
858+
"description": "Create a new folder or use an existing one, and open it with VS Code.\n[Open Folder](command:vscode.openFolder)",
859859
"media": {
860-
"markdown": "media/settings.md"
860+
"markdown": "media/empty.md"
861861
},
862-
"completionEvents": [
863-
"onSettingChanged:ada.projectFile"
864-
]
862+
"when": "workspaceFolderCount == 0"
865863
},
866864
{
867-
"id": "als-open-project-file",
868-
"title": "GPR project file support",
869-
"description": "Open the GPR project file you have specified in the ``ada.projectFile`` setting. Open the ``Outline`` view to see all the entities (packages, switches...) of your GPR file.",
865+
"id": "als-get-started-create-project",
866+
"title": "Create a project",
867+
"description": "If you don't already have a GPR project, create one!\n[Create a Hello World Project](command:toSide:ada.createHelloWorldProject)",
870868
"media": {
871-
"markdown": "media/settings.md"
869+
"markdown": "media/project.md"
870+
}
871+
},
872+
{
873+
"id": "als-get-started-edit",
874+
"title": "Navigate and edit your code",
875+
"description": "Open an Ada source file to explore features.\n[Open an Ada Source File](command:workbench.action.quickOpen?%22.ad%22)",
876+
"media": {
877+
"markdown": "media/edit.md"
878+
}
879+
},
880+
{
881+
"id": "als-get-started-build",
882+
"title": "Build your project",
883+
"description": "Use automatically provided `ada` tasks to build your project.\n[Build Project](command:workbench.action.tasks.runTask)",
884+
"media": {
885+
"markdown": "media/build.md"
872886
},
873887
"completionEvents": [
874-
"onLanguage:gpr"
888+
"onCommand:workbench.action.tasks.runTask"
875889
]
876890
},
877891
{
878-
"id": "als-get-stated-debug",
879-
"title": "Launch and debug",
880-
"description": "Use the pre-installed **C/C++** extension to debug Ada code.",
892+
"id": "als-get-started-debug",
893+
"title": "Launch and debug your application",
894+
"description": "Use automatically provided debug configurations.\n[Start Debugging](command:toSide:ada.walkthroughStartDebugging)",
881895
"media": {
882896
"markdown": "media/launch-debug.md"
883897
},
@@ -886,9 +900,25 @@
886900
]
887901
},
888902
{
889-
"id": "als-get-stated-github",
890-
"title": "Report issues or contribute to the extension",
891-
"description": "This extension is an open source software. Feel free to [open an issue](https://github.com/AdaCore/ada_language_server/issues) or [contribute on GitHub](https://github.com/AdaCore/ada_language_server/pulls)!",
903+
"id": "als-get-started-settings",
904+
"title": "Configure settings",
905+
"description": "Configure your Ada development environment.\n[Open Ada & SPARK Settings](command:toSide:workbench.action.openWorkspaceSettings?%22%40ext%3Aadacore.ada%22)\n[Open Ada & SPARK Keyboard Shortcuts](command:toSide:workbench.action.openGlobalKeybindings?%22%40source%3Aextension%20Ada%20%26%20SPARK%22)",
906+
"media": {
907+
"markdown": "media/settings.md"
908+
}
909+
},
910+
{
911+
"id": "als-get-started-more-resources",
912+
"title": "Tutorials and Demos",
913+
"description": "",
914+
"media": {
915+
"markdown": "media/more-resources.md"
916+
}
917+
},
918+
{
919+
"id": "als-get-started-github",
920+
"title": "Report issues or make contributions",
921+
"description": "This extension is open source software. Feel free to [open an issue](https://github.com/AdaCore/ada_language_server/issues) or [contribute on GitHub](https://github.com/AdaCore/ada_language_server/pulls)!",
892922
"media": {
893923
"image": "media/github.jpg",
894924
"altText": "Github snapshot"

integration/vscode/ada/src/commands.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
isFromWorkspace,
2020
workspaceTasksFirst,
2121
} from './taskProviders';
22+
import { createHelloWorldProject, walkthroughStartDebugging } from './walkthrough';
2223

2324
/**
2425
* Identifier for a hidden command used for building and running a project main.
@@ -57,6 +58,12 @@ export const CMD_SPARK_LIMIT_REGION_ARG = 'ada.spark.limitRegionArg';
5758
export const CMD_SPARK_PROVE_SUBP = 'ada.spark.proveSubprogram';
5859

5960
export function registerCommands(context: vscode.ExtensionContext, clients: ExtensionState) {
61+
context.subscriptions.push(
62+
vscode.commands.registerCommand('ada.createHelloWorldProject', createHelloWorldProject)
63+
);
64+
context.subscriptions.push(
65+
vscode.commands.registerCommand('ada.walkthroughStartDebugging', walkthroughStartDebugging)
66+
);
6067
context.subscriptions.push(vscode.commands.registerCommand('ada.otherFile', otherFileHandler));
6168
context.subscriptions.push(
6269
vscode.commands.registerCommand('ada.subprogramBox', addSubprogramBoxCommand)

0 commit comments

Comments
 (0)