You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tools/code-extension.mdx
+152-2Lines changed: 152 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: VS Code Extension
3
3
description: Visual Studio Code Extension for Lingua Franca.
4
4
---
5
5
6
-
The Lingua Franca extension for Visual Studio Code (VS Code) provides syntax-directed editing capability, compilation, and diagram synthesis for Lingua Franca programs.
6
+
The Lingua Franca extension for Visual Studio Code (VS Code) provides syntax-directed editing capability, compilation, diagram synthesis and a project explorer for Lingua Franca programs.
7
7
8
8
## Usage
9
9
@@ -18,6 +18,22 @@ src/
18
18
src-gen/Foo
19
19
```
20
20
21
+
Overall, we encourage you to open your project in VS Code using the following structure to fully leverage the features of the VS Code extension:
└── └── Lingo.toml # Configuration file for Lingo Package Manager
35
+
```
36
+
21
37
### Rendering diagrams
22
38
23
39
To show the diagram for the currently active Lingua Franca file, click on the diagrams icon at the upper right:
@@ -31,8 +47,142 @@ To compile the `.lf` source, open the command palette (<kbd>Ctrl</kbd> + <kbd>Sh
31
47
You can also build and immediately afterwards run your code by opening the command palette (<kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd>) and then entering `Lingua Franca: Build and Run`.
32
48
Running the code can also be done from the VS Code terminal by executing the generated file in `./bin`.
33
49
50
+
### Project Explorer
51
+
52
+
The **Lingua Franca Project Explorer** can be accessed by clicking on the **LF icon** in the activity bar on the left side of the screen. Once opened, the **Project Explorer** displays a **Tree View** with the following structure:
53
+
54
+
```shell
55
+
├── LF Project
56
+
│ ├── Lingo Packages
57
+
│ ├── Local Libraries
58
+
└── └── Source Files
59
+
```
60
+
61
+
-**Lingo Packages**: Lists libraries installed via the Lingo Package Manager, located in the `build/lfc_include` directory (if any).
62
+
63
+
-**Local Libraries**: Displays locally defined libraries (e.g., reusable reactors), located in the `src/lib` directory.
64
+
65
+
-**Source Files**: Contains the LF source files created by the developer, located in the `src` directory.
66
+
67
+
The **Source Files** section is always present as it reflects the main LF files in the project. However, the **Lingo Packages** and **Local Libraries** sections appear only if the respective directories and files exist in the workspace.
68
+
69
+
Hovering over the **LF Project** item reveals a terminal icon. Clicking this icon opens a terminal window at the project's root directory, allowing you to execute commands directly within that directory.
70
+
71
+
#### Lingo Packages
72
+
73
+
The **Lingo Packages** section lists libraries installed using the [Lingo Package Manager](https://github.com/lf-lang/lingo). Developers can use the Lingo Package Manager to retrieve and install LF programs from repositories such as the [Lingua Franca Community Organization](https://github.com/LF-Community).
74
+
75
+
To install libraries:
76
+
1. Configure the `Lingo.toml` file with the desired libraries.
77
+
2. Run `lingo build` to download the specified dependencies.
78
+
79
+
Once the libraries are installed, they will appear in the `{project_name}/build/lfc_include/` directory. The **Lingo Packages** section will then be structured as follows:
80
+
81
+
```shell
82
+
├── LF Project
83
+
│ ├── Lingo Packages
84
+
│ │ ├── lingo_library/
85
+
│ │ │ ├── File_1.lf
86
+
│ │ │ │ ├── Rusable_Reactor_1.lf
87
+
│ │ │ │ ├── Rusable_Reactor_2.lf
88
+
│ │ │ ├── File_2.lf
89
+
│ │ │ │ ├── Rusable_Reactor_1.lf
90
+
│ │ │ │ ├── Rusable_Reactor_2.lf
91
+
...
92
+
```
93
+
94
+
In this structure:
95
+
-**LF Project**: Represents the root folder of the main project.
96
+
-**lingo_library**: Represents each library listed in `Lingo.toml`, which contains one or more LF programs featuring reusable reactors.
97
+
98
+
The image below shows a visual representation of the **Lingo Packages** section. The **project** icon indicates the LF Project folder (e.g., `AudioClassification`), while the **root-folder** icon represents the downloaded libraries (e.g., the `edgeai` library in the example). The **code file** icon denotes an LF program within a library, and the **bracket** icon represents individual reactors inside the LF program.
The hierarchy categorizes tree items into the following types:
103
+
104
+
1.**`library-root`**: Refers to the root folder of each downloaded library.
105
+
2.**`file`**: Represents an LF program within the library.
106
+
3.**`reactor`**: Refers to individual reactors within the LF program.
107
+
108
+
When focusing on the **Lingo Packages** section, an `edit` command becomes available. Clicking it opens the `Lingo.toml` file in the editor for configuration changes. The following actions are available for items in the **Lingo Packages** section:
109
+
110
+
- For **file** items (from right to left):
111
+
-**Open in Split View**: Opens the file in a split editor view.
112
+
-**Go To File**: Navigates to the file in the editor.
113
+
114
+
- For **reactor** items (from right to left):
115
+
-**Import Selected Reactor**: Imports the selected reactor into the active LF program.
116
+
-**Go To File**: Opens the file where the reactor is defined.
117
+
-**Open in Split View**: Opens the file in a split editor view (accessible by right-clicking the item).
118
+
119
+
> **Note**: The **Import Selected Reactor** option is available only if an LF program is open in the editor.
120
+
121
+
#### Local Libraries
122
+
123
+
The **Local Libraries** section lists LF programs created by the developer, located in the `{project_name}/src/lib/` directory. These programs serve as local libraries, containing reusable reactors. The directory structure follows this format:
124
+
125
+
```shell
126
+
├── LF Project
127
+
...
128
+
│ ├── Local Libraries
129
+
│ │ ├── File_1.lf
130
+
│ │ │ ├── Rusable_Reactor_1.lf
131
+
│ │ │ ├── Rusable_Reactor_2.lf
132
+
│ │ ├── File_2.lf
133
+
│ │ │ │ ├── Rusable_Reactor_1.lf
134
+
│ │ │ │ ├── Rusable_Reactor_2.lf
135
+
...
136
+
```
137
+
138
+
The image below illustrates the **Local Libraries** section. In this depiction, the **"project"** icon represents the LF project folder, while the **"code file"** icon represents the LF program, and the **"bracket"** icon denotes individual reactors within the LF program.
The hierarchy categorizes tree items into two types:
143
+
144
+
1.**`file`**: Represents the LF program.
145
+
2.**`reactor`**: Represents a reactor within the LF program.
146
+
147
+
Actions for **Local Libraries** are similar to those in the [**Lingo Packages**](#lingo-packages) section:
148
+
149
+
- For **file** items (from right to left):
150
+
-**Open in Split View**: Opens the file in a split editor view.
151
+
-**Go To File**: Navigates to the file in the editor.
152
+
153
+
- For **reactor** items (from right to left):
154
+
-**Import Selected Reactor**: Imports the selected reactor into the active LF program.
155
+
-**Go To File**: Opens the file where the reactor is defined.
156
+
-**Open in Split View**: Opens the file in a split editor view (accessible by right-clicking the item).
157
+
158
+
> **Note**: The **Import Selected Reactor** option is available only if an LF program is open in the editor.
159
+
160
+
#### Source Files
161
+
162
+
The **Source Files** section lists all LF programs in the `{project_name}/src/` directory. This section provides direct access to the main source files of the project. The hierarchy for this view is straightforward:
163
+
164
+
```shell
165
+
├── LF Project
166
+
...
167
+
│ ├── Local Libraries
168
+
│ │ ├── File_1.lf
169
+
│ │ ├── File_1.lf
170
+
│ │ ├── File_1.lf
171
+
...
172
+
```
173
+
174
+
Clicking on any of the files will open the corresponding LF program in the editor, allowing developers to quickly navigate to and edit the source code of their project.
175
+
176
+
#### Correctness of Project Structure
177
+
178
+
If the project structure deviates from the expected format, an error message will appear:
0 commit comments