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

Add publish keyword #571

Merged
merged 19 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
78706d2
Introduce `publish` keyword and adapt scoping
georg-schwarz May 22, 2024
ca8cee6
Refactor scoping to only import exported elements
georg-schwarz May 23, 2024
01ca888
Add scoping behavior for delayed export statements
georg-schwarz May 23, 2024
9b6861f
Remove unnecessary recursion in followExportDefinitionChain
georg-schwarz May 23, 2024
48df33a
Add validation for import cycles
georg-schwarz May 23, 2024
dd29b3b
Show dependency cycle to user in validation
georg-schwarz May 23, 2024
5aceb98
Add license information to newly added test files
georg-schwarz May 23, 2024
15eeb73
Remove outdated TODO comment
georg-schwarz May 23, 2024
11e2f24
Update documentation of followExportDefinitionChain method
georg-schwarz May 23, 2024
b94c29c
Fix followExportDefinitionChain
georg-schwarz May 23, 2024
4fef7c4
Refactor export mechanism to have a common grammar element instead of…
georg-schwarz May 24, 2024
5e9aba2
Fix typo in JayveeScopeProvider
georg-schwarz May 26, 2024
2a1c5e7
Document import and export feature
georg-schwarz May 26, 2024
d7ef7ec
Add caching to document-based scoping
georg-schwarz May 26, 2024
a197d1a
Remove outdated TODO comment
georg-schwarz May 26, 2024
3db1d0e
Fix expect in executeExpressionTestHelper
georg-schwarz May 28, 2024
279300d
Pull out test helper function extractTestElements
georg-schwarz May 28, 2024
99dcda2
Move extractTestElements to @language-server/test
georg-schwarz May 28, 2024
5a5ea86
Use extractTestElements in execution lib
georg-schwarz May 28, 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
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
//
// SPDX-License-Identifier: AGPL-3.0-only

