Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: initialize Langium component #455

Merged
merged 16 commits into from
Apr 7, 2023
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
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ module.exports = {
},
},
extends: '@lars-reimann',
rules: {
'import/extensions': 'off',
},
};
40 changes: 38 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Main
on:
push:
branches: [main]
branches: [ main ]

jobs:
# Build and test DSL component
Expand All @@ -12,7 +12,7 @@ jobs:
working-directory: ./DSL
strategy:
matrix:
java-version: [17]
java-version: [ 17 ]

steps:
- name: Checkout repository
Expand Down Expand Up @@ -54,3 +54,39 @@ jobs:
coverage: ${{ matrix.python-version == '3.10' }}
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

# Build and test the DSL port to Langium
build-dsl-langium:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./DSL-langium

strategy:
matrix:
node-version: [ 18.x ]

steps:
- name: Checkout source
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: npm
cache-dependency-path: DSL-langium/package-lock.json

- name: Install dependencies
run: npm ci

- name: Test with Vitest
run: npm run test-with-coverage

- name: Upload coverage to Codecov
if: ${{ github.actor != 'dependabot[bot]' }}
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: DSL-langium/coverage
files: clover.xml
36 changes: 36 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,39 @@ jobs:
coverage: ${{ matrix.python-version == '3.10' }}
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

# Build and test the DSL port to Langium
build-dsl-langium:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./DSL-langium

strategy:
matrix:
node-version: [ 18.x ]

steps:
- name: Checkout source
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: npm
cache-dependency-path: DSL-langium/package-lock.json

- name: Install dependencies
run: npm ci

- name: Test with Vitest
run: npm run test-with-coverage

- name: Upload coverage to Codecov
if: ${{ github.actor != 'dependabot[bot]' }}
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: DSL-langium/coverage
files: clover.xml
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
.vscode/

# Compilation/build outputs
/DSL/**/bin/
/DSL-langium/**/generated/
build/
coverage/
dist/
dist-ssr/
out/

# Gradle
Expand Down
4 changes: 4 additions & 0 deletions DSL-langium/.vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.vscode/**
.vscode-test/**
.gitignore
langium-quickstart.md
3 changes: 3 additions & 0 deletions DSL-langium/bin/cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

require("../out/cli").default();
14 changes: 14 additions & 0 deletions DSL-langium/langium-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"projectName": "SafeDs",
"languages": [
{
"id": "safe-ds",
"grammar": "src/language-server/grammar/safe-ds.langium",
"fileExtensions": [".sdspipe", ".sdsschema", ".sdsstub", ".sdstest"],
"textMate": {
"out": "syntaxes/safe-ds.tmLanguage.json"
}
}
],
"out": "src/language-server/generated"
}
40 changes: 40 additions & 0 deletions DSL-langium/langium-quickstart.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Welcome to your Langium VS Code Extension

## What's in the folder

This folder contains all necessary files for your language extension.
* `package.json` - the manifest file in which you declare your language support.
* `language-configuration.json` - the language configuration used in the VS Code editor, defining the tokens that are used for comments and brackets.
* `src/extension.ts` - the main code of the extension, which is responsible for launching a language server and client.
* `src/language-server/safe-ds.langium` - the grammar definition of your language.
* `src/language-server/main.ts` - the entry point of the language server process.
* `src/language-server/safe-ds-module.ts` - the dependency injection module of your language implementation. Use this to register overridden and added services.
* `src/language-server/safe-ds-validator.ts` - an example validator. You should change it to reflect the semantics of your language.
* `src/cli/index.ts` - the entry point of the command line interface (CLI) of your language.
* `src/cli/generator.ts` - the code generator used by the CLI to write output files from DSL documents.
* `src/cli/cli-util.ts` - utility code for the CLI.

## Get up and running straight away

* Run `npm run langium:generate` to generate TypeScript code from the grammar definition.
* Run `npm run build` to compile all TypeScript code.
* Press `F5` to open a new window with your extension loaded.
* Create a new file with a file name suffix matching your language.
* Verify that syntax highlighting, validation, completion etc. are working as expected.
* Run `./bin/cli` to see options for the CLI; `./bin/cli generate <file>` generates code for a given DSL file.

## Make changes

* Run `npm run watch` to have the TypeScript compiler run automatically after every change of the source files.
* Run `npm run langium:watch` to have the Langium generator run automatically after every change of the grammar declaration.
* You can relaunch the extension from the debug toolbar after making changes to the files listed above.
* You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes.

## Install your extension

* To start using your extension with VS Code, copy it into the `<user home>/.vscode/extensions` folder and restart Code.
* To share your extension with the world, read the [VS Code documentation](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) about publishing an extension.

## To Go Further

Documentation about the Langium framework is available at https://langium.org
25 changes: 25 additions & 0 deletions DSL-langium/language-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"comments": {
"lineComment": "//",
"blockComment": ["/*", "*/"]
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
],
"autoClosingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
],
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
]
}
Loading