@domainlang/language 0.10.0 → 0.12.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 +44 -102
- package/out/diagram/context-map-diagram-generator.d.ts +65 -0
- package/out/diagram/context-map-diagram-generator.js +356 -0
- package/out/diagram/context-map-diagram-generator.js.map +1 -0
- package/out/diagram/context-map-layout-configurator.d.ts +15 -0
- package/out/diagram/context-map-layout-configurator.js +39 -0
- package/out/diagram/context-map-layout-configurator.js.map +1 -0
- package/out/diagram/elk-layout-factory.d.ts +43 -0
- package/out/diagram/elk-layout-factory.js +64 -0
- package/out/diagram/elk-layout-factory.js.map +1 -0
- package/out/domain-lang-module.d.ts +9 -2
- package/out/domain-lang-module.js +13 -4
- package/out/domain-lang-module.js.map +1 -1
- package/out/index.d.ts +6 -0
- package/out/index.js +7 -0
- package/out/index.js.map +1 -1
- package/out/lsp/domain-lang-code-lens-provider.d.ts +8 -0
- package/out/lsp/domain-lang-code-lens-provider.js +48 -0
- package/out/lsp/domain-lang-code-lens-provider.js.map +1 -0
- package/out/lsp/domain-lang-completion.js +1 -1
- package/out/lsp/domain-lang-completion.js.map +1 -1
- package/out/lsp/domain-lang-document-symbol-provider.js +5 -5
- package/out/lsp/domain-lang-document-symbol-provider.js.map +1 -1
- package/out/lsp/domain-lang-index-manager.d.ts +149 -5
- package/out/lsp/domain-lang-index-manager.js +388 -52
- package/out/lsp/domain-lang-index-manager.js.map +1 -1
- package/out/lsp/domain-lang-refresh.d.ts +35 -0
- package/out/lsp/domain-lang-refresh.js +129 -0
- package/out/lsp/domain-lang-refresh.js.map +1 -0
- package/out/lsp/domain-lang-workspace-manager.d.ts +10 -0
- package/out/lsp/domain-lang-workspace-manager.js +35 -0
- package/out/lsp/domain-lang-workspace-manager.js.map +1 -1
- package/out/lsp/tool-handlers.js +63 -57
- package/out/lsp/tool-handlers.js.map +1 -1
- package/out/main.js +30 -190
- package/out/main.js.map +1 -1
- package/out/sdk/loader-node.js +1 -1
- package/out/sdk/loader-node.js.map +1 -1
- package/out/sdk/validator.js +17 -14
- package/out/sdk/validator.js.map +1 -1
- package/out/services/import-resolver.d.ts +67 -17
- package/out/services/import-resolver.js +146 -65
- package/out/services/import-resolver.js.map +1 -1
- package/out/services/lsp-logger.d.ts +42 -0
- package/out/services/lsp-logger.js +50 -0
- package/out/services/lsp-logger.js.map +1 -0
- package/out/services/lsp-runtime-settings.d.ts +20 -0
- package/out/services/lsp-runtime-settings.js +20 -0
- package/out/services/lsp-runtime-settings.js.map +1 -0
- package/out/services/performance-optimizer.d.ts +9 -9
- package/out/services/performance-optimizer.js +17 -41
- package/out/services/performance-optimizer.js.map +1 -1
- package/out/services/workspace-manager.d.ts +22 -1
- package/out/services/workspace-manager.js +57 -9
- package/out/services/workspace-manager.js.map +1 -1
- package/out/utils/import-utils.js +6 -6
- package/out/utils/import-utils.js.map +1 -1
- package/out/validation/constants.d.ts +6 -0
- package/out/validation/constants.js +7 -0
- package/out/validation/constants.js.map +1 -1
- package/out/validation/import.d.ts +13 -3
- package/out/validation/import.js +54 -10
- package/out/validation/import.js.map +1 -1
- package/package.json +5 -2
- package/src/diagram/context-map-diagram-generator.ts +451 -0
- package/src/diagram/context-map-layout-configurator.ts +43 -0
- package/src/diagram/elk-layout-factory.ts +83 -0
- package/src/domain-lang-module.ts +22 -5
- package/src/index.ts +8 -0
- package/src/lsp/domain-lang-code-lens-provider.ts +54 -0
- package/src/lsp/domain-lang-completion.ts +3 -3
- package/src/lsp/domain-lang-document-symbol-provider.ts +5 -5
- package/src/lsp/domain-lang-index-manager.ts +438 -56
- package/src/lsp/domain-lang-refresh.ts +205 -0
- package/src/lsp/domain-lang-workspace-manager.ts +45 -0
- package/src/lsp/tool-handlers.ts +61 -47
- package/src/main.ts +36 -244
- package/src/sdk/loader-node.ts +1 -1
- package/src/sdk/validator.ts +17 -13
- package/src/services/import-resolver.ts +196 -89
- package/src/services/lsp-logger.ts +89 -0
- package/src/services/lsp-runtime-settings.ts +34 -0
- package/src/services/performance-optimizer.ts +18 -57
- package/src/services/workspace-manager.ts +62 -10
- package/src/utils/import-utils.ts +6 -6
- package/src/validation/constants.ts +9 -0
- package/src/validation/import.ts +67 -12
package/src/main.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { startLanguageServer } from 'langium/lsp';
|
|
2
2
|
import { NodeFileSystem } from 'langium/node';
|
|
3
|
-
import { createConnection, ProposedFeatures
|
|
3
|
+
import { createConnection, ProposedFeatures } from 'vscode-languageserver/node.js';
|
|
4
4
|
import { createDomainLangServices } from './domain-lang-module.js';
|
|
5
5
|
import { ensureImportGraphFromEntryFile } from './utils/import-utils.js';
|
|
6
|
-
import {
|
|
6
|
+
import { registerDomainLangRefresh } from './lsp/domain-lang-refresh.js';
|
|
7
7
|
import { registerToolHandlers } from './lsp/tool-handlers.js';
|
|
8
8
|
import { URI } from 'langium';
|
|
9
|
+
import { setLspRuntimeSettings } from './services/lsp-runtime-settings.js';
|
|
9
10
|
|
|
10
11
|
// Create a connection to the client
|
|
11
12
|
const connection = createConnection(ProposedFeatures.all);
|
|
@@ -16,6 +17,14 @@ const { shared, DomainLang } = createDomainLangServices({ connection, ...NodeFil
|
|
|
16
17
|
// Register custom LSP request handlers for VS Code Language Model Tools (PRS-015)
|
|
17
18
|
registerToolHandlers(connection, shared);
|
|
18
19
|
|
|
20
|
+
shared.lsp.LanguageServer.onInitialize((params) => {
|
|
21
|
+
applyLspSettings(params.initializationOptions);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
connection.onDidChangeConfiguration((params) => {
|
|
25
|
+
applyLspSettings(params.settings);
|
|
26
|
+
});
|
|
27
|
+
|
|
19
28
|
// Initialize workspace manager when language server initializes
|
|
20
29
|
// Uses Langium's LanguageServer.onInitialize hook (not raw connection handler)
|
|
21
30
|
// This integrates properly with Langium's initialization flow
|
|
@@ -29,7 +38,7 @@ shared.lsp.LanguageServer.onInitialize((params) => {
|
|
|
29
38
|
if (workspaceRoot) {
|
|
30
39
|
// Initialize workspace manager synchronously (just sets root path)
|
|
31
40
|
// Heavy work happens in initializeWorkspace() called by Langium later
|
|
32
|
-
const workspaceManager = DomainLang.imports.
|
|
41
|
+
const workspaceManager = DomainLang.imports.ManifestManager;
|
|
33
42
|
workspaceManager.initialize(workspaceRoot).catch(error => {
|
|
34
43
|
const message = error instanceof Error ? error.message : String(error);
|
|
35
44
|
console.warn(`Failed to initialize workspace: ${message}`);
|
|
@@ -39,247 +48,7 @@ shared.lsp.LanguageServer.onInitialize((params) => {
|
|
|
39
48
|
}
|
|
40
49
|
});
|
|
41
50
|
|
|
42
|
-
|
|
43
|
-
// Uses Langium's built-in file watcher which already watches **/* in workspace
|
|
44
|
-
// This invalidates caches when config files change externally
|
|
45
|
-
shared.lsp.DocumentUpdateHandler?.onWatchedFilesChange(async (params) => {
|
|
46
|
-
try {
|
|
47
|
-
await handleFileChanges(params, DomainLang.imports.WorkspaceManager, shared, DomainLang);
|
|
48
|
-
} catch (error) {
|
|
49
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
50
|
-
console.error(`Error handling file change notification: ${message}`);
|
|
51
|
-
// Continue - don't crash the server
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
/** Categorized file changes */
|
|
56
|
-
interface CategorizedChanges {
|
|
57
|
-
manifestChanged: boolean;
|
|
58
|
-
lockFileChanged: boolean;
|
|
59
|
-
changedDlangUris: Set<string>;
|
|
60
|
-
deletedDlangUris: Set<string>;
|
|
61
|
-
createdDlangUris: Set<string>;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Categorizes file changes by type.
|
|
66
|
-
*/
|
|
67
|
-
function categorizeChanges(
|
|
68
|
-
params: { changes: Array<{ uri: string; type: number }> },
|
|
69
|
-
workspaceManager: typeof DomainLang.imports.WorkspaceManager,
|
|
70
|
-
langServices: typeof DomainLang,
|
|
71
|
-
indexManager: DomainLangIndexManager
|
|
72
|
-
): CategorizedChanges {
|
|
73
|
-
const result: CategorizedChanges = {
|
|
74
|
-
manifestChanged: false,
|
|
75
|
-
lockFileChanged: false,
|
|
76
|
-
changedDlangUris: new Set(),
|
|
77
|
-
deletedDlangUris: new Set(),
|
|
78
|
-
createdDlangUris: new Set()
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
for (const change of params.changes) {
|
|
82
|
-
const uri = URI.parse(change.uri);
|
|
83
|
-
const fileName = uri.path.split('/').pop() ?? '';
|
|
84
|
-
const uriString = change.uri;
|
|
85
|
-
|
|
86
|
-
if (fileName === 'model.yaml') {
|
|
87
|
-
console.warn(`model.yaml changed: ${uriString}`);
|
|
88
|
-
workspaceManager.invalidateManifestCache();
|
|
89
|
-
langServices.imports.ImportResolver.clearCache();
|
|
90
|
-
indexManager.clearImportDependencies();
|
|
91
|
-
result.manifestChanged = true;
|
|
92
|
-
} else if (fileName === 'model.lock') {
|
|
93
|
-
console.warn(`model.lock changed: ${uriString}`);
|
|
94
|
-
langServices.imports.ImportResolver.clearCache();
|
|
95
|
-
indexManager.clearImportDependencies();
|
|
96
|
-
result.lockFileChanged = true;
|
|
97
|
-
} else if (fileName.endsWith('.dlang')) {
|
|
98
|
-
if (change.type === FileChangeType.Deleted) {
|
|
99
|
-
result.deletedDlangUris.add(uriString);
|
|
100
|
-
console.warn(`DomainLang file deleted: ${uriString}`);
|
|
101
|
-
} else if (change.type === FileChangeType.Created) {
|
|
102
|
-
result.createdDlangUris.add(uriString);
|
|
103
|
-
console.warn(`DomainLang file created: ${uriString}`);
|
|
104
|
-
} else {
|
|
105
|
-
result.changedDlangUris.add(uriString);
|
|
106
|
-
console.warn(`DomainLang file changed: ${uriString}`);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return result;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Rebuilds documents that depend on changed/deleted/created .dlang files.
|
|
116
|
-
*/
|
|
117
|
-
async function rebuildAffectedDocuments(
|
|
118
|
-
changes: CategorizedChanges,
|
|
119
|
-
indexManager: DomainLangIndexManager,
|
|
120
|
-
sharedServices: typeof shared,
|
|
121
|
-
langServices: typeof DomainLang
|
|
122
|
-
): Promise<void> {
|
|
123
|
-
const hasChanges = changes.changedDlangUris.size > 0 ||
|
|
124
|
-
changes.deletedDlangUris.size > 0 ||
|
|
125
|
-
changes.createdDlangUris.size > 0;
|
|
126
|
-
if (!hasChanges) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// CRITICAL: Clear ImportResolver cache BEFORE rebuilding.
|
|
131
|
-
// The WorkspaceCache only clears AFTER linking, but resolution happens
|
|
132
|
-
// DURING linking. Without this, stale cached resolutions would be used.
|
|
133
|
-
langServices.imports.ImportResolver.clearCache();
|
|
134
|
-
|
|
135
|
-
const affectedUris = collectAffectedDocuments(changes, indexManager);
|
|
136
|
-
|
|
137
|
-
if (affectedUris.size === 0) {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
console.warn(`Rebuilding ${affectedUris.size} documents affected by file changes`);
|
|
142
|
-
|
|
143
|
-
const langiumDocuments = sharedServices.workspace.LangiumDocuments;
|
|
144
|
-
const affectedDocs: URI[] = [];
|
|
145
|
-
|
|
146
|
-
for (const uriString of affectedUris) {
|
|
147
|
-
const uri = URI.parse(uriString);
|
|
148
|
-
if (langiumDocuments.hasDocument(uri)) {
|
|
149
|
-
affectedDocs.push(uri);
|
|
150
|
-
indexManager.markForReprocessing(uriString);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
const deletedUriObjects = [...changes.deletedDlangUris].map(u => URI.parse(u));
|
|
155
|
-
if (affectedDocs.length > 0 || deletedUriObjects.length > 0) {
|
|
156
|
-
await sharedServices.workspace.DocumentBuilder.update(affectedDocs, deletedUriObjects);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Collects all document URIs that should be rebuilt based on the changes.
|
|
162
|
-
*
|
|
163
|
-
* Uses targeted matching to avoid expensive full rebuilds:
|
|
164
|
-
* - For edits: rebuild documents that import the changed file (by resolved URI)
|
|
165
|
-
* - For all changes: rebuild documents whose import specifiers match the path
|
|
166
|
-
*
|
|
167
|
-
* The specifier matching handles renamed/moved/created files by comparing
|
|
168
|
-
* import specifiers against path segments (filename, parent/filename, etc.).
|
|
169
|
-
*/
|
|
170
|
-
function collectAffectedDocuments(
|
|
171
|
-
changes: CategorizedChanges,
|
|
172
|
-
indexManager: DomainLangIndexManager
|
|
173
|
-
): Set<string> {
|
|
174
|
-
const allChangedUris = new Set([
|
|
175
|
-
...changes.changedDlangUris,
|
|
176
|
-
...changes.deletedDlangUris,
|
|
177
|
-
...changes.createdDlangUris
|
|
178
|
-
]);
|
|
179
|
-
|
|
180
|
-
// Get documents affected by resolved URI changes (edits to imported files)
|
|
181
|
-
const affectedByUri = indexManager.getAllAffectedDocuments(allChangedUris);
|
|
182
|
-
|
|
183
|
-
// Get documents with import specifiers that match changed paths
|
|
184
|
-
// This catches:
|
|
185
|
-
// - File moves/renames: specifiers that previously resolved but now won't
|
|
186
|
-
// - File creations: specifiers that previously failed but might now resolve
|
|
187
|
-
// Uses fuzzy matching on path segments rather than rebuilding all imports
|
|
188
|
-
const affectedBySpecifier = indexManager.getDocumentsWithPotentiallyAffectedImports(allChangedUris);
|
|
189
|
-
|
|
190
|
-
return new Set([...affectedByUri, ...affectedBySpecifier]);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Handles all file changes including .dlang files, model.yaml, and model.lock.
|
|
195
|
-
*
|
|
196
|
-
* For .dlang files: rebuilds all documents that import the changed file.
|
|
197
|
-
* For config files: invalidates caches and rebuilds workspace as needed.
|
|
198
|
-
*/
|
|
199
|
-
async function handleFileChanges(
|
|
200
|
-
params: { changes: Array<{ uri: string; type: number }> },
|
|
201
|
-
workspaceManager: typeof DomainLang.imports.WorkspaceManager,
|
|
202
|
-
sharedServices: typeof shared,
|
|
203
|
-
langServices: typeof DomainLang
|
|
204
|
-
): Promise<void> {
|
|
205
|
-
const indexManager = sharedServices.workspace.IndexManager as DomainLangIndexManager;
|
|
206
|
-
|
|
207
|
-
// Categorize and process changes
|
|
208
|
-
const changes = categorizeChanges(params, workspaceManager, langServices, indexManager);
|
|
209
|
-
|
|
210
|
-
// Handle lock file changes
|
|
211
|
-
if (changes.lockFileChanged) {
|
|
212
|
-
const lockChange = params.changes.find(c => c.uri.endsWith('model.lock'));
|
|
213
|
-
if (lockChange) {
|
|
214
|
-
await handleLockFileChange(lockChange, workspaceManager);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// Rebuild documents affected by .dlang file changes
|
|
219
|
-
await rebuildAffectedDocuments(changes, indexManager, sharedServices, langServices);
|
|
220
|
-
|
|
221
|
-
// Handle config file changes
|
|
222
|
-
if (changes.manifestChanged || changes.lockFileChanged) {
|
|
223
|
-
await rebuildWorkspace(sharedServices, workspaceManager, changes.manifestChanged);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Handles lock file creation, change, or deletion.
|
|
229
|
-
*/
|
|
230
|
-
async function handleLockFileChange(
|
|
231
|
-
change: { uri: string; type: number },
|
|
232
|
-
workspaceManager: typeof DomainLang.imports.WorkspaceManager
|
|
233
|
-
): Promise<void> {
|
|
234
|
-
if (change.type === FileChangeType.Changed || change.type === FileChangeType.Created) {
|
|
235
|
-
await workspaceManager.refreshLockFile();
|
|
236
|
-
} else if (change.type === FileChangeType.Deleted) {
|
|
237
|
-
workspaceManager.invalidateLockCache();
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Rebuilds the workspace after config file changes.
|
|
243
|
-
* Uses incremental strategy: only full rebuild if dependencies changed.
|
|
244
|
-
*
|
|
245
|
-
* @param sharedServices - Shared Langium services
|
|
246
|
-
* @param workspaceManager - Workspace manager for manifest access
|
|
247
|
-
* @param manifestChanged - Whether model.yaml changed (vs just model.lock)
|
|
248
|
-
*/
|
|
249
|
-
async function rebuildWorkspace(
|
|
250
|
-
sharedServices: typeof shared,
|
|
251
|
-
workspaceManager: typeof DomainLang.imports.WorkspaceManager,
|
|
252
|
-
manifestChanged: boolean
|
|
253
|
-
): Promise<void> {
|
|
254
|
-
try {
|
|
255
|
-
// If only lock file changed, caches are already invalidated - no rebuild needed
|
|
256
|
-
// Lock file changes mean resolved versions changed, but import resolver cache is cleared
|
|
257
|
-
// Documents will re-resolve imports on next access
|
|
258
|
-
if (!manifestChanged) {
|
|
259
|
-
console.warn('Lock file changed - caches invalidated, no rebuild needed');
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// For manifest changes, check if dependencies section actually changed
|
|
264
|
-
// If only metadata changed (name, version, etc.), no rebuild needed
|
|
265
|
-
const manifest = await workspaceManager.getManifest();
|
|
266
|
-
const hasDependencies = manifest?.dependencies && Object.keys(manifest.dependencies).length > 0;
|
|
267
|
-
|
|
268
|
-
if (!hasDependencies) {
|
|
269
|
-
console.warn('Manifest changed but has no dependencies - skipping rebuild');
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// Dependencies exist and manifest changed - do full rebuild
|
|
274
|
-
const documents = sharedServices.workspace.LangiumDocuments.all.toArray();
|
|
275
|
-
const uris = documents.map(doc => doc.uri);
|
|
276
|
-
await sharedServices.workspace.DocumentBuilder.update([], uris);
|
|
277
|
-
console.warn(`Workspace rebuilt: ${documents.length} documents revalidated`);
|
|
278
|
-
} catch (error) {
|
|
279
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
280
|
-
console.error(`Failed to rebuild workspace: ${message}`);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
51
|
+
registerDomainLangRefresh(shared, DomainLang);
|
|
283
52
|
|
|
284
53
|
// Optionally start from a single entry file and follow imports.
|
|
285
54
|
// Configure via env DOMAINLANG_ENTRY (absolute or workspace-relative path)
|
|
@@ -331,3 +100,26 @@ if (entryFile) {
|
|
|
331
100
|
// No entry file configured: start normally
|
|
332
101
|
startLanguageServer(shared);
|
|
333
102
|
}
|
|
103
|
+
|
|
104
|
+
function applyLspSettings(settings: unknown): void {
|
|
105
|
+
const lsp = extractLspSettings(settings);
|
|
106
|
+
setLspRuntimeSettings({
|
|
107
|
+
traceImports: lsp.traceImports,
|
|
108
|
+
infoLogs: lsp.infoLogs,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function extractLspSettings(source: unknown): { traceImports: boolean; infoLogs: boolean } {
|
|
113
|
+
const root = isRecord(source) ? source : {};
|
|
114
|
+
const domainlang = isRecord(root.domainlang) ? root.domainlang : root;
|
|
115
|
+
const lsp = isRecord(domainlang.lsp) ? domainlang.lsp : {};
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
traceImports: typeof lsp.traceImports === 'boolean' ? lsp.traceImports : false,
|
|
119
|
+
infoLogs: typeof lsp.infoLogs === 'boolean' ? lsp.infoLogs : false,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
124
|
+
return typeof value === 'object' && value !== null;
|
|
125
|
+
}
|
package/src/sdk/loader-node.ts
CHANGED
|
@@ -77,7 +77,7 @@ export async function loadModel(
|
|
|
77
77
|
|
|
78
78
|
// Initialize workspace if directory provided
|
|
79
79
|
if (options?.workspaceDir) {
|
|
80
|
-
const workspaceManager = services.imports.
|
|
80
|
+
const workspaceManager = services.imports.ManifestManager;
|
|
81
81
|
await workspaceManager.initialize(options.workspaceDir);
|
|
82
82
|
}
|
|
83
83
|
|
package/src/sdk/validator.ts
CHANGED
|
@@ -130,8 +130,8 @@ export async function validateFile(
|
|
|
130
130
|
|
|
131
131
|
// Initialize workspace with the specified directory or file's directory
|
|
132
132
|
const workspaceDir = options.workspaceDir ?? dirname(absolutePath);
|
|
133
|
-
const
|
|
134
|
-
await
|
|
133
|
+
const manifestManager = services.imports.ManifestManager;
|
|
134
|
+
await manifestManager.initialize(workspaceDir);
|
|
135
135
|
|
|
136
136
|
// Load and parse the document
|
|
137
137
|
const uri = URI.file(absolutePath);
|
|
@@ -152,17 +152,21 @@ export async function validateFile(
|
|
|
152
152
|
const allDocuments = Array.from(shared.workspace.LangiumDocuments.all);
|
|
153
153
|
await shared.workspace.DocumentBuilder.build(allDocuments, { validation: true });
|
|
154
154
|
|
|
155
|
-
// Collect diagnostics from
|
|
156
|
-
const diagnostics = document.diagnostics ?? [];
|
|
155
|
+
// Collect diagnostics from all loaded documents (entry + imports)
|
|
157
156
|
const errors: ValidationDiagnostic[] = [];
|
|
158
157
|
const warnings: ValidationDiagnostic[] = [];
|
|
159
158
|
|
|
160
|
-
for (const
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
159
|
+
for (const doc of allDocuments) {
|
|
160
|
+
const diagnostics = doc.diagnostics ?? [];
|
|
161
|
+
const diagnosticFile = doc.uri.fsPath;
|
|
162
|
+
|
|
163
|
+
for (const diagnostic of diagnostics) {
|
|
164
|
+
const validationDiag = toValidationDiagnostic(diagnostic, diagnosticFile);
|
|
165
|
+
if (diagnostic.severity === 1) {
|
|
166
|
+
errors.push(validationDiag);
|
|
167
|
+
} else if (diagnostic.severity === 2) {
|
|
168
|
+
warnings.push(validationDiag);
|
|
169
|
+
}
|
|
166
170
|
}
|
|
167
171
|
}
|
|
168
172
|
|
|
@@ -262,18 +266,18 @@ export async function validateWorkspace(
|
|
|
262
266
|
const servicesObj = createDomainLangServices(NodeFileSystem);
|
|
263
267
|
const shared = servicesObj.shared;
|
|
264
268
|
const services = servicesObj.DomainLang;
|
|
265
|
-
const
|
|
269
|
+
const manifestManager = services.imports.ManifestManager;
|
|
266
270
|
|
|
267
271
|
try {
|
|
268
272
|
// Initialize workspace - this will find and load model.yaml
|
|
269
|
-
await
|
|
273
|
+
await manifestManager.initialize(absolutePath);
|
|
270
274
|
} catch (error) {
|
|
271
275
|
const message = error instanceof Error ? error.message : String(error);
|
|
272
276
|
throw new Error(`Failed to initialize workspace at ${workspaceDir}: ${message}`);
|
|
273
277
|
}
|
|
274
278
|
|
|
275
279
|
// Get the manifest to find the entry file
|
|
276
|
-
const manifest = await
|
|
280
|
+
const manifest = await manifestManager.getManifest();
|
|
277
281
|
let entryFile = 'index.dlang';
|
|
278
282
|
|
|
279
283
|
if (manifest?.model?.entry) {
|