Skip to content

Commit 129f7ed

Browse files
authored
Merge pull request #15 from lstreckeisen/CMI-79-Create-SemanticTokenProvider-for-language-server
Cmi 79 create semantic token provider for language server
2 parents 27674e8 + c657c01 commit 129f7ed

File tree

10 files changed

+703
-587
lines changed

10 files changed

+703
-587
lines changed

.github/workflows/build.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ jobs:
1616
build:
1717
runs-on: ubuntu-latest
1818
container:
19-
image: node:22-alpine
19+
image: node:22-slim
2020
steps:
21+
- name: Prepare debian
22+
run: |
23+
apt update
24+
apt install -y git wget unzip
2125
# required since test report action uses git
2226
- name: Setup git
2327
run: |
24-
apk --no-cache add git
2528
REPO_NAME=$(echo "${GITHUB_REPOSITORY}" | cut -d'/' -f2)
2629
git config --global --add safe.directory "/__w/$REPO_NAME/$REPO_NAME"
2730
@@ -48,6 +51,11 @@ jobs:
4851
path: out/test-results.xml
4952
reporter: java-junit
5053

54+
- name: SonarQube Scan
55+
uses: SonarSource/sonarqube-scan-action@v5
56+
env:
57+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
58+
5159
- name: Build
5260
run: yarn build
5361

.github/workflows/sonar.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
node_modules/
66
out/
77
dist/
8+
coverage/
89
src/language/generated/
910
syntaxes/
1011
.idea

.yarn/install-state.gz

3.26 KB
Binary file not shown.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"langium:generate:production": "langium generate --mode=production",
2929
"langium:watch": "langium generate --watch",
3030
"bundle:language-server": "npx ncc build dist/main.cjs -o cml-ls",
31-
"test": "vitest run",
31+
"test": "vitest run --coverage",
3232
"clean": "rm -rf src/language/generated && rm -rf cml-ls/ && rm -rf dist/"
3333
},
3434
"dependencies": {
@@ -41,6 +41,7 @@
4141
"@typescript-eslint/eslint-plugin": "~7.3.1",
4242
"@typescript-eslint/parser": "~7.3.1",
4343
"@vercel/ncc": "^0.38.3",
44+
"@vitest/coverage-v8": "^3.1.1",
4445
"concurrently": "~8.2.1",
4546
"esbuild": "~0.20.2",
4647
"eslint": "~8.57.0",
@@ -50,7 +51,7 @@
5051
"eslint-plugin-promise": "^7.2.1",
5152
"langium-cli": "~3.4.0",
5253
"typescript": "~5.1.6",
53-
"vitest": "~1.4.0"
54+
"vitest": "^3.1.1"
5455
},
5556
"packageManager": "yarn@4.8.1"
5657
}

sonar-project.properties

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ sonar.organization=lstreckeisen
33

44

55
# This is the name and version displayed in the SonarCloud UI.
6-
#sonar.projectName=context-mapper-language-server
6+
sonar.projectName=context-mapper-language-server
77
#sonar.projectVersion=1.0
88

99

1010
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
1111
#sonar.sources=.
1212

1313
# Encoding of the source code. Default is default system encoding
14-
#sonar.sourceEncoding=UTF-8
14+
sonar.sourceEncoding=UTF-8
15+
sonar.javascript.lcov.reportPaths=./coverage/lcov.info
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { createContextMapperDslServices } from '../../src/language/ContextMapperDslModule.js'
2+
import { parseHelper } from 'langium/test'
3+
import { ContextMappingModel } from '../../src/language/generated/ast.js'
4+
import { EmptyFileSystem } from 'langium'
5+
import { beforeAll, describe, expect, test } from 'vitest'
6+
import fs from 'fs'
7+
import { parseValidInput } from './ParsingTestHelper.js'
8+
import path from 'node:path'
9+
10+
let services: ReturnType<typeof createContextMapperDslServices>
11+
let parse: ReturnType<typeof parseHelper<ContextMappingModel>>
12+
13+
beforeAll(async () => {
14+
services = createContextMapperDslServices(EmptyFileSystem)
15+
parse = parseHelper<ContextMappingModel>(services.ContextMapperDsl)
16+
})
17+
18+
describe('Example file parsing tests', () => {
19+
test('Parse example files', async () => {
20+
const dir = path.resolve(__dirname, 'example-files')
21+
fs.readdir(dir, (err, files) => {
22+
expect(err).toBeNull()
23+
files.forEach(file => {
24+
fs.readFile(path.resolve(dir, file), { encoding: 'utf8' }, async (err, data) => {
25+
console.log('test parsing of file:', file)
26+
expect(err).toBeNull()
27+
await parseValidInput(parse, data)
28+
})
29+
})
30+
})
31+
})
32+
})
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/* The DDD Cargo sample application modeled in CML. Note that we split the application into multiple bounded contexts. */
2+
ContextMap DDDSampleMap {
3+
contains CargoBookingContext
4+
contains VoyagePlanningContext
5+
contains LocationContext
6+
7+
/* As Evans mentions in his book (Bounded Context chapter): The voyage planning can be seen as
8+
* separated bounded context. However, it still shares code with the booking application (CargoBookingContext).
9+
* Thus, they are in a 'Shared-Kernel' relationship.
10+
*/
11+
CargoBookingContext [SK]<->[SK] VoyagePlanningContext
12+
13+
/* Note that the splitting of the LocationContext is not mentioned in the original DDD sample of Evans.
14+
* However, locations and the management around them, can somehow be seen as a separated concept which is used by other
15+
* bounded contexts. But this is just an example, since we want to demonstrate our DSL with multiple bounded contexts.
16+
*/
17+
CargoBookingContext [D]<-[U,OHS,PL] LocationContext
18+
19+
VoyagePlanningContext [D]<-[U,OHS,PL] LocationContext
20+
21+
}
22+
23+
/* The original booking application context */
24+
BoundedContext CargoBookingContext {
25+
Module cargo {
26+
basePackage = se.citerus.dddsample.domain.model
27+
28+
Aggregate CargoItineraryLegDeliveryRouteSpecification
29+
}
30+
Module handling {
31+
basePackage = se.citerus.dddsample.domain.model
32+
33+
Aggregate Handling
34+
}
35+
}
36+
37+
/* We split the Voyage Planning into a separate bounded context as Evans proposes it in his book. */
38+
BoundedContext VoyagePlanningContext {
39+
Module voyage {
40+
basePackage = se.citerus.dddsample.domain.model
41+
42+
Aggregate Voyage
43+
}
44+
}
45+
46+
/* Separate bounded context for managing the locations. */
47+
BoundedContext LocationContext {
48+
Module location {
49+
basePackage = se.citerus.dddsample.domain.model
50+
51+
Aggregate Location
52+
}
53+
}

vitest.config.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import { defineConfig } from 'vitest/config';
66

77
export default defineConfig({
88
test: {
9-
// coverage: {
10-
// provider: 'v8',
11-
// reporter: ['text', 'html'],
12-
// include: ['src'],
13-
// exclude: ['**/generated'],
14-
// },
9+
coverage: {
10+
provider: 'v8',
11+
reporter: ['lcov'],
12+
include: ['src'],
13+
exclude: ['**/generated']
14+
},
1515
deps: {
1616
interopDefault: true
1717
},

0 commit comments

Comments
 (0)