From a2f66eee8690600655d585b5dcbf069005a9ea21 Mon Sep 17 00:00:00 2001 From: Benjamin Friedman Wilson Date: Thu, 7 Dec 2023 09:57:43 +0100 Subject: [PATCH] update generated content in examples, using lsp-based services instead of core --- .../src/language-server/arithmetics-module.ts | 9 +++++---- .../arithmetics/src/language-server/generated/module.ts | 7 ++++--- .../domainmodel/src/language-server/generated/module.ts | 7 ++++--- .../requirements/src/language-server/generated/module.ts | 9 +++++---- .../src/language-server/requirements-lang-module.ts | 7 ++++--- .../src/language-server/tests-lang-module.ts | 7 ++++--- .../statemachine/src/language-server/generated/module.ts | 7 ++++--- .../src/language-server/statemachine-module.ts | 9 +++++---- packages/langium/src/grammar/generated/module.ts | 7 ++++--- 9 files changed, 39 insertions(+), 30 deletions(-) diff --git a/examples/arithmetics/src/language-server/arithmetics-module.ts b/examples/arithmetics/src/language-server/arithmetics-module.ts index ee9119d38..b8bfc770b 100644 --- a/examples/arithmetics/src/language-server/arithmetics-module.ts +++ b/examples/arithmetics/src/language-server/arithmetics-module.ts @@ -4,9 +4,10 @@ * terms of the MIT License, which is available in the project root. ******************************************************************************/ -import type { DefaultSharedModuleContext, LangiumCoreServices, Module, PartialLangiumCoreServices } from 'langium'; +import type { DefaultSharedModuleContext, Module } from 'langium'; +import type { LangiumServices, LangiumSharedServices, PartialLangiumServices } from 'langium/lsp'; import { createDefaultModule, createDefaultSharedModule, inject } from 'langium'; -import { type LangiumSharedServices, createSharedLSPModule } from 'langium/lsp'; +import { createSharedLSPModule } from 'langium/lsp'; import { ArithmeticsGeneratedModule, ArithmeticsGeneratedSharedModule } from './generated/module.js'; import { ArithmeticsValidator, registerValidationChecks } from './arithmetics-validator.js'; import { ArithmeticsScopeProvider } from './arithmetics-scope-provider.js'; @@ -24,14 +25,14 @@ export type ArithmeticsAddedServices = { * Union of Langium default services and your custom services - use this as constructor parameter * of custom service classes. */ -export type ArithmeticsServices = LangiumCoreServices & ArithmeticsAddedServices +export type ArithmeticsServices = LangiumServices & ArithmeticsAddedServices /** * Dependency injection module that overrides Langium default services and contributes the * declared custom services. The Langium defaults can be partially specified to override only * selected services, while the custom services must be fully specified. */ -export const ArithmeticsModule: Module = { +export const ArithmeticsModule: Module = { references: { ScopeProvider: (services) => new ArithmeticsScopeProvider(services) }, diff --git a/examples/arithmetics/src/language-server/generated/module.ts b/examples/arithmetics/src/language-server/generated/module.ts index b93ddee7b..b352b7f28 100644 --- a/examples/arithmetics/src/language-server/generated/module.ts +++ b/examples/arithmetics/src/language-server/generated/module.ts @@ -3,7 +3,8 @@ * DO NOT EDIT MANUALLY! ******************************************************************************/ -import type { LangiumGeneratedServices, LangiumGeneratedSharedServices, LangiumSharedCoreServices, LangiumCoreServices, LanguageMetaData, Module } from 'langium'; +import type { LangiumGeneratedServices, LangiumGeneratedSharedServices, LanguageMetaData, Module } from 'langium'; +import type { LangiumSharedServices, LangiumServices } from 'langium/lsp'; import { ArithmeticsAstReflection } from './ast.js'; import { ArithmeticsGrammar } from './grammar.js'; @@ -13,11 +14,11 @@ export const ArithmeticsLanguageMetaData = { caseInsensitive: true } as const satisfies LanguageMetaData; -export const ArithmeticsGeneratedSharedModule: Module = { +export const ArithmeticsGeneratedSharedModule: Module = { AstReflection: () => new ArithmeticsAstReflection() }; -export const ArithmeticsGeneratedModule: Module = { +export const ArithmeticsGeneratedModule: Module = { Grammar: () => ArithmeticsGrammar(), LanguageMetaData: () => ArithmeticsLanguageMetaData, parser: {} diff --git a/examples/domainmodel/src/language-server/generated/module.ts b/examples/domainmodel/src/language-server/generated/module.ts index bfd8ca016..2b40264eb 100644 --- a/examples/domainmodel/src/language-server/generated/module.ts +++ b/examples/domainmodel/src/language-server/generated/module.ts @@ -3,7 +3,8 @@ * DO NOT EDIT MANUALLY! ******************************************************************************/ -import type { LangiumGeneratedServices, LangiumGeneratedSharedServices, LangiumSharedCoreServices, LangiumCoreServices, LanguageMetaData, Module, IParserConfig } from 'langium'; +import type { LangiumGeneratedServices, LangiumGeneratedSharedServices, LanguageMetaData, Module, IParserConfig } from 'langium'; +import type { LangiumSharedServices, LangiumServices } from 'langium/lsp'; import { DomainModelAstReflection } from './ast.js'; import { DomainModelGrammar } from './grammar.js'; @@ -19,11 +20,11 @@ export const parserConfig: IParserConfig = { maxLookahead: 3, }; -export const DomainModelGeneratedSharedModule: Module = { +export const DomainModelGeneratedSharedModule: Module = { AstReflection: () => new DomainModelAstReflection() }; -export const DomainModelGeneratedModule: Module = { +export const DomainModelGeneratedModule: Module = { Grammar: () => DomainModelGrammar(), LanguageMetaData: () => DomainModelLanguageMetaData, parser: { diff --git a/examples/requirements/src/language-server/generated/module.ts b/examples/requirements/src/language-server/generated/module.ts index 89ca941bd..faaeadc2c 100644 --- a/examples/requirements/src/language-server/generated/module.ts +++ b/examples/requirements/src/language-server/generated/module.ts @@ -3,7 +3,8 @@ * DO NOT EDIT MANUALLY! ******************************************************************************/ -import type { LangiumGeneratedServices, LangiumGeneratedSharedServices, LangiumSharedCoreServices, LangiumCoreServices, LanguageMetaData, Module } from 'langium'; +import type { LangiumGeneratedServices, LangiumGeneratedSharedServices, LanguageMetaData, Module } from 'langium'; +import type { LangiumSharedServices, LangiumServices } from 'langium/lsp'; import { RequirementsAndTestsAstReflection } from './ast.js'; import { RequirementsGrammar, TestsGrammar } from './grammar.js'; @@ -19,17 +20,17 @@ export const TestsLanguageMetaData = { caseInsensitive: false } as const satisfies LanguageMetaData; -export const RequirementsAndTestsGeneratedSharedModule: Module = { +export const RequirementsAndTestsGeneratedSharedModule: Module = { AstReflection: () => new RequirementsAndTestsAstReflection() }; -export const RequirementsGeneratedModule: Module = { +export const RequirementsGeneratedModule: Module = { Grammar: () => RequirementsGrammar(), LanguageMetaData: () => RequirementsLanguageMetaData, parser: {} }; -export const TestsGeneratedModule: Module = { +export const TestsGeneratedModule: Module = { Grammar: () => TestsGrammar(), LanguageMetaData: () => TestsLanguageMetaData, parser: {} diff --git a/examples/requirements/src/language-server/requirements-lang-module.ts b/examples/requirements/src/language-server/requirements-lang-module.ts index 035f40386..c1deb2547 100644 --- a/examples/requirements/src/language-server/requirements-lang-module.ts +++ b/examples/requirements/src/language-server/requirements-lang-module.ts @@ -4,7 +4,8 @@ * terms of the MIT License, which is available in the project root. ******************************************************************************/ -import type { LangiumCoreServices, Module, PartialLangiumCoreServices } from 'langium'; +import type { Module } from 'langium'; +import type { LangiumServices, PartialLangiumServices } from 'langium/lsp'; import { RequirementsLangValidator } from './requirements-lang-validator.js'; /** @@ -20,14 +21,14 @@ export type RequirementsLangAddedServices = { * Union of Langium default services and your custom services - use this as constructor parameter * of custom service classes. */ -export type RequirementsLangServices = LangiumCoreServices & RequirementsLangAddedServices +export type RequirementsLangServices = LangiumServices & RequirementsLangAddedServices /** * Dependency injection module that overrides Langium default services and contributes the * declared custom services. The Langium defaults can be partially specified to override only * selected services, while the custom services must be fully specified. */ -export const RequirementsLangModule: Module = { +export const RequirementsLangModule: Module = { validation: { RequirementsLangValidator: (services) => new RequirementsLangValidator(services) } diff --git a/examples/requirements/src/language-server/tests-lang-module.ts b/examples/requirements/src/language-server/tests-lang-module.ts index 8cf88e0ad..c628cb253 100644 --- a/examples/requirements/src/language-server/tests-lang-module.ts +++ b/examples/requirements/src/language-server/tests-lang-module.ts @@ -4,8 +4,9 @@ * terms of the MIT License, which is available in the project root. ******************************************************************************/ -import type { LangiumCoreServices, Module, PartialLangiumCoreServices } from 'langium'; +import type { Module } from 'langium'; import { TestsLangValidator } from './tests-lang-validator.js'; +import type { LangiumServices, PartialLangiumServices } from 'langium/lsp'; /** * Declaration of custom services - add your own service classes here. @@ -20,14 +21,14 @@ export type TestsLangAddedServices = { * Union of Langium default services and your custom services - use this as constructor parameter * of custom service classes. */ -export type TestsLangServices = LangiumCoreServices & TestsLangAddedServices +export type TestsLangServices = LangiumServices & TestsLangAddedServices /** * Dependency injection module that overrides Langium default services and contributes the * declared custom services. The Langium defaults can be partially specified to override only * selected services, while the custom services must be fully specified. */ -export const TestsLangModule: Module = { +export const TestsLangModule: Module = { validation: { TestsLangValidator: () => new TestsLangValidator() } diff --git a/examples/statemachine/src/language-server/generated/module.ts b/examples/statemachine/src/language-server/generated/module.ts index 7112a6b1d..ada743ed2 100644 --- a/examples/statemachine/src/language-server/generated/module.ts +++ b/examples/statemachine/src/language-server/generated/module.ts @@ -3,7 +3,8 @@ * DO NOT EDIT MANUALLY! ******************************************************************************/ -import type { LangiumGeneratedServices, LangiumGeneratedSharedServices, LangiumSharedCoreServices, LangiumCoreServices, LanguageMetaData, Module } from 'langium'; +import type { LangiumGeneratedServices, LangiumGeneratedSharedServices, LanguageMetaData, Module } from 'langium'; +import type { LangiumSharedServices, LangiumServices } from 'langium/lsp'; import { StatemachineAstReflection } from './ast.js'; import { StatemachineGrammar } from './grammar.js'; @@ -13,11 +14,11 @@ export const StatemachineLanguageMetaData = { caseInsensitive: false } as const satisfies LanguageMetaData; -export const StatemachineGeneratedSharedModule: Module = { +export const StatemachineGeneratedSharedModule: Module = { AstReflection: () => new StatemachineAstReflection() }; -export const StatemachineGeneratedModule: Module = { +export const StatemachineGeneratedModule: Module = { Grammar: () => StatemachineGrammar(), LanguageMetaData: () => StatemachineLanguageMetaData, parser: {} diff --git a/examples/statemachine/src/language-server/statemachine-module.ts b/examples/statemachine/src/language-server/statemachine-module.ts index 3209d9779..f15b7c941 100644 --- a/examples/statemachine/src/language-server/statemachine-module.ts +++ b/examples/statemachine/src/language-server/statemachine-module.ts @@ -4,11 +4,12 @@ * terms of the MIT License, which is available in the project root. ******************************************************************************/ -import type { DefaultSharedModuleContext, LangiumCoreServices, Module, PartialLangiumCoreServices } from 'langium'; +import type { DefaultSharedModuleContext, Module } from 'langium'; import { createDefaultModule, createDefaultSharedModule, inject } from 'langium'; import { StatemachineGeneratedModule, StatemachineGeneratedSharedModule } from './generated/module.js'; import { registerValidationChecks, StatemachineValidator } from './statemachine-validator.js'; -import { createSharedLSPModule, type LangiumSharedServices } from 'langium/lsp'; +import type { LangiumServices, LangiumSharedServices, PartialLangiumServices } from 'langium/lsp'; +import { createSharedLSPModule } from 'langium/lsp'; /** * Declaration of custom services - add your own service classes here. @@ -23,14 +24,14 @@ export type StatemachineAddedServices = { * Union of Langium default services and your custom services - use this as constructor parameter * of custom service classes. */ -export type StatemachineServices = LangiumCoreServices & StatemachineAddedServices +export type StatemachineServices = LangiumServices & StatemachineAddedServices /** * Dependency injection module that overrides Langium default services and contributes the * declared custom services. The Langium defaults can be partially specified to override only * selected services, while the custom services must be fully specified. */ -export const StatemachineModule: Module = { +export const StatemachineModule: Module = { validation: { StatemachineValidator: () => new StatemachineValidator() } diff --git a/packages/langium/src/grammar/generated/module.ts b/packages/langium/src/grammar/generated/module.ts index dc2a36f72..696c9ef9a 100644 --- a/packages/langium/src/grammar/generated/module.ts +++ b/packages/langium/src/grammar/generated/module.ts @@ -6,7 +6,8 @@ import type { LanguageMetaData } from '../../languages/language-meta-data.js'; import { LangiumGrammarAstReflection } from '../../languages/generated/ast.js'; import type { Module } from '../../dependency-injection.js'; -import type { LangiumGeneratedServices, LangiumGeneratedSharedServices, LangiumSharedCoreServices, LangiumCoreServices } from '../../services.js'; +import type { LangiumGeneratedServices, LangiumGeneratedSharedServices } from '../../services.js'; +import type { LangiumSharedServices, LangiumServices } from '../../lsp/lsp-services.js'; import type { IParserConfig } from '../../parser/parser-config.js'; import { LangiumGrammarGrammar } from './grammar.js'; @@ -20,11 +21,11 @@ export const LangiumGrammarParserConfig: IParserConfig = { maxLookahead: 3, }; -export const LangiumGrammarGeneratedSharedModule: Module = { +export const LangiumGrammarGeneratedSharedModule: Module = { AstReflection: () => new LangiumGrammarAstReflection() }; -export const LangiumGrammarGeneratedModule: Module = { +export const LangiumGrammarGeneratedModule: Module = { Grammar: () => LangiumGrammarGrammar(), LanguageMetaData: () => LangiumGrammarLanguageMetaData, parser: {