@domainlang/language 0.5.2 → 0.7.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.js +5 -1
- package/out/domain-lang-module.js.map +1 -1
- package/out/generated/ast.d.ts +24 -0
- package/out/generated/ast.js.map +1 -1
- package/out/generated/grammar.js +22 -32
- package/out/generated/grammar.js.map +1 -1
- package/out/index.d.ts +2 -5
- package/out/index.js +10 -6
- package/out/index.js.map +1 -1
- package/out/lsp/domain-lang-code-actions.js +14 -8
- package/out/lsp/domain-lang-code-actions.js.map +1 -1
- package/out/lsp/domain-lang-completion.d.ts +3 -0
- package/out/lsp/domain-lang-completion.js +41 -13
- package/out/lsp/domain-lang-completion.js.map +1 -1
- package/out/lsp/domain-lang-formatter.js +24 -18
- package/out/lsp/domain-lang-formatter.js.map +1 -1
- package/out/lsp/domain-lang-index-manager.d.ts +170 -0
- package/out/lsp/domain-lang-index-manager.js +389 -0
- package/out/lsp/domain-lang-index-manager.js.map +1 -0
- package/out/lsp/domain-lang-scope-provider.d.ts +67 -0
- package/out/lsp/domain-lang-scope-provider.js +95 -0
- package/out/lsp/domain-lang-scope-provider.js.map +1 -0
- package/out/lsp/domain-lang-scope.js +31 -17
- package/out/lsp/domain-lang-scope.js.map +1 -1
- package/out/lsp/domain-lang-workspace-manager.d.ts +76 -9
- package/out/lsp/domain-lang-workspace-manager.js +176 -54
- package/out/lsp/domain-lang-workspace-manager.js.map +1 -1
- package/out/lsp/hover/domain-lang-hover.d.ts +45 -1
- package/out/lsp/hover/domain-lang-hover.js +308 -232
- package/out/lsp/hover/domain-lang-hover.js.map +1 -1
- package/out/lsp/hover/domain-lang-keywords.d.ts +3 -7
- package/out/lsp/hover/domain-lang-keywords.js +115 -38
- package/out/lsp/hover/domain-lang-keywords.js.map +1 -1
- package/out/lsp/manifest-diagnostics.js +95 -50
- package/out/lsp/manifest-diagnostics.js.map +1 -1
- package/out/main.js +204 -17
- package/out/main.js.map +1 -1
- package/out/services/import-resolver.d.ts +39 -2
- package/out/services/import-resolver.js +77 -12
- package/out/services/import-resolver.js.map +1 -1
- package/out/services/types.d.ts +2 -2
- package/out/services/workspace-manager.d.ts +33 -31
- package/out/services/workspace-manager.js +92 -148
- package/out/services/workspace-manager.js.map +1 -1
- package/out/utils/document-utils.d.ts +41 -0
- package/out/utils/document-utils.js +64 -0
- package/out/utils/document-utils.js.map +1 -0
- package/out/utils/import-utils.d.ts +0 -17
- package/out/utils/import-utils.js +2 -32
- package/out/utils/import-utils.js.map +1 -1
- package/out/utils/manifest-utils.d.ts +56 -0
- package/out/utils/manifest-utils.js +119 -0
- package/out/utils/manifest-utils.js.map +1 -0
- package/out/validation/constants.d.ts +13 -0
- package/out/validation/constants.js +18 -0
- package/out/validation/constants.js.map +1 -1
- package/out/validation/import.d.ts +12 -2
- package/out/validation/import.js +95 -22
- package/out/validation/import.js.map +1 -1
- package/out/validation/maps.js +51 -2
- package/out/validation/maps.js.map +1 -1
- package/package.json +1 -1
- package/src/domain-lang-module.ts +6 -1
- package/src/domain-lang.langium +37 -13
- package/src/generated/ast.ts +24 -0
- package/src/generated/grammar.ts +22 -32
- package/src/index.ts +12 -6
- package/src/lsp/domain-lang-code-actions.ts +13 -8
- package/src/lsp/domain-lang-completion.ts +61 -13
- package/src/lsp/domain-lang-formatter.ts +28 -23
- package/src/lsp/domain-lang-index-manager.ts +447 -0
- package/src/lsp/domain-lang-scope-provider.ts +134 -0
- package/src/lsp/domain-lang-scope.ts +29 -17
- package/src/lsp/domain-lang-workspace-manager.ts +201 -53
- package/src/lsp/hover/domain-lang-hover.ts +332 -226
- package/src/lsp/hover/domain-lang-keywords.ts +129 -43
- package/src/lsp/manifest-diagnostics.ts +100 -59
- package/src/main.ts +258 -16
- package/src/services/import-resolver.ts +91 -12
- package/src/services/types.ts +2 -2
- package/src/services/workspace-manager.ts +101 -175
- package/src/utils/document-utils.ts +80 -0
- package/src/utils/import-utils.ts +2 -40
- package/src/utils/manifest-utils.ts +132 -0
- package/src/validation/constants.ts +24 -0
- package/src/validation/import.ts +107 -24
- package/src/validation/maps.ts +59 -2
- package/out/lsp/hover/ddd-pattern-explanations.d.ts +0 -50
- package/out/lsp/hover/ddd-pattern-explanations.js +0 -196
- package/out/lsp/hover/ddd-pattern-explanations.js.map +0 -1
- package/out/services/dependency-analyzer.d.ts +0 -58
- package/out/services/dependency-analyzer.js +0 -254
- package/out/services/dependency-analyzer.js.map +0 -1
- package/out/services/dependency-resolver.d.ts +0 -146
- package/out/services/dependency-resolver.js +0 -452
- package/out/services/dependency-resolver.js.map +0 -1
- package/out/services/git-url-resolver.browser.d.ts +0 -10
- package/out/services/git-url-resolver.browser.js +0 -19
- package/out/services/git-url-resolver.browser.js.map +0 -1
- package/out/services/git-url-resolver.d.ts +0 -158
- package/out/services/git-url-resolver.js +0 -416
- package/out/services/git-url-resolver.js.map +0 -1
- package/out/services/governance-validator.d.ts +0 -44
- package/out/services/governance-validator.js +0 -153
- package/out/services/governance-validator.js.map +0 -1
- package/out/services/semver.d.ts +0 -98
- package/out/services/semver.js +0 -195
- package/out/services/semver.js.map +0 -1
- package/src/lsp/hover/ddd-pattern-explanations.ts +0 -237
- package/src/services/dependency-analyzer.ts +0 -321
- package/src/services/dependency-resolver.ts +0 -551
- package/src/services/git-url-resolver.browser.ts +0 -26
- package/src/services/git-url-resolver.ts +0 -517
- package/src/services/governance-validator.ts +0 -177
- package/src/services/semver.ts +0 -213
|
@@ -3,19 +3,86 @@ import type { CancellationToken } from 'vscode-languageserver-protocol';
|
|
|
3
3
|
/**
|
|
4
4
|
* Langium WorkspaceManager override implementing manifest-centric import loading per PRS-010.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* -
|
|
10
|
-
* -
|
|
6
|
+
* **Three Operational Modes:**
|
|
7
|
+
*
|
|
8
|
+
* **Mode A (Pure Workspace with model.yaml):**
|
|
9
|
+
* - model.yaml exists at workspace root
|
|
10
|
+
* - Loads entry file (default: index.dlang, or custom via model.entry)
|
|
11
|
+
* - Pre-builds entry and follows import graph
|
|
12
|
+
* - All imported documents built to Validated state before workspace ready
|
|
13
|
+
* - LSP features have immediate access to complete reference information
|
|
14
|
+
*
|
|
15
|
+
* **Mode B (Pure Standalone files):**
|
|
16
|
+
* - No model.yaml anywhere in workspace
|
|
17
|
+
* - No pre-loading of .dlang files during workspace scan
|
|
18
|
+
* - Documents loaded on-demand when user opens them
|
|
19
|
+
* - Imports resolved lazily via ImportResolver
|
|
20
|
+
* - Each document built individually when opened
|
|
21
|
+
* - Works with relative imports only (no path aliases or external deps)
|
|
22
|
+
*
|
|
23
|
+
* **Mode C (Mixed - Standalone + Module folders):**
|
|
24
|
+
* - Workspace contains both standalone .dlang files AND folders with model.yaml
|
|
25
|
+
* - Each model.yaml folder treated as a module/package:
|
|
26
|
+
* - Module entry + import graph pre-loaded
|
|
27
|
+
* - Path aliases and external deps work within module
|
|
28
|
+
* - Standalone files outside modules loaded on-demand
|
|
29
|
+
* - Example structure:
|
|
30
|
+
* ```
|
|
31
|
+
* workspace/
|
|
32
|
+
* ├── standalone.dlang ← Mode B (on-demand)
|
|
33
|
+
* ├── core/
|
|
34
|
+
* │ ├── model.yaml ← Module root
|
|
35
|
+
* │ ├── index.dlang ← Pre-loaded
|
|
36
|
+
* │ └── domains/
|
|
37
|
+
* │ └── sales.dlang ← Pre-loaded via imports
|
|
38
|
+
* └── util.dlang ← Mode B (on-demand)
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* **Performance Characteristics:**
|
|
42
|
+
* - Mode A/C modules: Slower initial load, instant LSP features afterward
|
|
43
|
+
* - Mode B/C standalone: Instant workspace init, per-file build on open
|
|
44
|
+
* - All modes cache import resolution for subsequent access
|
|
45
|
+
*
|
|
46
|
+
* **Never performs network fetches** - relies on cached dependencies/lock files.
|
|
47
|
+
* Missing cache produces diagnostics upstream via ImportValidator.
|
|
11
48
|
*/
|
|
12
49
|
export declare class DomainLangWorkspaceManager extends DefaultWorkspaceManager {
|
|
50
|
+
private readonly sharedServices;
|
|
13
51
|
constructor(services: LangiumSharedCoreServices);
|
|
14
52
|
shouldIncludeEntry(entry: FileSystemNode): boolean;
|
|
15
53
|
initializeWorkspace(folders: WorkspaceFolder[], cancelToken?: CancellationToken): Promise<void>;
|
|
16
54
|
protected loadAdditionalDocuments(folders: WorkspaceFolder[], collector: (document: LangiumDocument) => void): Promise<void>;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Loads standalone .dlang files from workspace folders recursively.
|
|
57
|
+
*
|
|
58
|
+
* Skips:
|
|
59
|
+
* - Module directories (directories with model.yaml) - loaded via import graph
|
|
60
|
+
* - `.dlang/cache` directory - package cache managed by CLI
|
|
61
|
+
*
|
|
62
|
+
* @param folders - Workspace folders to scan
|
|
63
|
+
* @param moduleDirectories - Set of directories containing model.yaml (to skip)
|
|
64
|
+
* @param collector - Document collector callback
|
|
65
|
+
*/
|
|
66
|
+
private loadStandaloneFiles;
|
|
67
|
+
/**
|
|
68
|
+
* Recursively loads .dlang files from a directory.
|
|
69
|
+
* Skips module directories and the .dlang/cache package cache.
|
|
70
|
+
*/
|
|
71
|
+
private loadDlangFilesRecursively;
|
|
72
|
+
/**
|
|
73
|
+
* Checks if a directory entry is a .dlang file.
|
|
74
|
+
*/
|
|
75
|
+
private isDlangFile;
|
|
76
|
+
/**
|
|
77
|
+
* Attempts to load a document, returning undefined on failure.
|
|
78
|
+
*/
|
|
79
|
+
private tryLoadDocument;
|
|
80
|
+
/**
|
|
81
|
+
* Finds ALL model.yaml files in the workspace.
|
|
82
|
+
* Delegates to shared manifest utilities.
|
|
83
|
+
*
|
|
84
|
+
* @param folders - Workspace folders to search
|
|
85
|
+
* @returns Array of manifest info (one per model.yaml found)
|
|
86
|
+
*/
|
|
87
|
+
private findAllManifestsInFolders;
|
|
21
88
|
}
|
|
@@ -1,19 +1,58 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
1
2
|
import path from 'node:path';
|
|
2
|
-
import YAML from 'yaml';
|
|
3
3
|
import { DefaultWorkspaceManager, URI, UriUtils } from 'langium';
|
|
4
4
|
import { ensureImportGraphFromDocument } from '../utils/import-utils.js';
|
|
5
|
+
import { findManifestsInDirectories } from '../utils/manifest-utils.js';
|
|
5
6
|
/**
|
|
6
7
|
* Langium WorkspaceManager override implementing manifest-centric import loading per PRS-010.
|
|
7
8
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* -
|
|
12
|
-
* -
|
|
9
|
+
* **Three Operational Modes:**
|
|
10
|
+
*
|
|
11
|
+
* **Mode A (Pure Workspace with model.yaml):**
|
|
12
|
+
* - model.yaml exists at workspace root
|
|
13
|
+
* - Loads entry file (default: index.dlang, or custom via model.entry)
|
|
14
|
+
* - Pre-builds entry and follows import graph
|
|
15
|
+
* - All imported documents built to Validated state before workspace ready
|
|
16
|
+
* - LSP features have immediate access to complete reference information
|
|
17
|
+
*
|
|
18
|
+
* **Mode B (Pure Standalone files):**
|
|
19
|
+
* - No model.yaml anywhere in workspace
|
|
20
|
+
* - No pre-loading of .dlang files during workspace scan
|
|
21
|
+
* - Documents loaded on-demand when user opens them
|
|
22
|
+
* - Imports resolved lazily via ImportResolver
|
|
23
|
+
* - Each document built individually when opened
|
|
24
|
+
* - Works with relative imports only (no path aliases or external deps)
|
|
25
|
+
*
|
|
26
|
+
* **Mode C (Mixed - Standalone + Module folders):**
|
|
27
|
+
* - Workspace contains both standalone .dlang files AND folders with model.yaml
|
|
28
|
+
* - Each model.yaml folder treated as a module/package:
|
|
29
|
+
* - Module entry + import graph pre-loaded
|
|
30
|
+
* - Path aliases and external deps work within module
|
|
31
|
+
* - Standalone files outside modules loaded on-demand
|
|
32
|
+
* - Example structure:
|
|
33
|
+
* ```
|
|
34
|
+
* workspace/
|
|
35
|
+
* ├── standalone.dlang ← Mode B (on-demand)
|
|
36
|
+
* ├── core/
|
|
37
|
+
* │ ├── model.yaml ← Module root
|
|
38
|
+
* │ ├── index.dlang ← Pre-loaded
|
|
39
|
+
* │ └── domains/
|
|
40
|
+
* │ └── sales.dlang ← Pre-loaded via imports
|
|
41
|
+
* └── util.dlang ← Mode B (on-demand)
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* **Performance Characteristics:**
|
|
45
|
+
* - Mode A/C modules: Slower initial load, instant LSP features afterward
|
|
46
|
+
* - Mode B/C standalone: Instant workspace init, per-file build on open
|
|
47
|
+
* - All modes cache import resolution for subsequent access
|
|
48
|
+
*
|
|
49
|
+
* **Never performs network fetches** - relies on cached dependencies/lock files.
|
|
50
|
+
* Missing cache produces diagnostics upstream via ImportValidator.
|
|
13
51
|
*/
|
|
14
52
|
export class DomainLangWorkspaceManager extends DefaultWorkspaceManager {
|
|
15
53
|
constructor(services) {
|
|
16
54
|
super(services);
|
|
55
|
+
this.sharedServices = services;
|
|
17
56
|
}
|
|
18
57
|
shouldIncludeEntry(entry) {
|
|
19
58
|
// Prevent auto-including .dlang files; we'll load via entry/import graph
|
|
@@ -27,67 +66,150 @@ export class DomainLangWorkspaceManager extends DefaultWorkspaceManager {
|
|
|
27
66
|
await super.initializeWorkspace(folders, cancelToken);
|
|
28
67
|
}
|
|
29
68
|
async loadAdditionalDocuments(folders, collector) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
69
|
+
// Find ALL model.yaml files in workspace (supports mixed mode)
|
|
70
|
+
const manifestInfos = await this.findAllManifestsInFolders(folders);
|
|
71
|
+
// Track directories covered by manifests to avoid loading their files as standalone
|
|
72
|
+
const moduleDirectories = new Set(manifestInfos.map(m => path.dirname(m.manifestPath)));
|
|
73
|
+
// Mode A or Mode C: Load each module's entry + import graph
|
|
74
|
+
for (const manifestInfo of manifestInfos) {
|
|
75
|
+
try {
|
|
76
|
+
const entryUri = URI.file(manifestInfo.entryPath);
|
|
77
|
+
const entryDoc = await this.langiumDocuments.getOrCreateDocument(entryUri);
|
|
78
|
+
collector(entryDoc);
|
|
79
|
+
// Build entry document first to ensure it's ready for import resolution
|
|
80
|
+
await this.sharedServices.workspace.DocumentBuilder.build([entryDoc], {
|
|
81
|
+
validation: true
|
|
82
|
+
});
|
|
83
|
+
const uris = await ensureImportGraphFromDocument(entryDoc, this.langiumDocuments);
|
|
84
|
+
const importedDocs = [];
|
|
85
|
+
for (const uriString of uris) {
|
|
86
|
+
const uri = URI.parse(uriString);
|
|
87
|
+
const doc = await this.langiumDocuments.getOrCreateDocument(uri);
|
|
88
|
+
collector(doc);
|
|
89
|
+
importedDocs.push(doc);
|
|
90
|
+
}
|
|
91
|
+
// Build all imported documents in batch for performance
|
|
92
|
+
if (importedDocs.length > 0) {
|
|
93
|
+
await this.sharedServices.workspace.DocumentBuilder.build(importedDocs, {
|
|
94
|
+
validation: true
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
100
|
+
console.error(`Failed to load import graph from ${manifestInfo.manifestPath}: ${message}`);
|
|
101
|
+
// Continue with other modules - partial failure is acceptable
|
|
102
|
+
}
|
|
42
103
|
}
|
|
104
|
+
// Load standalone .dlang files in workspace root folders
|
|
105
|
+
// These are files NOT covered by any module's import graph
|
|
106
|
+
await this.loadStandaloneFiles(folders, moduleDirectories, collector);
|
|
43
107
|
}
|
|
44
|
-
|
|
108
|
+
/**
|
|
109
|
+
* Loads standalone .dlang files from workspace folders recursively.
|
|
110
|
+
*
|
|
111
|
+
* Skips:
|
|
112
|
+
* - Module directories (directories with model.yaml) - loaded via import graph
|
|
113
|
+
* - `.dlang/cache` directory - package cache managed by CLI
|
|
114
|
+
*
|
|
115
|
+
* @param folders - Workspace folders to scan
|
|
116
|
+
* @param moduleDirectories - Set of directories containing model.yaml (to skip)
|
|
117
|
+
* @param collector - Document collector callback
|
|
118
|
+
*/
|
|
119
|
+
async loadStandaloneFiles(folders, moduleDirectories, collector) {
|
|
120
|
+
const standaloneDocs = [];
|
|
45
121
|
for (const folder of folders) {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const entryPath = path.resolve(path.dirname(manifestPath), entry);
|
|
50
|
-
return { manifestPath, entryPath };
|
|
51
|
-
}
|
|
122
|
+
const folderPath = URI.parse(folder.uri).fsPath;
|
|
123
|
+
const docs = await this.loadDlangFilesRecursively(folderPath, moduleDirectories, collector);
|
|
124
|
+
standaloneDocs.push(...docs);
|
|
52
125
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
while (true) {
|
|
59
|
-
const candidate = path.join(current, 'model.yaml');
|
|
60
|
-
if (await this.pathExists(candidate)) {
|
|
61
|
-
return candidate;
|
|
62
|
-
}
|
|
63
|
-
if (current === root) {
|
|
64
|
-
return undefined;
|
|
65
|
-
}
|
|
66
|
-
const parent = path.dirname(current);
|
|
67
|
-
if (parent === current) {
|
|
68
|
-
return undefined;
|
|
69
|
-
}
|
|
70
|
-
current = parent;
|
|
126
|
+
// Build all standalone documents in batch for performance
|
|
127
|
+
if (standaloneDocs.length > 0) {
|
|
128
|
+
await this.sharedServices.workspace.DocumentBuilder.build(standaloneDocs, {
|
|
129
|
+
validation: true
|
|
130
|
+
});
|
|
71
131
|
}
|
|
72
132
|
}
|
|
73
|
-
|
|
133
|
+
/**
|
|
134
|
+
* Recursively loads .dlang files from a directory.
|
|
135
|
+
* Skips module directories and the .dlang/cache package cache.
|
|
136
|
+
*/
|
|
137
|
+
async loadDlangFilesRecursively(dirPath, moduleDirectories, collector) {
|
|
138
|
+
// Skip module directories - they're loaded via import graph
|
|
139
|
+
if (moduleDirectories.has(dirPath)) {
|
|
140
|
+
return [];
|
|
141
|
+
}
|
|
142
|
+
// Skip .dlang/cache - package cache managed by CLI
|
|
143
|
+
const baseName = path.basename(dirPath);
|
|
144
|
+
const parentName = path.basename(path.dirname(dirPath));
|
|
145
|
+
if (baseName === 'cache' && parentName === '.dlang') {
|
|
146
|
+
return [];
|
|
147
|
+
}
|
|
148
|
+
// Also skip the .dlang directory itself if it contains cache
|
|
149
|
+
if (baseName === '.dlang') {
|
|
150
|
+
return [];
|
|
151
|
+
}
|
|
152
|
+
const docs = [];
|
|
74
153
|
try {
|
|
75
|
-
const
|
|
76
|
-
const
|
|
77
|
-
|
|
154
|
+
const entries = await fs.readdir(dirPath, { withFileTypes: true });
|
|
155
|
+
for (const entry of entries) {
|
|
156
|
+
const entryPath = path.join(dirPath, entry.name);
|
|
157
|
+
if (entry.isDirectory()) {
|
|
158
|
+
// Recurse into subdirectories
|
|
159
|
+
const subDocs = await this.loadDlangFilesRecursively(entryPath, moduleDirectories, collector);
|
|
160
|
+
docs.push(...subDocs);
|
|
161
|
+
}
|
|
162
|
+
else if (this.isDlangFile(entry)) {
|
|
163
|
+
const doc = await this.tryLoadDocument(dirPath, entry.name, collector);
|
|
164
|
+
if (doc) {
|
|
165
|
+
docs.push(doc);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
78
169
|
}
|
|
79
|
-
catch {
|
|
80
|
-
|
|
170
|
+
catch (error) {
|
|
171
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
172
|
+
console.warn(`Failed to read directory ${dirPath}: ${message}`);
|
|
81
173
|
}
|
|
174
|
+
return docs;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Checks if a directory entry is a .dlang file.
|
|
178
|
+
*/
|
|
179
|
+
isDlangFile(entry) {
|
|
180
|
+
return entry.isFile() && entry.name.toLowerCase().endsWith('.dlang');
|
|
82
181
|
}
|
|
83
|
-
|
|
182
|
+
/**
|
|
183
|
+
* Attempts to load a document, returning undefined on failure.
|
|
184
|
+
*/
|
|
185
|
+
async tryLoadDocument(folderPath, fileName, collector) {
|
|
186
|
+
const filePath = path.join(folderPath, fileName);
|
|
187
|
+
const uri = URI.file(filePath);
|
|
188
|
+
// Skip if already loaded (e.g., through imports)
|
|
189
|
+
if (this.langiumDocuments.hasDocument(uri)) {
|
|
190
|
+
return undefined;
|
|
191
|
+
}
|
|
84
192
|
try {
|
|
85
|
-
await this.
|
|
86
|
-
|
|
193
|
+
const doc = await this.langiumDocuments.getOrCreateDocument(uri);
|
|
194
|
+
collector(doc);
|
|
195
|
+
return doc;
|
|
87
196
|
}
|
|
88
|
-
catch {
|
|
89
|
-
|
|
197
|
+
catch (error) {
|
|
198
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
199
|
+
console.warn(`Failed to load standalone file ${filePath}: ${message}`);
|
|
200
|
+
return undefined;
|
|
90
201
|
}
|
|
91
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Finds ALL model.yaml files in the workspace.
|
|
205
|
+
* Delegates to shared manifest utilities.
|
|
206
|
+
*
|
|
207
|
+
* @param folders - Workspace folders to search
|
|
208
|
+
* @returns Array of manifest info (one per model.yaml found)
|
|
209
|
+
*/
|
|
210
|
+
async findAllManifestsInFolders(folders) {
|
|
211
|
+
const directories = folders.map(f => URI.parse(f.uri).fsPath);
|
|
212
|
+
return findManifestsInDirectories(directories);
|
|
213
|
+
}
|
|
92
214
|
}
|
|
93
215
|
//# 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,
|
|
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,CAA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AK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;QAC9D,OAAO,0BAA0B,CAAC,WAAW,CAAC,CAAC;IACnD,CAAC;CACJ"}
|
|
@@ -5,15 +5,59 @@ import type { Hover, HoverParams } from 'vscode-languageserver';
|
|
|
5
5
|
import { QualifiedNameProvider } from '../domain-lang-naming.js';
|
|
6
6
|
/**
|
|
7
7
|
* Provides hover information for DomainLang elements.
|
|
8
|
+
*
|
|
9
|
+
* Extends Langium's AstNodeHoverProvider with DDD-specific hover content
|
|
10
|
+
* for domains, bounded contexts, relationships, and other DSL constructs.
|
|
8
11
|
*/
|
|
9
12
|
export declare class DomainLangHoverProvider extends AstNodeHoverProvider {
|
|
10
13
|
protected readonly documentationProvider: DocumentationProvider;
|
|
11
14
|
protected readonly commentProvider: CommentProvider;
|
|
12
15
|
protected readonly qualifiedNameProvider: QualifiedNameProvider;
|
|
16
|
+
/**
|
|
17
|
+
* Registry of type-specific hover content generators.
|
|
18
|
+
* Each generator returns content for its node type, or undefined to skip.
|
|
19
|
+
*/
|
|
20
|
+
private readonly hoverGenerators;
|
|
13
21
|
constructor(services: LangiumServices);
|
|
14
22
|
getHoverContent(document: LangiumDocument, params: HoverParams): Promise<Hover | undefined>;
|
|
23
|
+
/**
|
|
24
|
+
* Try to get hover for a declaration node (AST node).
|
|
25
|
+
*/
|
|
26
|
+
private tryGetDeclarationHover;
|
|
27
|
+
/**
|
|
28
|
+
* Try to get hover for a keyword node.
|
|
29
|
+
* Uses the keyword dictionary for all keywords.
|
|
30
|
+
*/
|
|
31
|
+
private tryGetKeywordHover;
|
|
15
32
|
protected getAstNodeHoverContent(node: AstNode): MaybePromise<string | undefined>;
|
|
33
|
+
private getDomainHover;
|
|
34
|
+
private getThisRefHover;
|
|
35
|
+
private getBoundedContextHover;
|
|
36
|
+
private getNamespaceHover;
|
|
37
|
+
private getContextMapHover;
|
|
38
|
+
private getDomainMapHover;
|
|
39
|
+
private getDecisionHover;
|
|
40
|
+
private getPolicyHover;
|
|
41
|
+
private getBusinessRuleHover;
|
|
42
|
+
private getDomainTermHover;
|
|
43
|
+
private getTeamHover;
|
|
44
|
+
private getClassificationHover;
|
|
45
|
+
private getMetadataHover;
|
|
46
|
+
private getRelationshipHover;
|
|
47
|
+
private getImportHover;
|
|
48
|
+
private getDefaultHover;
|
|
49
|
+
/**
|
|
50
|
+
* Formats a relationship line for hover display.
|
|
51
|
+
*/
|
|
52
|
+
private formatRelationshipLine;
|
|
53
|
+
/**
|
|
54
|
+
* Wraps text in a domain-lang code block.
|
|
55
|
+
*/
|
|
56
|
+
private codeBlock;
|
|
57
|
+
/**
|
|
58
|
+
* Formats the final hover content with consistent structure.
|
|
59
|
+
*/
|
|
60
|
+
private formatHover;
|
|
16
61
|
private getRefName;
|
|
17
62
|
private refLink;
|
|
18
|
-
protected getKeywordHoverContent(node: AstNode): MaybePromise<Hover | undefined>;
|
|
19
63
|
}
|