|
| 1 | +.. _getting-started-with-vscode-debugger: |
| 2 | + |
| 3 | +Getting Started with the VS Code Debugger |
| 4 | +========================================= |
| 5 | + |
| 6 | +Unlike the ExtendScript Toolkit, the VS Code debugger takes some work to get up and running. This document is intended to make that process as straightforward as possible. |
| 7 | + |
| 8 | +.. note:: |
| 9 | + |
| 10 | + This guide is meant to walk you through how to install and run the Extendscript for VS Code debugger. |
| 11 | + |
| 12 | + If you're looking on how to use specific features of the extension, see :ref:`vscode-extension-features`. |
| 13 | + |
| 14 | +Generally, you'll need to follow these steps: |
| 15 | + |
| 16 | +- :ref:`installing-the-extension` |
| 17 | +- :ref:`opening-a-project` |
| 18 | +- :ref:`creating-a-debug-launch-task` |
| 19 | +- :ref:`attaching-the-debugger` |
| 20 | +- :ref:`running-the-debugger` |
| 21 | +- :ref:`further-reading` |
| 22 | + |
| 23 | +-------------------------------------------------------------------------------- |
| 24 | + |
| 25 | +.. _installing-the-extension: |
| 26 | + |
| 27 | +Installing the extension |
| 28 | +------------------------ |
| 29 | + |
| 30 | +Either head to the `extension marketplace link <https://marketplace.visualstudio.com/items?itemName=Adobe.extendscript-debug>`_ and install from there, or search "ExtendScript Debugger" within VS Code's extension browser and install. |
| 31 | + |
| 32 | +If you're going the latter route, make sure you're installing the one from Adobe! |
| 33 | + |
| 34 | +-------------------------------------------------------------------------------- |
| 35 | + |
| 36 | +.. _opening-a-project: |
| 37 | + |
| 38 | +Opening a project directory |
| 39 | +--------------------------- |
| 40 | + |
| 41 | +- `File > Open Folder` |
| 42 | +- Choose your project directory |
| 43 | + |
| 44 | +-------------------------------------------------------------------------------- |
| 45 | + |
| 46 | +.. _creating-a-debug-launch-task: |
| 47 | + |
| 48 | +Creating a debug launch task |
| 49 | +---------------------------- |
| 50 | + |
| 51 | +To use the extension, you need to create a debug task for VS Code to run when you want to debug extendscript. |
| 52 | + |
| 53 | +In your project directory: |
| 54 | + |
| 55 | + - create a folder called `.vscode` (with the period) |
| 56 | + - in that folder, create a file `launch.json` |
| 57 | + - paste in the following code |
| 58 | + :: |
| 59 | + |
| 60 | + { |
| 61 | + "version": "0.2.0", |
| 62 | + "configurations": [ |
| 63 | + { |
| 64 | + "type": "extendscript-debug", |
| 65 | + "request": "launch", |
| 66 | + "name": "Run Current Script", |
| 67 | + "program": "${file}", |
| 68 | + "stopOnEntry": false, |
| 69 | + "excludes": [ |
| 70 | + "undefined", |
| 71 | + "builtin", |
| 72 | + // "Function", |
| 73 | + "prototype" |
| 74 | + ], |
| 75 | + } |
| 76 | + ] |
| 77 | + } |
| 78 | + |
| 79 | + - this will let you run the debugger on the *currently open file* |
| 80 | + - it also keeps functions included in the default object browser during breakpoints, which are otherwise excluded |
| 81 | + |
| 82 | +If you wanted to run a task on a specific file, not necessarily the currently-open one, you'd replace the `program` entry with something like: |
| 83 | + |
| 84 | + - For a specific script:: |
| 85 | + |
| 86 | + "${workspaceFolder}/path/to/my/script.jsx" |
| 87 | + |
| 88 | + - To be prompted for the filename / path to a jsx folder:: |
| 89 | + |
| 90 | + "${workspaceFolder}/${command:AskForScriptName}" |
| 91 | + |
| 92 | +-------------------------------------------------------------------------------- |
| 93 | + |
| 94 | +.. _attaching-the-debugger: |
| 95 | + |
| 96 | +Attaching the debugger |
| 97 | +---------------------- |
| 98 | + |
| 99 | +Once the extension is installed: |
| 100 | + |
| 101 | +- Open a JS workspace |
| 102 | +- Launch your Adobe app of choice |
| 103 | +- At the bottom of your VS Code window, at the far right of the status bar, you should see 'Select the target application' glowing yellow |
| 104 | +- Click this and pick the application you want to debug for |
| 105 | + |
| 106 | +-------------------------------------------------------------------------------- |
| 107 | + |
| 108 | +.. _running-the-debugger: |
| 109 | + |
| 110 | +Running the debugger |
| 111 | +-------------------- |
| 112 | + |
| 113 | +Once you've set up your environment and built your script: |
| 114 | + |
| 115 | +- In VS Code, Debug > Start Debugging > 'Run Current Script' (or the task name you specified in :ref:`creating-a-debug-launch-task` |
| 116 | +- If the script throws any errors, you'll be able to view variables & a call stack |
| 117 | + |
| 118 | +.. note:: |
| 119 | + |
| 120 | + If you're compiling the end jsx file from a number of source files, the debugger will catch errors in the *compiled* script, not the source files -- you'll need to backtrack yourself to figure out what source file the error came from, unless you're building source maps in some way. |
| 121 | + |
| 122 | + This may not apply to compiled files using `#include` |
| 123 | + |
| 124 | +-------------------------------------------------------------------------------- |
| 125 | + |
| 126 | +.. _further-reading: |
| 127 | + |
| 128 | +Futher reading |
| 129 | +-------------- |
| 130 | + |
| 131 | +- `Debugging in VS Code <https://code.visualstudio.com/docs/editor/debugging>`_ |
0 commit comments