Skip to content

Commit

Permalink
130 non debug repl (#136)
Browse files Browse the repository at this point in the history
* Fixed some issues with running in non-debug mode.

* Prepared for new release.
  • Loading branch information
indiejames committed Jun 2, 2017
1 parent 9f6620d commit a80c8b1
Show file tree
Hide file tree
Showing 5 changed files with 232 additions and 114 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changes

## V1.2.0

* Added optional REPL startup in non-debug mode
* Code runs twice as fast
* Fixed some bugs with test run support
* Error handing
* Clearing old errors/failures before each test run
* Added `$lein_path` template var for launch.json to fill in lein path from preferences

## V1.1.0

* Added new test run support.
Expand Down
50 changes: 30 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Visual Studio Code Version](https://img.shields.io/badge/Visual%20Studio%20Code-1.10.1-6193DF.svg)
![Join the chat at https://gitter.im/vscode-continuum/Lobby](https://badges.gitter.im/vscode-continuum/Lobby.svg)](https://gitter.im/vscode-continuum/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

\*\***NEW** *New features for running tests with feedback*\*\*
\*\***NEW** *Running the debugger is now optional - you can launch the REPL and access other features in non-debug mode - code runs twice as fast*\*\*

## Introduction

Expand All @@ -23,10 +23,11 @@ as language support and debugging.
* Peek at / jump to symbol definition
* Fix namespace declaration - cleans up requires/imports
* Function signature help
* \*\***New** *Run tests with progress feedback in status bar and links to tests that fail or result in error in the Problems view*\*\*
* Set breakpoints
* Examine stack frames / variables at breakpoint
* Evaluate code at breakpoints
* Run tests with progress feedback in status bar and links to tests that fail or result in error in the Problems view
* Debugger (now optional - can run interactive REPL without debugging)
* Set breakpoints
* Examine stack frames / variables at breakpoint
* Evaluate code at breakpoints
* Adds a Clojure specific setting for "editor.wordSeparators" to make selecting Clojure symbols easier
* Project type agnostic (leiningen, boot, etc.)

Expand All @@ -39,12 +40,11 @@ as language support and debugging.
* Symbol search
* Find references
* Linter support
* Test result / VS Code problems view integration
* Exception stack traces in REPL output with links to jump to file

## Installation

**tl;dr** watch the [YouTube video](https://youtu.be/73PnuVBkXxU); otherwise, follow the instructions here. Note that the video has not been updated yet to reflect the change in way [the REPL is launched](#launching-a-repl).
**tl;dr** The quickest way to get started is to clone the github [demo project](https://github.com/indiejames/clojure-code-demo) and follow the (brief) instructions in the README.md file. If you want to get started with your own project right away then read on.

#### Prerequisites
* [Visual Studio Code](https://code.visualstudio.com/) 1.10.1 or higher
Expand Down Expand Up @@ -94,18 +94,10 @@ You can get started by opening a Clojure project in VS Code and creating a launc

A launch.json file will be created with a default launch configuration. You should edit this file for your own environment. VS Code provides Intellisense support when editing this file to help you make valid choices. Also, as of version 0.4.0, you can set defaults for several of the fields in the extension preferences. These defaults will be used for any of the fields you leave blank. The full details of the available settings are documented at the end of this readme file, but for now the only fields you need to change are the following:

* `commandLine` - the exact command plus arguments needed to launch your REPL. The default uses leiningen and sets the profile to `debug-repl` (the one defined in the example above). You _do not_ need to use leiningen, but you do need to make sure the REPL uses the debug middleware. Also, if you do not start the REPL on the same port as in your extension preference settings then you need to specify the port in the launch configuration using the `replPort` setting. This gives you maximum flexibility in choosing the way to launch your code. It just has to run in (or provide) nREPL running with the debug middleware.
* `replPort` - Set this if you are not launching on the default port as specified in your extension preference settings.

The extension can launch the REPL in three different ways: in the internal debug console, in an internal command terminal, or in an external terminal. This is controlled by the **console** attribute. The default uses the internal debug console. Running in a terminal can be useful if, for example, you need to type input into your program or if your program expects to run in a terminal environment.
* `commandLine` - the exact command plus arguments needed to launch your REPL. The default uses leiningen and sets the profile to `debug-repl` (the one defined in the example above). You _do not_ need to use leiningen, but you do need to make sure the REPL uses the debug middleware. If you do use leiningen you can use the `$lein_path` template variable here and the full path to the `lein` binary will be filled in from your prefrences setting.

## Starting the REPL

The functionality of the extension is not available unless a REPL is running. You need to either launch a REPL or attach to one. We will cover launching a REPL first.

#### Launching a REPL

Once you have set up your profile (or otherwise enabled the nREPL middleware) and created a suitable launch.json file you can launch the REPL by going to the Debug viewlet, choosing the launch configuration you want to use, then clicking the debug icon ![START](http://i.imgur.com/ZAmkn5M.png). Note that this has changed from the previous method of launching the REPL from the command palette.
Also, if you do not start the REPL on the same port as in your extension preference settings then you need to specify the port in the launch configuration using the `replPort` setting. This gives you maximum flexibility in choosing the way to launch your code. It just has to run in (or provide) nREPL running with the debug middleware.
* `replPort` - Set this if you are not launching on the default port as specified in your extension preference settings.

On a mac an example launch configuration might look like this

Expand All @@ -115,7 +107,7 @@ On a mac an example launch configuration might look like this
"type": "clojure",
"request": "launch",
"commandLine": [
"/usr/local/bin/lein",
"$lein_path",
"with-profile",
"+debug-repl",
"repl",
Expand All @@ -130,6 +122,20 @@ On a mac an example launch configuration might look like this
}
```

The extension can launch the REPL in three different ways: in the internal debug console, in an internal command terminal, or in an external terminal. This is controlled by the **console** attribute. The default uses the internal debug console. Running in a terminal can be useful if, for example, you need to type input into your program or if your program expects to run in a terminal environment.

\*\***NEW** *Running the debugger is now optional when starting the REPL.*\*\*

You can launch the REPL and access all the other features in non-debug mode. Code runs twice as fast when not in debug mode - really useful if you are going to run many tests. In order to run without the debuger just add `"debug": false` to your `launch.json` file.

## Starting the REPL

The functionality of the extension is not available unless a REPL is running. You need to either launch a REPL or attach to one. We will cover launching a REPL first.

#### Launching a REPL

Once you have set up your profile (or otherwise enabled the nREPL middleware) and created a suitable launch.json file you can launch the REPL by going to the Debug viewlet, choosing the launch configuration you want to use, then clicking the debug icon ![START](http://i.imgur.com/ZAmkn5M.png).

![LAUNCH](http://i.imgur.com/dJDFgNA.gif)

This can take a while (minutes for large projects). You should see output from the REPL as is starts up in the debug console or in the terminal (for terminal launches). Eventually you should see a screen like the following (note color change in status bar at bottom). You should see the status message 'Attached to process' at the bottom and information in the debug console about the running REPLs and namespaces that were loaded.
Expand Down Expand Up @@ -179,6 +185,7 @@ The second way to evaluate code is by typing it into the debug console input box

#### Setting Breakpoints

*Note: to debug code the REPL must be started in debug mode (the default).*
Currently Clojure Code supports two kinds of breakpoints, line breakpoints and exceptions breakpoints. Line breakpoints let you set set a breakpoint at a specific line in a given file. These are set by clicking in the left margin of an open editor.

![BREAKPOINT](https://media.giphy.com/media/l3q2YGpocqMDRnMTS/source.gif)
Expand All @@ -197,9 +204,11 @@ If you have the source for the Java code in your source path then VS Code will d

### Running Tests

Clojure code contributes three commands to support running tests. These can can be accessed from the command palette (`cmd+shift+p` (mac) / `ctrl+shift+p` (win/linux)) and allow you to run all tests, run a single test (the one under the cursor), and run all tests in the currently opened namespace. In order to run all tests you need to tell the extension which directories contin tests that are safe to run in parallel and which ones must be run sequentially. This is done using the
Clojure code contributes three commands to support running tests. These can can be accessed from the command palette (`cmd+shift+p` (mac) / `ctrl+shift+p` (win/linux)) and allow you to run all tests, run a single test (the one under the cursor), and run all tests in the currently opened namespace. In order to run all tests you need to tell the extension which directories contain tests that are safe to run in parallel and which ones must be run sequentially. This is done using the
`parallelTestDirs` and `sequentialTestDirs` settings in the launch.json file.

While the tests are running a progress bar is shown in the status bar. After the tests complete the `PROBLEM` panel provides a list of tests that failed or ran into errors while running. Clicking on these will jump to the location with the test file. Hovering over the red squiggly lines under the failed/errored tests pops up a summary of the problem.

![TESTS](https://media.giphy.com/media/l0Iya2NoKQl2lLagw/source.gif)

### All Contributed Commands
Expand Down Expand Up @@ -275,6 +284,7 @@ The latest version by Shaun LeBron is based on the Atom plugin and is excellent.
| cwd | string | Workspace relative or absolute path to the working directory of the program being debugged. | The current workspace |
| debugPort | number | JDI port on which the debugger should connect to the process to be debugged. | 8030 |
| debugReplPort | number | Port on which the client/debugger nREPL should listen. | 5556 |
| debug | boolean | If true the REPL starts in debug mode | true |
| env | map | Environment variables passed to the program. | {} |
| leinPath | string | Path the the lein executable. | "/usr/local/bin/lein" |
| refreshOnLaunch | boolean | Automatically load all namespaces on launch. | true |
Expand Down
22 changes: 15 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Clojure Code",
"license": "MIT",
"version": "1.1.0",
"debugMiddlewareVersion": "0.5.1",
"debugMiddlewareVersion": "0.5.2",
"publisher": "jamesnorton",
"description": "Clojure debugger / nREPL / language support for Visual Studio Code.",
"preview": false,
Expand Down Expand Up @@ -235,7 +235,7 @@
"toolsJar": {
"type": "string",
"description": "Path to the tools.jar in your Java installation.",
"default": "${env.JAVA_HOME}/lib/tools.jar"
"default": "$tools_jar_path"
},
"cwd": {
"type": "string",
Expand All @@ -244,8 +244,7 @@
},
"leinPath": {
"type": "string",
"description": "Path the the lein executable.",
"default": "/usr/local/bin/lein"
"description": "Path the the lein executable."
},
"replHost": {
"type": "string",
Expand All @@ -263,6 +262,11 @@
"type": "number",
"description": "JDI port on which the debugger should connect to the process to be debugged."
},
"debug": {
"type": "boolean",
"description": "Whether or not to start the debugger.",
"default": true
},
"sideChannelPort": {
"type": "number",
"description": "Port on which the debugger should talk to the extension."
Expand Down Expand Up @@ -305,8 +309,7 @@
},
"leinPath": {
"type": "string",
"description": "Path the the lein executable.",
"default": "/usr/local/bin/lein"
"description": "Path the the lein executable."
},
"replPort": {
"type": "number",
Expand All @@ -323,6 +326,11 @@
"description": "JDI port on which the debugger should connect to the process to be debugged.",
"default": 8030
},
"debug": {
"type": "boolean",
"description": "Whether or not to start the debugger.",
"default": true
},
"sideChannelPort": {
"type": "number",
"description": "Port on which the debugger should talk to the extension.",
Expand Down Expand Up @@ -361,7 +369,7 @@
"initialConfigurations": [
{
"commandLine": [
"lein",
"$lein_path",
"with-profile",
"+debug-repl",
"repl",
Expand Down
Loading

0 comments on commit a80c8b1

Please sign in to comment.