# OpenModelica in CodeProber (prototype 0.1.0)

CodeProber (https://github.com/lu-cs-sde/codeprober) lets you right-click any part of a Modelica model
in a browser editor and ask the OpenModelica compiler (omc) about it: definitions and uses of names,
the simulation equations and generated C code of an equation, the flat model, connection equations,
and omc's error messages as squiggles in the editor.

## Requirements

- Java 11 or newer (`java -version`)
- An OpenModelica nightly build (1.28.0-dev, late September 2026 or newer). The prototype uses
  `getDefUseChains`, which is not in 1.27 or older releases.
- Tested on Linux. Windows and macOS are not tested yet.

## Install and run

1. Download and unpack:

       wget https://build.openmodelica.org/omc/codeprober/omc-codeprober-0.1.0.zip
       unzip omc-codeprober-0.1.0.zip
       cd omc-codeprober-0.1.0

2. Tell it which omc to use, if `omc` is not on the PATH and OPENMODELICAHOME is not set:

       export OMPROBE_OMC=/path/to/omc

3. Start CodeProber on the example circuit, with model P.B as the model to translate:

       ./run.sh -model=P.B

   or, on any platform:

       java -Dcpr.type_identification_style=NODE_LABEL -Dcpr.workspace=examples -jar codeprober.jar omprobe.jar -model=P.B

4. Open the URL it prints (http://localhost:8000?auth=...), click Circuit.mo in the workspace,
   right-click a name or an equation, choose Create Probe, pick a node and a property.

Options after omprobe.jar: `-model=P.M` (the model whose translation is used; default: the model
around the probed node), `-lib=Modelica` (load a library first), `-omc=/path/to/omc`, `-flags=...`
(omc command line options).

## Without a browser

    java -jar omprobe.jar -model=P.B -probe=10:15:Equation:simEquations examples/Circuit.mo

`-probe=LINE:COLUMN:NodeLabel:property`; without `-probe` it prints the tree.

## Text probes as tests

    java -Dcpr.type_identification_style=NODE_LABEL -Dcpr.workspace=tests -jar codeprober.jar --test omprobe.jar -model=P.B

runs the assertions in the comments of tests/CircuitTest.mo and exits with 0 when they pass. Note: in
CodeProber 1.0.1 a failing `~=` assertion is not reported in `--test`
(https://github.com/lu-cs-sde/codeprober/issues/17); `=` assertions are.

## Properties

- every node: text, hover
- ClassDefinition: definition, uses, dependsOn, checkModel, flatModelica, modelInstance, simVariables,
  simEquations, translationMessages
- ComponentDeclaration: definition, uses, useArrows, simVariables, flatDeclarations
- Equation, Statement: simEquations, jacobianEquations, cCode, connectionEquations (connects)
- Ident: definition, role, uses, useArrows
- ComponentReference, Name, TypeSpecifier: definition, parts
- StoredDefinition (the file): errors, contextModel, topClasses, omcVersion

## Contents

- omprobe.jar: the wrapper (parser generated from OpenModelica's OMParser/modelica.g4, ANTLR 4.8)
- codeprober.jar: CodeProber 1.0.1, BSD 3-Clause license (LICENSE-CodeProber.txt)
- examples/, tests/: the example models and the text-probe test
- source/: the wrapper sources; build with `mvn package -Dom.dir=/path/to/OpenModelica`
