# Study validation

**Validate Current Study** checks a study for mistakes that would otherwise only show up when code_aster runs. Find it in the Command Palette, in the editor title bar of `.comm`, `.com0` to `.com9` and `.export` files, and as **Validate current study** in the sidebar's Quick actions.

It checks the text of the open editors, saved or not, and needs the language server to be running.

## Finding the pair of files

- **From a `.comm`**: the `.export` is searched in the folder of the `.comm` and its parents, up to the workspace root. Files that reference this `.comm` are preferred. When several match, pick one ("Select the .export file for this study").
- **From a `.export`**: the `.comm` it declares (`F comm`) is used, or the `.comm` files of the same folder ("Select the command file (.comm) for this study").

Without a `.export`, the file unit checks are skipped.

## Checks on the .comm

For every concept (the result of a command) and command:

- **Syntactic**: the command is known to the catalog and well formed.
- **Dependency**: every concept passed to a top-level keyword is defined earlier in the file.
- **Naming**: the result has a valid name, is assigned to a name when the command produces one, and is not redefined (reusing a concept with `reuse=` is allowed).
- **Used**: the concept is used somewhere later (a mention in a comment counts).

Concepts declared with `CO("name")` are understood. Keywords inside `_F(...)` are not checked.

## Checks between the .comm and the .export

For every `UNITE=<number>` of the `.comm` (or, when a command has none, the unit it uses by default: 20 for `LIRE_MAILLAGE`, 80 for `IMPR_RESU` in MED...):

- the unit is declared in the `.export`;
- its direction matches: `LIRE_*` and `PRE_*` commands read (input `D`), `IMPR_*` commands write (output `R`).

And for every file of the `.export`, the unit is used in the `.comm`. Unit 0 and the `comm` and `mess` files are implicit and never reported. A default unit with no file in the `.export` (such as `IMPR_TABLE` writing unit 8) is allowed and not reported.

## Messages

| Code | Example |
| --- | --- |
| `dependency` | "Undefined concept `R` used in keyword `K` of `CMD`." / "Concept `R` is used in `CMD` before it is defined." |
| `naming` | "`CMD` produces a concept but the result is not assigned to a name." / "`N` is not a valid concept name." / "Concept `N` is redefined (first defined at line L)." |
| `unused` | "Concept `N` is defined by `CMD` but never used." |
| `io-missing-export` | "UNITE=u is used in CMD but no matching file is declared in the export file." |
| `io-unused-export` | "Unit u is declared in the export file but is not explicitly used in the command file." |
| `io-direction` | "UNITE=u is used as input by CMD but is declared as output in the export file." |

They appear in the **Problems** panel with the source `code_aster study`. A command that fails the syntactic check is marked in the report only; the [editor diagnostics](/comm-files#diagnostics) give the detail.

## The report

A **Validation: `<file>`** tab opens beside the editor with:

- the files checked ("Command file: X · Export: Y", or a note that no `.export` was found);
- a legend: ✅ passed, ⚠️ worth checking but will not necessarily fail the run, ❌ likely to break the run, and a dash for not applicable;
- **Command / concept validity**: one row per concept with the Command, Syntactic, Dependency, Naming and Used columns (hover a column title for its meaning);
- **I/O validity**: one row per unit with its direction, file, export type, use in the `.comm` and status;
- **Findings**: every issue written out in words, sorted by severity then line. Click one (or press Enter) to jump to the line.

When everything passes, the report says "No issues detected".

While the report is open, it updates by itself as you edit the `.comm` or the `.export` (half a second after you stop typing, saved or not, and when the `.export` is saved from the form), together with the Problems panel. Closing the report stops the updates.
