@domainlang/language 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +163 -0
- package/out/ast-augmentation.d.ts +6 -0
- package/out/ast-augmentation.js +2 -0
- package/out/ast-augmentation.js.map +1 -0
- package/out/domain-lang-module.d.ts +57 -0
- package/out/domain-lang-module.js +67 -0
- package/out/domain-lang-module.js.map +1 -0
- package/out/generated/ast.d.ts +759 -0
- package/out/generated/ast.js +556 -0
- package/out/generated/ast.js.map +1 -0
- package/out/generated/grammar.d.ts +6 -0
- package/out/generated/grammar.js +2407 -0
- package/out/generated/grammar.js.map +1 -0
- package/out/generated/module.d.ts +13 -0
- package/out/generated/module.js +21 -0
- package/out/generated/module.js.map +1 -0
- package/out/index.d.ts +16 -0
- package/out/index.js +22 -0
- package/out/index.js.map +1 -0
- package/out/lsp/domain-lang-code-actions.d.ts +55 -0
- package/out/lsp/domain-lang-code-actions.js +143 -0
- package/out/lsp/domain-lang-code-actions.js.map +1 -0
- package/out/lsp/domain-lang-completion.d.ts +37 -0
- package/out/lsp/domain-lang-completion.js +452 -0
- package/out/lsp/domain-lang-completion.js.map +1 -0
- package/out/lsp/domain-lang-formatter.d.ts +15 -0
- package/out/lsp/domain-lang-formatter.js +43 -0
- package/out/lsp/domain-lang-formatter.js.map +1 -0
- package/out/lsp/domain-lang-naming.d.ts +34 -0
- package/out/lsp/domain-lang-naming.js +49 -0
- package/out/lsp/domain-lang-naming.js.map +1 -0
- package/out/lsp/domain-lang-scope.d.ts +59 -0
- package/out/lsp/domain-lang-scope.js +102 -0
- package/out/lsp/domain-lang-scope.js.map +1 -0
- package/out/lsp/domain-lang-workspace-manager.d.ts +21 -0
- package/out/lsp/domain-lang-workspace-manager.js +93 -0
- package/out/lsp/domain-lang-workspace-manager.js.map +1 -0
- package/out/lsp/hover/ddd-pattern-explanations.d.ts +50 -0
- package/out/lsp/hover/ddd-pattern-explanations.js +196 -0
- package/out/lsp/hover/ddd-pattern-explanations.js.map +1 -0
- package/out/lsp/hover/domain-lang-hover.d.ts +19 -0
- package/out/lsp/hover/domain-lang-hover.js +302 -0
- package/out/lsp/hover/domain-lang-hover.js.map +1 -0
- package/out/lsp/hover/domain-lang-keywords.d.ts +13 -0
- package/out/lsp/hover/domain-lang-keywords.js +47 -0
- package/out/lsp/hover/domain-lang-keywords.js.map +1 -0
- package/out/lsp/manifest-diagnostics.d.ts +82 -0
- package/out/lsp/manifest-diagnostics.js +230 -0
- package/out/lsp/manifest-diagnostics.js.map +1 -0
- package/out/main-browser.d.ts +1 -0
- package/out/main-browser.js +11 -0
- package/out/main-browser.js.map +1 -0
- package/out/main.d.ts +1 -0
- package/out/main.js +74 -0
- package/out/main.js.map +1 -0
- package/out/sdk/ast-augmentation.d.ts +136 -0
- package/out/sdk/ast-augmentation.js +62 -0
- package/out/sdk/ast-augmentation.js.map +1 -0
- package/out/sdk/index.d.ts +94 -0
- package/out/sdk/index.js +97 -0
- package/out/sdk/index.js.map +1 -0
- package/out/sdk/indexes.d.ts +16 -0
- package/out/sdk/indexes.js +97 -0
- package/out/sdk/indexes.js.map +1 -0
- package/out/sdk/loader-node.d.ts +51 -0
- package/out/sdk/loader-node.js +119 -0
- package/out/sdk/loader-node.js.map +1 -0
- package/out/sdk/loader.d.ts +49 -0
- package/out/sdk/loader.js +85 -0
- package/out/sdk/loader.js.map +1 -0
- package/out/sdk/patterns.d.ts +93 -0
- package/out/sdk/patterns.js +123 -0
- package/out/sdk/patterns.js.map +1 -0
- package/out/sdk/query.d.ts +90 -0
- package/out/sdk/query.js +679 -0
- package/out/sdk/query.js.map +1 -0
- package/out/sdk/resolution.d.ts +52 -0
- package/out/sdk/resolution.js +68 -0
- package/out/sdk/resolution.js.map +1 -0
- package/out/sdk/types.d.ts +280 -0
- package/out/sdk/types.js +8 -0
- package/out/sdk/types.js.map +1 -0
- package/out/services/dependency-analyzer.d.ts +58 -0
- package/out/services/dependency-analyzer.js +254 -0
- package/out/services/dependency-analyzer.js.map +1 -0
- package/out/services/dependency-resolver.d.ts +146 -0
- package/out/services/dependency-resolver.js +452 -0
- package/out/services/dependency-resolver.js.map +1 -0
- package/out/services/git-url-resolver.browser.d.ts +10 -0
- package/out/services/git-url-resolver.browser.js +19 -0
- package/out/services/git-url-resolver.browser.js.map +1 -0
- package/out/services/git-url-resolver.d.ts +158 -0
- package/out/services/git-url-resolver.js +416 -0
- package/out/services/git-url-resolver.js.map +1 -0
- package/out/services/governance-validator.d.ts +44 -0
- package/out/services/governance-validator.js +153 -0
- package/out/services/governance-validator.js.map +1 -0
- package/out/services/import-resolver.d.ts +77 -0
- package/out/services/import-resolver.js +240 -0
- package/out/services/import-resolver.js.map +1 -0
- package/out/services/performance-optimizer.d.ts +60 -0
- package/out/services/performance-optimizer.js +140 -0
- package/out/services/performance-optimizer.js.map +1 -0
- package/out/services/relationship-inference.d.ts +11 -0
- package/out/services/relationship-inference.js +98 -0
- package/out/services/relationship-inference.js.map +1 -0
- package/out/services/semver.d.ts +98 -0
- package/out/services/semver.js +195 -0
- package/out/services/semver.js.map +1 -0
- package/out/services/types.d.ts +340 -0
- package/out/services/types.js +46 -0
- package/out/services/types.js.map +1 -0
- package/out/services/workspace-manager.d.ts +123 -0
- package/out/services/workspace-manager.js +489 -0
- package/out/services/workspace-manager.js.map +1 -0
- package/out/syntaxes/domain-lang.monarch.d.ts +76 -0
- package/out/syntaxes/domain-lang.monarch.js +29 -0
- package/out/syntaxes/domain-lang.monarch.js.map +1 -0
- package/out/utils/import-utils.d.ts +49 -0
- package/out/utils/import-utils.js +128 -0
- package/out/utils/import-utils.js.map +1 -0
- package/out/validation/bounded-context.d.ts +11 -0
- package/out/validation/bounded-context.js +79 -0
- package/out/validation/bounded-context.js.map +1 -0
- package/out/validation/classification.d.ts +3 -0
- package/out/validation/classification.js +3 -0
- package/out/validation/classification.js.map +1 -0
- package/out/validation/constants.d.ts +180 -0
- package/out/validation/constants.js +235 -0
- package/out/validation/constants.js.map +1 -0
- package/out/validation/domain-lang-validator.d.ts +2 -0
- package/out/validation/domain-lang-validator.js +27 -0
- package/out/validation/domain-lang-validator.js.map +1 -0
- package/out/validation/domain.d.ts +11 -0
- package/out/validation/domain.js +63 -0
- package/out/validation/domain.js.map +1 -0
- package/out/validation/import.d.ts +68 -0
- package/out/validation/import.js +237 -0
- package/out/validation/import.js.map +1 -0
- package/out/validation/manifest.d.ts +144 -0
- package/out/validation/manifest.js +327 -0
- package/out/validation/manifest.js.map +1 -0
- package/out/validation/maps.d.ts +21 -0
- package/out/validation/maps.js +60 -0
- package/out/validation/maps.js.map +1 -0
- package/out/validation/metadata.d.ts +7 -0
- package/out/validation/metadata.js +16 -0
- package/out/validation/metadata.js.map +1 -0
- package/out/validation/model.d.ts +12 -0
- package/out/validation/model.js +29 -0
- package/out/validation/model.js.map +1 -0
- package/out/validation/relationships.d.ts +12 -0
- package/out/validation/relationships.js +94 -0
- package/out/validation/relationships.js.map +1 -0
- package/out/validation/shared.d.ts +6 -0
- package/out/validation/shared.js +12 -0
- package/out/validation/shared.js.map +1 -0
- package/package.json +110 -0
- package/src/ast-augmentation.ts +5 -0
- package/src/domain-lang-module.ts +112 -0
- package/src/domain-lang.langium +351 -0
- package/src/generated/ast.ts +986 -0
- package/src/generated/grammar.ts +2409 -0
- package/src/generated/module.ts +25 -0
- package/src/index.ts +24 -0
- package/src/lsp/domain-lang-code-actions.ts +189 -0
- package/src/lsp/domain-lang-completion.ts +514 -0
- package/src/lsp/domain-lang-formatter.ts +51 -0
- package/src/lsp/domain-lang-naming.ts +56 -0
- package/src/lsp/domain-lang-scope.ts +137 -0
- package/src/lsp/domain-lang-workspace-manager.ts +104 -0
- package/src/lsp/hover/ddd-pattern-explanations.ts +237 -0
- package/src/lsp/hover/domain-lang-hover.ts +338 -0
- package/src/lsp/hover/domain-lang-keywords.ts +50 -0
- package/src/lsp/manifest-diagnostics.ts +290 -0
- package/src/main-browser.ts +15 -0
- package/src/main.ts +85 -0
- package/src/sdk/README.md +297 -0
- package/src/sdk/ast-augmentation.ts +157 -0
- package/src/sdk/index.ts +126 -0
- package/src/sdk/indexes.ts +155 -0
- package/src/sdk/loader-node.ts +146 -0
- package/src/sdk/loader.ts +99 -0
- package/src/sdk/patterns.ts +147 -0
- package/src/sdk/query.ts +802 -0
- package/src/sdk/resolution.ts +78 -0
- package/src/sdk/types.ts +323 -0
- package/src/services/dependency-analyzer.ts +321 -0
- package/src/services/dependency-resolver.ts +551 -0
- package/src/services/git-url-resolver.browser.ts +26 -0
- package/src/services/git-url-resolver.ts +517 -0
- package/src/services/governance-validator.ts +177 -0
- package/src/services/import-resolver.ts +292 -0
- package/src/services/performance-optimizer.ts +170 -0
- package/src/services/relationship-inference.ts +121 -0
- package/src/services/semver.ts +213 -0
- package/src/services/types.ts +415 -0
- package/src/services/workspace-manager.ts +607 -0
- package/src/syntaxes/domain-lang.monarch.ts +29 -0
- package/src/utils/import-utils.ts +152 -0
- package/src/validation/bounded-context.ts +99 -0
- package/src/validation/classification.ts +5 -0
- package/src/validation/constants.ts +304 -0
- package/src/validation/domain-lang-validator.ts +33 -0
- package/src/validation/domain.ts +77 -0
- package/src/validation/import.ts +295 -0
- package/src/validation/manifest.ts +439 -0
- package/src/validation/maps.ts +76 -0
- package/src/validation/metadata.ts +18 -0
- package/src/validation/model.ts +37 -0
- package/src/validation/relationships.ts +154 -0
- package/src/validation/shared.ts +14 -0
package/README.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# @domainlang/language
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@domainlang/language)
|
|
4
|
+
[](https://github.com/larsbaunwall/DomainLang/blob/main/LICENSE)
|
|
5
|
+
|
|
6
|
+
Core language library for [DomainLang](https://github.com/larsbaunwall/DomainLang) - a Domain-Driven Design modeling language built with [Langium](https://langium.org/).
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- 🔤 **Parser** - Full DomainLang grammar with error recovery
|
|
11
|
+
- ✅ **Validation** - Semantic validation for DDD best practices
|
|
12
|
+
- 🔗 **Linking** - Cross-reference resolution across files and packages
|
|
13
|
+
- 🔍 **Model Query SDK** - Programmatic access to DDD models with fluent queries
|
|
14
|
+
- 🌐 **Browser Support** - Works in Node.js and browser environments
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @domainlang/language
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
### Parse and Query Models
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { loadModelFromText } from '@domainlang/language/sdk';
|
|
28
|
+
|
|
29
|
+
const { query } = await loadModelFromText(`
|
|
30
|
+
Domain Sales {
|
|
31
|
+
vision: "Enable seamless commerce"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
bc OrderContext for Sales as Core by SalesTeam {
|
|
35
|
+
description: "Handles order lifecycle"
|
|
36
|
+
}
|
|
37
|
+
`);
|
|
38
|
+
|
|
39
|
+
// Query bounded contexts
|
|
40
|
+
const coreContexts = query.boundedContexts()
|
|
41
|
+
.withRole('Core')
|
|
42
|
+
.toArray();
|
|
43
|
+
|
|
44
|
+
console.log(coreContexts[0].name); // 'OrderContext'
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Load from File (Node.js)
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { loadModel } from '@domainlang/language/sdk/loader-node';
|
|
51
|
+
|
|
52
|
+
const { model, query } = await loadModel('./my-model.dlang');
|
|
53
|
+
|
|
54
|
+
// Access domains
|
|
55
|
+
for (const domain of query.domains()) {
|
|
56
|
+
console.log(`${domain.name}: ${domain.vision}`);
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## API Overview
|
|
61
|
+
|
|
62
|
+
### Entry Points
|
|
63
|
+
|
|
64
|
+
| Function | Environment | Use Case |
|
|
65
|
+
| -------- | ----------- | -------- |
|
|
66
|
+
| `loadModelFromText(text)` | Browser & Node | Parse inline DSL text |
|
|
67
|
+
| `loadModel(file)` | Node.js only | Load from file system |
|
|
68
|
+
| `fromDocument(doc)` | LSP integration | Zero-copy from Langium document |
|
|
69
|
+
| `fromModel(model)` | Advanced | Direct AST wrapping |
|
|
70
|
+
|
|
71
|
+
### Query Builder
|
|
72
|
+
|
|
73
|
+
The SDK provides fluent query builders with lazy evaluation:
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
// Find all bounded contexts owned by a team
|
|
77
|
+
const teamContexts = query.boundedContexts()
|
|
78
|
+
.withTeam('PaymentsTeam')
|
|
79
|
+
.toArray();
|
|
80
|
+
|
|
81
|
+
// Get context maps containing specific contexts
|
|
82
|
+
const maps = query.contextMaps()
|
|
83
|
+
.containing('OrderContext')
|
|
84
|
+
.toArray();
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Direct Property Access
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
// Direct AST properties
|
|
91
|
+
const desc = boundedContext.description;
|
|
92
|
+
const vision = domain.vision;
|
|
93
|
+
|
|
94
|
+
// SDK-augmented properties (with precedence resolution)
|
|
95
|
+
const role = boundedContext.effectiveRole; // Header 'as' wins over body 'role:'
|
|
96
|
+
const team = boundedContext.effectiveTeam; // Header 'by' wins over body 'team:'
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## DomainLang Syntax
|
|
100
|
+
|
|
101
|
+
DomainLang models Domain-Driven Design concepts:
|
|
102
|
+
|
|
103
|
+
```dlang
|
|
104
|
+
// Define domains with vision
|
|
105
|
+
Domain Sales {
|
|
106
|
+
vision: "Drive revenue through great customer experience"
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Bounded contexts with ownership
|
|
110
|
+
bc OrderContext for Sales as Core by SalesTeam {
|
|
111
|
+
description: "Order lifecycle management"
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
bc PaymentContext for Sales as Supporting by PaymentsTeam
|
|
115
|
+
|
|
116
|
+
// Context maps showing integrations
|
|
117
|
+
ContextMap SalesIntegration {
|
|
118
|
+
contains OrderContext, PaymentContext
|
|
119
|
+
|
|
120
|
+
[OHS,PL] OrderContext -> [CF] PaymentContext
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Package Structure
|
|
125
|
+
|
|
126
|
+
| Path | Purpose |
|
|
127
|
+
| ---- | ------- |
|
|
128
|
+
| `src/domain-lang.langium` | Grammar definition |
|
|
129
|
+
| `src/generated/` | Auto-generated AST (do not edit) |
|
|
130
|
+
| `src/validation/` | Semantic validation rules |
|
|
131
|
+
| `src/lsp/` | LSP features (hover, completion, formatting) |
|
|
132
|
+
| `src/sdk/` | Model Query SDK |
|
|
133
|
+
|
|
134
|
+
## Related Packages
|
|
135
|
+
|
|
136
|
+
- [@domainlang/cli](https://www.npmjs.com/package/@domainlang/cli) - Command-line interface
|
|
137
|
+
- [DomainLang VS Code Extension](https://marketplace.visualstudio.com/items?itemName=thinkability.domain-lang) - IDE support
|
|
138
|
+
|
|
139
|
+
## Documentation
|
|
140
|
+
|
|
141
|
+
- [Getting Started](https://github.com/larsbaunwall/DomainLang/blob/main/dsl/domain-lang/docs/getting-started.md)
|
|
142
|
+
- [Language Reference](https://github.com/larsbaunwall/DomainLang/blob/main/dsl/domain-lang/docs/language.md)
|
|
143
|
+
- [Quick Reference](https://github.com/larsbaunwall/DomainLang/blob/main/dsl/domain-lang/docs/quick-reference.md)
|
|
144
|
+
- [SDK Documentation](https://github.com/larsbaunwall/DomainLang/blob/main/dsl/domain-lang/packages/language/src/sdk/README.md)
|
|
145
|
+
|
|
146
|
+
## Development
|
|
147
|
+
|
|
148
|
+
From the workspace root (`dsl/domain-lang/`):
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
# After editing the grammar
|
|
152
|
+
npm run langium:generate
|
|
153
|
+
|
|
154
|
+
# Build this package
|
|
155
|
+
npm run build --workspace packages/language
|
|
156
|
+
|
|
157
|
+
# Run tests
|
|
158
|
+
npm test --workspace packages/language
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## License
|
|
162
|
+
|
|
163
|
+
Apache-2.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast-augmentation.js","sourceRoot":"","sources":["../src/ast-augmentation.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type Module } from 'langium';
|
|
2
|
+
import type { DefaultSharedModuleContext, LangiumServices, LangiumSharedServices, PartialLangiumServices } from 'langium/lsp';
|
|
3
|
+
import { QualifiedNameProvider } from './lsp/domain-lang-naming.js';
|
|
4
|
+
import { DomainLangFormatter } from './lsp/domain-lang-formatter.js';
|
|
5
|
+
import { DomainLangHoverProvider } from './lsp/hover/domain-lang-hover.js';
|
|
6
|
+
import { DomainLangCompletionProvider } from './lsp/domain-lang-completion.js';
|
|
7
|
+
import { DomainLangCodeActionProvider } from './lsp/domain-lang-code-actions.js';
|
|
8
|
+
import { ImportResolver } from './services/import-resolver.js';
|
|
9
|
+
import { WorkspaceManager } from './services/workspace-manager.js';
|
|
10
|
+
/**
|
|
11
|
+
* Declaration of custom services - add your own service classes here.
|
|
12
|
+
*/
|
|
13
|
+
export type DomainLangAddedServices = {
|
|
14
|
+
imports: {
|
|
15
|
+
ImportResolver: ImportResolver;
|
|
16
|
+
WorkspaceManager: WorkspaceManager;
|
|
17
|
+
};
|
|
18
|
+
references: {
|
|
19
|
+
QualifiedNameProvider: QualifiedNameProvider;
|
|
20
|
+
};
|
|
21
|
+
lsp: {
|
|
22
|
+
Formatter: DomainLangFormatter;
|
|
23
|
+
HoverProvider: DomainLangHoverProvider;
|
|
24
|
+
CompletionProvider: DomainLangCompletionProvider;
|
|
25
|
+
CodeActionProvider: DomainLangCodeActionProvider;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Union of Langium default services and your custom services - use this as constructor parameter
|
|
30
|
+
* of custom service classes.
|
|
31
|
+
*/
|
|
32
|
+
export type DomainLangServices = LangiumServices & DomainLangAddedServices;
|
|
33
|
+
/**
|
|
34
|
+
* Dependency injection module that overrides Langium default services and contributes the
|
|
35
|
+
* declared custom services. The Langium defaults can be partially specified to override only
|
|
36
|
+
* selected services, while the custom services must be fully specified.
|
|
37
|
+
*/
|
|
38
|
+
export declare const DomainLangModule: Module<DomainLangServices, PartialLangiumServices & DomainLangAddedServices>;
|
|
39
|
+
/**
|
|
40
|
+
* Create the full set of services required by Langium.
|
|
41
|
+
*
|
|
42
|
+
* First inject the shared services by merging two modules:
|
|
43
|
+
* - Langium default shared services
|
|
44
|
+
* - Services generated by langium-cli
|
|
45
|
+
*
|
|
46
|
+
* Then inject the language-specific services by merging three modules:
|
|
47
|
+
* - Langium default language-specific services
|
|
48
|
+
* - Services generated by langium-cli
|
|
49
|
+
* - Services specified in this file
|
|
50
|
+
*
|
|
51
|
+
* @param context Optional module context with the LSP connection
|
|
52
|
+
* @returns An object wrapping the shared services and the language-specific services
|
|
53
|
+
*/
|
|
54
|
+
export declare function createDomainLangServices(context: DefaultSharedModuleContext): {
|
|
55
|
+
shared: LangiumSharedServices;
|
|
56
|
+
DomainLang: DomainLangServices;
|
|
57
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { inject } from 'langium';
|
|
2
|
+
import { createDefaultModule, createDefaultSharedModule } from 'langium/lsp';
|
|
3
|
+
import { DomainLangGeneratedModule, DomainLangGeneratedSharedModule } from './generated/module.js';
|
|
4
|
+
import { registerValidationChecks } from './validation/domain-lang-validator.js';
|
|
5
|
+
import { QualifiedNameProvider } from './lsp/domain-lang-naming.js';
|
|
6
|
+
import { DomainLangScopeComputation } from './lsp/domain-lang-scope.js';
|
|
7
|
+
import { DomainLangFormatter } from './lsp/domain-lang-formatter.js';
|
|
8
|
+
import { DomainLangHoverProvider } from './lsp/hover/domain-lang-hover.js';
|
|
9
|
+
import { DomainLangCompletionProvider } from './lsp/domain-lang-completion.js';
|
|
10
|
+
import { DomainLangCodeActionProvider } from './lsp/domain-lang-code-actions.js';
|
|
11
|
+
import { ImportResolver } from './services/import-resolver.js';
|
|
12
|
+
import { WorkspaceManager } from './services/workspace-manager.js';
|
|
13
|
+
import { DomainLangWorkspaceManager } from './lsp/domain-lang-workspace-manager.js';
|
|
14
|
+
const DomainLangSharedModule = {
|
|
15
|
+
workspace: {
|
|
16
|
+
WorkspaceManager: (services) => new DomainLangWorkspaceManager(services)
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Dependency injection module that overrides Langium default services and contributes the
|
|
21
|
+
* declared custom services. The Langium defaults can be partially specified to override only
|
|
22
|
+
* selected services, while the custom services must be fully specified.
|
|
23
|
+
*/
|
|
24
|
+
export const DomainLangModule = {
|
|
25
|
+
imports: {
|
|
26
|
+
ImportResolver: (services) => new ImportResolver(services),
|
|
27
|
+
WorkspaceManager: () => new WorkspaceManager({ autoResolve: false, allowNetwork: false })
|
|
28
|
+
},
|
|
29
|
+
references: {
|
|
30
|
+
ScopeComputation: (services) => new DomainLangScopeComputation(services),
|
|
31
|
+
QualifiedNameProvider: () => new QualifiedNameProvider()
|
|
32
|
+
},
|
|
33
|
+
lsp: {
|
|
34
|
+
Formatter: () => new DomainLangFormatter(),
|
|
35
|
+
HoverProvider: (services) => new DomainLangHoverProvider(services),
|
|
36
|
+
CompletionProvider: (services) => new DomainLangCompletionProvider(services),
|
|
37
|
+
CodeActionProvider: () => new DomainLangCodeActionProvider()
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Create the full set of services required by Langium.
|
|
42
|
+
*
|
|
43
|
+
* First inject the shared services by merging two modules:
|
|
44
|
+
* - Langium default shared services
|
|
45
|
+
* - Services generated by langium-cli
|
|
46
|
+
*
|
|
47
|
+
* Then inject the language-specific services by merging three modules:
|
|
48
|
+
* - Langium default language-specific services
|
|
49
|
+
* - Services generated by langium-cli
|
|
50
|
+
* - Services specified in this file
|
|
51
|
+
*
|
|
52
|
+
* @param context Optional module context with the LSP connection
|
|
53
|
+
* @returns An object wrapping the shared services and the language-specific services
|
|
54
|
+
*/
|
|
55
|
+
export function createDomainLangServices(context) {
|
|
56
|
+
const shared = inject(createDefaultSharedModule(context), DomainLangGeneratedSharedModule, DomainLangSharedModule);
|
|
57
|
+
const DomainLang = inject(createDefaultModule({ shared }), DomainLangGeneratedModule, DomainLangModule);
|
|
58
|
+
shared.ServiceRegistry.register(DomainLang);
|
|
59
|
+
registerValidationChecks(DomainLang);
|
|
60
|
+
if (!context.connection) {
|
|
61
|
+
// We don't run inside a language server
|
|
62
|
+
// Therefore, initialize the configuration provider instantly
|
|
63
|
+
shared.workspace.ConfigurationProvider.initialized({});
|
|
64
|
+
}
|
|
65
|
+
return { shared, DomainLang };
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=domain-lang-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain-lang-module.js","sourceRoot":"","sources":["../src/domain-lang-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,MAAM,EAAE,MAAM,SAAS,CAAC;AAQ9C,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,+BAA+B,EAAE,MAAM,uBAAuB,CAAC;AACnG,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,EAAE,4BAA4B,EAAE,MA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