Penstock

VS Code / Using it

Code links in VS Code

In VS Code, code links connect a diagram to the code that runs it and back: code lenses, go to definition, references, the Penstock view and Problems.

Pro

What code links are, and what they check, is described once in Code links. This page is about what works in VS Code. The code links need a Pro licence on this machine. Without one, the Penstock view says what the feature gives and offers to buy or sign in, no code lens or definition is offered, and the Problems view stays empty. Going from a Camunda 7 task to its Java class or Spring bean needs no licence: it is a file search by package path and name.

What is read

The index is the one penstock code builds. Penstock reads the source files of the workspace once and after that only the file that a save, a create or a delete touched. A workspace with no diagram is not read at all. These are never read: node_modules, target, out, dist, folders that start with a dot, and a repository the project does not name under linked in penstock.yaml.

The languages are the nine the command line reads: Java, Kotlin, Groovy, Scala, Python, JavaScript, TypeScript, Go and C#. A process, element, message, decision, variable or error code that the code names in a call, a field or a BpmnError is found. A job type stays a worker. Only a string literal counts as a reference.

From a diagram to the code

From the code to a diagram

Go to Definition and Find All References answer in the code files and in a diagram file opened as text. See Penstock: Open as text in Where things are in VS Code.

The debugger position on the diagram

When a debugger pauses in Java worker code (such as an ActivatedJob, DelegateExecution, DelegateTask or ExternalTask), the diagram marks the paused task and active elements of the process instance. Pro.

Running tests from a diagram

Running the tests a diagram is linked to opens the test file at the cursor and starts VS Code's testing commands (testing.runAtCursor or testing.debugAtCursor). Pro. Test-case files also run in the Test Explorer under the Penstock scenarios controller.

Create element template

Put the caret in a worker method or class and run Penstock: Create element template in the Command Palette or context menu to write the element template file. Pro.

The Penstock view

The Activity Bar has a view called Penstock. It holds the sections the JetBrains tool window has: processes, workers, variables, messages, errors, decisions, forms, templates, deployment, files and migration, with the workers the code implements under each task. A node opens the diagram or the code. A row menu offers Find usages in code, Copy ID and Go to implementation. The toolbar button Reload from disk (and the command Penstock: Refresh the code links) reads the project again.

Problems and quick fixes

The Problems view reports diagnostics under three sources:

Tests

A file in a test folder, or one named …Test, …Tests, …Spec or *.test.*, is a test, and a link in it is a test rather than an implementation. This is decided by the path. A project that keeps its tests somewhere else is read as production code.

What is not in VS Code

Common problems

No code lenses, no definitions.
Code links need Pro. Open the Penstock view: it offers to buy or sign in.
A worker in another repository is reported as missing.
Add that repository to linked in penstock.yaml.
A change is not reflected.
Save the file, or press the reload button in the toolbar of the Penstock view.