@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
|
@@ -1,50 +1,136 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Keyword explanations for DomainLang hover documentation.
|
|
3
3
|
*
|
|
4
|
-
* This dictionary provides
|
|
5
|
-
*
|
|
4
|
+
* This dictionary provides concise hover content for all DomainLang keywords,
|
|
5
|
+
* DDD patterns, and special symbols. Uses exact casing from grammar.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
* as JSDoc comments. This dictionary focuses on DDD integration patterns and advanced concepts.
|
|
9
|
-
*
|
|
10
|
-
* @see src/language/domain-lang.langium for basic keyword JSDoc
|
|
11
|
-
* @see ddd-pattern-explanations.ts for role patterns and relationship types
|
|
7
|
+
* @see https://domainlang.net/reference/language for full documentation
|
|
12
8
|
*/
|
|
9
|
+
|
|
10
|
+
// Documentation links
|
|
11
|
+
const DOMAIN_LINK = '\n\n[Read more](https://domainlang.net/guide/domains)';
|
|
12
|
+
const BC_LINK = '\n\n[Read more](https://domainlang.net/guide/bounded-contexts)';
|
|
13
|
+
const TEAM_LINK = '\n\n[Read more](https://domainlang.net/guide/teams-classifications)';
|
|
14
|
+
const MAP_LINK = '\n\n[Read more](https://domainlang.net/guide/context-maps)';
|
|
15
|
+
const REL_LINK = '\n\n[Read more](https://domainlang.net/guide/context-maps#relationships)';
|
|
16
|
+
const IMPORT_LINK = '\n\n[Read more](https://domainlang.net/guide/imports)';
|
|
17
|
+
const NS_LINK = '\n\n[Read more](https://domainlang.net/guide/namespaces)';
|
|
18
|
+
const TERM_LINK = '\n\n[Read more](https://domainlang.net/reference/language#terminology)';
|
|
19
|
+
const DECISION_LINK = '\n\n[Read more](https://domainlang.net/reference/language#decisions-policies-rules)';
|
|
20
|
+
const METADATA_LINK = '\n\n[Read more](https://domainlang.net/reference/language#metadata)';
|
|
21
|
+
const SYNTAX_LINK = '\n\n[Read more](https://domainlang.net/reference/language)';
|
|
22
|
+
|
|
13
23
|
export const keywordExplanations: Record<string, string> = {
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
// ========================================================================
|
|
25
|
+
// Primary Constructs
|
|
26
|
+
// ========================================================================
|
|
27
|
+
domain: `**Domain** - A sphere of knowledge or activity. Can be nested to show subdomain hierarchy.${DOMAIN_LINK}`,
|
|
28
|
+
dom: `**Domain** - A sphere of knowledge or activity. Can be nested to show subdomain hierarchy.${DOMAIN_LINK}`,
|
|
29
|
+
boundedcontext: `**BoundedContext** - A boundary where a domain model is defined. Central DDD pattern for managing complexity.${BC_LINK}`,
|
|
30
|
+
bc: `**BoundedContext** - A boundary where a domain model is defined. Central DDD pattern for managing complexity.${BC_LINK}`,
|
|
31
|
+
team: `**Team** - A group responsible for one or more bounded contexts.${TEAM_LINK}`,
|
|
32
|
+
classification: `**Classification** - Reusable label for categorizing elements (e.g., Core, Supporting, Generic).${TEAM_LINK}`,
|
|
33
|
+
metadata: `**Metadata** - Defines a key that can be used in metadata blocks.${METADATA_LINK}`,
|
|
34
|
+
meta: `**Metadata** - Defines a key that can be used in metadata blocks.${METADATA_LINK}`,
|
|
35
|
+
|
|
36
|
+
// ========================================================================
|
|
37
|
+
// Maps
|
|
38
|
+
// ========================================================================
|
|
39
|
+
contextmap: `**ContextMap** - Shows relationships between bounded contexts.${MAP_LINK}`,
|
|
40
|
+
cmap: `**ContextMap** - Shows relationships between bounded contexts.${MAP_LINK}`,
|
|
41
|
+
domainmap: `**DomainMap** - Visualizes domains and their subdomain structure.${MAP_LINK}`,
|
|
42
|
+
dmap: `**DomainMap** - Visualizes domains and their subdomain structure.${MAP_LINK}`,
|
|
43
|
+
contains: `**contains** - Specifies which elements are part of a map.${MAP_LINK}`,
|
|
44
|
+
|
|
45
|
+
// ========================================================================
|
|
46
|
+
// Bounded Context & Domain Properties
|
|
47
|
+
// ========================================================================
|
|
48
|
+
for: `**for** - Associates a bounded context with its parent domain.${BC_LINK}`,
|
|
49
|
+
as: `**as** - Assigns a classification to an element.${BC_LINK}`,
|
|
50
|
+
by: `**by** - Assigns a team responsible for an element.${BC_LINK}`,
|
|
51
|
+
in: `**in** - Specifies parent domain for subdomain nesting.${DOMAIN_LINK}`,
|
|
52
|
+
description: `**description** - Human-readable explanation of the element's purpose.${SYNTAX_LINK}`,
|
|
53
|
+
vision: `**vision** - Strategic vision statement for a domain.${DOMAIN_LINK}`,
|
|
54
|
+
type: `**type** - Assigns a classification type to a domain or relationship.${DOMAIN_LINK}`,
|
|
55
|
+
businessmodel: `**businessModel** - Revenue or engagement model for a context.${BC_LINK}`,
|
|
56
|
+
evolution: `**evolution** - Maturity stage (Genesis, Custom, Product, Commodity).${BC_LINK}`,
|
|
57
|
+
archetype: `**archetype** - Behavioral role (Gateway, Execution, etc.).${BC_LINK}`,
|
|
58
|
+
relationships: `**relationships** - Block defining integration patterns with other contexts.${REL_LINK}`,
|
|
59
|
+
integrations: `**integrations** - Block defining integration patterns with other contexts.${REL_LINK}`,
|
|
60
|
+
|
|
61
|
+
// ========================================================================
|
|
62
|
+
// Terminology & Glossary
|
|
63
|
+
// ========================================================================
|
|
64
|
+
terminology: `**terminology** - Block defining domain-specific terms and definitions.${TERM_LINK}`,
|
|
65
|
+
glossary: `**glossary** - Block defining domain-specific terms and definitions.${TERM_LINK}`,
|
|
66
|
+
term: `**Term** - Defines a domain term with its meaning.${TERM_LINK}`,
|
|
67
|
+
aka: `**aka** - Alternative names (also known as) for a term.${TERM_LINK}`,
|
|
68
|
+
synonyms: `**synonyms** - Alternative names (also known as) for a term.${TERM_LINK}`,
|
|
69
|
+
examples: `**examples** - Example usage of a term.${TERM_LINK}`,
|
|
70
|
+
meaning: `**meaning** - The definition or explanation of a term.${TERM_LINK}`,
|
|
71
|
+
|
|
72
|
+
// ========================================================================
|
|
73
|
+
// Decisions, Policies & Rules
|
|
74
|
+
// ========================================================================
|
|
75
|
+
decisions: `**decisions** - Block containing architectural decisions or business rules.${DECISION_LINK}`,
|
|
76
|
+
rules: `**rules** - Block containing architectural decisions or business rules.${DECISION_LINK}`,
|
|
77
|
+
decision: `**Decision** - An architectural or domain decision.${DECISION_LINK}`,
|
|
78
|
+
policy: `**Policy** - A business policy or organizational rule.${DECISION_LINK}`,
|
|
79
|
+
rule: `**Rule** - A business rule or constraint (also BusinessRule).${DECISION_LINK}`,
|
|
80
|
+
|
|
81
|
+
// ========================================================================
|
|
82
|
+
// Import System
|
|
83
|
+
// ========================================================================
|
|
84
|
+
import: `**Import** - Imports definitions from an external model or file.${IMPORT_LINK}`,
|
|
85
|
+
|
|
86
|
+
// ========================================================================
|
|
87
|
+
// Namespaces
|
|
88
|
+
// ========================================================================
|
|
89
|
+
namespace: `**Namespace** - Groups elements under a qualified name.${NS_LINK}`,
|
|
90
|
+
ns: `**Namespace** - Groups elements under a qualified name.${NS_LINK}`,
|
|
91
|
+
|
|
92
|
+
// ========================================================================
|
|
93
|
+
// Assignment Operators
|
|
94
|
+
// ========================================================================
|
|
95
|
+
':': `**:** - Assignment operator (property: value).${SYNTAX_LINK}`,
|
|
96
|
+
is: `**is** - Assignment operator (property is value).${SYNTAX_LINK}`,
|
|
97
|
+
'=': `**=** - Assignment operator (property = value).${SYNTAX_LINK}`,
|
|
98
|
+
|
|
99
|
+
// ========================================================================
|
|
100
|
+
// Context Reference
|
|
101
|
+
// ========================================================================
|
|
102
|
+
this: `**this** - References the current bounded context in relationships.${REL_LINK}`,
|
|
103
|
+
|
|
104
|
+
// ========================================================================
|
|
30
105
|
// DDD Integration Patterns
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
partnership:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
106
|
+
// ========================================================================
|
|
107
|
+
acl: `**ACL** - Anti-Corruption Layer. Protects from external models by translating between domains.${REL_LINK}`,
|
|
108
|
+
anticorruptionlayer: `**AntiCorruptionLayer** - Protects from external models by translating between domains.${REL_LINK}`,
|
|
109
|
+
ohs: `**OHS** - Open Host Service. Provides a well-documented API for integration.${REL_LINK}`,
|
|
110
|
+
openhostservice: `**OpenHostService** - Provides a well-documented API for integration.${REL_LINK}`,
|
|
111
|
+
pl: `**PL** - Published Language. Documented language for inter-context communication.${REL_LINK}`,
|
|
112
|
+
publishedlanguage: `**PublishedLanguage** - Documented language for inter-context communication.${REL_LINK}`,
|
|
113
|
+
cf: `**CF** - Conformist. Adopts upstream model without translation.${REL_LINK}`,
|
|
114
|
+
conformist: `**Conformist** - Adopts upstream model without translation.${REL_LINK}`,
|
|
115
|
+
p: `**P** - Partnership. Two teams with mutual dependency and shared goals.${REL_LINK}`,
|
|
116
|
+
partnership: `**Partnership** - Two teams with mutual dependency and shared goals.${REL_LINK}`,
|
|
117
|
+
sk: `**SK** - Shared Kernel. Shared code/data requiring careful coordination.${REL_LINK}`,
|
|
118
|
+
sharedkernel: `**SharedKernel** - Shared code/data requiring careful coordination.${REL_LINK}`,
|
|
119
|
+
bbom: `**BBoM** - Big Ball of Mud. Legacy area without clear boundaries.${REL_LINK}`,
|
|
120
|
+
bigballofmud: `**BigBallOfMud** - Legacy area without clear boundaries.${REL_LINK}`,
|
|
121
|
+
|
|
122
|
+
// ========================================================================
|
|
123
|
+
// Relationship Types
|
|
124
|
+
// ========================================================================
|
|
125
|
+
customersupplier: `**CustomerSupplier** - Downstream depends on upstream with influence over priorities.${REL_LINK}`,
|
|
126
|
+
upstreamdownstream: `**UpstreamDownstream** - One context depends on another's model.${REL_LINK}`,
|
|
127
|
+
separateways: `**SeparateWays** - Contexts with no integration, solving problems independently.${REL_LINK}`,
|
|
128
|
+
|
|
129
|
+
// ========================================================================
|
|
130
|
+
// Relationship Arrows
|
|
131
|
+
// ========================================================================
|
|
132
|
+
'->': `**->** - Unidirectional dependency (upstream to downstream).${REL_LINK}`,
|
|
133
|
+
'<->': `**<->** - Bidirectional dependency (mutual).${REL_LINK}`,
|
|
134
|
+
'<-': `**<-** - Reverse unidirectional dependency (downstream to upstream).${REL_LINK}`,
|
|
135
|
+
'><': `**><** - Separate Ways (no integration).${REL_LINK}`,
|
|
136
|
+
};
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
import type { Connection } from 'vscode-languageserver';
|
|
16
16
|
import { Diagnostic, DiagnosticSeverity, Position, Range } from 'vscode-languageserver-types';
|
|
17
|
-
import YAML, { type Document as YAMLDocument, type
|
|
17
|
+
import YAML, { type Document as YAMLDocument, type Pair, isMap, isPair, isScalar } from 'yaml';
|
|
18
18
|
import { ManifestValidator, type ManifestDiagnostic, type ManifestSeverity } from '../validation/manifest.js';
|
|
19
19
|
import type { ModelManifest } from '../services/types.js';
|
|
20
20
|
|
|
@@ -45,16 +45,32 @@ export class ManifestDiagnosticsService {
|
|
|
45
45
|
content: string,
|
|
46
46
|
options?: { requirePublishable?: boolean }
|
|
47
47
|
): Promise<void> {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
try {
|
|
49
|
+
if (!this.connection) {
|
|
50
|
+
return; // No connection, skip diagnostics
|
|
51
|
+
}
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
const diagnostics = this.validate(content, options);
|
|
54
|
+
|
|
55
|
+
await this.connection.sendDiagnostics({
|
|
56
|
+
uri: manifestUri,
|
|
57
|
+
diagnostics
|
|
58
|
+
});
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.error('Error in validateAndSendDiagnostics:', error);
|
|
61
|
+
// Send minimal error diagnostic instead of crashing
|
|
62
|
+
if (this.connection) {
|
|
63
|
+
await this.connection.sendDiagnostics({
|
|
64
|
+
uri: manifestUri,
|
|
65
|
+
diagnostics: [{
|
|
66
|
+
severity: DiagnosticSeverity.Error,
|
|
67
|
+
range: Range.create(Position.create(0, 0), Position.create(0, 1)),
|
|
68
|
+
message: 'Internal error validating manifest file',
|
|
69
|
+
source: 'domainlang'
|
|
70
|
+
}]
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
58
74
|
}
|
|
59
75
|
|
|
60
76
|
/**
|
|
@@ -68,42 +84,53 @@ export class ManifestDiagnosticsService {
|
|
|
68
84
|
content: string,
|
|
69
85
|
options?: { requirePublishable?: boolean }
|
|
70
86
|
): Diagnostic[] {
|
|
71
|
-
// Parse YAML to get both the manifest object and source map
|
|
72
|
-
let yamlDoc: YAMLDocument.Parsed;
|
|
73
|
-
let manifest: ModelManifest;
|
|
74
|
-
|
|
75
87
|
try {
|
|
76
|
-
|
|
88
|
+
// Parse YAML to get both the manifest object and source map
|
|
89
|
+
let yamlDoc: YAMLDocument.Parsed;
|
|
90
|
+
let manifest: ModelManifest;
|
|
77
91
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
92
|
+
try {
|
|
93
|
+
yamlDoc = YAML.parseDocument(content);
|
|
94
|
+
|
|
95
|
+
// Check for YAML parse errors (they're in the errors array, not thrown)
|
|
96
|
+
if (yamlDoc.errors && yamlDoc.errors.length > 0) {
|
|
97
|
+
return yamlDoc.errors.map(err => ({
|
|
98
|
+
severity: DiagnosticSeverity.Error,
|
|
99
|
+
range: this.yamlErrorToRange(err, content),
|
|
100
|
+
message: `YAML parse error: ${err.message}`,
|
|
101
|
+
source: 'domainlang'
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
manifest = (yamlDoc.toJSON() ?? {}) as ModelManifest;
|
|
106
|
+
} catch (error) {
|
|
107
|
+
// Fallback for unexpected errors
|
|
108
|
+
const message = error instanceof Error ? error.message : 'Invalid YAML syntax';
|
|
109
|
+
return [{
|
|
81
110
|
severity: DiagnosticSeverity.Error,
|
|
82
|
-
range:
|
|
83
|
-
message: `YAML parse error: ${
|
|
111
|
+
range: Range.create(Position.create(0, 0), Position.create(0, 1)),
|
|
112
|
+
message: `YAML parse error: ${message}`,
|
|
84
113
|
source: 'domainlang'
|
|
85
|
-
}
|
|
114
|
+
}];
|
|
86
115
|
}
|
|
116
|
+
|
|
117
|
+
// Run manifest validation
|
|
118
|
+
const result = this.validator.validate(manifest, options);
|
|
87
119
|
|
|
88
|
-
|
|
120
|
+
// Convert to LSP diagnostics with source locations
|
|
121
|
+
return result.diagnostics.map(diag =>
|
|
122
|
+
this.toVSCodeDiagnostic(diag, yamlDoc)
|
|
123
|
+
);
|
|
89
124
|
} catch (error) {
|
|
90
|
-
|
|
91
|
-
|
|
125
|
+
console.error('Error in validate:', error);
|
|
126
|
+
// Return minimal error diagnostic
|
|
92
127
|
return [{
|
|
93
128
|
severity: DiagnosticSeverity.Error,
|
|
94
129
|
range: Range.create(Position.create(0, 0), Position.create(0, 1)),
|
|
95
|
-
message:
|
|
130
|
+
message: 'Internal error during validation',
|
|
96
131
|
source: 'domainlang'
|
|
97
132
|
}];
|
|
98
133
|
}
|
|
99
|
-
|
|
100
|
-
// Run manifest validation
|
|
101
|
-
const result = this.validator.validate(manifest, options);
|
|
102
|
-
|
|
103
|
-
// Convert to LSP diagnostics with source locations
|
|
104
|
-
return result.diagnostics.map(diag =>
|
|
105
|
-
this.toVSCodeDiagnostic(diag, yamlDoc)
|
|
106
|
-
);
|
|
107
134
|
}
|
|
108
135
|
|
|
109
136
|
/**
|
|
@@ -130,14 +157,19 @@ export class ManifestDiagnosticsService {
|
|
|
130
157
|
* Call this when the file is closed or deleted.
|
|
131
158
|
*/
|
|
132
159
|
async clearDiagnostics(manifestUri: string): Promise<void> {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
160
|
+
try {
|
|
161
|
+
if (!this.connection) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
136
164
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
165
|
+
await this.connection.sendDiagnostics({
|
|
166
|
+
uri: manifestUri,
|
|
167
|
+
diagnostics: []
|
|
168
|
+
});
|
|
169
|
+
} catch (error) {
|
|
170
|
+
console.error('Error in clearDiagnostics:', error);
|
|
171
|
+
// Ignore - don't crash on cleanup
|
|
172
|
+
}
|
|
141
173
|
}
|
|
142
174
|
|
|
143
175
|
/**
|
|
@@ -147,20 +179,32 @@ export class ManifestDiagnosticsService {
|
|
|
147
179
|
diag: ManifestDiagnostic,
|
|
148
180
|
yamlDoc: YAMLDocument.Parsed
|
|
149
181
|
): Diagnostic {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
182
|
+
try {
|
|
183
|
+
const range = this.findRangeForPath(diag.path, yamlDoc);
|
|
184
|
+
|
|
185
|
+
let message = diag.message;
|
|
186
|
+
if (diag.hint) {
|
|
187
|
+
message += `\nHint: ${diag.hint}`;
|
|
188
|
+
}
|
|
156
189
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
190
|
+
return {
|
|
191
|
+
severity: this.toVSCodeSeverity(diag.severity),
|
|
192
|
+
range,
|
|
193
|
+
message,
|
|
194
|
+
source: 'domainlang',
|
|
195
|
+
code: diag.code
|
|
196
|
+
};
|
|
197
|
+
} catch (error) {
|
|
198
|
+
console.error('Error converting diagnostic:', error);
|
|
199
|
+
// Return minimal diagnostic at file start
|
|
200
|
+
return {
|
|
201
|
+
severity: DiagnosticSeverity.Error,
|
|
202
|
+
range: Range.create(Position.create(0, 0), Position.create(0, 1)),
|
|
203
|
+
message: diag.message,
|
|
204
|
+
source: 'domainlang',
|
|
205
|
+
code: diag.code
|
|
206
|
+
};
|
|
207
|
+
}
|
|
164
208
|
}
|
|
165
209
|
|
|
166
210
|
/**
|
|
@@ -198,8 +242,7 @@ export class ManifestDiagnosticsService {
|
|
|
198
242
|
return fallback;
|
|
199
243
|
}
|
|
200
244
|
|
|
201
|
-
const
|
|
202
|
-
const item = mapNode.items.find((pair): pair is Pair =>
|
|
245
|
+
const item = currentNode.items.find((pair): pair is Pair =>
|
|
203
246
|
isPair(pair) && isScalar(pair.key) && String(pair.key.value) === part
|
|
204
247
|
);
|
|
205
248
|
|
|
@@ -208,7 +251,7 @@ export class ManifestDiagnosticsService {
|
|
|
208
251
|
}
|
|
209
252
|
|
|
210
253
|
// If this is the last part, return the range of the key
|
|
211
|
-
if (part === parts
|
|
254
|
+
if (part === parts.at(-1)) {
|
|
212
255
|
const keyNode = item.key;
|
|
213
256
|
if (isScalar(keyNode) && keyNode.range) {
|
|
214
257
|
const [start, end] = keyNode.range;
|
|
@@ -269,9 +312,7 @@ let manifestDiagnosticsService: ManifestDiagnosticsService | undefined;
|
|
|
269
312
|
* Gets or creates the manifest diagnostics service singleton.
|
|
270
313
|
*/
|
|
271
314
|
export function getManifestDiagnosticsService(): ManifestDiagnosticsService {
|
|
272
|
-
|
|
273
|
-
manifestDiagnosticsService = new ManifestDiagnosticsService();
|
|
274
|
-
}
|
|
315
|
+
manifestDiagnosticsService ??= new ManifestDiagnosticsService();
|
|
275
316
|
return manifestDiagnosticsService;
|
|
276
317
|
}
|
|
277
318
|
|