-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'DevTest/dev'
- Loading branch information
Showing
70 changed files
with
1,449 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-only |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
sidebar_position: 5 | ||
sidebar_position: 8 | ||
--- | ||
|
||
# Runtime Parameters | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
sidebar_position: 4 | ||
sidebar_position: 7 | ||
--- | ||
|
||
# Transforms | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
builtin-valuetypes.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"label": "Valuetypes", | ||
"position": 4, | ||
"link": { | ||
"type": "generated-index", | ||
"description": "Jayvee supports these different kinds of valuetypes." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg | ||
|
||
SPDX-License-Identifier: AGPL-3.0-only |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
sidebar_position: 2 | ||
--- | ||
# Primitive ValueTypes | ||
|
||
`Primitive ValueTypes` are based on `Built-in ValueTypes` and use a collection of constraints to restrict the range of valid values. | ||
Such constraints are implicitly connected via a logical `AND` relation. | ||
Note that the `Constraints` need to be applicable to the base-type of the `ValueType` - indicated by the identifier after the keyword `oftype`: | ||
|
||
```jayvee | ||
valuetype GasFillLevel oftype integer { | ||
constraints: [ GasFillLevelRange ]; | ||
} | ||
``` | ||
|
||
|
||
## Constraints | ||
|
||
`Constraints` for `ValueTypes` declare the validity criteria that each concrete value is checked against. | ||
|
||
### Syntax 1: Expression syntax | ||
|
||
The syntax of expression-based `Constraints` uses an expression that evaluates to `true` or `false` for the given `value`. The type of the values the expression is working in is indicated ofter the keyword `on`: | ||
|
||
```jayvee | ||
constraint GasFillLevelRange on decimal: | ||
value >= 0 and value <= 100; | ||
``` | ||
|
||
Refer to the [Expression documentation](../expressions.md) for further reading on expressions. | ||
|
||
|
||
### Syntax 2: Block-like syntax | ||
|
||
The syntax of `Constraints` is similar to the syntax of `Blocks`. | ||
The availability of property keys and their respective `ValueTypes` is determined by the type of the `Constraint` - indicated by the identifier after the keyword `oftype`: | ||
|
||
```jayvee | ||
constraint GasFillLevelRange oftype RangeConstraint { | ||
lowerBound: 0; | ||
lowerBoundInclusive: true; | ||
upperBound: 100; | ||
upperBoundInclusive: true; | ||
} | ||
``` | ||
|
||
Note that the type of `Constraint` also determines its applicability to `ValueTypes`. | ||
For instance, a `RangeConstraint` can only be applied to the numerical types `integer` and `decimal`. |
3 changes: 3 additions & 0 deletions
3
apps/docs/docs/user/valuetypes/primitive-valuetypes.md.license
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg | ||
|
||
SPDX-License-Identifier: AGPL-3.0-only |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
libs/extensions/std/lang/src/gtfs-rt-interpreter-meta-inf.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
import { | ||
createJayveeServices, | ||
useExtension, | ||
} from '@jvalue/jayvee-language-server'; | ||
import { | ||
TestLangExtension, | ||
ValidationResult, | ||
readJvTestAssetHelper, | ||
validationHelper, | ||
} from '@jvalue/jayvee-language-server/test'; | ||
import { AstNode } from 'langium'; | ||
import { NodeFileSystem } from 'langium/node'; | ||
|
||
import { StdLangExtension } from './extension'; | ||
|
||
describe('Validation of GtfsRTInterpreterMetaInformation', () => { | ||
let validate: (input: string) => Promise<ValidationResult<AstNode>>; | ||
|
||
const readJvTestAsset = readJvTestAssetHelper(__dirname, '../test/assets/'); | ||
|
||
beforeAll(() => { | ||
// Register std extension | ||
useExtension(new StdLangExtension()); | ||
// Register test extension | ||
useExtension(new TestLangExtension()); | ||
// Create language services | ||
const services = createJayveeServices(NodeFileSystem).Jayvee; | ||
// Create validation helper for language services | ||
validate = validationHelper(services); | ||
}); | ||
|
||
it('should diagnose no error on valid entity parameter value', async () => { | ||
const text = readJvTestAsset( | ||
'gtfs-rt-interpreter-meta-inf/valid-valid-entity-param.jv', | ||
); | ||
|
||
const validationResult = await validate(text); | ||
const diagnostics = validationResult.diagnostics; | ||
|
||
expect(diagnostics).toHaveLength(0); | ||
}); | ||
|
||
it('should diagnose error on invalid entity parameter value', async () => { | ||
const text = readJvTestAsset( | ||
'gtfs-rt-interpreter-meta-inf/invalid-invalid-entity-param.jv', | ||
); | ||
|
||
const validationResult = await validate(text); | ||
const diagnostics = validationResult.diagnostics; | ||
|
||
expect(diagnostics).toHaveLength(1); | ||
expect(diagnostics).toEqual( | ||
expect.arrayContaining([ | ||
expect.objectContaining({ | ||
message: 'Entity must be "trip_update", "alert" or "vehicle"', | ||
}), | ||
]), | ||
); | ||
}); | ||
}); |
Oops, something went wrong.