builtin blocktype TestFileExtractor {
publish builtin blocktype TestFileExtractor {
input inPort oftype None;
output outPort oftype File;
}

builtin blocktype TestFileLoader {
publish builtin blocktype TestFileLoader {
input inPort oftype File;
output outPort oftype None;
}

builtin blocktype TestTableLoader {
publish builtin blocktype TestTableLoader {
input inPort oftype Table;
output outPort oftype None;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: AGPL-3.0-only

builtin blocktype TestTableExtractor {
publish builtin blocktype TestTableExtractor {
input inPort oftype None;
output outPort oftype Table;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
//
// SPDX-License-Identifier: AGPL-3.0-only

builtin blocktype TestFileExtractor {
publish builtin blocktype TestFileExtractor {
input inPort oftype None;
output outPort oftype File;
}

builtin blocktype TestFileLoader {
publish builtin blocktype TestFileLoader {
input inPort oftype File;
output outPort oftype None;
}

builtin blocktype TestSheetLoader {
publish builtin blocktype TestSheetLoader {
input inPort oftype Sheet;
output outPort oftype None;
}

builtin blocktype TestTextFileLoader {
publish builtin blocktype TestTextFileLoader {
input inPort oftype TextFile;
output outPort oftype None;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,42 @@
//
// SPDX-License-Identifier: AGPL-3.0-only

builtin blocktype TestSheetExtractor {
publish builtin blocktype TestSheetExtractor {
input inPort oftype None;
output outPort oftype Sheet;
}

builtin blocktype TestSheetLoader {
publish builtin blocktype TestSheetLoader {
input inPort oftype Sheet;
output outPort oftype None;
}

builtin blocktype TestTextFileExtractor {
publish builtin blocktype TestTextFileExtractor {
input inPort oftype None;
output outPort oftype TextFile;
}

builtin blocktype TestFileExtractor {
publish builtin blocktype TestFileExtractor {
input inPort oftype None;
output outPort oftype File;
}

builtin blocktype TestWorkbookExtractor {
publish builtin blocktype TestWorkbookExtractor {
input inPort oftype None;
output outPort oftype Workbook;
}

builtin blocktype TestWorkbookLoader {
publish builtin blocktype TestWorkbookLoader {
input inPort oftype Workbook;
output outPort oftype None;
}

builtin blocktype TestTableExtractor {
publish builtin blocktype TestTableExtractor {
input inPort oftype None;
output outPort oftype Table;
}

builtin blocktype TestTableLoader {
publish builtin blocktype TestTableLoader {
input inPort oftype Table;
output outPort oftype None;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
//
// SPDX-License-Identifier: AGPL-3.0-only

builtin blocktype TestFileExtractor {
publish builtin blocktype TestFileExtractor {
input inPort oftype None;
output outPort oftype File;
}

builtin blocktype TestFileLoader {
publish builtin blocktype TestFileLoader {
input inPort oftype File;
output outPort oftype None;
}

builtin blocktype TestTableLoader {
publish builtin blocktype TestTableLoader {
input inPort oftype Table;
output outPort oftype None;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: AGPL-3.0-only

builtin blocktype TestProperty {
publish builtin blocktype TestProperty {
input inPort oftype File;
output outPort oftype Table;

Expand Down
4 changes: 2 additions & 2 deletions libs/language-server/src/grammar/block-type.langium
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ ReferenceableBlockTypeDefinition:
BuiltinBlockTypeDefinition | CompositeBlockTypeDefinition;

BuiltinBlockTypeDefinition:
'builtin' 'blocktype' name=ID '{'
(isPublished?='publish')? 'builtin' 'blocktype' name=ID '{'
(inputs+=BlockTypeInput | outputs+=BlockTypeOutput | properties+=BlockTypeProperty)*
'}';

CompositeBlockTypeDefinition:
'composite' 'blocktype' name=ID '{'
(isPublished?='publish')? 'composite' 'blocktype' name=ID '{'
(
inputs+=BlockTypeInput
| outputs+=BlockTypeOutput
Expand Down
6 changes: 3 additions & 3 deletions libs/language-server/src/grammar/constraint.langium
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ ConstraintDefinition:
TypedConstraintDefinition | ExpressionConstraintDefinition;

TypedConstraintDefinition:
'constraint' name=ID 'oftype' type=[BuiltinConstrainttypeDefinition] body=PropertyBody;
(isPublished?='publish')? 'constraint' name=ID 'oftype' type=[BuiltinConstrainttypeDefinition] body=PropertyBody;

ExpressionConstraintDefinition:
'constraint' name=ID 'on' valueType=ValueTypeReference ':' expression=Expression ';';
(isPublished?='publish')? 'constraint' name=ID 'on' valueType=ValueTypeReference ':' expression=Expression ';';

BuiltinConstrainttypeDefinition:
'builtin' 'constrainttype' name=ID 'on' valueType=ValueTypeReference '{'
(isPublished?='publish')? 'builtin' 'constrainttype' name=ID 'on' valueType=ValueTypeReference '{'
(properties+=ConstrainttypeProperty)*
'}';

Expand Down
2 changes: 1 addition & 1 deletion libs/language-server/src/grammar/io-type.langium
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import './expression'
import './terminal'

IotypeDefinition:
'builtin' 'iotype' name=ID ';';
(isPublished?='publish')? 'builtin' 'iotype' name=ID ';';
16 changes: 16 additions & 0 deletions libs/language-server/src/grammar/main.langium
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import './io-type'
entry JayveeModel:
(
imports+=ImportDefinition
| exports+=ExportDefinition
| pipelines+=PipelineDefinition
| valueTypes+=(CustomValuetypeDefinition | BuiltinValuetypeDefinition)
| constraints+=ConstraintDefinition
Expand All @@ -25,6 +26,21 @@ entry JayveeModel:
| iotypes+=IotypeDefinition
)*;

// When adding an element here, make sure the element has the following prependix in its rule
// (isPublished?='publish')?
// TypeScript lets us then infer that there is a field `isPublished` after using the type guard `isExportableElement`.
ExportableElement:
// Must ref rules where isPublished is defined
// So don't use aggregates like ReferenceableBlockTypeDefinition
// Otherwise it doesn't work to resolve the refenerces
(CustomValuetypeDefinition | BuiltinValuetypeDefinition)
| (TypedConstraintDefinition | ExpressionConstraintDefinition | BuiltinConstrainttypeDefinition)
| TransformDefinition
| (BuiltinBlockTypeDefinition | CompositeBlockTypeDefinition)
| IotypeDefinition;

ExportDefinition:
'publish' element=[ExportableElement] ';';

ImportDefinition:
'use' '*' 'from' path=STRING ';';
2 changes: 1 addition & 1 deletion libs/language-server/src/grammar/transform.langium
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'value-type'
import 'expression'

TransformDefinition:
'transform' name=ID body=TransformBody;
(isPublished?='publish')? 'transform' name=ID body=TransformBody;

TransformBody:
'{' (ports+=TransformPortDefinition)* (outputAssignments+=TransformOutputAssignment)* '}';
Expand Down
4 changes: 2 additions & 2 deletions libs/language-server/src/grammar/value-type.langium
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import './expression'
import './terminal'

BuiltinValuetypeDefinition infers ValuetypeDefinition:
isBuiltin?='builtin' 'valuetype' name=ID
(isPublished?='publish')? isBuiltin?='builtin' 'valuetype' name=ID
(genericDefinition=ValuetypeGenericsDefinition)?
';';

CustomValuetypeDefinition infers ValuetypeDefinition:
'valuetype' name=ID
(isPublished?='publish')? 'valuetype' name=ID
(genericDefinition=ValuetypeGenericsDefinition)?
'oftype' type=ValueTypeReference '{'
'constraints' ':' constraints=CollectionLiteral ';'
Expand Down
6 changes: 3 additions & 3 deletions libs/language-server/src/lib/builtin-library/stdlib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function getBuiltinValuetypesLib() {
.map(parseBuiltinValuetypeToJayvee);

const collectionValuetype = `${parseAsComment('For internal use only.')}
builtin valuetype Collection<ElementType>;`;
publish builtin valuetype Collection<ElementType>;`;

return {
'builtin:///stdlib/builtin-value-types.jv': [
Expand All @@ -24,7 +24,7 @@ builtin valuetype Collection<ElementType>;`;

export const IOtypesLib = {
'builtin:///stdlib/io-types.jv': Object.values(IOType)
.map((iotype) => `builtin iotype ${iotype};`)
.map((iotype) => `publish builtin iotype ${iotype};`)
.join('\n\n'),
};

Expand All @@ -46,7 +46,7 @@ function parseBuiltinValuetypeToJayvee(valueType: PrimitiveValueType): string {
if (!valueType.isReferenceableByUser()) {
lines.push(parseAsComment('For internal use only.'));
}
lines.push(`builtin valuetype ${valueType.getName()};`);
lines.push(`publish builtin valuetype ${valueType.getName()};`);

return lines.join('\n');
}
Expand Down
2 changes: 0 additions & 2 deletions libs/language-server/src/lib/jayvee-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
JayveeDefinitionProvider,
JayveeFormatter,
JayveeHoverProvider,
JayveeScopeComputation,
JayveeScopeProvider,
} from './lsp';
import { JayveeImportResolver } from './services/import-resolver';
Expand Down Expand Up @@ -91,7 +90,6 @@ export const JayveeModule: Module<
},
references: {
ScopeProvider: (services) => new JayveeScopeProvider(services),
ScopeComputation: (service) => new JayveeScopeComputation(service),
},
RuntimeParameterProvider: () => new RuntimeParameterProvider(),
operators: {
Expand Down
Loading
Loading