Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,26 @@ Build and execution commands act on the document active when the command starts.
The compiler currently supports `.zasm`; `.zsrc` files can be opened, edited, and
saved, but are not yet supported by the compiler.

Save, validation, build, and optional run/debug startup are coordinated by
`EditorExecutionCoordinator` using Lite.StateMachine. The state classes all use
the `State` suffix: `ValidateCompilerState`, `SaveSourceState`,
`ValidateSourceState`, `CompileState`, `LaunchState`, and the terminal
`CompletedState`, `CanceledState`, `FailedState`, and `RunFailedState`.
Canceling the save picker stops the workflow before compilation; this does not
add cancellation of an already-running compiler process. Failed compilation
never launches a program, and run failures retain compiler diagnostics.
Debug startup always builds the Debug configuration. Each request captures its
source document, compiler path, and configuration, and overlapping executions
are rejected. UI callbacks return to the caller's synchronization context.
The native debugger session continues to own running/paused state independently.
See the [generated execution state diagrams](ide-execution.md) for Build, Run,
and Debug flows and regeneration instructions.

Other potential state-machine workflows include update download/verification/
installation, extension activation/deactivation, and future project loading
and dependency restoration. Those workflows are not implemented as state
machines yet; simple editor and docking notifications do not need one.

The toolbar provides icon buttons for New, Open, Save, Undo, Redo, and Build and
Execute. Hover over a button for its name and shortcut. The build configuration
selector offers Debug and Release. Play or F5 builds and launches the current
Expand Down
70 changes: 70 additions & 0 deletions docs/ide-execution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# IDE execution state diagrams

These diagrams are generated by Lite.StateMachine's `ExportUml` method from the
same registered transitions used by `EditorExecutionCoordinator`. They describe
build and launch orchestration, not the native debugger's running/paused states.

State labels use the class names; normal steps and cancellation/run-failure
branches carry the execution numbering from the XML comments.
Blue **Success** edges continue the workflow. Red **Error** edges report a
failure. The amber **Failure** edge from `SaveSourceState` means the user
canceled saving; no compilation or launch follows. Black circles mark entry and
terminal exits. Each request ends at one terminal state; terminals do not execute
in sequence.

## Build only

Successful compilation goes straight to `CompletedState`, skipping step 5.
The clean-and-build option is handled within `CompileState`.

![Build-only execution state diagram](images/ide-execution/build.svg)

[Graphviz DOT source](images/ide-execution/build.dot)

## Build and run without debugging

After compilation, `LaunchState` starts the program. Launch errors lead to
`RunFailedState`, retaining successful compiler diagnostics.

![Build-and-run execution state diagram](images/ide-execution/run.svg)

[Graphviz DOT source](images/ide-execution/run.dot)

## Build and start debugging

Debug startup always uses the Debug configuration. `LaunchState` starts the
debugger; startup errors lead to `FailedState`. After startup completes, the
separate `IDebugSession` owns execution, pause, step, and stop state.

![Build-and-debug execution state diagram](images/ide-execution/debug.svg)

[Graphviz DOT source](images/ide-execution/debug.dot)

`Built` is a progress notification emitted inside `CompileState`, not a separate
registered state, so it does not appear as a node.

## Regenerating

From the repository root, export all three DOT files without executing the
workflow, saving documents, invoking a compiler, or starting a debugger:

```powershell
dotnet run --project source/Zero.Ide.Diagrams/Zero.Ide.Diagrams.csproj -c Release -- docs/images/ide-execution
```

Render the DOT files with a local Graphviz installation, for example:

```powershell
dot -Tsvg docs/images/ide-execution/run.dot -o docs/images/ide-execution/run.svg
```

To reproduce the committed SVG styling without a system Graphviz installation,
use the optional Graphviz WebAssembly renderer (requires Node.js and npm):

```powershell
npm install --prefix output/ide-diagram-tools --no-save --ignore-scripts --no-audit --no-fund @viz-js/viz@3.31.0
node source/Zero.Ide.Diagrams/render.mjs output/ide-diagram-tools/node_modules/@viz-js/viz/dist/viz.js docs/images/ide-execution
```

The renderer changes presentation only. State names, edges, and transition
results come directly from Lite.StateMachine's exported DOT.
26 changes: 26 additions & 0 deletions docs/images/ide-execution/build.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
digraph "Zero IDE — Build" {
compound=true;
fontsize=12;
"ValidateCompiler" [shape=box, style=rounded, label="1. ValidateCompilerState"];
"Save" [shape=box, style=rounded, label="2. SaveSourceState"];
"ValidateSource" [shape=box, style=rounded, label="3. ValidateSourceState"];
"Build" [shape=box, style=rounded, label="4. CompileState"];
"Completed" [shape=box, style=rounded, label="6. CompletedState"];
"Canceled" [shape=box, style=rounded, label="2a. CanceledState"];
"Failed" [shape=box, style=rounded, label="FailedState"];
"ValidateCompiler" -> "Save" [color="#2563EB", label="Success"];
"ValidateCompiler" -> "Failed" [color="#B91C1C", label="Error"];
"Save" -> "ValidateSource" [color="#2563EB", label="Success"];
"Save" -> "Failed" [color="#B91C1C", label="Error"];
"Save" -> "Canceled" [color="#B45309", label="Failure"];
"ValidateSource" -> "Build" [color="#2563EB", label="Success"];
"ValidateSource" -> "Failed" [color="#B91C1C", label="Error"];
"Build" -> "Completed" [color="#2563EB", label="Success"];
"Build" -> "Failed" [color="#B91C1C", label="Error"];
"start_global" [shape=circle, style=filled, fillcolor="black", color="black", label="", width=0.25, height=0.25, fixedsize=true];
"start_global" -> "ValidateCompiler" [color="black", label="start"];
"final_global" [shape=doublecircle, style=filled, fillcolor="black", color="black", label="", width=0.35, height=0.35, fixedsize=true];
"Completed" -> "final_global" [color="black", label="final"];
"Canceled" -> "final_global" [color="black", label="final"];
"Failed" -> "final_global" [color="black", label="final"];
}
158 changes: 158 additions & 0 deletions docs/images/ide-execution/build.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading