Skip to content

Commit

Permalink
update generated content in examples, using lsp-based services instead
Browse files Browse the repository at this point in the history
of core
  • Loading branch information
montymxb committed Dec 7, 2023
1 parent 437c575 commit a2f66ee
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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<ArithmeticsServices, PartialLangiumCoreServices & ArithmeticsAddedServices> = {
export const ArithmeticsModule: Module<ArithmeticsServices, PartialLangiumServices & ArithmeticsAddedServices> = {
references: {
ScopeProvider: (services) => new ArithmeticsScopeProvider(services)
},
Expand Down
7 changes: 4 additions & 3 deletions examples/arithmetics/src/language-server/generated/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -13,11 +14,11 @@ export const ArithmeticsLanguageMetaData = {
caseInsensitive: true
} as const satisfies LanguageMetaData;

export const ArithmeticsGeneratedSharedModule: Module<LangiumSharedCoreServices, LangiumGeneratedSharedServices> = {
export const ArithmeticsGeneratedSharedModule: Module<LangiumSharedServices, LangiumGeneratedSharedServices> = {
AstReflection: () => new ArithmeticsAstReflection()
};

export const ArithmeticsGeneratedModule: Module<LangiumCoreServices, LangiumGeneratedServices> = {
export const ArithmeticsGeneratedModule: Module<LangiumServices, LangiumGeneratedServices> = {
Grammar: () => ArithmeticsGrammar(),
LanguageMetaData: () => ArithmeticsLanguageMetaData,
parser: {}
Expand Down
7 changes: 4 additions & 3 deletions examples/domainmodel/src/language-server/generated/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -19,11 +20,11 @@ export const parserConfig: IParserConfig = {
maxLookahead: 3,
};

export const DomainModelGeneratedSharedModule: Module<LangiumSharedCoreServices, LangiumGeneratedSharedServices> = {
export const DomainModelGeneratedSharedModule: Module<LangiumSharedServices, LangiumGeneratedSharedServices> = {
AstReflection: () => new DomainModelAstReflection()
};

export const DomainModelGeneratedModule: Module<LangiumCoreServices, LangiumGeneratedServices> = {
export const DomainModelGeneratedModule: Module<LangiumServices, LangiumGeneratedServices> = {
Grammar: () => DomainModelGrammar(),
LanguageMetaData: () => DomainModelLanguageMetaData,
parser: {
Expand Down
9 changes: 5 additions & 4 deletions examples/requirements/src/language-server/generated/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -19,17 +20,17 @@ export const TestsLanguageMetaData = {
caseInsensitive: false
} as const satisfies LanguageMetaData;

export const RequirementsAndTestsGeneratedSharedModule: Module<LangiumSharedCoreServices, LangiumGeneratedSharedServices> = {
export const RequirementsAndTestsGeneratedSharedModule: Module<LangiumSharedServices, LangiumGeneratedSharedServices> = {
AstReflection: () => new RequirementsAndTestsAstReflection()
};

export const RequirementsGeneratedModule: Module<LangiumCoreServices, LangiumGeneratedServices> = {
export const RequirementsGeneratedModule: Module<LangiumServices, LangiumGeneratedServices> = {
Grammar: () => RequirementsGrammar(),
LanguageMetaData: () => RequirementsLanguageMetaData,
parser: {}
};

export const TestsGeneratedModule: Module<LangiumCoreServices, LangiumGeneratedServices> = {
export const TestsGeneratedModule: Module<LangiumServices, LangiumGeneratedServices> = {
Grammar: () => TestsGrammar(),
LanguageMetaData: () => TestsLanguageMetaData,
parser: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand All @@ -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<RequirementsLangServices, PartialLangiumCoreServices & RequirementsLangAddedServices> = {
export const RequirementsLangModule: Module<RequirementsLangServices, PartialLangiumServices & RequirementsLangAddedServices> = {
validation: {
RequirementsLangValidator: (services) => new RequirementsLangValidator(services)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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<TestsLangServices, PartialLangiumCoreServices & TestsLangAddedServices> = {
export const TestsLangModule: Module<TestsLangServices, PartialLangiumServices & TestsLangAddedServices> = {
validation: {
TestsLangValidator: () => new TestsLangValidator()
}
Expand Down
7 changes: 4 additions & 3 deletions examples/statemachine/src/language-server/generated/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -13,11 +14,11 @@ export const StatemachineLanguageMetaData = {
caseInsensitive: false
} as const satisfies LanguageMetaData;

export const StatemachineGeneratedSharedModule: Module<LangiumSharedCoreServices, LangiumGeneratedSharedServices> = {
export const StatemachineGeneratedSharedModule: Module<LangiumSharedServices, LangiumGeneratedSharedServices> = {
AstReflection: () => new StatemachineAstReflection()
};

export const StatemachineGeneratedModule: Module<LangiumCoreServices, LangiumGeneratedServices> = {
export const StatemachineGeneratedModule: Module<LangiumServices, LangiumGeneratedServices> = {
Grammar: () => StatemachineGrammar(),
LanguageMetaData: () => StatemachineLanguageMetaData,
parser: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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<StatemachineServices, PartialLangiumCoreServices & StatemachineAddedServices> = {
export const StatemachineModule: Module<StatemachineServices, PartialLangiumServices & StatemachineAddedServices> = {
validation: {
StatemachineValidator: () => new StatemachineValidator()
}
Expand Down
7 changes: 4 additions & 3 deletions packages/langium/src/grammar/generated/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -20,11 +21,11 @@ export const LangiumGrammarParserConfig: IParserConfig = {
maxLookahead: 3,
};

export const LangiumGrammarGeneratedSharedModule: Module<LangiumSharedCoreServices, LangiumGeneratedSharedServices> = {
export const LangiumGrammarGeneratedSharedModule: Module<LangiumSharedServices, LangiumGeneratedSharedServices> = {
AstReflection: () => new LangiumGrammarAstReflection()
};

export const LangiumGrammarGeneratedModule: Module<LangiumCoreServices, LangiumGeneratedServices> = {
export const LangiumGrammarGeneratedModule: Module<LangiumServices, LangiumGeneratedServices> = {
Grammar: () => LangiumGrammarGrammar(),
LanguageMetaData: () => LangiumGrammarLanguageMetaData,
parser: {
Expand Down

0 comments on commit a2f66ee

Please sign in to comment.