src/Tools/VSCode/extension/vsc-extension-quickstart.md
author wenzelm
Mon Mar 25 17:21:26 2019 +0100 (8 weeks ago)
changeset 69981 3dced198b9ec
parent 64605 9c1173a7e4cb
permissions -rw-r--r--
more strict AFP properties;
wenzelm@64605
     1
# Welcome to your first VS Code Extension
wenzelm@64605
     2
wenzelm@64605
     3
## What's in the folder
wenzelm@64605
     4
* This folder contains all of the files necessary for your extension
wenzelm@64605
     5
* `package.json` - this is the manifest file in which you declare your extension and command.
wenzelm@64605
     6
The sample plugin registers a command and defines its title and command name. With this information
wenzelm@64605
     7
VS Code can show the command in the command palette. It doesn’t yet need to load the plugin.
wenzelm@64605
     8
* `src/extension.ts` - this is the main file where you will provide the implementation of your command.
wenzelm@64605
     9
The file exports one function, `activate`, which is called the very first time your extension is
wenzelm@64605
    10
activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`.
wenzelm@64605
    11
We pass the function containing the implementation of the command as the second parameter to
wenzelm@64605
    12
`registerCommand`.
wenzelm@64605
    13
wenzelm@64605
    14
## Get up and running straight away
wenzelm@64605
    15
* press `F5` to open a new window with your extension loaded
wenzelm@64605
    16
* run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World`
wenzelm@64605
    17
* set breakpoints in your code inside `src/extension.ts` to debug your extension
wenzelm@64605
    18
* find output from your extension in the debug console
wenzelm@64605
    19
wenzelm@64605
    20
## Make changes
wenzelm@64605
    21
* you can relaunch the extension from the debug toolbar after changing code in `src/extension.ts`
wenzelm@64605
    22
* you can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes
wenzelm@64605
    23
wenzelm@64605
    24
## Explore the API
wenzelm@64605
    25
* you can open the full set of our API when you open the file `node_modules/vscode/vscode.d.ts`
wenzelm@64605
    26
wenzelm@64605
    27
## Run tests
wenzelm@64605
    28
* open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration dropdown pick `Launch Tests`
wenzelm@64605
    29
* press `F5` to run the tests in a new window with your extension loaded
wenzelm@64605
    30
* see the output of the test result in the debug console
wenzelm@64605
    31
* make changes to `test/extension.test.ts` or create new test files inside the `test` folder
wenzelm@64605
    32
    * by convention, the test runner will only consider files matching the name pattern `**.test.ts`
wenzelm@64605
    33
    * you can create folders inside the `test` folder to structure your tests any way you want