@domainlang/language 0.1.20

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.
Files changed (212) hide show
  1. package/README.md +163 -0
  2. package/out/ast-augmentation.d.ts +6 -0
  3. package/out/ast-augmentation.js +2 -0
  4. package/out/ast-augmentation.js.map +1 -0
  5. package/out/domain-lang-module.d.ts +57 -0
  6. package/out/domain-lang-module.js +67 -0
  7. package/out/domain-lang-module.js.map +1 -0
  8. package/out/generated/ast.d.ts +759 -0
  9. package/out/generated/ast.js +556 -0
  10. package/out/generated/ast.js.map +1 -0
  11. package/out/generated/grammar.d.ts +6 -0
  12. package/out/generated/grammar.js +2407 -0
  13. package/out/generated/grammar.js.map +1 -0
  14. package/out/generated/module.d.ts +13 -0
  15. package/out/generated/module.js +21 -0
  16. package/out/generated/module.js.map +1 -0
  17. package/out/index.d.ts +16 -0
  18. package/out/index.js +22 -0
  19. package/out/index.js.map +1 -0
  20. package/out/lsp/domain-lang-code-actions.d.ts +55 -0
  21. package/out/lsp/domain-lang-code-actions.js +143 -0
  22. package/out/lsp/domain-lang-code-actions.js.map +1 -0
  23. package/out/lsp/domain-lang-completion.d.ts +37 -0
  24. package/out/lsp/domain-lang-completion.js +452 -0
  25. package/out/lsp/domain-lang-completion.js.map +1 -0
  26. package/out/lsp/domain-lang-formatter.d.ts +15 -0
  27. package/out/lsp/domain-lang-formatter.js +43 -0
  28. package/out/lsp/domain-lang-formatter.js.map +1 -0
  29. package/out/lsp/domain-lang-naming.d.ts +34 -0
  30. package/out/lsp/domain-lang-naming.js +49 -0
  31. package/out/lsp/domain-lang-naming.js.map +1 -0
  32. package/out/lsp/domain-lang-scope.d.ts +59 -0
  33. package/out/lsp/domain-lang-scope.js +102 -0
  34. package/out/lsp/domain-lang-scope.js.map +1 -0
  35. package/out/lsp/domain-lang-workspace-manager.d.ts +21 -0
  36. package/out/lsp/domain-lang-workspace-manager.js +93 -0
  37. package/out/lsp/domain-lang-workspace-manager.js.map +1 -0
  38. package/out/lsp/hover/ddd-pattern-explanations.d.ts +50 -0
  39. package/out/lsp/hover/ddd-pattern-explanations.js +196 -0
  40. package/out/lsp/hover/ddd-pattern-explanations.js.map +1 -0
  41. package/out/lsp/hover/domain-lang-hover.d.ts +19 -0
  42. package/out/lsp/hover/domain-lang-hover.js +302 -0
  43. package/out/lsp/hover/domain-lang-hover.js.map +1 -0
  44. package/out/lsp/hover/domain-lang-keywords.d.ts +13 -0
  45. package/out/lsp/hover/domain-lang-keywords.js +47 -0
  46. package/out/lsp/hover/domain-lang-keywords.js.map +1 -0
  47. package/out/lsp/manifest-diagnostics.d.ts +82 -0
  48. package/out/lsp/manifest-diagnostics.js +230 -0
  49. package/out/lsp/manifest-diagnostics.js.map +1 -0
  50. package/out/main-browser.d.ts +1 -0
  51. package/out/main-browser.js +11 -0
  52. package/out/main-browser.js.map +1 -0
  53. package/out/main.d.ts +1 -0
  54. package/out/main.js +74 -0
  55. package/out/main.js.map +1 -0
  56. package/out/sdk/ast-augmentation.d.ts +136 -0
  57. package/out/sdk/ast-augmentation.js +62 -0
  58. package/out/sdk/ast-augmentation.js.map +1 -0
  59. package/out/sdk/index.d.ts +94 -0
  60. package/out/sdk/index.js +97 -0
  61. package/out/sdk/index.js.map +1 -0
  62. package/out/sdk/indexes.d.ts +16 -0
  63. package/out/sdk/indexes.js +97 -0
  64. package/out/sdk/indexes.js.map +1 -0
  65. package/out/sdk/loader-node.d.ts +51 -0
  66. package/out/sdk/loader-node.js +119 -0
  67. package/out/sdk/loader-node.js.map +1 -0
  68. package/out/sdk/loader.d.ts +49 -0
  69. package/out/sdk/loader.js +85 -0
  70. package/out/sdk/loader.js.map +1 -0
  71. package/out/sdk/patterns.d.ts +93 -0
  72. package/out/sdk/patterns.js +123 -0
  73. package/out/sdk/patterns.js.map +1 -0
  74. package/out/sdk/query.d.ts +90 -0
  75. package/out/sdk/query.js +679 -0
  76. package/out/sdk/query.js.map +1 -0
  77. package/out/sdk/resolution.d.ts +52 -0
  78. package/out/sdk/resolution.js +68 -0
  79. package/out/sdk/resolution.js.map +1 -0
  80. package/out/sdk/types.d.ts +280 -0
  81. package/out/sdk/types.js +8 -0
  82. package/out/sdk/types.js.map +1 -0
  83. package/out/services/dependency-analyzer.d.ts +58 -0
  84. package/out/services/dependency-analyzer.js +254 -0
  85. package/out/services/dependency-analyzer.js.map +1 -0
  86. package/out/services/dependency-resolver.d.ts +146 -0
  87. package/out/services/dependency-resolver.js +452 -0
  88. package/out/services/dependency-resolver.js.map +1 -0
  89. package/out/services/git-url-resolver.browser.d.ts +10 -0
  90. package/out/services/git-url-resolver.browser.js +19 -0
  91. package/out/services/git-url-resolver.browser.js.map +1 -0
  92. package/out/services/git-url-resolver.d.ts +158 -0
  93. package/out/services/git-url-resolver.js +416 -0
  94. package/out/services/git-url-resolver.js.map +1 -0
  95. package/out/services/governance-validator.d.ts +44 -0
  96. package/out/services/governance-validator.js +153 -0
  97. package/out/services/governance-validator.js.map +1 -0
  98. package/out/services/import-resolver.d.ts +77 -0
  99. package/out/services/import-resolver.js +240 -0
  100. package/out/services/import-resolver.js.map +1 -0
  101. package/out/services/performance-optimizer.d.ts +60 -0
  102. package/out/services/performance-optimizer.js +140 -0
  103. package/out/services/performance-optimizer.js.map +1 -0
  104. package/out/services/relationship-inference.d.ts +11 -0
  105. package/out/services/relationship-inference.js +98 -0
  106. package/out/services/relationship-inference.js.map +1 -0
  107. package/out/services/semver.d.ts +98 -0
  108. package/out/services/semver.js +195 -0
  109. package/out/services/semver.js.map +1 -0
  110. package/out/services/types.d.ts +340 -0
  111. package/out/services/types.js +46 -0
  112. package/out/services/types.js.map +1 -0
  113. package/out/services/workspace-manager.d.ts +123 -0
  114. package/out/services/workspace-manager.js +489 -0
  115. package/out/services/workspace-manager.js.map +1 -0
  116. package/out/syntaxes/domain-lang.monarch.d.ts +76 -0
  117. package/out/syntaxes/domain-lang.monarch.js +29 -0
  118. package/out/syntaxes/domain-lang.monarch.js.map +1 -0
  119. package/out/utils/import-utils.d.ts +49 -0
  120. package/out/utils/import-utils.js +128 -0
  121. package/out/utils/import-utils.js.map +1 -0
  122. package/out/validation/bounded-context.d.ts +11 -0
  123. package/out/validation/bounded-context.js +79 -0
  124. package/out/validation/bounded-context.js.map +1 -0
  125. package/out/validation/classification.d.ts +3 -0
  126. package/out/validation/classification.js +3 -0
  127. package/out/validation/classification.js.map +1 -0
  128. package/out/validation/constants.d.ts +180 -0
  129. package/out/validation/constants.js +235 -0
  130. package/out/validation/constants.js.map +1 -0
  131. package/out/validation/domain-lang-validator.d.ts +2 -0
  132. package/out/validation/domain-lang-validator.js +27 -0
  133. package/out/validation/domain-lang-validator.js.map +1 -0
  134. package/out/validation/domain.d.ts +11 -0
  135. package/out/validation/domain.js +63 -0
  136. package/out/validation/domain.js.map +1 -0
  137. package/out/validation/import.d.ts +68 -0
  138. package/out/validation/import.js +237 -0
  139. package/out/validation/import.js.map +1 -0
  140. package/out/validation/manifest.d.ts +144 -0
  141. package/out/validation/manifest.js +327 -0
  142. package/out/validation/manifest.js.map +1 -0
  143. package/out/validation/maps.d.ts +21 -0
  144. package/out/validation/maps.js +60 -0
  145. package/out/validation/maps.js.map +1 -0
  146. package/out/validation/metadata.d.ts +7 -0
  147. package/out/validation/metadata.js +16 -0
  148. package/out/validation/metadata.js.map +1 -0
  149. package/out/validation/model.d.ts +12 -0
  150. package/out/validation/model.js +29 -0
  151. package/out/validation/model.js.map +1 -0
  152. package/out/validation/relationships.d.ts +12 -0
  153. package/out/validation/relationships.js +94 -0
  154. package/out/validation/relationships.js.map +1 -0
  155. package/out/validation/shared.d.ts +6 -0
  156. package/out/validation/shared.js +12 -0
  157. package/out/validation/shared.js.map +1 -0
  158. package/package.json +110 -0
  159. package/src/ast-augmentation.ts +5 -0
  160. package/src/domain-lang-module.ts +112 -0
  161. package/src/domain-lang.langium +351 -0
  162. package/src/generated/ast.ts +986 -0
  163. package/src/generated/grammar.ts +2409 -0
  164. package/src/generated/module.ts +25 -0
  165. package/src/index.ts +24 -0
  166. package/src/lsp/domain-lang-code-actions.ts +189 -0
  167. package/src/lsp/domain-lang-completion.ts +514 -0
  168. package/src/lsp/domain-lang-formatter.ts +51 -0
  169. package/src/lsp/domain-lang-naming.ts +56 -0
  170. package/src/lsp/domain-lang-scope.ts +137 -0
  171. package/src/lsp/domain-lang-workspace-manager.ts +104 -0
  172. package/src/lsp/hover/ddd-pattern-explanations.ts +237 -0
  173. package/src/lsp/hover/domain-lang-hover.ts +338 -0
  174. package/src/lsp/hover/domain-lang-keywords.ts +50 -0
  175. package/src/lsp/manifest-diagnostics.ts +290 -0
  176. package/src/main-browser.ts +15 -0
  177. package/src/main.ts +85 -0
  178. package/src/sdk/README.md +297 -0
  179. package/src/sdk/ast-augmentation.ts +157 -0
  180. package/src/sdk/index.ts +126 -0
  181. package/src/sdk/indexes.ts +155 -0
  182. package/src/sdk/loader-node.ts +146 -0
  183. package/src/sdk/loader.ts +99 -0
  184. package/src/sdk/patterns.ts +147 -0
  185. package/src/sdk/query.ts +802 -0
  186. package/src/sdk/resolution.ts +78 -0
  187. package/src/sdk/types.ts +323 -0
  188. package/src/services/dependency-analyzer.ts +321 -0
  189. package/src/services/dependency-resolver.ts +551 -0
  190. package/src/services/git-url-resolver.browser.ts +26 -0
  191. package/src/services/git-url-resolver.ts +517 -0
  192. package/src/services/governance-validator.ts +177 -0
  193. package/src/services/import-resolver.ts +292 -0
  194. package/src/services/performance-optimizer.ts +170 -0
  195. package/src/services/relationship-inference.ts +121 -0
  196. package/src/services/semver.ts +213 -0
  197. package/src/services/types.ts +415 -0
  198. package/src/services/workspace-manager.ts +607 -0
  199. package/src/syntaxes/domain-lang.monarch.ts +29 -0
  200. package/src/utils/import-utils.ts +152 -0
  201. package/src/validation/bounded-context.ts +99 -0
  202. package/src/validation/classification.ts +5 -0
  203. package/src/validation/constants.ts +304 -0
  204. package/src/validation/domain-lang-validator.ts +33 -0
  205. package/src/validation/domain.ts +77 -0
  206. package/src/validation/import.ts +295 -0
  207. package/src/validation/manifest.ts +439 -0
  208. package/src/validation/maps.ts +76 -0
  209. package/src/validation/metadata.ts +18 -0
  210. package/src/validation/model.ts +37 -0
  211. package/src/validation/relationships.ts +154 -0
  212. package/src/validation/shared.ts +14 -0
