@domainlang/language 0.7.0 → 0.9.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 +31 -11
- package/out/sdk/index.js +30 -11
- package/out/sdk/index.js.map +1 -1
- package/out/sdk/loader-node.d.ts +2 -0
- package/out/sdk/loader-node.js +3 -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/sdk/validator.d.ts +134 -0
- package/out/sdk/validator.js +249 -0
- package/out/sdk/validator.js.map +1 -0
- 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 +8 -9
- 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 +33 -11
- package/src/sdk/loader-node.ts +6 -1
- package/src/sdk/loader.ts +125 -34
- package/src/sdk/query.ts +15 -11
- package/src/sdk/validator.ts +358 -0
- 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
|
@@ -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,8 +17,9 @@
|
|
|
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
|
-
import { AstUtils, DefaultScopeProvider, EMPTY_SCOPE, MapScope } from 'langium';
|
|
22
|
+
import { AstUtils, DefaultScopeProvider, EMPTY_SCOPE, MapScope, stream } from 'langium';
|
|
22
23
|
/**
|
|
23
24
|
* Custom scope provider that restricts cross-file references to imported documents only.
|
|
24
25
|
*
|
|
@@ -28,68 +29,142 @@ export class DomainLangScopeProvider extends DefaultScopeProvider {
|
|
|
28
29
|
constructor(services) {
|
|
29
30
|
super(services);
|
|
30
31
|
this.domainLangIndexManager = services.shared.workspace.IndexManager;
|
|
32
|
+
this.packageBoundaryDetector = services.imports.PackageBoundaryDetector;
|
|
31
33
|
}
|
|
32
34
|
/**
|
|
33
|
-
* Override getGlobalScope to
|
|
35
|
+
* Override getGlobalScope to implement alias-scoped and package-boundary transitive imports.
|
|
34
36
|
*
|
|
35
37
|
* The default Langium behavior includes ALL documents in the workspace.
|
|
36
|
-
* We restrict
|
|
38
|
+
* We restrict and transform scope to:
|
|
37
39
|
* 1. The current document's own exported symbols
|
|
38
|
-
* 2.
|
|
40
|
+
* 2. Symbols from directly imported documents (with alias prefixing)
|
|
41
|
+
* 3. Symbols from package-boundary transitive imports (external packages only)
|
|
39
42
|
*
|
|
40
43
|
* @param referenceType - The AST type being referenced
|
|
41
44
|
* @param context - Information about the reference
|
|
42
45
|
* @returns A scope containing only visible elements
|
|
43
46
|
*/
|
|
44
47
|
getGlobalScope(referenceType, context) {
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
try {
|
|
49
|
+
const document = AstUtils.getDocument(context.container);
|
|
50
|
+
if (!document) {
|
|
51
|
+
return EMPTY_SCOPE;
|
|
52
|
+
}
|
|
53
|
+
const descriptions = this.computeVisibleDescriptions(referenceType, document);
|
|
54
|
+
return new MapScope(descriptions);
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
console.error('Error in getGlobalScope:', error);
|
|
47
58
|
return EMPTY_SCOPE;
|
|
48
59
|
}
|
|
49
|
-
// Get the set of URIs that are in scope for this document
|
|
50
|
-
const importedUris = this.getImportedDocumentUris(document);
|
|
51
|
-
// Filter the global index to only include descriptions from imported documents
|
|
52
|
-
const filteredDescriptions = this.filterDescriptionsByImports(referenceType, document, importedUris);
|
|
53
|
-
// Create a scope from the filtered descriptions
|
|
54
|
-
return new MapScope(filteredDescriptions);
|
|
55
60
|
}
|
|
56
61
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
62
|
+
* Computes all visible descriptions for a document, including:
|
|
63
|
+
* - Current document's own symbols
|
|
64
|
+
* - Direct imports (with alias prefixing)
|
|
65
|
+
* - Package-boundary transitive imports
|
|
61
66
|
*
|
|
62
|
-
* @param
|
|
63
|
-
* @
|
|
67
|
+
* @param referenceType - The AST type being referenced
|
|
68
|
+
* @param document - The document making the reference
|
|
69
|
+
* @returns Stream of visible descriptions
|
|
64
70
|
*/
|
|
65
|
-
|
|
71
|
+
computeVisibleDescriptions(referenceType, document) {
|
|
66
72
|
const docUri = document.uri.toString();
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
const allVisibleDescriptions = [];
|
|
74
|
+
// 1. Always include current document's own symbols
|
|
75
|
+
const ownDescriptions = this.indexManager.allElements(referenceType)
|
|
76
|
+
.filter(desc => desc.documentUri.toString() === docUri);
|
|
77
|
+
allVisibleDescriptions.push(...ownDescriptions.toArray());
|
|
78
|
+
// 2. Get import info (with aliases)
|
|
79
|
+
const importInfo = this.domainLangIndexManager.getImportInfo(docUri);
|
|
80
|
+
// Track which documents we've already included to avoid duplicates
|
|
81
|
+
const processedUris = new Set([docUri]);
|
|
82
|
+
// 3. Process each direct import
|
|
83
|
+
for (const imp of importInfo) {
|
|
84
|
+
if (!imp.resolvedUri || processedUris.has(imp.resolvedUri)) {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
// Add descriptions from the directly imported document
|
|
88
|
+
this.addDescriptionsFromImport(imp, referenceType, processedUris, allVisibleDescriptions);
|
|
89
|
+
// 4. Check for package-boundary transitive imports
|
|
90
|
+
this.addPackageBoundaryTransitiveImports(imp, referenceType, document, processedUris, allVisibleDescriptions);
|
|
91
|
+
}
|
|
92
|
+
return stream(allVisibleDescriptions);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Adds descriptions from a single import, applying alias prefixing if needed.
|
|
96
|
+
*
|
|
97
|
+
* @param imp - Import information (specifier, alias, resolved URI)
|
|
98
|
+
* @param referenceType - The AST type being referenced
|
|
99
|
+
* @param processedUris - Set of already-processed URIs to avoid duplicates
|
|
100
|
+
* @param output - Array to append visible descriptions to
|
|
101
|
+
*/
|
|
102
|
+
addDescriptionsFromImport(imp, referenceType, processedUris, output) {
|
|
103
|
+
const descriptions = this.indexManager.allElements(referenceType)
|
|
104
|
+
.filter(desc => desc.documentUri.toString() === imp.resolvedUri);
|
|
105
|
+
if (imp.alias) {
|
|
106
|
+
// With alias: prefix all names with alias
|
|
107
|
+
// Example: CoreDomain → ddd.CoreDomain
|
|
108
|
+
for (const desc of descriptions) {
|
|
109
|
+
output.push(this.createAliasedDescription(desc, imp.alias));
|
|
110
|
+
}
|
|
74
111
|
}
|
|
75
|
-
|
|
112
|
+
else {
|
|
113
|
+
// Without alias: use original names
|
|
114
|
+
output.push(...descriptions.toArray());
|
|
115
|
+
}
|
|
116
|
+
processedUris.add(imp.resolvedUri);
|
|
76
117
|
}
|
|
77
118
|
/**
|
|
78
|
-
*
|
|
119
|
+
* Adds package-boundary transitive imports for external packages.
|
|
120
|
+
*
|
|
121
|
+
* When document A imports package document B (e.g., index.dlang),
|
|
122
|
+
* and B imports internal package files C, D, etc. (same package root),
|
|
123
|
+
* then A can see types from C, D, etc. (package re-exports).
|
|
124
|
+
*
|
|
125
|
+
* Local file imports remain non-transitive.
|
|
79
126
|
*
|
|
127
|
+
* @param imp - Import information for the direct import
|
|
80
128
|
* @param referenceType - The AST type being referenced
|
|
81
129
|
* @param currentDocument - The document making the reference
|
|
82
|
-
* @param
|
|
83
|
-
* @
|
|
130
|
+
* @param processedUris - Set of already-processed URIs to avoid duplicates
|
|
131
|
+
* @param output - Array to append visible descriptions to
|
|
132
|
+
*/
|
|
133
|
+
addPackageBoundaryTransitiveImports(imp, referenceType, currentDocument, processedUris, output) {
|
|
134
|
+
// Get the imports of the imported document (B's imports)
|
|
135
|
+
const transitiveImports = this.domainLangIndexManager.getImportInfo(imp.resolvedUri);
|
|
136
|
+
for (const transitiveImp of transitiveImports) {
|
|
137
|
+
if (!transitiveImp.resolvedUri || processedUris.has(transitiveImp.resolvedUri)) {
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
// Check if both documents are in the same external package
|
|
141
|
+
// (package boundary = same commit directory within .dlang/packages/)
|
|
142
|
+
const samePackage = this.packageBoundaryDetector.areInSamePackageSync(imp.resolvedUri, transitiveImp.resolvedUri);
|
|
143
|
+
if (samePackage) {
|
|
144
|
+
// Within package boundary: include transitive imports
|
|
145
|
+
// Apply the top-level import's alias (if any)
|
|
146
|
+
this.addDescriptionsFromImport({
|
|
147
|
+
specifier: transitiveImp.specifier,
|
|
148
|
+
alias: imp.alias, // Use the top-level import's alias
|
|
149
|
+
resolvedUri: transitiveImp.resolvedUri
|
|
150
|
+
}, referenceType, processedUris, output);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Creates an alias-prefixed version of a description.
|
|
156
|
+
*
|
|
157
|
+
* Example: CoreDomain with alias "ddd" → ddd.CoreDomain
|
|
158
|
+
*
|
|
159
|
+
* @param original - Original description
|
|
160
|
+
* @param alias - Import alias to prefix with
|
|
161
|
+
* @returns New description with prefixed name
|
|
84
162
|
*/
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const descDocUri = desc.documentUri.toString();
|
|
91
|
-
return importedUris.has(descDocUri);
|
|
92
|
-
});
|
|
163
|
+
createAliasedDescription(original, alias) {
|
|
164
|
+
return {
|
|
165
|
+
...original,
|
|
166
|
+
name: `${alias}.${original.name}`
|
|
167
|
+
};
|
|
93
168
|
}
|
|
94
169
|
}
|
|
95
170
|
//# sourceMappingURL=domain-lang-scope-provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain-lang-scope-provider.js","sourceRoot":"","sources":["../../src/lsp/domain-lang-scope-provider.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version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5B,QAA4B,EAC5B,KAAa;QAEb,OAAO;YACH,GAAG,QAAQ;YACX,IAAI,EAAE,GAAG,KAAK,IAAI,QAAQ,CAAC,IAAI,EAAE;SACpC,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DefaultWorkspaceManager, type FileSystemNode, type LangiumDocument, type LangiumSharedCoreServices, type WorkspaceFolder } from 'langium';
|
|
2
2
|
import type { CancellationToken } from 'vscode-languageserver-protocol';
|
|
3
|
+
import type { DomainLangServices } from '../domain-lang-module.js';
|
|
3
4
|
/**
|
|
4
5
|
* Langium WorkspaceManager override implementing manifest-centric import loading per PRS-010.
|
|
5
6
|
*
|
|
@@ -48,7 +49,18 @@ import type { CancellationToken } from 'vscode-languageserver-protocol';
|
|
|
48
49
|
*/
|
|
49
50
|
export declare class DomainLangWorkspaceManager extends DefaultWorkspaceManager {
|
|
50
51
|
private readonly sharedServices;
|
|
52
|
+
/**
|
|
53
|
+
* DI-injected import resolver. Set via late-binding because
|
|
54
|
+
* WorkspaceManager (shared module) is created before ImportResolver (language module).
|
|
55
|
+
* Falls back to standalone ensureImportGraphFromDocument when not set.
|
|
56
|
+
*/
|
|
57
|
+
private importResolver;
|
|
51
58
|
constructor(services: LangiumSharedCoreServices);
|
|
59
|
+
/**
|
|
60
|
+
* Late-binds the language-specific services after DI initialization.
|
|
61
|
+
* Called from `createDomainLangServices()` after the language module is created.
|
|
62
|
+
*/
|
|
63
|
+
setLanguageServices(services: DomainLangServices): void;
|
|
52
64
|
shouldIncludeEntry(entry: FileSystemNode): boolean;
|
|
53
65
|
initializeWorkspace(folders: WorkspaceFolder[], cancelToken?: CancellationToken): Promise<void>;
|
|
54
66
|
protected loadAdditionalDocuments(folders: WorkspaceFolder[], collector: (document: LangiumDocument) => void): Promise<void>;
|
|
@@ -57,7 +69,7 @@ export declare class DomainLangWorkspaceManager extends DefaultWorkspaceManager
|
|
|
57
69
|
*
|
|
58
70
|
* Skips:
|
|
59
71
|
* - Module directories (directories with model.yaml) - loaded via import graph
|
|
60
|
-
* - `.dlang/
|
|
72
|
+
* - `.dlang/packages` directory - package cache managed by CLI
|
|
61
73
|
*
|
|
62
74
|
* @param folders - Workspace folders to scan
|
|
63
75
|
* @param moduleDirectories - Set of directories containing model.yaml (to skip)
|
|
@@ -66,7 +78,7 @@ export declare class DomainLangWorkspaceManager extends DefaultWorkspaceManager
|
|
|
66
78
|
private loadStandaloneFiles;
|
|
67
79
|
/**
|
|
68
80
|
* Recursively loads .dlang files from a directory.
|
|
69
|
-
* Skips module directories and the .dlang/
|
|
81
|
+
* Skips module directories and the .dlang/packages cache.
|
|
70
82
|
*/
|
|
71
83
|
private loadDlangFilesRecursively;
|
|
72
84
|
/**
|
|
@@ -85,4 +97,13 @@ export declare class DomainLangWorkspaceManager extends DefaultWorkspaceManager
|
|
|
85
97
|
* @returns Array of manifest info (one per model.yaml found)
|
|
86
98
|
*/
|
|
87
99
|
private findAllManifestsInFolders;
|
|
100
|
+
/**
|
|
101
|
+
* Recursively builds the import graph from a document.
|
|
102
|
+
* Uses the DI-injected ImportResolver when available,
|
|
103
|
+
* falling back to the standalone utility.
|
|
104
|
+
*
|
|
105
|
+
* @param document - The starting document
|
|
106
|
+
* @returns Set of URIs (as strings) for all documents in the import graph
|
|
107
|
+
*/
|
|
108
|
+
private loadImportGraph;
|
|
88
109
|
}
|
|
@@ -54,6 +54,13 @@ export class DomainLangWorkspaceManager extends DefaultWorkspaceManager {
|
|
|
54
54
|
super(services);
|
|
55
55
|
this.sharedServices = services;
|
|
56
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Late-binds the language-specific services after DI initialization.
|
|
59
|
+
* Called from `createDomainLangServices()` after the language module is created.
|
|
60
|
+
*/
|
|
61
|
+
setLanguageServices(services) {
|
|
62
|
+
this.importResolver = services.imports.ImportResolver;
|
|
63
|
+
}
|
|
57
64
|
shouldIncludeEntry(entry) {
|
|
58
65
|
// Prevent auto-including .dlang files; we'll load via entry/import graph
|
|
59
66
|
const name = UriUtils.basename(entry.uri);
|
|
@@ -80,7 +87,7 @@ export class DomainLangWorkspaceManager extends DefaultWorkspaceManager {
|
|
|
80
87
|
await this.sharedServices.workspace.DocumentBuilder.build([entryDoc], {
|
|
81
88
|
validation: true
|
|
82
89
|
});
|
|
83
|
-
const uris = await
|
|
90
|
+
const uris = await this.loadImportGraph(entryDoc);
|
|
84
91
|
const importedDocs = [];
|
|
85
92
|
for (const uriString of uris) {
|
|
86
93
|
const uri = URI.parse(uriString);
|
|
@@ -110,7 +117,7 @@ export class DomainLangWorkspaceManager extends DefaultWorkspaceManager {
|
|
|
110
117
|
*
|
|
111
118
|
* Skips:
|
|
112
119
|
* - Module directories (directories with model.yaml) - loaded via import graph
|
|
113
|
-
* - `.dlang/
|
|
120
|
+
* - `.dlang/packages` directory - package cache managed by CLI
|
|
114
121
|
*
|
|
115
122
|
* @param folders - Workspace folders to scan
|
|
116
123
|
* @param moduleDirectories - Set of directories containing model.yaml (to skip)
|
|
@@ -132,20 +139,20 @@ export class DomainLangWorkspaceManager extends DefaultWorkspaceManager {
|
|
|
132
139
|
}
|
|
133
140
|
/**
|
|
134
141
|
* Recursively loads .dlang files from a directory.
|
|
135
|
-
* Skips module directories and the .dlang/
|
|
142
|
+
* Skips module directories and the .dlang/packages cache.
|
|
136
143
|
*/
|
|
137
144
|
async loadDlangFilesRecursively(dirPath, moduleDirectories, collector) {
|
|
138
145
|
// Skip module directories - they're loaded via import graph
|
|
139
146
|
if (moduleDirectories.has(dirPath)) {
|
|
140
147
|
return [];
|
|
141
148
|
}
|
|
142
|
-
// Skip .dlang/
|
|
149
|
+
// Skip .dlang/packages - package cache managed by CLI
|
|
143
150
|
const baseName = path.basename(dirPath);
|
|
144
151
|
const parentName = path.basename(path.dirname(dirPath));
|
|
145
|
-
if (baseName === '
|
|
152
|
+
if (baseName === 'packages' && parentName === '.dlang') {
|
|
146
153
|
return [];
|
|
147
154
|
}
|
|
148
|
-
// Also skip the .dlang directory itself
|
|
155
|
+
// Also skip the .dlang directory itself (contains packages cache)
|
|
149
156
|
if (baseName === '.dlang') {
|
|
150
157
|
return [];
|
|
151
158
|
}
|
|
@@ -211,5 +218,43 @@ export class DomainLangWorkspaceManager extends DefaultWorkspaceManager {
|
|
|
211
218
|
const directories = folders.map(f => URI.parse(f.uri).fsPath);
|
|
212
219
|
return findManifestsInDirectories(directories);
|
|
213
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* Recursively builds the import graph from a document.
|
|
223
|
+
* Uses the DI-injected ImportResolver when available,
|
|
224
|
+
* falling back to the standalone utility.
|
|
225
|
+
*
|
|
226
|
+
* @param document - The starting document
|
|
227
|
+
* @returns Set of URIs (as strings) for all documents in the import graph
|
|
228
|
+
*/
|
|
229
|
+
async loadImportGraph(document) {
|
|
230
|
+
if (!this.importResolver) {
|
|
231
|
+
// Fallback to standalone utility when DI isn't wired
|
|
232
|
+
return ensureImportGraphFromDocument(document, this.langiumDocuments);
|
|
233
|
+
}
|
|
234
|
+
const resolver = this.importResolver;
|
|
235
|
+
const langiumDocuments = this.langiumDocuments;
|
|
236
|
+
const visited = new Set();
|
|
237
|
+
async function visit(doc) {
|
|
238
|
+
const uriString = doc.uri.toString();
|
|
239
|
+
if (visited.has(uriString))
|
|
240
|
+
return;
|
|
241
|
+
visited.add(uriString);
|
|
242
|
+
const model = doc.parseResult.value;
|
|
243
|
+
for (const imp of model.imports ?? []) {
|
|
244
|
+
if (!imp.uri)
|
|
245
|
+
continue;
|
|
246
|
+
try {
|
|
247
|
+
const resolvedUri = await resolver.resolveForDocument(doc, imp.uri);
|
|
248
|
+
const childDoc = await langiumDocuments.getOrCreateDocument(resolvedUri);
|
|
249
|
+
await visit(childDoc);
|
|
250
|
+
}
|
|
251
|
+
catch {
|
|
252
|
+
// Import resolution failed — validation will report the error
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
await visit(document);
|
|
257
|
+
return visited;
|
|
258
|
+
}
|
|
214
259
|
}
|
|
215
260
|
//# sourceMappingURL=domain-lang-workspace-manager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain-lang-workspace-manager.js","sourceRoot":"","sources":["../../src/lsp/domain-lang-workspace-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,GAAG,EAAE,QAAQ,EAAmG,MAAM,SAAS,CAAC;AAElK,OAAO,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"domain-lang-workspace-manager.js","sourceRoot":"","sources":["../../src/lsp/domain-lang-workspace-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,GAAG,EAAE,QAAQ,EAAmG,MAAM,SAAS,CAAC;AAElK,OAAO,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAIxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,MAAM,OAAO,0BAA2B,SAAQ,uBAAuB;IAUnE,YAAY,QAAmC;QAC3C,KAAK,CAAC,QAAQ,CAAC,CAAC;QAChB,IAAI,CAAC,cAAc,GAAG,QAAQ,CAAC;IACnC,CAAC;IAED;;;OAGG;IACH,mBAAmB,CAAC,QAA4B;QAC5C,IAAI,CAAC,cAAc,GAAG,QAAQ,CAAC,OAAO,CAAC,cAAc,CAAC;IAC1D,CAAC;IAEQ,kBAAkB,CAAC,KAAqB;QAC7C,yEAAyE;QACzE,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,C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,SAAS,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;YACrC,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;gBAAE,OAAO;YACnC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAEvB,MAAM,KAAK,GAAG,GAAG,CAAC,WAAW,CAAC,KAA8C,CAAC;YAC7E,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC;gBACpC,IAAI,CAAC,GAAG,CAAC,GAAG;oBAAE,SAAS;gBAEvB,IAAI,CAAC;oBACD,MAAM,WAAW,GAAG,MAAM,QAAQ,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;oBACpE,MAAM,QAAQ,GAAG,MAAM,gBAAgB,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC;oBACzE,MAAM,KAAK,CAAC,QAAQ,CAAC,CAAC;gBAC1B,CAAC;gBAAC,MAAM,CAAC;oBACL,8DAA8D;gBAClE,CAAC;YACL,CAAC;QACL,CAAC;QAED,MAAM,KAAK,CAAC,QAAQ,CAAC,CAAC;QACtB,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ"}
|
|
@@ -3,6 +3,7 @@ import type { LangiumServices } from 'langium/lsp';
|
|
|
3
3
|
import { AstNodeHoverProvider } from 'langium/lsp';
|
|
4
4
|
import type { Hover, HoverParams } from 'vscode-languageserver';
|
|
5
5
|
import { QualifiedNameProvider } from '../domain-lang-naming.js';
|
|
6
|
+
import type { DomainLangIndexManager } from '../domain-lang-index-manager.js';
|
|
6
7
|
/**
|
|
7
8
|
* Provides hover information for DomainLang elements.
|
|
8
9
|
*
|
|
@@ -13,6 +14,7 @@ export declare class DomainLangHoverProvider extends AstNodeHoverProvider {
|
|
|
13
14
|
protected readonly documentationProvider: DocumentationProvider;
|
|
14
15
|
protected readonly commentProvider: CommentProvider;
|
|
15
16
|
protected readonly qualifiedNameProvider: QualifiedNameProvider;
|
|
17
|
+
protected readonly indexManager: DomainLangIndexManager;
|
|
16
18
|
/**
|
|
17
19
|
* Registry of type-specific hover content generators.
|
|
18
20
|
* Each generator returns content for its node type, or undefined to skip.
|
|
@@ -22,6 +24,8 @@ export declare class DomainLangHoverProvider extends AstNodeHoverProvider {
|
|
|
22
24
|
getHoverContent(document: LangiumDocument, params: HoverParams): Promise<Hover | undefined>;
|
|
23
25
|
/**
|
|
24
26
|
* Try to get hover for a declaration node (AST node).
|
|
27
|
+
* For qualified name references, only shows hover when hovering over the last segment.
|
|
28
|
+
* For qualified name declarations (like namespace names), shows hover on any segment.
|
|
25
29
|
*/
|
|
26
30
|
private tryGetDeclarationHover;
|
|
27
31
|
/**
|
|
@@ -29,7 +33,12 @@ export declare class DomainLangHoverProvider extends AstNodeHoverProvider {
|
|
|
29
33
|
* Uses the keyword dictionary for all keywords.
|
|
30
34
|
*/
|
|
31
35
|
private tryGetKeywordHover;
|
|
32
|
-
protected getAstNodeHoverContent(node: AstNode): MaybePromise<string | undefined>;
|
|
36
|
+
protected getAstNodeHoverContent(node: AstNode, currentDocument?: LangiumDocument): MaybePromise<string | undefined>;
|
|
37
|
+
/**
|
|
38
|
+
* Gets the import alias for a node if it's from an imported document.
|
|
39
|
+
* Returns undefined if the node is in the same document or not imported with an alias.
|
|
40
|
+
*/
|
|
41
|
+
private getImportAliasForNode;
|
|
33
42
|
private getDomainHover;
|
|
34
43
|
private getThisRefHover;
|
|
35
44
|
private getBoundedContextHover;
|
|
@@ -47,17 +56,18 @@ export declare class DomainLangHoverProvider extends AstNodeHoverProvider {
|
|
|
47
56
|
private getImportHover;
|
|
48
57
|
private getDefaultHover;
|
|
49
58
|
/**
|
|
50
|
-
*
|
|
59
|
+
* Computes the display name for a node in hover, considering import aliases.
|
|
60
|
+
* If node is imported with an alias, shows `alias.name`, otherwise shows full qualified name.
|
|
51
61
|
*/
|
|
52
|
-
private
|
|
62
|
+
private getDisplayNameForHover;
|
|
53
63
|
/**
|
|
54
|
-
*
|
|
64
|
+
* Formats a relationship line for hover display.
|
|
55
65
|
*/
|
|
56
|
-
private
|
|
66
|
+
private formatRelationshipLine;
|
|
57
67
|
/**
|
|
58
68
|
* Formats the final hover content with consistent structure.
|
|
69
|
+
* Delegates to the shared hover-builders utility.
|
|
59
70
|
*/
|
|
60
71
|
private formatHover;
|
|
61
|
-
private getRefName;
|
|
62
72
|
private refLink;
|
|
63
73
|
}
|