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

Remove Import Cycle for ValueTypes #549

Merged
merged 29 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
74416b0
Refactor value type creation to be used via WrapperFactoryProvider
georg-schwarz Apr 15, 2024
28f47d8
Create TransformExecutor with ExecutionContext
georg-schwarz Apr 15, 2024
0dffbc8
Remove unnecessary parameter from AtomicValueType.getConstraints
georg-schwarz Apr 15, 2024
af72beb
Adapt test to changes to TransformExecutor
georg-schwarz Apr 15, 2024
6a60b4c
Bottom-up exports of value types
georg-schwarz Apr 15, 2024
48ecbd0
Remove deprecated method createPrimitiveValuetype
georg-schwarz Apr 15, 2024
d594b84
Export EmptyCollection
georg-schwarz Apr 15, 2024
fa58a67
Add PrimitiveValuetypeContainer to ValueTypeWrapperFactory
georg-schwarz Apr 16, 2024
37b5704
Add PrimitiveValuetypeContainer to JayveeServices
georg-schwarz Apr 16, 2024
dc4b16f
Rename PrimitiveValueTypeContainer
georg-schwarz Apr 16, 2024
cf5abf9
Introduce PrimitiveValueTypeProvider and add to ExecutionContext
georg-schwarz Apr 16, 2024
ba89015
Use PrimitiveValueTypeProvider instead of WrapperFactory in executors
georg-schwarz Apr 16, 2024
d68022f
Use PrimitiveValueTypeProvider instead of WrapperFactory in type comp…
georg-schwarz Apr 16, 2024
6814d00
Use PrimitiveValueTypeProvider in validations
georg-schwarz Apr 16, 2024
a8f46ee
User PrimitiveValueTypeProvider in validations and wrappers
georg-schwarz Apr 16, 2024
4fd1896
User PrimitiveValueTypeProvider in EvaluationContext
georg-schwarz Apr 16, 2024
4688b37
User PrimitiveValueTypeProvider to refer to EmptyCollection
georg-schwarz Apr 16, 2024
e78d52a
Remove fields Primitives and EmptyCollection from WrapperFactoryProvider
georg-schwarz Apr 16, 2024
3522961
Adapt tests to changes
georg-schwarz Apr 16, 2024
131b06e
Fix license header in PrimitiveValueTypeProvider
georg-schwarz Apr 16, 2024
6e1ed75
Adapt docs generation to changes
georg-schwarz Apr 17, 2024
27a7f66
Undo modification of npm lint job
georg-schwarz Apr 17, 2024
5576158
Rename AtomicValuetype to AtomicValueType
georg-schwarz Apr 17, 2024
14fb324
Rename method createCollection to createCollectionValueTypeOf
georg-schwarz Apr 18, 2024
c8ac828
Move method createCollectionValueTypeOf to PrimitiveValueTypeProvider
georg-schwarz Apr 18, 2024
aa60337
Add reason to use of type exports in index.ts files in wrappers direc…
georg-schwarz Apr 18, 2024
4ea4e3b
Rename PrimitiveValueTypeProvider to ValueTypeProvider
georg-schwarz Apr 18, 2024
3e3f367
Rename variables and members of type valueTypeProvider
georg-schwarz Apr 18, 2024
25a5be0
Merge branch 'main' into import-cycle-value-types
georg-schwarz Apr 18, 2024
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
6 changes: 3 additions & 3 deletions apps/docs/generator/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { join } from 'path';

