JetBrains / Using it
Code links in the IDE
In a JetBrains IDE, code links let you click from a string in your Java or Kotlin code to the diagram element it names, and back.
What code links are, and what they check, is described once in Code links. This page is about the IDE features that use them. All of them need Pro, except going from a Camunda 7 task to its Java class or Spring bean. Without Pro, only class and bean links appear, and an action that needs the rest says what it gives and offers to buy or sign in.
From code to diagram
A process id, element id, job type, topic, message name or decision id in a Java or Kotlin string is a link.
- Hold Cmd (or Ctrl) and click the string, or use Go to Declaration.
- The diagram opens and the element is selected. Any navigation into a diagram file selects the element on the canvas.
- Completion offers the ids where Camunda expects them: starting a process, asserting in a test (
isWaitingAt,hasPassed,hasCompletedElements,byIdand others),@JobWorkerand external task subscriptions, correlating a message, evaluating a decision. - An id that no diagram has is marked.
- Gutter icons sit beside such a string, beside a
JavaDelegateor bean that diagrams name, and beside a@JobWorkermethod whose name is the job type. Click one to jump to the tasks that use it. - A
@JobWorkerwithout atypeis marked, and a quick fix writes the type into the annotation. - Variables:
getVariable,setVariable,variable,@Variableand the test assertions complete the names the diagrams use and link to the elements that use them. A name a letter away from a known one is marked, with a fix. - Error codes: the code in
new BpmnError("...")and the other forms opens the error event that catches it.
From diagram to code
- Go to Implementation is in an element's context menu. It opens that method, not just the file.
- Find Usages in Code, from an element's menu or from the tool window, lists the code that names the element, its process, the job type, class or bean it runs, its message or its decision.
- Code Vision above a worker, delegate or bean says which tasks it runs and how many tests reach it. Above a test it says how much of each process it covers. A click opens the diagram at the element.
- The tool window shows, under each job type, topic, class and bean, the code that implements it. A worker nothing implements is marked, once the project implements any of them.
Element references in comments and strings
A reference to an element can be written in a comment or a string, in any language: the file name or path of the diagram, then # and the element id, as in order.bpmn#ServiceTask_charge, or a process id then # and the element id. Ctrl or Cmd and click opens the diagram with that element selected. Completion after # offers the ids of the diagram that is named. An id that no diagram has is marked, and a quick fix offers the near ones.
Inspections and quick fixes
The marks above come from inspections in the group Penstock of Settings | Editor | Inspections, so each can be switched off. They are listed in Settings in the IDE. The quick fixes are Change to a near name, Name the job type in an annotation, and Use an element id from the diagrams.
Element templates from a worker
Right-click a @JobWorker method, a newWorker().jobType(...) registration or a Camunda 7 external task subscription and choose Create element template. It writes the template of the job type or topic into .camunda/element-templates, with one field for each variable the worker reads, and the variables it sets as output mappings. A template that exists for that job type is updated, and the labels and descriptions you wrote are kept. The tool window shows which worker a template came from. See Element templates.
The debugger
When the debugger stops in a job worker, an external task handler, a JavaDelegate or a task listener, the diagram marks the task it is running for, with the process instance. The position is read while the debugger is paused, and again when you pick another stack frame, so it follows the frame you are looking at. On Camunda 7, Operaton and CIB seven it marks the other active elements of that instance too. The tool window lists the same under Debug. The marks go when the program resumes.
Other repositories and other languages
Name other repositories under linked in penstock.yaml. Workers in Java, Kotlin, JavaScript, TypeScript, Python, Go or C# are found by reading their text, so a worker in another repository, or in a language the IDE does not know, still counts as a task's implementation.
What you see
- Underlined strings you can click, and small gutter icons beside them.
- Grey lines above workers and tests (Code Vision). The Code Vision provider is named Diagrams that use the code.
- Marks on the diagram while the debugger is stopped in a worker.
Common problems
- No links, no gutter icons.
- Code links need Pro. The tool window shows a Code line with Buy or Sign In….
- Click-through works in Java but not in another language.
- Completion and click-through are for Java and Kotlin. The check against the code reads more languages.
- A worker in another repository is reported as missing.
- Add that repository to
linkedinpenstock.yaml.