@@ -0,0 +1,12 @@
1
+ import type { ValidationAcceptor } from 'langium';
2
+ import type { Relationship } from '../generated/ast.js';
3
+ /**
4
+ * Validates that SharedKernel patterns use bidirectional relationships.
5
+ * SharedKernel implies mutual dependency and shared code ownership.
6
+ *
7
+ * @param relationship - The relationship to validate
8
+ * @param accept - The validation acceptor for reporting issues
9
+ */
10
+ declare function validateSharedKernelBidirectional(relationship: Relationship, accept: ValidationAcceptor): void;
11
+ export declare const relationshipChecks: (typeof validateSharedKernelBidirectional)[];
12
+ export {};
@@ -0,0 +1,94 @@
1
+ import { isThisRef } from '../generated/ast.js';
2
+ import { ValidationMessages, buildCodeDescription } from './constants.js';
3
+ /**
4
+ * Gets a display name for a BoundedContextRef (handles 'this' and regular refs).
5
+ */
6
+ function getContextName(ref) {
7
+ if (isThisRef(ref)) {
8
+ return 'this';
9
+ }
10
+ return ref.link?.$refText ?? 'unknown';
11
+ }
12
+ /**
13
+ * Validates that SharedKernel patterns use bidirectional relationships.
14
+ * SharedKernel implies mutual dependency and shared code ownership.
15
+ *
16
+ * @param relationship - The relationship to validate
17
+ * @param accept - The validation acceptor for reporting issues
18
+ */
19
+ function validateSharedKernelBidirectional(relationship, accept) {
20
+ // Check if SharedKernel pattern exists on either side
21
+ const hasSharedKernelLeft = relationship.leftPatterns?.some(pattern => pattern === 'SK' || pattern === 'SharedKernel');
22
+ const hasSharedKernelRight = relationship.rightPatterns?.some(pattern => pattern === 'SK' || pattern === 'SharedKernel');
23
+ if ((hasSharedKernelLeft || hasSharedKernelRight) && relationship.arrow !== '<->') {
24
+ const leftName = getContextName(relationship.left);
25
+ const rightName = getContextName(relationship.right);
26
+ accept('warning', ValidationMessages.SHARED_KERNEL_MUST_BE_BIDIRECTIONAL(leftName, rightName, relationship.arrow), { node: relationship, property: 'arrow', codeDescription: buildCodeDescription('language.md', 'integration-patterns') });
27
+ }
28
+ }
29
+ /**
30
+ * Validates that Anti-Corruption Layer (ACL) is on the consuming side.
31
+ * ACL protects downstream context from upstream changes.
32
+ *
33
+ * @param relationship - The relationship to validate
34
+ * @param accept - The validation acceptor for reporting issues
35
+ */
36
+ function validateACLPlacement(relationship, accept) {
37
+ const hasACLLeft = relationship.leftPatterns?.some(pattern => pattern === 'ACL' || pattern === 'AntiCorruptionLayer');
38
+ const hasACLRight = relationship.rightPatterns?.some(pattern => pattern === 'ACL' || pattern === 'AntiCorruptionLayer');
39
+ // ACL on left side with -> arrow means upstream has ACL (incorrect)
40
+ if (hasACLLeft && relationship.arrow === '->') {
41
+ const leftName = getContextName(relationship.left);
42
+ accept('warning', ValidationMessages.ACL_ON_WRONG_SIDE(leftName, 'left'), { node: relationship, property: 'leftPatterns', codeDescription: buildCodeDescription('language.md', 'integration-patterns') });
43
+ }
44
+ // ACL on right side with <- arrow means upstream has ACL (incorrect)
45
+ if (hasACLRight && relationship.arrow === '<-') {
46
+ const rightName = getContextName(relationship.right);
47
+ accept('warning', ValidationMessages.ACL_ON_WRONG_SIDE(rightName, 'right'), { node: relationship, property: 'rightPatterns', codeDescription: buildCodeDescription('language.md', 'integration-patterns') });
48
+ }
49
+ }
50
+ /**
51
+ * Validates that Conformist pattern is on the consuming side.
52
+ * Conformist means accepting upstream model without translation.
53
+ *
54
+ * @param relationship - The relationship to validate
55
+ * @param accept - The validation acceptor for reporting issues
56
+ */
57
+ function validateConformistPlacement(relationship, accept) {
58
+ const hasCFLeft = relationship.leftPatterns?.some(pattern => pattern === 'CF' || pattern === 'Conformist');
59
+ const hasCFRight = relationship.rightPatterns?.some(pattern => pattern === 'CF' || pattern === 'Conformist');
60
+ // CF on left side with -> arrow means upstream is conformist (incorrect)
61
+ if (hasCFLeft && relationship.arrow === '->') {
62
+ const leftName = getContextName(relationship.left);
63
+ accept('warning', ValidationMessages.CONFORMIST_ON_WRONG_SIDE(leftName, 'left'), { node: relationship, property: 'leftPatterns', codeDescription: buildCodeDescription('language.md', 'integration-patterns') });
64
+ }
65
+ // CF on right side with <- arrow means upstream is conformist (incorrect)
66
+ if (hasCFRight && relationship.arrow === '<-') {
67
+ const rightName = getContextName(relationship.right);
68
+ accept('warning', ValidationMessages.CONFORMIST_ON_WRONG_SIDE(rightName, 'right'), { node: relationship, property: 'rightPatterns', codeDescription: buildCodeDescription('language.md', 'integration-patterns') });
69
+ }
70
+ }
71
+ /**
72
+ * Validates that relationships don't have too many integration patterns.
73
+ * More than 3 patterns on one side suggests syntax confusion.
74
+ *
75
+ * @param relationship - The relationship to validate
76
+ * @param accept - The validation acceptor for reporting issues
77
+ */
78
+ function validatePatternCount(relationship, accept) {
79
+ const leftCount = relationship.leftPatterns?.length ?? 0;
80
+ const rightCount = relationship.rightPatterns?.length ?? 0;
81
+ if (leftCount > 3) {
82
+ accept('info', ValidationMessages.TOO_MANY_PATTERNS(leftCount, 'left'), { node: relationship, property: 'leftPatterns', codeDescription: buildCodeDescription('language.md', 'integration-patterns') });
83
+ }
84
+ if (rightCount > 3) {
85
+ accept('info', ValidationMessages.TOO_MANY_PATTERNS(rightCount, 'right'), { node: relationship, property: 'rightPatterns', codeDescription: buildCodeDescription('language.md', 'integration-patterns') });
86
+ }
87
+ }
88
+ export const relationshipChecks = [
89
+ validateSharedKernelBidirectional,
90
+ validateACLPlacement,
91
+ validateConformistPlacement,
92
+ validatePatternCount
93
+ ];
94
+ //# sourceMappingURL=relationships.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relationships.js","sourceRoot":"","sources":["../../src/validation/relationships.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE1E;;GAEG;AACH,SAAS,cAAc,CAAC,GAAs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AC;IACN,CAAC;IAED,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;QACjB,MAAM,CAAC,MAAM,EACT,kBAAkB,CAAC,iBAAiB,CAAC,UAAU,EAAE,OAAO,CAAC,EACzD,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,eAAe,EAAE,oBAAoB,CAAC,aAAa,EAAE,sBAAsB,CAAC,EAAE,CAClI,CAAC;IACN,CAAC;AACL,CAAC;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAC9B,iCAAiC;IACjC,oBAAoB;IACpB,2BAA2B;IAC3B,oBAAoB;CACvB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { AstNode } from 'langium';
2
+ import type { Container } from '../generated/ast.js';
3
+ export declare function extractNames(element: Container): Generator<{
4
+ fqn: string;
5
+ node: AstNode;
6
+ }>;
@@ -0,0 +1,12 @@
1
+ import { isContainer } from '../generated/ast.js';
2
+ import { QualifiedNameProvider } from '../lsp/domain-lang-naming.js';
3
+ export function* extractNames(element) {
4
+ const fqnProvider = new QualifiedNameProvider();
5
+ for (const child of element.children) {
6
+ yield { fqn: fqnProvider.getQualifiedName(child.$container, child.name), node: child };
7
+ if (isContainer(child)) {
8
+ yield* extractNames(child);
9
+ }
10
+ }
11
+ }
12
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/validation/shared.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE,MAAM,SAAS,CAAC,CAAC,YAAY,CAAC,OAAkB;IAC5C,MAAM,WAAW,GAAG,IAAI,qBAAqB,EAAE,CAAC;IAChD,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACnC,MAAM,EAAC,GAAG,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAC,CAAC;QACrF,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;YACrB,KAAK,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAC/B,CAAC;IACL,CAAC;AACL,CAAC"}
package/package.json ADDED
@@ -0,0 +1,110 @@
1
+ {
2
+ "name": "@domainlang/language",
3
+ "version": "0.1.20",
4
+ "displayName": "DomainLang Language",
5
+ "description": "Core language library for DomainLang - parse, validate, and query Domain-Driven Design models programmatically",
6
+ "author": "larsbaunwall",
7
+ "license": "Apache-2.0",
8
+ "icon": "images/icon.png",
9
+ "keywords": [
10
+ "ddd",
11
+ "domain-driven design",
12
+ "langium",
13
+ "dlang",
14
+ "domainlang",
15
+ "bounded-context",
16
+ "context-map",
17
+ "aggregate",
18
+ "ubiquitous-language",
19
+ "dsl",
20
+ "modeling",
21
+ "architecture",
22
+ "strategic-design",
23
+ "parser",
24
+ "sdk"
25
+ ],
26
+ "homepage": "https://domainlang.net",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "https://github.com/DomainLang/DomainLang",
30
+ "directory": "dsl/domain-lang/packages/language"
31
+ },
32
+ "bugs": {
33
+ "url": "https://github.com/DomainLang/DomainLang/issues"
34
+ },
35
+ "type": "module",
36
+ "engines": {
37
+ "node": ">=20.10.0",
38
+ "npm": ">=10.2.3"
39
+ },
40
+ "files": [
41
+ "out",
42
+ "src"
43
+ ],
44
+ "main": "./out/index.js",
45
+ "module": "./out/index.js",
46
+ "exports": {
47
+ ".": {
48
+ "types": "./out/index.d.ts",
49
+ "default": "./out/index.js"
50
+ },
51
+ "./sdk": {
52
+ "types": "./out/sdk/index.d.ts",
53
+ "default": "./out/sdk/index.js"
54
+ },
55
+ "./main-browser": {
56
+ "types": "./out/main-browser.d.ts",
57
+ "default": "./out/main-browser.js"
58
+ },
59
+ "./syntaxes/domain-lang.monarch.js": {
60
+ "types": "./out/syntaxes/domain-lang.monarch.d.ts",
61
+ "default": "./out/syntaxes/domain-lang.monarch.js"
62
+ },
63
+ "./syntaxes/domain-lang.monarch": {
64
+ "types": "./out/syntaxes/domain-lang.monarch.d.ts",
65
+ "default": "./out/syntaxes/domain-lang.monarch.js"
66
+ },
67
+ "./src/services/git-url-resolver.js": {
68
+ "browser": "./src/services/git-url-resolver.browser.js",
69
+ "default": "./src/services/git-url-resolver.js"
70
+ }
71
+ },
72
+ "typesVersions": {
73
+ "*": {
74
+ ".": [
75
+ "out/index"
76
+ ]
77
+ }
78
+ },
79
+ "scripts": {
80
+ "clean": "shx rm -fr *.tsbuildinfo out",
81
+ "build": "tsc -b tsconfig.src.json",
82
+ "build:clean": "npm run clean && npm run build",
83
+ "langium:generate": "langium generate",
84
+ "langium:watch": "langium generate --watch",
85
+ "test": "vitest run",
86
+ "test:coverage": "vitest run --coverage"
87
+ },
88
+ "dependencies": {
89
+ "langium": "~4.2.0",
90
+ "monaco-editor": "0.55.1",
91
+ "vite": "6.4.1",
92
+ "yaml": "^2.5.0"
93
+ },
94
+ "devDependencies": {
95
+ "@types/node": "~20.17.48",
96
+ "@vitest/coverage-v8": "^3.1.4",
97
+ "langium-cli": "~4.2.0",
98
+ "shx": "~0.4.0",
99
+ "typescript": "~5.8.3",
100
+ "vitest": "~3.1.3"
101
+ },
102
+ "volta": {
103
+ "node": "20.19.2",
104
+ "npm": "10.8.2"
105
+ },
106
+ "publishConfig": {
107
+ "access": "public",
108
+ "registry": "https://registry.npmjs.org/"
109
+ }
110
+ }
@@ -0,0 +1,5 @@
1
+ declare module './generated/ast.js' {
2
+ interface Relationship {
3
+ inferredType?: string;
4
+ }
5
+ }
@@ -0,0 +1,112 @@
1
+ import { type Module, inject } from 'langium';
2
+ import type {
3
+ DefaultSharedModuleContext,
4
+ LangiumServices,
5
+ LangiumSharedServices,
6
+ PartialLangiumServices,
7
+ PartialLangiumSharedServices
8
+ } from 'langium/lsp';
9
+ import { createDefaultModule, createDefaultSharedModule } from 'langium/lsp';
10
+ import { DomainLangGeneratedModule, DomainLangGeneratedSharedModule } from './generated/module.js';
11
+ import { registerValidationChecks } from './validation/domain-lang-validator.js';
12
+ import { QualifiedNameProvider } from './lsp/domain-lang-naming.js';
13
+ import { DomainLangScopeComputation } from './lsp/domain-lang-scope.js';
14
+ import { DomainLangFormatter } from './lsp/domain-lang-formatter.js';
15
+ import { DomainLangHoverProvider } from './lsp/hover/domain-lang-hover.js';
16
+ import { DomainLangCompletionProvider } from './lsp/domain-lang-completion.js';
17
+ import { DomainLangCodeActionProvider } from './lsp/domain-lang-code-actions.js';
18
+ import { ImportResolver } from './services/import-resolver.js';
19
+ import { WorkspaceManager } from './services/workspace-manager.js';
20
+ import { DomainLangWorkspaceManager } from './lsp/domain-lang-workspace-manager.js';
21
+
22
+ /**
23
+ * Declaration of custom services - add your own service classes here.
24
+ */
25
+ export type DomainLangAddedServices = {
26
+ imports: {
27
+ ImportResolver: ImportResolver,
28
+ WorkspaceManager: WorkspaceManager
29
+ },
30
+ references: {
31
+ QualifiedNameProvider: QualifiedNameProvider
32
+ },
33
+ lsp: {
34
+ Formatter: DomainLangFormatter,
35
+ HoverProvider: DomainLangHoverProvider,
36
+ CompletionProvider: DomainLangCompletionProvider,
37
+ CodeActionProvider: DomainLangCodeActionProvider
38
+ }
39
+ }
40
+
41
+ /**
42
+ * Union of Langium default services and your custom services - use this as constructor parameter
43
+ * of custom service classes.
44
+ */
45
+ export type DomainLangServices = LangiumServices & DomainLangAddedServices
46
+
47
+ const DomainLangSharedModule: Module<LangiumSharedServices, PartialLangiumSharedServices> = {
48
+ workspace: {
49
+ WorkspaceManager: (services: LangiumSharedServices) => new DomainLangWorkspaceManager(services)
50
+ }
51
+ };
52
+
53
+ /**
54
+ * Dependency injection module that overrides Langium default services and contributes the
55
+ * declared custom services. The Langium defaults can be partially specified to override only
56
+ * selected services, while the custom services must be fully specified.
57
+ */
58
+ export const DomainLangModule: Module<DomainLangServices, PartialLangiumServices & DomainLangAddedServices> = {
59
+ imports: {
60
+ ImportResolver: (services) => new ImportResolver(services),
61
+ WorkspaceManager: () => new WorkspaceManager({ autoResolve: false, allowNetwork: false })
62
+ },
63
+ references: {
64
+ ScopeComputation: (services) => new DomainLangScopeComputation(services),
65
+ QualifiedNameProvider: () => new QualifiedNameProvider()
66
+ },
67
+ lsp: {
68
+ Formatter: () => new DomainLangFormatter(),
69
+ HoverProvider: (services) => new DomainLangHoverProvider(services),
70
+ CompletionProvider: (services) => new DomainLangCompletionProvider(services),
71
+ CodeActionProvider: () => new DomainLangCodeActionProvider()
72
+ },
73
+ };
74
+
75
+ /**
76
+ * Create the full set of services required by Langium.
77
+ *
78
+ * First inject the shared services by merging two modules:
79
+ * - Langium default shared services
80
+ * - Services generated by langium-cli
81
+ *
82
+ * Then inject the language-specific services by merging three modules:
83
+ * - Langium default language-specific services
84
+ * - Services generated by langium-cli
85
+ * - Services specified in this file
86
+ *
87
+ * @param context Optional module context with the LSP connection
88
+ * @returns An object wrapping the shared services and the language-specific services
89
+ */
90
+ export function createDomainLangServices(context: DefaultSharedModuleContext): {
91
+ shared: LangiumSharedServices,
92
+ DomainLang: DomainLangServices
93
+ } {
94
+ const shared = inject(
95
+ createDefaultSharedModule(context),
96
+ DomainLangGeneratedSharedModule,
97
+ DomainLangSharedModule
98
+ );
99
+ const DomainLang = inject(
100
+ createDefaultModule({ shared }),
101
+ DomainLangGeneratedModule,
102
+ DomainLangModule
103
+ );
104
+ shared.ServiceRegistry.register(DomainLang);
105
+ registerValidationChecks(DomainLang);
106
+ if (!context.connection) {
107
+ // We don't run inside a language server
108
+ // Therefore, initialize the configuration provider instantly
109
+ shared.workspace.ConfigurationProvider.initialized({});
110
+ }
111
+ return { shared, DomainLang };
112
+ }