import {
type JayveeServices,
PrimitiveValuetypes,
createJayveeServices,
getAllBuiltinBlockTypes,
getAllBuiltinConstraintTypes,
Expand Down Expand Up @@ -102,8 +101,9 @@ function generateValueTypeDocs(
'value-types',
);
const userDocBuilder = new UserDocGenerator(services);
const valueTypeDoc =
userDocBuilder.generateValueTypesDoc(PrimitiveValuetypes);
const valueTypeDoc = userDocBuilder.generateValueTypesDoc(
services.ValueTypeProvider.Primitives.getAll(),
);

const fileName = `built-in-value-types.md`;
writeFileSync(join(docsPath, fileName), valueTypeDoc, {
Expand Down
13 changes: 5 additions & 8 deletions apps/docs/generator/src/user-doc-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ export class UserDocGenerator
{
constructor(private services: JayveeServices) {}

generateValueTypesDoc(
valueTypes: Record<string, PrimitiveValueType>,
): string {
generateValueTypesDoc(valueTypes: PrimitiveValueType[]): string {
const builder = new UserDocMarkdownBuilder()
.docTitle('Built-in Value Types')
.generationComment()
Expand All @@ -42,16 +40,15 @@ that fullfil [_constraints_](./primitive-value-types#constraints).`.trim(),
)
.heading('Available built-in value types', 1);

Object.entries(valueTypes)
// eslint-disable-next-line @typescript-eslint/no-unused-vars
.filter(([_, valueType]) => valueType.isReferenceableByUser())
.forEach(([name, valueType]) => {
valueTypes
.filter((valueType) => valueType.isReferenceableByUser())
.forEach((valueType) => {
assert(
valueType.getUserDoc(),
`Documentation is missing for user extendable value type: ${valueType.getName()}`,
);
builder
.heading(name, 2)
.heading(valueType.getName(), 2)
.description(valueType.getUserDoc() ?? '', 3)
.examples(
[
Expand Down
5 changes: 3 additions & 2 deletions libs/execution/src/lib/blocks/composite-block-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
type InternalValueRepresentation,
type ValueType,
type WrapperFactoryProvider,
createValueType,
evaluateExpression,
evaluatePropertyValue,
getIOType,
Expand Down Expand Up @@ -121,7 +120,9 @@ export function createCompositeBlockExecutor(
context: ExecutionContext,
) {
properties.forEach((blockTypeProperty) => {
const valueType = createValueType(blockTypeProperty.valueType);
const valueType = context.wrapperFactories.ValueType.wrap(
blockTypeProperty.valueType,
);

assert(
valueType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import {
type BlockDefinition,
type InternalValueRepresentation,
type JayveeServices,
type TypedConstraintDefinition,
createJayveeServices,
} from '@jvalue/jayvee-language-server';
Expand Down Expand Up @@ -32,6 +33,7 @@ describe('Validation of AllowlistConstraintExecutor', () => {
) => Promise<LangiumDocument<AstNode>>;

let locator: AstNodeLocator;
let services: JayveeServices;

const readJvTestAsset = readJvTestAssetHelper(
__dirname,
Expand All @@ -57,13 +59,16 @@ describe('Validation of AllowlistConstraintExecutor', () => {
return new AllowlistConstraintExecutor().isValid(
value,
// Execution context with initial stack containing usage block of constraint and constraint itself
getTestExecutionContext(locator, document, [usageBlock, constraint]),
getTestExecutionContext(locator, document, services, [
usageBlock,
constraint,
]),
);
}

beforeAll(() => {
// Create language services
const services = createJayveeServices(NodeFileSystem).Jayvee;
services = createJayveeServices(NodeFileSystem).Jayvee;
locator = services.workspace.AstNodeLocator;
// Parse function for Jayvee (without validation)
parse = parseHelper(services);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
//
// SPDX-License-Identifier: AGPL-3.0-only

import {
CollectionValuetype,
type InternalValueRepresentation,
PrimitiveValuetypes,
} from '@jvalue/jayvee-language-server';
import { type InternalValueRepresentation } from '@jvalue/jayvee-language-server';

import { type ExecutionContext } from '../../execution-context';
import { implementsStatic } from '../../util/implements-static-decorator';
Expand All @@ -27,7 +23,9 @@ export class AllowlistConstraintExecutor implements ConstraintExecutor {

const allowlist = context.getPropertyValue(
'allowlist',
new CollectionValuetype(PrimitiveValuetypes.Text),
context.valueTypeProvider.createCollectionValueTypeOf(
context.valueTypeProvider.Primitives.Text,
),
);
return allowlist.includes(value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import {
type BlockDefinition,
type InternalValueRepresentation,
type JayveeServices,
type TypedConstraintDefinition,
createJayveeServices,
} from '@jvalue/jayvee-language-server';
Expand Down Expand Up @@ -32,6 +33,7 @@ describe('Validation of DenylistConstraintExecutor', () => {
) => Promise<LangiumDocument<AstNode>>;

let locator: AstNodeLocator;
let services: JayveeServices;

const readJvTestAsset = readJvTestAssetHelper(
__dirname,
Expand All @@ -57,13 +59,16 @@ describe('Validation of DenylistConstraintExecutor', () => {
return new DenylistConstraintExecutor().isValid(
value,
// Execution context with initial stack containing usage block of constraint and constraint itself
getTestExecutionContext(locator, document, [usageBlock, constraint]),
getTestExecutionContext(locator, document, services, [
usageBlock,
constraint,
]),
);
}

beforeAll(() => {
// Create language services
const services = createJayveeServices(NodeFileSystem).Jayvee;
services = createJayveeServices(NodeFileSystem).Jayvee;
locator = services.workspace.AstNodeLocator;
// Parse function for Jayvee (without validation)
parse = parseHelper(services);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
//
// SPDX-License-Identifier: AGPL-3.0-only

import {
CollectionValuetype,
type InternalValueRepresentation,
PrimitiveValuetypes,
} from '@jvalue/jayvee-language-server';
import { type InternalValueRepresentation } from '@jvalue/jayvee-language-server';

import { type ExecutionContext } from '../../execution-context';
import { implementsStatic } from '../../util/implements-static-decorator';
Expand All @@ -27,7 +23,9 @@ export class DenylistConstraintExecutor implements ConstraintExecutor {

const denylist = context.getPropertyValue(
'denylist',
new CollectionValuetype(PrimitiveValuetypes.Text),
context.valueTypeProvider.createCollectionValueTypeOf(
context.valueTypeProvider.Primitives.Text,
),
);
return !denylist.includes(value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
type BlockDefinition,
type ExpressionConstraintDefinition,
type InternalValueRepresentation,
type JayveeServices,
createJayveeServices,
} from '@jvalue/jayvee-language-server';
import {
Expand All @@ -32,6 +33,7 @@ describe('Validation of AllowlistConstraintExecutor', () => {
) => Promise<LangiumDocument<AstNode>>;

let locator: AstNodeLocator;
let services: JayveeServices;

const readJvTestAsset = readJvTestAssetHelper(
__dirname,
Expand All @@ -57,13 +59,16 @@ describe('Validation of AllowlistConstraintExecutor', () => {
return new ExpressionConstraintExecutor(constraint).isValid(
value,
// Execution context with initial stack containing usage block of constraint and constraint itself
getTestExecutionContext(locator, document, [usageBlock, constraint]),
getTestExecutionContext(locator, document, services, [
usageBlock,
constraint,
]),
);
}

beforeAll(() => {
// Create language services
const services = createJayveeServices(NodeFileSystem).Jayvee;
services = createJayveeServices(NodeFileSystem).Jayvee;
locator = services.workspace.AstNodeLocator;
// Parse function for Jayvee (without validation)
parse = parseHelper(services);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
type AstNodeWrapper,
type ExpressionConstraintDefinition,
type InternalValueRepresentation,
PrimitiveValuetypes,
evaluateExpression,
} from '@jvalue/jayvee-language-server';

Expand All @@ -33,7 +32,11 @@ export class ExpressionConstraintExecutor
context.evaluationContext,
context.wrapperFactories,
);
assert(PrimitiveValuetypes.Boolean.isInternalValueRepresentation(result));
assert(
context.valueTypeProvider.Primitives.Boolean.isInternalValueRepresentation(
result,
),
);

context.evaluationContext.deleteValueForValueKeyword();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import {
type BlockDefinition,
type InternalValueRepresentation,
type JayveeServices,
type TypedConstraintDefinition,
createJayveeServices,
} from '@jvalue/jayvee-language-server';
Expand Down Expand Up @@ -32,6 +33,7 @@ describe('Validation of LengthConstraintExecutor', () => {
) => Promise<LangiumDocument<AstNode>>;

let locator: AstNodeLocator;
let services: JayveeServices;

const readJvTestAsset = readJvTestAssetHelper(
__dirname,
Expand All @@ -57,13 +59,16 @@ describe('Validation of LengthConstraintExecutor', () => {
return new LengthConstraintExecutor().isValid(
value,
// Execution context with initial stack containing usage block of constraint and constraint itself
getTestExecutionContext(locator, document, [usageBlock, constraint]),
getTestExecutionContext(locator, document, services, [
usageBlock,
constraint,
]),
);
}

beforeAll(() => {
// Create language services
const services = createJayveeServices(NodeFileSystem).Jayvee;
services = createJayveeServices(NodeFileSystem).Jayvee;
locator = services.workspace.AstNodeLocator;
// Parse function for Jayvee (without validation)
parse = parseHelper(services);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
//
// SPDX-License-Identifier: AGPL-3.0-only

import {
type InternalValueRepresentation,
PrimitiveValuetypes,
} from '@jvalue/jayvee-language-server';
import { type InternalValueRepresentation } from '@jvalue/jayvee-language-server';

import { type ExecutionContext } from '../../execution-context';
import { implementsStatic } from '../../util/implements-static-decorator';
Expand All @@ -26,11 +23,11 @@ export class LengthConstraintExecutor implements ConstraintExecutor {

const minLength = context.getPropertyValue(
'minLength',
PrimitiveValuetypes.Integer,
context.valueTypeProvider.Primitives.Integer,
);
const maxLength = context.getPropertyValue(
'maxLength',
PrimitiveValuetypes.Integer,
context.valueTypeProvider.Primitives.Integer,
);

return minLength <= value.length && value.length <= maxLength;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import {
type BlockDefinition,
type InternalValueRepresentation,
type JayveeServices,
type TypedConstraintDefinition,
createJayveeServices,
initializeWorkspace,
Expand Down Expand Up @@ -33,6 +34,7 @@ describe('Validation of RangeConstraintExecutor', () => {
) => Promise<LangiumDocument<AstNode>>;

let locator: AstNodeLocator;
let services: JayveeServices;

const readJvTestAsset = readJvTestAssetHelper(
__dirname,
Expand All @@ -58,13 +60,16 @@ describe('Validation of RangeConstraintExecutor', () => {
return new RangeConstraintExecutor().isValid(
value,
// Execution context with initial stack containing usage block of constraint and constraint itself
getTestExecutionContext(locator, document, [usageBlock, constraint]),
getTestExecutionContext(locator, document, services, [
usageBlock,
constraint,
]),
);
}

beforeAll(async () => {
// Create language services
const services = createJayveeServices(NodeFileSystem).Jayvee;
services = createJayveeServices(NodeFileSystem).Jayvee;
await initializeWorkspace(services);

locator = services.workspace.AstNodeLocator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
//
// SPDX-License-Identifier: AGPL-3.0-only

import {
type InternalValueRepresentation,
PrimitiveValuetypes,
} from '@jvalue/jayvee-language-server';
import { type InternalValueRepresentation } from '@jvalue/jayvee-language-server';

import { type ExecutionContext } from '../../execution-context';
import { implementsStatic } from '../../util/implements-static-decorator';
Expand All @@ -31,19 +28,19 @@ export class RangeConstraintExecutor implements ConstraintExecutor {

const lowerBound = context.getPropertyValue(
'lowerBound',
PrimitiveValuetypes.Decimal,
context.valueTypeProvider.Primitives.Decimal,
);
const lowerBoundInclusive = context.getPropertyValue(
'lowerBoundInclusive',
PrimitiveValuetypes.Boolean,
context.valueTypeProvider.Primitives.Boolean,
);
const upperBound = context.getPropertyValue(
'upperBound',
PrimitiveValuetypes.Decimal,
context.valueTypeProvider.Primitives.Decimal,
);
const upperBoundInclusive = context.getPropertyValue(
'upperBoundInclusive',
PrimitiveValuetypes.Boolean,
context.valueTypeProvider.Primitives.Boolean,
);

const lowerBoundFulfilled = lowerBoundInclusive
Expand Down
Loading
Loading