@domainlang/language 0.6.0 → 0.8.0
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 +1 -1
- package/out/domain-lang-module.d.ts +2 -0
- package/out/domain-lang-module.js +23 -2
- package/out/domain-lang-module.js.map +1 -1
- package/out/lsp/domain-lang-completion.d.ts +142 -1
- package/out/lsp/domain-lang-completion.js +620 -22
- package/out/lsp/domain-lang-completion.js.map +1 -1
- package/out/lsp/domain-lang-document-symbol-provider.d.ts +79 -0
- package/out/lsp/domain-lang-document-symbol-provider.js +210 -0
- package/out/lsp/domain-lang-document-symbol-provider.js.map +1 -0
- package/out/lsp/domain-lang-index-manager.d.ts +98 -1
- package/out/lsp/domain-lang-index-manager.js +214 -7
- package/out/lsp/domain-lang-index-manager.js.map +1 -1
- package/out/lsp/domain-lang-node-kind-provider.d.ts +27 -0
- package/out/lsp/domain-lang-node-kind-provider.js +87 -0
- package/out/lsp/domain-lang-node-kind-provider.js.map +1 -0
- package/out/lsp/domain-lang-scope-provider.d.ts +100 -0
- package/out/lsp/domain-lang-scope-provider.js +170 -0
- package/out/lsp/domain-lang-scope-provider.js.map +1 -0
- package/out/lsp/domain-lang-workspace-manager.d.ts +46 -0
- package/out/lsp/domain-lang-workspace-manager.js +148 -4
- package/out/lsp/domain-lang-workspace-manager.js.map +1 -1
- package/out/lsp/hover/domain-lang-hover.d.ts +16 -6
- package/out/lsp/hover/domain-lang-hover.js +160 -134
- package/out/lsp/hover/domain-lang-hover.js.map +1 -1
- package/out/lsp/hover/hover-builders.d.ts +57 -0
- package/out/lsp/hover/hover-builders.js +171 -0
- package/out/lsp/hover/hover-builders.js.map +1 -0
- package/out/main.js +116 -20
- package/out/main.js.map +1 -1
- package/out/sdk/index.d.ts +2 -1
- package/out/sdk/index.js +1 -1
- package/out/sdk/index.js.map +1 -1
- package/out/sdk/loader-node.js +1 -1
- package/out/sdk/loader-node.js.map +1 -1
- package/out/sdk/loader.d.ts +55 -2
- package/out/sdk/loader.js +87 -28
- package/out/sdk/loader.js.map +1 -1
- package/out/sdk/query.js +14 -11
- package/out/sdk/query.js.map +1 -1
- package/out/services/import-resolver.d.ts +29 -6
- package/out/services/import-resolver.js +48 -9
- package/out/services/import-resolver.js.map +1 -1
- package/out/services/package-boundary-detector.d.ts +101 -0
- package/out/services/package-boundary-detector.js +211 -0
- package/out/services/package-boundary-detector.js.map +1 -0
- package/out/services/performance-optimizer.js +6 -2
- package/out/services/performance-optimizer.js.map +1 -1
- package/out/services/types.d.ts +24 -0
- package/out/services/types.js.map +1 -1
- package/out/services/workspace-manager.d.ts +73 -6
- package/out/services/workspace-manager.js +210 -57
- package/out/services/workspace-manager.js.map +1 -1
- package/out/utils/import-utils.d.ts +9 -6
- package/out/utils/import-utils.js +26 -15
- package/out/utils/import-utils.js.map +1 -1
- package/out/validation/constants.d.ts +20 -0
- package/out/validation/constants.js +39 -3
- package/out/validation/constants.js.map +1 -1
- package/out/validation/import.d.ts +22 -1
- package/out/validation/import.js +104 -16
- package/out/validation/import.js.map +1 -1
- package/out/validation/maps.js +101 -3
- package/out/validation/maps.js.map +1 -1
- package/package.json +5 -5
- package/src/domain-lang-module.ts +26 -3
- package/src/lsp/domain-lang-completion.ts +736 -27
- package/src/lsp/domain-lang-document-symbol-provider.ts +254 -0
- package/src/lsp/domain-lang-index-manager.ts +250 -7
- package/src/lsp/domain-lang-node-kind-provider.ts +119 -0
- package/src/lsp/domain-lang-scope-provider.ts +250 -0
- package/src/lsp/domain-lang-workspace-manager.ts +187 -4
- package/src/lsp/hover/domain-lang-hover.ts +189 -131
- package/src/lsp/hover/hover-builders.ts +208 -0
- package/src/main.ts +156 -23
- package/src/sdk/index.ts +2 -1
- package/src/sdk/loader-node.ts +2 -1
- package/src/sdk/loader.ts +125 -34
- package/src/sdk/query.ts +15 -11
- package/src/services/import-resolver.ts +60 -9
- package/src/services/package-boundary-detector.ts +238 -0
- package/src/services/performance-optimizer.ts +6 -2
- package/src/services/types.ts +25 -0
- package/src/services/workspace-manager.ts +259 -62
- package/src/utils/import-utils.ts +27 -15
- package/src/validation/constants.ts +47 -6
- package/src/validation/import.ts +124 -16
- package/src/validation/maps.ts +118 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @domainlang/language
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/@domainlang/language)[](https://www.npmjs.com/package/@domainlang/language)[](https://sonarcloud.io/summary/new_code?id=DomainLang_DomainLang)[](https://sonarcloud.io/summary/new_code?id=DomainLang_DomainLang)
|
|
4
4
|
[](https://github.com/DomainLang/DomainLang/blob/main/LICENSE)
|
|
5
5
|
|
|
6
6
|
Core language library for [DomainLang](https://github.com/DomainLang/DomainLang) - a Domain-Driven Design modeling language built with [Langium](https://langium.org/).
|
|
@@ -7,6 +7,7 @@ import { DomainLangCompletionProvider } from './lsp/domain-lang-completion.js';
|
|
|
7
7
|
import { DomainLangCodeActionProvider } from './lsp/domain-lang-code-actions.js';
|
|
8
8
|
import { ImportResolver } from './services/import-resolver.js';
|
|
9
9
|
import { WorkspaceManager } from './services/workspace-manager.js';
|
|
10
|
+
import { PackageBoundaryDetector } from './services/package-boundary-detector.js';
|
|
10
11
|
/**
|
|
11
12
|
* Declaration of custom services - add your own service classes here.
|
|
12
13
|
*/
|
|
@@ -14,6 +15,7 @@ export type DomainLangAddedServices = {
|
|
|
14
15
|
imports: {
|
|
15
16
|
ImportResolver: ImportResolver;
|
|
16
17
|
WorkspaceManager: WorkspaceManager;
|
|
18
|
+
PackageBoundaryDetector: PackageBoundaryDetector;
|
|
17
19
|
};
|
|
18
20
|
references: {
|
|
19
21
|
QualifiedNameProvider: QualifiedNameProvider;
|
|
@@ -4,15 +4,22 @@ import { DomainLangGeneratedModule, DomainLangGeneratedSharedModule } from './ge
|
|
|
4
4
|
import { registerValidationChecks } from './validation/domain-lang-validator.js';
|
|
5
5
|
import { QualifiedNameProvider } from './lsp/domain-lang-naming.js';
|
|
6
6
|
import { DomainLangScopeComputation } from './lsp/domain-lang-scope.js';
|
|
7
|
+
import { DomainLangScopeProvider } from './lsp/domain-lang-scope-provider.js';
|
|
7
8
|
import { DomainLangFormatter } from './lsp/domain-lang-formatter.js';
|
|
8
9
|
import { DomainLangHoverProvider } from './lsp/hover/domain-lang-hover.js';
|
|
9
10
|
import { DomainLangCompletionProvider } from './lsp/domain-lang-completion.js';
|
|
10
11
|
import { DomainLangCodeActionProvider } from './lsp/domain-lang-code-actions.js';
|
|
12
|
+
import { DomainLangNodeKindProvider } from './lsp/domain-lang-node-kind-provider.js';
|
|
13
|
+
import { DomainLangDocumentSymbolProvider } from './lsp/domain-lang-document-symbol-provider.js';
|
|
11
14
|
import { ImportResolver } from './services/import-resolver.js';
|
|
12
15
|
import { WorkspaceManager } from './services/workspace-manager.js';
|
|
16
|
+
import { PackageBoundaryDetector } from './services/package-boundary-detector.js';
|
|
13
17
|
import { DomainLangWorkspaceManager } from './lsp/domain-lang-workspace-manager.js';
|
|
14
18
|
import { DomainLangIndexManager } from './lsp/domain-lang-index-manager.js';
|
|
15
19
|
const DomainLangSharedModule = {
|
|
20
|
+
lsp: {
|
|
21
|
+
NodeKindProvider: () => new DomainLangNodeKindProvider()
|
|
22
|
+
},
|
|
16
23
|
workspace: {
|
|
17
24
|
WorkspaceManager: (services) => new DomainLangWorkspaceManager(services),
|
|
18
25
|
IndexManager: (services) => new DomainLangIndexManager(services)
|
|
@@ -26,17 +33,20 @@ const DomainLangSharedModule = {
|
|
|
26
33
|
export const DomainLangModule = {
|
|
27
34
|
imports: {
|
|
28
35
|
ImportResolver: (services) => new ImportResolver(services),
|
|
29
|
-
WorkspaceManager: () => new WorkspaceManager({ autoResolve: false, allowNetwork: false })
|
|
36
|
+
WorkspaceManager: () => new WorkspaceManager({ autoResolve: false, allowNetwork: false }),
|
|
37
|
+
PackageBoundaryDetector: () => new PackageBoundaryDetector()
|
|
30
38
|
},
|
|
31
39
|
references: {
|
|
32
40
|
ScopeComputation: (services) => new DomainLangScopeComputation(services),
|
|
41
|
+
ScopeProvider: (services) => new DomainLangScopeProvider(services),
|
|
33
42
|
QualifiedNameProvider: () => new QualifiedNameProvider()
|
|
34
43
|
},
|
|
35
44
|
lsp: {
|
|
36
45
|
Formatter: () => new DomainLangFormatter(),
|
|
37
46
|
HoverProvider: (services) => new DomainLangHoverProvider(services),
|
|
38
47
|
CompletionProvider: (services) => new DomainLangCompletionProvider(services),
|
|
39
|
-
CodeActionProvider: () => new DomainLangCodeActionProvider()
|
|
48
|
+
CodeActionProvider: () => new DomainLangCodeActionProvider(),
|
|
49
|
+
DocumentSymbolProvider: (services) => new DomainLangDocumentSymbolProvider(services)
|
|
40
50
|
},
|
|
41
51
|
};
|
|
42
52
|
/**
|
|
@@ -59,6 +69,17 @@ export function createDomainLangServices(context) {
|
|
|
59
69
|
const DomainLang = inject(createDefaultModule({ shared }), DomainLangGeneratedModule, DomainLangModule);
|
|
60
70
|
shared.ServiceRegistry.register(DomainLang);
|
|
61
71
|
registerValidationChecks(DomainLang);
|
|
72
|
+
// Late-bind language services into shared module services.
|
|
73
|
+
// IndexManager and WorkspaceManager are in the shared module (created first),
|
|
74
|
+
// but need access to ImportResolver from the language module (created second).
|
|
75
|
+
const indexManager = shared.workspace.IndexManager;
|
|
76
|
+
if (indexManager instanceof DomainLangIndexManager) {
|
|
77
|
+
indexManager.setLanguageServices(DomainLang);
|
|
78
|
+
}
|
|
79
|
+
const workspaceManager = shared.workspace.WorkspaceManager;
|
|
80
|
+
if (workspaceManager instanceof DomainLangWorkspaceManager) {
|
|
81
|
+
workspaceManager.setLanguageServices(DomainLang);
|
|
82
|
+
}
|
|
62
83
|
if (!context.connection) {
|
|
63
84
|
// We don't run inside a language server
|
|
64
85
|
// Therefore, initialize the configuration provider instantly
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain-lang-module.js","sourceRoot":"","sources":["../src/domain-lang-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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CAAC,UAAU,CAAC,CAAC;IACjD,CAAC;IACD,MAAM,gBAAgB,GAAG,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC;IAC3D,IAAI,gBAAgB,YAAY,0BAA0B,EAAE,CAAC;QACzD,gBAAgB,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;IACrD,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QACtB,wCAAwC;QACxC,6DAA6D;QAC7D,MAAM,CAAC,SAAS,CAAC,qBAAqB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -6,12 +6,153 @@
|
|
|
6
6
|
* - Grammar-aligned: Completions match grammar structure exactly
|
|
7
7
|
* - Simple: Uses parent node to determine context
|
|
8
8
|
* - Maintainable: Clear mapping from grammar to completions
|
|
9
|
+
* - Import-aware: Provides completions for local paths, aliases, and dependencies
|
|
9
10
|
*/
|
|
11
|
+
import type { LangiumDocument } from 'langium';
|
|
12
|
+
import { GrammarAST } from 'langium';
|
|
10
13
|
import { CompletionAcceptor, CompletionContext, DefaultCompletionProvider, NextFeature } from 'langium/lsp';
|
|
14
|
+
import { CompletionList } from 'vscode-languageserver';
|
|
15
|
+
import type { CancellationToken, CompletionParams } from 'vscode-languageserver-protocol';
|
|
16
|
+
import type { DomainLangServices } from '../domain-lang-module.js';
|
|
11
17
|
export declare class DomainLangCompletionProvider extends DefaultCompletionProvider {
|
|
12
|
-
|
|
18
|
+
private readonly workspaceManager;
|
|
19
|
+
readonly completionOptions: {
|
|
20
|
+
triggerCharacters: string[];
|
|
21
|
+
};
|
|
22
|
+
constructor(services: DomainLangServices);
|
|
23
|
+
/**
|
|
24
|
+
* Override getCompletion to handle import string completions for incomplete strings.
|
|
25
|
+
*
|
|
26
|
+
* **Why this override is necessary:**
|
|
27
|
+
* When the cursor sits inside an incomplete string token (e.g. `import "partial`)
|
|
28
|
+
* Langium's lexer cannot produce a valid STRING token, so `completionFor()` never
|
|
29
|
+
* fires for the `uri` property. This override detects the incomplete-string case
|
|
30
|
+
* via regex and returns completions directly. For all other positions the parent
|
|
31
|
+
* implementation (which routes through `completionFor`) is used.
|
|
32
|
+
*/
|
|
33
|
+
getCompletion(document: LangiumDocument, params: CompletionParams, cancelToken?: CancellationToken): Promise<CompletionList | undefined>;
|
|
34
|
+
/**
|
|
35
|
+
* Post-process completion results to replace full-FQN items with segmented items
|
|
36
|
+
* when the cursor is at a dotted path.
|
|
37
|
+
*
|
|
38
|
+
* **Why this is necessary:**
|
|
39
|
+
* Langium's `buildContexts` creates a "data type rule" context that triggers our
|
|
40
|
+
* `completionForCrossReference` override, which correctly produces segmented items.
|
|
41
|
+
* However, when the CST is broken (e.g., partial `Core.B` doesn't fully parse as
|
|
42
|
+
* a QualifiedName), `findDataTypeRuleStart` returns `undefined` and only token-based
|
|
43
|
+
* contexts fire. These contexts have features that are ID terminals (not cross-references),
|
|
44
|
+
* so `completionForCrossReference` is never called. Langium's default pipeline then
|
|
45
|
+
* produces full-FQN items like `Core.Baunwalls.Jannie`.
|
|
46
|
+
*
|
|
47
|
+
* This post-processing step catches those FQN items and segments them,
|
|
48
|
+
* ensuring consistent behavior regardless of parse state.
|
|
49
|
+
*/
|
|
50
|
+
private segmentDottedCompletions;
|
|
51
|
+
/** Check if any items are already segmented by our completionForCrossReference. */
|
|
52
|
+
private hasSegmentedItems;
|
|
53
|
+
/** Remove full-FQN items that leaked alongside segmented items. */
|
|
54
|
+
private removeLeakedFqnItems;
|
|
55
|
+
/** Calculate line/character positions from text offsets. */
|
|
56
|
+
private calculateTextPositions;
|
|
57
|
+
/** Transform FQN completion items into segmented (next-segment-only) items. */
|
|
58
|
+
private transformToSegmentedItems;
|
|
59
|
+
/** Transform a single FQN item into a segmented item, or keep non-matching items. */
|
|
60
|
+
private segmentSingleItem;
|
|
61
|
+
/**
|
|
62
|
+
* Check if two dotted names share a common prefix up to the first differing segment.
|
|
63
|
+
*/
|
|
64
|
+
private sharesDottedPrefix;
|
|
65
|
+
/**
|
|
66
|
+
* Scan backwards from cursor to find a dotted identifier path.
|
|
67
|
+
* Returns the full typed text and start position, or undefined if no dots found.
|
|
68
|
+
*
|
|
69
|
+
* This is intentionally cursor-based (not tokenOffset-based) to be robust
|
|
70
|
+
* across all Langium completion contexts.
|
|
71
|
+
*/
|
|
72
|
+
private extractDottedPathAtCursor;
|
|
73
|
+
/** Walk backwards through `.ID` pairs from the given position. */
|
|
74
|
+
private walkBackThroughDotIdPairs;
|
|
75
|
+
/**
|
|
76
|
+
* Collect import completion items for a given partial input string.
|
|
77
|
+
*
|
|
78
|
+
* Shared by both the `getCompletion` override (incomplete string case)
|
|
79
|
+
* and the `completionFor` path (normal Langium feature-based routing).
|
|
80
|
+
*/
|
|
81
|
+
private collectImportItems;
|
|
82
|
+
protected completionFor(context: CompletionContext, next: NextFeature, acceptor: CompletionAcceptor): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Override cross-reference completion to provide dot-segmented completions.
|
|
85
|
+
*
|
|
86
|
+
* When the user types a dotted prefix (e.g., `Core.`), only the next
|
|
87
|
+
* namespace segment is shown instead of the full qualified name —
|
|
88
|
+
* matching how modern IDEs handle hierarchical completions.
|
|
89
|
+
*
|
|
90
|
+
* Example: Scope contains `Core.CoreDomain`, `Core.BaunWalls.Jannie`, `Core.BaunWalls.Anna`
|
|
91
|
+
* - No dots typed → default FQN labels: `Core.CoreDomain`, `Core.BaunWalls.Jannie`, ...
|
|
92
|
+
* - `Core.` typed → segmented: `CoreDomain`, `BaunWalls`
|
|
93
|
+
* - `Core.BaunWalls.` typed → segmented: `Jannie`, `Anna`
|
|
94
|
+
*/
|
|
95
|
+
protected completionForCrossReference(context: CompletionContext, next: NextFeature<GrammarAST.CrossReference>, acceptor: CompletionAcceptor): void | Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Walk backwards from `tokenOffset` through preceding `.ID` pairs
|
|
98
|
+
* to find the start of the full dotted path.
|
|
99
|
+
* QualifiedName = ID ('.' ID)* — Langium tokenises each ID separately.
|
|
100
|
+
*/
|
|
101
|
+
private findDottedPathStart;
|
|
102
|
+
/**
|
|
103
|
+
* Iterate scope candidates and emit segmented completion items.
|
|
104
|
+
* Splits FQN candidates by the typed prefix, extracting only the next segment.
|
|
105
|
+
*/
|
|
106
|
+
private acceptSegmentedCandidates;
|
|
13
107
|
private safeCompletionFor;
|
|
108
|
+
/**
|
|
109
|
+
* Detect if we're completing inside an import statement's uri property.
|
|
110
|
+
*
|
|
111
|
+
* This checks:
|
|
112
|
+
* 1. The NextFeature's type and property (when completing STRING for uri)
|
|
113
|
+
* 2. The current AST node (when inside an ImportStatement)
|
|
114
|
+
* 3. Text-based pattern matching (fallback for edge cases)
|
|
115
|
+
*/
|
|
116
|
+
private isImportUriCompletion;
|
|
117
|
+
/** Check if the node or any ancestor is an ImportStatement. */
|
|
118
|
+
private isInImportStatementHierarchy;
|
|
119
|
+
/** Check if text before cursor matches an import string pattern. */
|
|
120
|
+
private isImportTextPattern;
|
|
121
|
+
/**
|
|
122
|
+
* Add import completions asynchronously.
|
|
123
|
+
* This method ensures the manifest is loaded before providing completions.
|
|
124
|
+
*/
|
|
125
|
+
private addImportCompletions;
|
|
126
|
+
/**
|
|
127
|
+
* Extract the current input inside the import string.
|
|
128
|
+
*/
|
|
129
|
+
private extractImportInput;
|
|
130
|
+
/**
|
|
131
|
+
* Add local path starters.
|
|
132
|
+
*/
|
|
133
|
+
private addLocalPathStarters;
|
|
134
|
+
/**
|
|
135
|
+
* Add all starter options when input is empty.
|
|
136
|
+
*/
|
|
137
|
+
private addAllStarterOptions;
|
|
138
|
+
/**
|
|
139
|
+
* Add alias completions that match the current input.
|
|
140
|
+
*/
|
|
141
|
+
private addAliasCompletions;
|
|
142
|
+
/**
|
|
143
|
+
* Add dependency completions that match the current input.
|
|
144
|
+
*/
|
|
145
|
+
private addDependencyCompletions;
|
|
146
|
+
/**
|
|
147
|
+
* Add filtered options for partial input that doesn't start with special characters.
|
|
148
|
+
* Shows aliases and dependencies that match the user's partial input.
|
|
149
|
+
*/
|
|
150
|
+
private addFilteredOptions;
|
|
14
151
|
private handleNodeCompletions;
|
|
152
|
+
/**
|
|
153
|
+
* Add import statement snippet at top level.
|
|
154
|
+
*/
|
|
155
|
+
private addImportSnippet;
|
|
15
156
|
private handleContainerCompletions;
|
|
16
157
|
private addTopLevelSnippets;
|
|
17
158
|
/**
|