Skip to content

Commit

Permalink
Merge pull request #162 from lf-lang/proprietary-extension-support
Browse files Browse the repository at this point in the history
Proprietary extension support
  • Loading branch information
lhstrh authored May 23, 2024
2 parents 49ed815 + c8b303e commit 7c5436f
Show file tree
Hide file tree
Showing 34 changed files with 3,998 additions and 673 deletions.
18 changes: 10 additions & 8 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,16 @@ runs:
echo $JAVA_HOME
working-directory: lingua-franca
shell: bash
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
- name: Install the wasm-pack dev dependency globally
run: cargo install wasm-pack
shell: bash
- name: Build the VS Code extension
run: npm install --ignore-scripts
run: npm install --ignore-scripts && npm run compile
shell: bash
- name: Install Code
run: |
Expand All @@ -54,19 +62,13 @@ runs:
- name: Install pylint
run: |
python -m pip install --upgrade pip
pip3 install pylint --break-system-packages
PIP_BREAK_SYSTEM_PACKAGES=1 pip3 install pylint
shell: bash
if: ${{ inputs.partial == 'false' }}
- name: Install pnpm
run: npm i -g pnpm
shell: bash
if: ${{ inputs.partial == 'false' }}
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
if: ${{ inputs.partial == 'false' }}
- name: Install RTI
run: |
cd lingua-franca
Expand Down
27 changes: 13 additions & 14 deletions .github/workflows/dependency-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,11 @@ jobs:
uses: ./.github/actions/build
with:
partial: true
- name: Uninstall dependencies
run: |
python3 -m pip uninstall -y pylint
- name: Downgrade dependencies
run: |
pip install -I pylint==2.10.0
rustup default 1.26.0
- name: Run tests (Linux)
run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test-dependencies-outdated
run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npx --yes cross-env LF_VS_CODE_ALLOW_GLOBAL_UNINSTALLS=OK npm run test-dependencies-outdated
if: ${{ runner.os == 'Linux' }}
- name: Run tests (non-Linux)
run: npm run test-dependencies-outdated
Expand All @@ -61,27 +57,30 @@ jobs:
uses: ./.github/actions/build
with:
partial: true
- name: Uninstall dependencies
run: |
python3 -m pip uninstall -y pylint
- name: Run tests (Linux)
run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test-dependencies-missing-extended
run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npx --yes cross-env LF_VS_CODE_ALLOW_GLOBAL_UNINSTALLS=OK npm run test-dependencies-missing-extended
if: ${{ runner.os == 'Linux' }}
- name: Run tests (non-Linux)
run: npm run test-dependencies-missing-extended
run: npx --yes cross-env LF_VS_CODE_ALLOW_GLOBAL_UNINSTALLS=OK npx --yes cross-env PIP_BREAK_SYSTEM_PACKAGES=1 npm run test-dependencies-missing-extended
if: ${{ runner.os != 'Linux' }}
test-dependencies-missing-basic:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: lf-lang/vscode-lingua-franca/.github/actions/build@main
- name: Check out vscode-lingua-franca repository
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 1
- name: Build the extension
uses: ./.github/actions/build
with:
partial: "true"
partial: true
- name: Run tests (Linux)
run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test-dependencies-missing-basic
run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npx --yes cross-env LF_VS_CODE_ALLOW_GLOBAL_UNINSTALLS=OK npm run test-dependencies-missing-basic
if: ${{ runner.os == 'Linux' }}
- name: Run tests (non-Linux)
run: npm run test-dependencies-missing-basic
run: npx --yes cross-env LF_VS_CODE_ALLOW_GLOBAL_UNINSTALLS=OK npm run test-dependencies-missing-basic
if: ${{ runner.os != 'Linux' }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
*.vsix
.vscode-test
node_modules/*
out/*
out/
.gradle/*
__pycache__/*
lfw-pkg/
dist/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "lingua-franca"]
path = lingua-franca
url = https://github.com/lf-lang/lingua-franca.git
[submodule "editor-support"]
path = editor-support
url = https://github.com/xronos-inc/editor-support.git
11 changes: 6 additions & 5 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,28 @@
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"name": "Launch Extension",
"name": "Launch LF Extension",
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"request": "launch",
"type": "extensionHost"
"type": "extensionHost",
"preLaunchTask": "${defaultBuildTask}"
},
{
"name": "Launch VS Code Extension (Socket) LF with Klighd Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--disable-extensions",
"--extensionDevelopmentPath=${workspaceFolder}/../klighd-vscode/applications/klighd-vscode",
"--extensionDevelopmentPath=${workspaceFolder}/../klighd-vscode/applications/klighd-vscode",
"--extensionDevelopmentPath=${workspaceFolder}/",
],
"env": {
"LF_LS_PORT": "7670"
},
"skipFiles": [
"<node_internals>/**"
"<node_internals>/**"
],
"sourceMaps": true,
"smartStep": true,
Expand All @@ -49,7 +50,7 @@
"LF_LS_PORT": "7670"
},
"skipFiles": [
"<node_internals>/**"
"<node_internals>/**"
],
"sourceMaps": true,
"smartStep": true,
Expand Down
11 changes: 11 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
{
"type": "npm",
"script": "compile-tests"
},
{
"type": "npm",
"script": "compile",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [],
"label": "npm: compile",
"detail": "npm run esbuild-base -- --sourcemap"
}
]
}
1 change: 1 addition & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ tslint.json
uf.py
package-lock.json
developer-notes.md
temp*
47 changes: 35 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Contributing

This repo provides the [Lingua Franca](https://www.lf-lang.org/) (LF) [Visual
Studio Code](https://code.visualstudio.com/) (VSCode) extension built around the
LF Language and Diagram Server (LDS).
Expand All @@ -9,77 +10,99 @@ from the VSCode marketplace. See
[README.md](https://github.com/lf-lang/vscode-lingua-franca/) for more info.

## Getting started

To check out the repository, build from source, and install the VS Code plugin, run the following command:

```
git clone [email protected]:lf-lang/vscode-lingua-franca.git \
&& cd vscode-lingua-franca \
&& npm install
```

If you do not have a public key set up for authentication with GitHub, you can also use HTTPS:

```
git clone https://github.com/lf-lang/vscode-lingua-franca.git \
&& cd vscode-lingua-franca \
&& npm install
```

Note that this assumes that you have the WASM dependency somewhere on your system. Eventually, the WASM will probably be published; however, that hasn't been done yet, and it isn't currently possible to build it from source from this open-source repo because it is closed-source.

### Trouble Shooting

#### VS Code is not detected on Mac OS X

If you have VS Code installed, it might not get recognized if it is not on your `PATH`.
To add `code` to your `PATH` and allow our install script to find it, open the command pallete in VS Code (<kbd>ctrl</kbd>+<kbd>p</kbd>) and type `Install 'code' command in PATH`.

#### Maven uses an incompatible JDK

Maven may come with an OpenJDK, depending on how it is installed. If this JDK is not the right version, the build process will fail.
To point `mvn` to the correct JDK, set the `JAVA_HOME` environment variable accordingly. To see which version of Java is used, run `mvn --version`.

## Running the tests

To run integration tests with the assumption that the correct dependencies are installed, run:

```bash
npm run test
```

To test the Textmate syntax highlighting only, run

```bash
npm run test-syntax
```

To save the current Textmate syntax highlighting as the correct "known good" behavior, run

```bash
npm run update-known-good
```

## Adding tests

Tests are located in the `src` directory and are marked using the `.test.ts` extension. We use [Mocha](https://mochajs.org/) as our testing framework.

## Submitting a Pull Request (PR)

Please keep your PRs manageable and easy to review.
- Provide a clear title and description of the proposed changes;
- Keep the changes limited to a particular feature, fix, or enhancement;
- Mark the PR as "draft" until it is ready for review;
- Provide tests along with your code; and
- Follow the [TypeScript style
guide](https://google.github.io/styleguide/tsguide.html) to avoid trivial
review feedback.

- Provide a clear title and description of the proposed changes;
- Keep the changes limited to a particular feature, fix, or enhancement;
- Mark the PR as "draft" until it is ready for review;
- Provide tests along with your code; and
- Follow the [TypeScript style
guide](https://google.github.io/styleguide/tsguide.html) to avoid trivial
review feedback.

## Suggested debugging workflow

For development purposes, it is possible to manually perform an incremental build simply by bypassing Maven and Gradle entirely and
instead running the Python script `./uf.py`. This script will re-compile Java and Kotlin files and add them to the fat jar using
the `jar` command with the `-uf` flag.

We suggest the following workflow for debugging the extension (implemented in TypeScript):

1. Run the command `npm run compile` to generate JavaScript together with a source map (in the `out` directory). The source map is necessary for breakpoints to work.
2. Set breakpoints in the TypeScript source files.
3. Open `./src/extension.ts` in Visual Studio Code.
4. Press <kbd>F5</kbd> to run the extension in a new Extension Development Host window.

We suggest the following workflow for debugging the language server (implemented in Java/Kotlin):

1. Ensure that the appropriate compiler is on your PATH.
* To build Java files, `javac` is required.
* To build Kotlin files, [the Kotlin JVM compiler](https://github.com/JetBrains/kotlin/releases/tag/v1.5.30) `kotlinc` is required. It must be the JVM compiler, not the native compiler.

- To build Java files, `javac` is required.
- To build Kotlin files, [the Kotlin JVM compiler](https://github.com/JetBrains/kotlin/releases/tag/v1.5.30) `kotlinc` is required. It must be the JVM compiler, not the native compiler.

2. Ensure that the language and diagram server fat JAR exists. This file is called `./lib/lflang-lds.jar`. If it does not exist, then it is necessary to build it using the build task: `npm run build`.
3. Run the command: ```./uf.py <CANONICAL_NAME>``` or ```npm run amend-jar -- <CANONICAL_NAME>```, where <CANONICAL_NAME> is either:
* the canonical name of a package that you would like to update, or
* the canonical name of the class that you would like to update. An example would be: ```./uf.py org.lflang.FileConfig```. This will also update any nested classes, and it should work as you would expect even for Kotlin files that do not include exactly one top-level class.
3. Run the command: `./uf.py <CANONICAL_NAME>` or `npm run amend-jar -- <CANONICAL_NAME>`, where <CANONICAL_NAME> is either:

- the canonical name of a package that you would like to update, or
- the canonical name of the class that you would like to update. An example would be: `./uf.py org.lflang.FileConfig`. This will also update any nested classes, and it should work as you would expect even for Kotlin files that do not include exactly one top-level class.

4. Open `./src/extension.ts` in Visual Studio Code.
5. Press <kbd>F5</kbd> to run the extension in a new Extension Development Host window.

Expand Down
1 change: 1 addition & 0 deletions editor-support
Submodule editor-support added at 83df49
2 changes: 1 addition & 1 deletion lingua-franca
Loading

0 comments on commit 7c5436f

Please sign in to comment.