@domainlang/language 0.7.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/out/domain-lang-module.d.ts +2 -0
- package/out/domain-lang-module.js +21 -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 +34 -5
- package/out/lsp/domain-lang-index-manager.js +66 -27
- 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 +53 -20
- package/out/lsp/domain-lang-scope-provider.js +119 -44
- package/out/lsp/domain-lang-scope-provider.js.map +1 -1
- package/out/lsp/domain-lang-workspace-manager.d.ts +23 -2
- package/out/lsp/domain-lang-workspace-manager.js +51 -6
- 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 +2 -1
- 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/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 +7 -0
- package/out/validation/constants.js +21 -3
- package/out/validation/constants.js.map +1 -1
- package/out/validation/import.d.ts +11 -1
- package/out/validation/import.js +42 -14
- package/out/validation/import.js.map +1 -1
- package/out/validation/maps.js +50 -1
- package/out/validation/maps.js.map +1 -1
- package/package.json +5 -5
- package/src/domain-lang-module.ts +24 -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 +79 -27
- package/src/lsp/domain-lang-node-kind-provider.ts +119 -0
- package/src/lsp/domain-lang-scope-provider.ts +171 -55
- package/src/lsp/domain-lang-workspace-manager.ts +64 -6
- package/src/lsp/hover/domain-lang-hover.ts +189 -131
- package/src/lsp/hover/hover-builders.ts +208 -0
- package/src/main.ts +3 -1
- 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/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 +23 -6
- package/src/validation/import.ts +49 -14
- package/src/validation/maps.ts +59 -2
|
@@ -35,12 +35,12 @@ export class DomainLangIndexManager extends DefaultIndexManager {
|
|
|
35
35
|
*/
|
|
36
36
|
this.importDependencies = new Map();
|
|
37
37
|
/**
|
|
38
|
-
* Maps document URI to its import
|
|
39
|
-
* Used
|
|
38
|
+
* Maps document URI to its import information (specifier, alias, resolved URI).
|
|
39
|
+
* Used for scope resolution with aliases and detecting when file moves affect imports.
|
|
40
40
|
* Key: importing document URI
|
|
41
|
-
* Value:
|
|
41
|
+
* Value: Array of ImportInfo objects
|
|
42
42
|
*/
|
|
43
|
-
this.
|
|
43
|
+
this.documentImportInfo = new Map();
|
|
44
44
|
/**
|
|
45
45
|
* Tracks documents that have had their imports loaded to avoid redundant work.
|
|
46
46
|
* Cleared on workspace config changes.
|
|
@@ -48,6 +48,27 @@ export class DomainLangIndexManager extends DefaultIndexManager {
|
|
|
48
48
|
this.importsLoaded = new Set();
|
|
49
49
|
this.sharedServices = services;
|
|
50
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Late-binds the language-specific services after DI initialization.
|
|
53
|
+
* Called from `createDomainLangServices()` after the language module is created.
|
|
54
|
+
*
|
|
55
|
+
* This is necessary because the IndexManager lives in the shared module,
|
|
56
|
+
* which is created before the language module that provides ImportResolver.
|
|
57
|
+
*/
|
|
58
|
+
setLanguageServices(services) {
|
|
59
|
+
this.importResolver = services.imports.ImportResolver;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Resolves an import path using the DI-injected ImportResolver when available,
|
|
63
|
+
* falling back to the standalone resolver for backwards compatibility.
|
|
64
|
+
*/
|
|
65
|
+
async resolveImport(document, specifier) {
|
|
66
|
+
if (this.importResolver) {
|
|
67
|
+
return this.importResolver.resolveForDocument(document, specifier);
|
|
68
|
+
}
|
|
69
|
+
// Fallback for contexts where language services aren't wired (e.g., tests)
|
|
70
|
+
return resolveImportPath(document, specifier);
|
|
71
|
+
}
|
|
51
72
|
/**
|
|
52
73
|
* Extends the default content update to:
|
|
53
74
|
* 1. Ensure all imported documents are loaded
|
|
@@ -107,14 +128,14 @@ export class DomainLangIndexManager extends DefaultIndexManager {
|
|
|
107
128
|
* Tracks import dependencies for a document.
|
|
108
129
|
* For each import in the document, records:
|
|
109
130
|
* 1. That the imported URI is depended upon (for direct change detection)
|
|
110
|
-
* 2. The import specifier
|
|
131
|
+
* 2. The import specifier and alias (for scope resolution)
|
|
111
132
|
*/
|
|
112
133
|
async trackImportDependencies(document) {
|
|
113
134
|
const importingUri = document.uri.toString();
|
|
114
135
|
// First, remove old dependencies from this document
|
|
115
136
|
// (in case imports changed)
|
|
116
137
|
this.removeDocumentFromDependencies(importingUri);
|
|
117
|
-
this.
|
|
138
|
+
this.documentImportInfo.delete(importingUri);
|
|
118
139
|
// Skip if document isn't ready (no parse result)
|
|
119
140
|
if (document.state < DocumentState.Parsed) {
|
|
120
141
|
return;
|
|
@@ -123,15 +144,19 @@ export class DomainLangIndexManager extends DefaultIndexManager {
|
|
|
123
144
|
if (!model.imports) {
|
|
124
145
|
return;
|
|
125
146
|
}
|
|
126
|
-
const
|
|
147
|
+
const importInfoList = [];
|
|
127
148
|
for (const imp of model.imports) {
|
|
128
149
|
if (!imp.uri)
|
|
129
150
|
continue;
|
|
130
151
|
try {
|
|
131
|
-
const resolvedUri = await
|
|
152
|
+
const resolvedUri = await this.resolveImport(document, imp.uri);
|
|
132
153
|
const importedUri = resolvedUri.toString();
|
|
133
|
-
// Track the specifier
|
|
134
|
-
|
|
154
|
+
// Track the full import info (specifier, alias, resolved URI)
|
|
155
|
+
importInfoList.push({
|
|
156
|
+
specifier: imp.uri,
|
|
157
|
+
alias: imp.alias,
|
|
158
|
+
resolvedUri: importedUri
|
|
159
|
+
});
|
|
135
160
|
// Add to reverse dependency graph: importedUri → importingUri
|
|
136
161
|
let dependents = this.importDependencies.get(importedUri);
|
|
137
162
|
if (!dependents) {
|
|
@@ -142,11 +167,15 @@ export class DomainLangIndexManager extends DefaultIndexManager {
|
|
|
142
167
|
}
|
|
143
168
|
catch {
|
|
144
169
|
// Import resolution failed - still track the specifier with empty resolution
|
|
145
|
-
|
|
170
|
+
importInfoList.push({
|
|
171
|
+
specifier: imp.uri,
|
|
172
|
+
alias: imp.alias,
|
|
173
|
+
resolvedUri: ''
|
|
174
|
+
});
|
|
146
175
|
}
|
|
147
176
|
}
|
|
148
|
-
if (
|
|
149
|
-
this.
|
|
177
|
+
if (importInfoList.length > 0) {
|
|
178
|
+
this.documentImportInfo.set(importingUri, importInfoList);
|
|
150
179
|
}
|
|
151
180
|
}
|
|
152
181
|
/**
|
|
@@ -178,7 +207,7 @@ export class DomainLangIndexManager extends DefaultIndexManager {
|
|
|
178
207
|
if (!imp.uri)
|
|
179
208
|
continue;
|
|
180
209
|
try {
|
|
181
|
-
const resolvedUri = await
|
|
210
|
+
const resolvedUri = await this.resolveImport(document, imp.uri);
|
|
182
211
|
const importedUriString = resolvedUri.toString();
|
|
183
212
|
// Skip if already loaded
|
|
184
213
|
if (this.importsLoaded.has(importedUriString)) {
|
|
@@ -228,7 +257,7 @@ export class DomainLangIndexManager extends DefaultIndexManager {
|
|
|
228
257
|
*/
|
|
229
258
|
clearImportDependencies() {
|
|
230
259
|
this.importDependencies.clear();
|
|
231
|
-
this.
|
|
260
|
+
this.documentImportInfo.clear();
|
|
232
261
|
this.importsLoaded.clear();
|
|
233
262
|
}
|
|
234
263
|
/**
|
|
@@ -256,19 +285,29 @@ export class DomainLangIndexManager extends DefaultIndexManager {
|
|
|
256
285
|
* @returns Set of resolved import URIs, or empty set if none
|
|
257
286
|
*/
|
|
258
287
|
getResolvedImports(documentUri) {
|
|
259
|
-
const
|
|
260
|
-
if (!
|
|
288
|
+
const importInfoList = this.documentImportInfo.get(documentUri);
|
|
289
|
+
if (!importInfoList) {
|
|
261
290
|
return new Set();
|
|
262
291
|
}
|
|
263
292
|
const resolved = new Set();
|
|
264
|
-
for (const
|
|
293
|
+
for (const info of importInfoList) {
|
|
265
294
|
// Only include successfully resolved imports (non-empty string)
|
|
266
|
-
if (resolvedUri) {
|
|
267
|
-
resolved.add(resolvedUri);
|
|
295
|
+
if (info.resolvedUri) {
|
|
296
|
+
resolved.add(info.resolvedUri);
|
|
268
297
|
}
|
|
269
298
|
}
|
|
270
299
|
return resolved;
|
|
271
300
|
}
|
|
301
|
+
/**
|
|
302
|
+
* Gets the full import information (including aliases) for a document.
|
|
303
|
+
* Used by the scope provider to implement alias-prefixed name resolution.
|
|
304
|
+
*
|
|
305
|
+
* @param documentUri - The URI of the document
|
|
306
|
+
* @returns Array of ImportInfo objects, or empty array if none
|
|
307
|
+
*/
|
|
308
|
+
getImportInfo(documentUri) {
|
|
309
|
+
return this.documentImportInfo.get(documentUri) ?? [];
|
|
310
|
+
}
|
|
272
311
|
/**
|
|
273
312
|
* Gets all documents that would be affected by changes to the given URIs.
|
|
274
313
|
* This includes direct dependents and transitive dependents.
|
|
@@ -351,8 +390,8 @@ export class DomainLangIndexManager extends DefaultIndexManager {
|
|
|
351
390
|
*/
|
|
352
391
|
findDocumentsMatchingPaths(changedPaths) {
|
|
353
392
|
const affected = new Set();
|
|
354
|
-
for (const [docUri,
|
|
355
|
-
if (this.hasMatchingSpecifierOrResolvedUri(
|
|
393
|
+
for (const [docUri, importInfoList] of this.documentImportInfo) {
|
|
394
|
+
if (this.hasMatchingSpecifierOrResolvedUri(importInfoList, changedPaths)) {
|
|
356
395
|
affected.add(docUri);
|
|
357
396
|
}
|
|
358
397
|
}
|
|
@@ -368,17 +407,17 @@ export class DomainLangIndexManager extends DefaultIndexManager {
|
|
|
368
407
|
*
|
|
369
408
|
* We check both to ensure moves of aliased imports trigger revalidation.
|
|
370
409
|
*/
|
|
371
|
-
hasMatchingSpecifierOrResolvedUri(
|
|
372
|
-
for (const
|
|
373
|
-
const normalizedSpecifier = specifier.replace(/^[.@/]+/, '');
|
|
410
|
+
hasMatchingSpecifierOrResolvedUri(importInfoList, changedPaths) {
|
|
411
|
+
for (const info of importInfoList) {
|
|
412
|
+
const normalizedSpecifier = info.specifier.replace(/^[.@/]+/, '');
|
|
374
413
|
for (const changedPath of changedPaths) {
|
|
375
414
|
// Check the raw specifier (handles relative imports)
|
|
376
|
-
if (specifier.includes(changedPath) || changedPath.endsWith(normalizedSpecifier)) {
|
|
415
|
+
if (info.specifier.includes(changedPath) || changedPath.endsWith(normalizedSpecifier)) {
|
|
377
416
|
return true;
|
|
378
417
|
}
|
|
379
418
|
// Check the resolved URI (handles path aliases like @domains/...)
|
|
380
419
|
// The resolved URI contains the full file path which matches moved files
|
|
381
|
-
if (resolvedUri?.includes(changedPath)) {
|
|
420
|
+
if (info.resolvedUri?.includes(changedPath)) {
|
|
382
421
|
return true;
|
|
383
422
|
}
|
|
384
423
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain-lang-index-manager.js","sourceRoot":"","sources":["../../src/lsp/domain-lang-index-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"domain-lang-index-manager.js","sourceRoot":"","sources":["../../src/lsp/domain-lang-index-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAM7D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,sBAAuB,SAAQ,mBAAmB;IAkC3D,YAAY,QAAmC;QAC3C,KAAK,CAAC,QAAQ,CAAC,CAAC;QAlCpB;;;;WAIG;QACc,uBAAkB,GAAG,IAAI,GAAG,EAAuB,CAAC;QAErE;;;;;WAKG;QACc,uBA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CAAC;IACjB,CAAC;CACJ"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom NodeKindProvider — maps DomainLang AST types to VS Code SymbolKinds.
|
|
3
|
+
*
|
|
4
|
+
* Langium's DefaultNodeKindProvider returns `SymbolKind.Field` for everything.
|
|
5
|
+
* This override provides semantically meaningful icons for the Outline view,
|
|
6
|
+
* breadcrumbs, Go to Symbol, and completion items.
|
|
7
|
+
*
|
|
8
|
+
* @module lsp/domain-lang-node-kind-provider
|
|
9
|
+
*/
|
|
10
|
+
import { DefaultNodeKindProvider } from 'langium/lsp';
|
|
11
|
+
import { CompletionItemKind, SymbolKind } from 'vscode-languageserver';
|
|
12
|
+
import type { AstNode, AstNodeDescription } from 'langium';
|
|
13
|
+
/**
|
|
14
|
+
* Maps DomainLang AST types to semantically appropriate SymbolKind values.
|
|
15
|
+
*
|
|
16
|
+
* Used by the DocumentSymbolProvider (outline/breadcrumbs), WorkspaceSymbolProvider,
|
|
17
|
+
* and the CompletionProvider.
|
|
18
|
+
*/
|
|
19
|
+
export declare class DomainLangNodeKindProvider extends DefaultNodeKindProvider {
|
|
20
|
+
getSymbolKind(node: AstNode | AstNodeDescription): SymbolKind;
|
|
21
|
+
getCompletionItemKind(node: AstNode | AstNodeDescription): CompletionItemKind;
|
|
22
|
+
/**
|
|
23
|
+
* Resolves an AstNode from an AstNodeDescription (which may only have a reference).
|
|
24
|
+
* Returns the node directly if it's already an AstNode.
|
|
25
|
+
*/
|
|
26
|
+
private resolveNode;
|
|
27
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom NodeKindProvider — maps DomainLang AST types to VS Code SymbolKinds.
|
|
3
|
+
*
|
|
4
|
+
* Langium's DefaultNodeKindProvider returns `SymbolKind.Field` for everything.
|
|
5
|
+
* This override provides semantically meaningful icons for the Outline view,
|
|
6
|
+
* breadcrumbs, Go to Symbol, and completion items.
|
|
7
|
+
*
|
|
8
|
+
* @module lsp/domain-lang-node-kind-provider
|
|
9
|
+
*/
|
|
10
|
+
import { DefaultNodeKindProvider } from 'langium/lsp';
|
|
11
|
+
import { CompletionItemKind, SymbolKind } from 'vscode-languageserver';
|
|
12
|
+
import { isDomain, isBoundedContext, isTeam, isClassification, isMetadata, isContextMap, isDomainMap, isNamespaceDeclaration, isRelationship, isDomainTerm, isDecision, isPolicy, isBusinessRule, isMetadataEntry, } from '../generated/ast.js';
|
|
13
|
+
const KIND_MAPPINGS = [
|
|
14
|
+
// Strategic design
|
|
15
|
+
[isDomain, SymbolKind.Namespace, CompletionItemKind.Folder],
|
|
16
|
+
[isBoundedContext, SymbolKind.Package, CompletionItemKind.Module],
|
|
17
|
+
// Tactical design
|
|
18
|
+
[isTeam, SymbolKind.Interface, CompletionItemKind.Interface],
|
|
19
|
+
[isClassification, SymbolKind.Enum, CompletionItemKind.Enum],
|
|
20
|
+
[isMetadata, SymbolKind.Enum, CompletionItemKind.Enum],
|
|
21
|
+
// Architecture mapping
|
|
22
|
+
[isContextMap, SymbolKind.Package, CompletionItemKind.Module],
|
|
23
|
+
[isDomainMap, SymbolKind.Package, CompletionItemKind.Module],
|
|
24
|
+
// Module system
|
|
25
|
+
[isNamespaceDeclaration, SymbolKind.Namespace, CompletionItemKind.Module],
|
|
26
|
+
// Relationships
|
|
27
|
+
[isRelationship, SymbolKind.Interface, CompletionItemKind.Interface],
|
|
28
|
+
// Documentation & governance
|
|
29
|
+
[isDomainTerm, SymbolKind.Field, CompletionItemKind.Field],
|
|
30
|
+
[isDecision, SymbolKind.Field, CompletionItemKind.Field],
|
|
31
|
+
[isPolicy, SymbolKind.Field, CompletionItemKind.Field],
|
|
32
|
+
[isBusinessRule, SymbolKind.Field, CompletionItemKind.Field],
|
|
33
|
+
// Metadata entries
|
|
34
|
+
[isMetadataEntry, SymbolKind.Field, CompletionItemKind.Field],
|
|
35
|
+
];
|
|
36
|
+
/**
|
|
37
|
+
* Maps DomainLang AST types to semantically appropriate SymbolKind values.
|
|
38
|
+
*
|
|
39
|
+
* Used by the DocumentSymbolProvider (outline/breadcrumbs), WorkspaceSymbolProvider,
|
|
40
|
+
* and the CompletionProvider.
|
|
41
|
+
*/
|
|
42
|
+
export class DomainLangNodeKindProvider extends DefaultNodeKindProvider {
|
|
43
|
+
getSymbolKind(node) {
|
|
44
|
+
try {
|
|
45
|
+
const astNode = this.resolveNode(node);
|
|
46
|
+
if (!astNode)
|
|
47
|
+
return super.getSymbolKind(node);
|
|
48
|
+
for (const [guard, symbolKind] of KIND_MAPPINGS) {
|
|
49
|
+
if (guard(astNode))
|
|
50
|
+
return symbolKind;
|
|
51
|
+
}
|
|
52
|
+
return super.getSymbolKind(node);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
console.error('Error in getSymbolKind:', error);
|
|
56
|
+
return super.getSymbolKind(node);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
getCompletionItemKind(node) {
|
|
60
|
+
try {
|
|
61
|
+
const astNode = this.resolveNode(node);
|
|
62
|
+
if (!astNode)
|
|
63
|
+
return super.getCompletionItemKind(node);
|
|
64
|
+
for (const [guard, , completionKind] of KIND_MAPPINGS) {
|
|
65
|
+
if (guard(astNode))
|
|
66
|
+
return completionKind;
|
|
67
|
+
}
|
|
68
|
+
return super.getCompletionItemKind(node);
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
console.error('Error in getCompletionItemKind:', error);
|
|
72
|
+
return super.getCompletionItemKind(node);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Resolves an AstNode from an AstNodeDescription (which may only have a reference).
|
|
77
|
+
* Returns the node directly if it's already an AstNode.
|
|
78
|
+
*/
|
|
79
|
+
resolveNode(node) {
|
|
80
|
+
if ('$type' in node) {
|
|
81
|
+
return node;
|
|
82
|
+
}
|
|
83
|
+
// AstNodeDescription — resolve if possible
|
|
84
|
+
return node.node;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=domain-lang-node-kind-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain-lang-node-kind-provider.js","sourceRoot":"","sources":["../../src/lsp/domain-lang-node-kind-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEvE,OAAO,EACH,QAAQ,EACR,gBAAgB,EAChB,MAAM,EACN,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,WAAW,EACX,sBAAsB,EACtB,cAAc,EACd,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,cAAc,EACd,eAAe,GAClB,MAAM,qBAAqB,CAAC;AAW7B,MAAM,aAAa,GAA2B;IAC1C,mBAAmB;IACnB,CAAC,QAAQ,EAAiB,UAAU,CAAC,SAAS,EAAM,kBAAkB,CAAC,MAAM,CAAC;IAC9E,CAAC,gBAAgB,EAAS,UAAU,CAAC,OAAO,EAAQ,kBAAkB,CAAC,MAAM,CAAC;IAE9E,kBAAkB;IAClB,CAAC,MAAM,EAAmB,UAAU,CAAC,SAAS,EAAM,kBAAkB,CAAC,SAAS,CAAC;IACjF,CAAC,gBAAgB,EAAS,UAAU,CAAC,IAAI,EAAW,kBAAkB,CAAC,IAAI,CAAC;IAC5E,CAAC,UAAU,EAAe,UAAU,CAAC,IAAI,EAAW,kBAAkB,CAAC,IAAI,CAAC;IAE5E,uBAAuB;IACvB,CAAC,YAAY,EAAa,UAAU,CAAC,OAAO,EAAQ,kBAAkB,CAAC,MAAM,CAAC;IAC9E,CAAC,WAAW,EAAc,UAAU,CAAC,OAAO,EAAQ,kBAAkB,CAAC,MAAM,CAAC;IAE9E,gBAAgB;IAChB,CAAC,sBAAsB,EAAG,UAAU,CAAC,SAAS,EAAM,kBAAkB,CAAC,MAAM,CAAC;IAE9E,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AAI,CAAC,CAAC;YACvC,IAAI,CAAC,OAAO;gBAAE,OAAO,KAAK,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;YAEvD,KAAK,MAAM,CAAC,KAAK,EAAE,AAAD,EAAG,cAAc,CAAC,IAAI,aAAa,EAAE,CAAC;gBACpD,IAAI,KAAK,CAAC,OAAO,CAAC;oBAAE,OAAO,cAAc,CAAC;YAC9C,CAAC;YACD,OAAO,KAAK,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;QAC7C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;YACxD,OAAO,KAAK,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;QAC7C,CAAC;IACL,CAAC;IAED;;;OAGG;IACK,WAAW,CAAC,IAAkC;QAClD,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;YAClB,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,2CAA2C;QAC3C,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;CACJ"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* DomainLang Scope Provider
|
|
3
3
|
*
|
|
4
|
-
* Implements import-based scoping
|
|
4
|
+
* Implements import-based scoping with alias support and package-boundary transitive imports.
|
|
5
5
|
*
|
|
6
|
-
* **Key
|
|
7
|
-
*
|
|
8
|
-
* -
|
|
9
|
-
* -
|
|
10
|
-
* -
|
|
6
|
+
* **Key Concepts (per ADR-003):**
|
|
7
|
+
* - Elements are only visible if defined in current document OR explicitly imported
|
|
8
|
+
* - Import aliases control visibility: `import "pkg" as ddd` makes types visible as `ddd.*` only
|
|
9
|
+
* - Package-boundary transitive imports: External packages (.dlang/packages/) can re-export
|
|
10
|
+
* - Local file imports remain non-transitive (explicit dependencies only)
|
|
11
11
|
*
|
|
12
12
|
* **Why this matters:**
|
|
13
13
|
* Without this, Langium's DefaultScopeProvider would make ALL indexed documents visible
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
* 3. Create confusion about dependencies between files
|
|
18
18
|
*
|
|
19
19
|
* @see https://langium.org/docs/recipes/scoping/ for Langium scoping patterns
|
|
20
|
+
* @see ADR-003 for alias and package-boundary design decisions
|
|
20
21
|
*/
|
|
21
22
|
import type { ReferenceInfo, Scope } from 'langium';
|
|
22
23
|
import { DefaultScopeProvider } from 'langium';
|
|
@@ -28,17 +29,22 @@ import type { DomainLangServices } from '../domain-lang-module.js';
|
|
|
28
29
|
*/
|
|
29
30
|
export declare class DomainLangScopeProvider extends DefaultScopeProvider {
|
|
30
31
|
/**
|
|
31
|
-
* Reference to IndexManager for getting resolved imports.
|
|
32
|
+
* Reference to IndexManager for getting resolved imports with aliases.
|
|
32
33
|
*/
|
|
33
34
|
private readonly domainLangIndexManager;
|
|
35
|
+
/**
|
|
36
|
+
* Detects package boundaries for transitive import resolution.
|
|
37
|
+
*/
|
|
38
|
+
private readonly packageBoundaryDetector;
|
|
34
39
|
constructor(services: DomainLangServices);
|
|
35
40
|
/**
|
|
36
|
-
* Override getGlobalScope to
|
|
41
|
+
* Override getGlobalScope to implement alias-scoped and package-boundary transitive imports.
|
|
37
42
|
*
|
|
38
43
|
* The default Langium behavior includes ALL documents in the workspace.
|
|
39
|
-
* We restrict
|
|
44
|
+
* We restrict and transform scope to:
|
|
40
45
|
* 1. The current document's own exported symbols
|
|
41
|
-
* 2.
|
|
46
|
+
* 2. Symbols from directly imported documents (with alias prefixing)
|
|
47
|
+
* 3. Symbols from package-boundary transitive imports (external packages only)
|
|
42
48
|
*
|
|
43
49
|
* @param referenceType - The AST type being referenced
|
|
44
50
|
* @param context - Information about the reference
|
|
@@ -46,22 +52,49 @@ export declare class DomainLangScopeProvider extends DefaultScopeProvider {
|
|
|
46
52
|
*/
|
|
47
53
|
protected getGlobalScope(referenceType: string, context: ReferenceInfo): Scope;
|
|
48
54
|
/**
|
|
49
|
-
*
|
|
55
|
+
* Computes all visible descriptions for a document, including:
|
|
56
|
+
* - Current document's own symbols
|
|
57
|
+
* - Direct imports (with alias prefixing)
|
|
58
|
+
* - Package-boundary transitive imports
|
|
50
59
|
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
60
|
+
* @param referenceType - The AST type being referenced
|
|
61
|
+
* @param document - The document making the reference
|
|
62
|
+
* @returns Stream of visible descriptions
|
|
63
|
+
*/
|
|
64
|
+
private computeVisibleDescriptions;
|
|
65
|
+
/**
|
|
66
|
+
* Adds descriptions from a single import, applying alias prefixing if needed.
|
|
53
67
|
*
|
|
54
|
-
* @param
|
|
55
|
-
* @
|
|
68
|
+
* @param imp - Import information (specifier, alias, resolved URI)
|
|
69
|
+
* @param referenceType - The AST type being referenced
|
|
70
|
+
* @param processedUris - Set of already-processed URIs to avoid duplicates
|
|
71
|
+
* @param output - Array to append visible descriptions to
|
|
56
72
|
*/
|
|
57
|
-
private
|
|
73
|
+
private addDescriptionsFromImport;
|
|
58
74
|
/**
|
|
59
|
-
*
|
|
75
|
+
* Adds package-boundary transitive imports for external packages.
|
|
60
76
|
*
|
|
77
|
+
* When document A imports package document B (e.g., index.dlang),
|
|
78
|
+
* and B imports internal package files C, D, etc. (same package root),
|
|
79
|
+
* then A can see types from C, D, etc. (package re-exports).
|
|
80
|
+
*
|
|
81
|
+
* Local file imports remain non-transitive.
|
|
82
|
+
*
|
|
83
|
+
* @param imp - Import information for the direct import
|
|
61
84
|
* @param referenceType - The AST type being referenced
|
|
62
85
|
* @param currentDocument - The document making the reference
|
|
63
|
-
* @param
|
|
64
|
-
* @
|
|
86
|
+
* @param processedUris - Set of already-processed URIs to avoid duplicates
|
|
87
|
+
* @param output - Array to append visible descriptions to
|
|
88
|
+
*/
|
|
89
|
+
private addPackageBoundaryTransitiveImports;
|
|
90
|
+
/**
|
|
91
|
+
* Creates an alias-prefixed version of a description.
|
|
92
|
+
*
|
|
93
|
+
* Example: CoreDomain with alias "ddd" → ddd.CoreDomain
|
|
94
|
+
*
|
|
95
|
+
* @param original - Original description
|
|
96
|
+
* @param alias - Import alias to prefix with
|
|
97
|
+
* @returns New description with prefixed name
|
|
65
98
|
*/
|
|
66
|
-
private
|
|
99
|
+
private createAliasedDescription;
|
|
67
100
|
}
|