@likec4/language-server 1.1.1 → 1.2.1

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 (173) hide show
  1. package/contrib/likec4.monarch.ts +4 -4
  2. package/contrib/likec4.tmLanguage.json +1 -1
  3. package/package.json +8 -10
  4. package/src/Rpc.ts +108 -0
  5. package/src/ast.ts +443 -0
  6. package/src/browser/index.ts +30 -0
  7. package/src/elementRef.ts +26 -0
  8. package/src/generated/ast.ts +1632 -0
  9. package/src/generated/grammar.ts +10 -0
  10. package/src/generated/module.ts +32 -0
  11. package/src/index.ts +4 -0
  12. package/src/like-c4.langium +395 -0
  13. package/src/logger.ts +54 -0
  14. package/src/lsp/CodeLensProvider.ts +51 -0
  15. package/src/lsp/DocumentHighlightProvider.ts +12 -0
  16. package/src/lsp/DocumentLinkProvider.test.ts +66 -0
  17. package/src/lsp/DocumentLinkProvider.ts +53 -0
  18. package/src/lsp/DocumentSymbolProvider.ts +201 -0
  19. package/src/lsp/HoverProvider.ts +58 -0
  20. package/{dist/lsp/SemanticTokenProvider.js → src/lsp/SemanticTokenProvider.ts} +58 -43
  21. package/src/lsp/index.ts +6 -0
  22. package/src/model/fqn-computation.ts +47 -0
  23. package/src/model/fqn-index.ts +161 -0
  24. package/src/model/index.ts +5 -0
  25. package/src/model/model-builder.ts +447 -0
  26. package/src/model/model-locator.ts +130 -0
  27. package/src/model/model-parser.ts +580 -0
  28. package/src/model-change/ModelChanges.ts +120 -0
  29. package/src/model-change/changeElementStyle.ts +176 -0
  30. package/src/model-change/changeViewLayout.ts +41 -0
  31. package/src/module.ts +197 -0
  32. package/src/node/index.ts +20 -0
  33. package/src/protocol.ts +87 -0
  34. package/src/references/index.ts +2 -0
  35. package/src/references/scope-computation.ts +142 -0
  36. package/src/references/scope-provider.ts +166 -0
  37. package/src/shared/NodeKindProvider.ts +67 -0
  38. package/src/shared/WorkspaceManager.ts +39 -0
  39. package/src/shared/WorkspaceSymbolProvider.ts +3 -0
  40. package/src/shared/index.ts +3 -0
  41. package/src/test/index.ts +1 -0
  42. package/src/test/testServices.ts +119 -0
  43. package/src/utils/index.ts +1 -0
  44. package/src/utils/printDocs.ts +3 -0
  45. package/src/utils/stringHash.ts +6 -0
  46. package/src/validation/dynamic-view-rule.ts +35 -0
  47. package/src/validation/dynamic-view-step.ts +39 -0
  48. package/src/validation/element.ts +52 -0
  49. package/{dist/validation/index.js → src/validation/index.ts} +25 -17
  50. package/src/validation/property-checks.ts +17 -0
  51. package/src/validation/relation.ts +57 -0
  52. package/src/validation/specification.ts +118 -0
  53. package/src/validation/view-predicates/custom-element-expr.ts +21 -0
  54. package/src/validation/view-predicates/expanded-element.ts +34 -0
  55. package/src/validation/view-predicates/incoming.ts +19 -0
  56. package/src/validation/view-predicates/index.ts +4 -0
  57. package/src/validation/view-predicates/outgoing.ts +19 -0
  58. package/src/validation/view.ts +26 -0
  59. package/src/view-utils/assignNavigateTo.ts +30 -0
  60. package/src/view-utils/index.ts +3 -0
  61. package/src/view-utils/resolve-extended-views.ts +57 -0
  62. package/src/view-utils/resolve-relative-paths.ts +84 -0
  63. package/dist/Rpc.d.ts +0 -10
  64. package/dist/Rpc.js +0 -98
  65. package/dist/ast.d.ts +0 -133
  66. package/dist/ast.js +0 -267
  67. package/dist/browser/index.d.ts +0 -9
  68. package/dist/browser/index.js +0 -16
  69. package/dist/elementRef.d.ts +0 -12
  70. package/dist/elementRef.js +0 -15
  71. package/dist/generated/ast.d.ts +0 -559
  72. package/dist/generated/ast.js +0 -868
  73. package/dist/generated/grammar.d.ts +0 -7
  74. package/dist/generated/grammar.js +0 -3
  75. package/dist/generated/module.d.ts +0 -14
  76. package/dist/generated/module.js +0 -22
  77. package/dist/index.d.ts +0 -5
  78. package/dist/index.js +0 -2
  79. package/dist/logger.d.ts +0 -12
  80. package/dist/logger.js +0 -51
  81. package/dist/lsp/CodeLensProvider.d.ts +0 -10
  82. package/dist/lsp/CodeLensProvider.js +0 -37
  83. package/dist/lsp/DocumentHighlightProvider.d.ts +0 -10
  84. package/dist/lsp/DocumentHighlightProvider.js +0 -10
  85. package/dist/lsp/DocumentLinkProvider.d.ts +0 -11
  86. package/dist/lsp/DocumentLinkProvider.js +0 -41
  87. package/dist/lsp/DocumentLinkProvider.test.d.ts +0 -2
  88. package/dist/lsp/DocumentLinkProvider.test.js +0 -54
  89. package/dist/lsp/DocumentSymbolProvider.d.ts +0 -22
  90. package/dist/lsp/DocumentSymbolProvider.js +0 -184
  91. package/dist/lsp/HoverProvider.d.ts +0 -10
  92. package/dist/lsp/HoverProvider.js +0 -36
  93. package/dist/lsp/SemanticTokenProvider.d.ts +0 -8
  94. package/dist/lsp/index.d.ts +0 -7
  95. package/dist/lsp/index.js +0 -6
  96. package/dist/model/fqn-computation.d.ts +0 -4
  97. package/dist/model/fqn-computation.js +0 -43
  98. package/dist/model/fqn-index.d.ts +0 -26
  99. package/dist/model/fqn-index.js +0 -114
  100. package/dist/model/index.d.ts +0 -6
  101. package/dist/model/index.js +0 -5
  102. package/dist/model/model-builder.d.ts +0 -20
  103. package/dist/model/model-builder.js +0 -352
  104. package/dist/model/model-locator.d.ts +0 -22
  105. package/dist/model/model-locator.js +0 -119
  106. package/dist/model/model-parser.d.ts +0 -27
  107. package/dist/model/model-parser.js +0 -410
  108. package/dist/model-change/ModelChanges.d.ts +0 -15
  109. package/dist/model-change/ModelChanges.js +0 -100
  110. package/dist/model-change/changeElementStyle.d.ts +0 -15
  111. package/dist/model-change/changeElementStyle.js +0 -141
  112. package/dist/model-change/changeViewLayout.d.ts +0 -13
  113. package/dist/model-change/changeViewLayout.js +0 -30
  114. package/dist/module.d.ts +0 -59
  115. package/dist/module.js +0 -121
  116. package/dist/node/index.d.ts +0 -6
  117. package/dist/node/index.js +0 -13
  118. package/dist/protocol.d.ts +0 -58
  119. package/dist/protocol.js +0 -14
  120. package/dist/references/index.d.ts +0 -3
  121. package/dist/references/index.js +0 -2
  122. package/dist/references/scope-computation.d.ts +0 -11
  123. package/dist/references/scope-computation.js +0 -108
  124. package/dist/references/scope-provider.d.ts +0 -18
  125. package/dist/references/scope-provider.js +0 -136
  126. package/dist/shared/NodeKindProvider.d.ts +0 -16
  127. package/dist/shared/NodeKindProvider.js +0 -58
  128. package/dist/shared/WorkspaceManager.d.ts +0 -17
  129. package/dist/shared/WorkspaceManager.js +0 -29
  130. package/dist/shared/WorkspaceSymbolProvider.d.ts +0 -4
  131. package/dist/shared/WorkspaceSymbolProvider.js +0 -3
  132. package/dist/shared/index.d.ts +0 -4
  133. package/dist/shared/index.js +0 -3
  134. package/dist/test/index.d.ts +0 -2
  135. package/dist/test/index.js +0 -1
  136. package/dist/test/testServices.d.ts +0 -23
  137. package/dist/test/testServices.js +0 -102
  138. package/dist/utils/index.d.ts +0 -2
  139. package/dist/utils/index.js +0 -1
  140. package/dist/utils/printDocs.d.ts +0 -3
  141. package/dist/utils/printDocs.js +0 -1
  142. package/dist/utils/stringHash.d.ts +0 -2
  143. package/dist/utils/stringHash.js +0 -5
  144. package/dist/validation/element.d.ts +0 -6
  145. package/dist/validation/element.js +0 -38
  146. package/dist/validation/index.d.ts +0 -3
  147. package/dist/validation/property-checks.d.ts +0 -5
  148. package/dist/validation/property-checks.js +0 -11
  149. package/dist/validation/relation.d.ts +0 -5
  150. package/dist/validation/relation.js +0 -50
  151. package/dist/validation/specification.d.ts +0 -10
  152. package/dist/validation/specification.js +0 -97
  153. package/dist/validation/view-predicates/custom-element-expr.d.ts +0 -5
  154. package/dist/validation/view-predicates/custom-element-expr.js +0 -16
  155. package/dist/validation/view-predicates/expanded-element.d.ts +0 -5
  156. package/dist/validation/view-predicates/expanded-element.js +0 -28
  157. package/dist/validation/view-predicates/incoming.d.ts +0 -5
  158. package/dist/validation/view-predicates/incoming.js +0 -14
  159. package/dist/validation/view-predicates/index.d.ts +0 -5
  160. package/dist/validation/view-predicates/index.js +0 -4
  161. package/dist/validation/view-predicates/outgoing.d.ts +0 -5
  162. package/dist/validation/view-predicates/outgoing.js +0 -14
  163. package/dist/validation/view.d.ts +0 -5
  164. package/dist/validation/view.js +0 -18
  165. package/dist/view-utils/assignNavigateTo.d.ts +0 -3
  166. package/dist/view-utils/assignNavigateTo.js +0 -23
  167. package/dist/view-utils/index.d.ts +0 -4
  168. package/dist/view-utils/index.js +0 -3
  169. package/dist/view-utils/resolve-extended-views.d.ts +0 -7
  170. package/dist/view-utils/resolve-extended-views.js +0 -41
  171. package/dist/view-utils/resolve-relative-paths.d.ts +0 -3
  172. package/dist/view-utils/resolve-relative-paths.js +0 -76
  173. /package/{dist → src}/reset.d.ts +0 -0
@@ -1,17 +0,0 @@
1
- /// <reference types="node" />
2
- import type { LangiumDocument } from 'langium';
3
- import { DefaultWorkspaceManager } from 'langium';
4
- import type { WorkspaceFolder } from 'vscode-languageserver';
5
- import { URI } from 'vscode-uri';
6
- export declare class LikeC4WorkspaceManager extends DefaultWorkspaceManager {
7
- /**
8
- * Load all additional documents that shall be visible in the context of the given workspace
9
- * folders and add them to the collector. This can be used to include built-in libraries of
10
- * your language, which can be either loaded from provided files or constructed in memory.
11
- */
12
- protected loadAdditionalDocuments(_folders: WorkspaceFolder[], _collector: (document: LangiumDocument) => void): Promise<void>;
13
- workspace(): WorkspaceFolder | null;
14
- get workspaceUri(): URI;
15
- get workspaceURL(): import("url").URL;
16
- }
17
- //# sourceMappingURL=WorkspaceManager.d.ts.map
@@ -1,29 +0,0 @@
1
- import { hasAtLeast, invariant } from "@likec4/core";
2
- import { DefaultWorkspaceManager } from "langium";
3
- import { URI } from "vscode-uri";
4
- export class LikeC4WorkspaceManager extends DefaultWorkspaceManager {
5
- /**
6
- * Load all additional documents that shall be visible in the context of the given workspace
7
- * folders and add them to the collector. This can be used to include built-in libraries of
8
- * your language, which can be either loaded from provided files or constructed in memory.
9
- */
10
- loadAdditionalDocuments(_folders, _collector) {
11
- return Promise.resolve();
12
- }
13
- workspace() {
14
- if (this.folders && hasAtLeast(this.folders, 1)) {
15
- return this.folders[0];
16
- }
17
- return null;
18
- }
19
- get workspaceUri() {
20
- const workspace = this.workspace();
21
- invariant(workspace, "Workspace not initialized");
22
- return URI.parse(workspace.uri);
23
- }
24
- get workspaceURL() {
25
- const workspace = this.workspace();
26
- invariant(workspace, "Workspace not initialized");
27
- return new URL(workspace.uri);
28
- }
29
- }
@@ -1,4 +0,0 @@
1
- import { DefaultWorkspaceSymbolProvider } from 'langium/lsp';
2
- export declare class WorkspaceSymbolProvider extends DefaultWorkspaceSymbolProvider {
3
- }
4
- //# sourceMappingURL=WorkspaceSymbolProvider.d.ts.map
@@ -1,3 +0,0 @@
1
- import { DefaultWorkspaceSymbolProvider } from "langium/lsp";
2
- export class WorkspaceSymbolProvider extends DefaultWorkspaceSymbolProvider {
3
- }
@@ -1,4 +0,0 @@
1
- export * from './NodeKindProvider';
2
- export * from './WorkspaceManager';
3
- export * from './WorkspaceSymbolProvider';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1,3 +0,0 @@
1
- export * from "./NodeKindProvider.js";
2
- export * from "./WorkspaceManager.js";
3
- export * from "./WorkspaceSymbolProvider.js";
@@ -1,2 +0,0 @@
1
- export * from './testServices';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- export * from "./testServices.js";
@@ -1,23 +0,0 @@
1
- import { type Diagnostic } from 'vscode-languageserver-protocol';
2
- import type { LikeC4LangiumDocument } from '../ast';
3
- export declare function createTestServices(workspace?: string): {
4
- services: import("../module").LikeC4Services;
5
- parse: (input: string, uri?: string) => Promise<LikeC4LangiumDocument>;
6
- validate: (input: string | LikeC4LangiumDocument, uri?: string) => Promise<{
7
- document: LikeC4LangiumDocument;
8
- diagnostics: (Diagnostic & import("langium").DiagnosticInfo<import("../ast").LikeC4AstNode>)[];
9
- warnings: string[];
10
- errors: string[];
11
- }>;
12
- validateAll: () => Promise<{
13
- diagnostics: Diagnostic[];
14
- errors: string[];
15
- warnings: string[];
16
- }>;
17
- buildModel: () => Promise<import("@likec4/core").LikeC4ComputedModel>;
18
- resetState: () => Promise<void>;
19
- };
20
- export type TestServices = ReturnType<typeof createTestServices>;
21
- export type TestParseFn = TestServices['validate'];
22
- export type TestValidateFn = TestServices['validate'];
23
- //# sourceMappingURL=testServices.d.ts.map
@@ -1,102 +0,0 @@
1
- import { DocumentState, EmptyFileSystem } from "langium";
2
- import * as assert from "node:assert";
3
- import stripIndent from "strip-indent";
4
- import { DiagnosticSeverity } from "vscode-languageserver-protocol";
5
- import { URI, Utils } from "vscode-uri";
6
- import { createLanguageServices } from "../module.js";
7
- export function createTestServices(workspace = "file:///test/workspace") {
8
- const services = createLanguageServices(EmptyFileSystem).likec4;
9
- const metaData = services.LanguageMetaData;
10
- const langiumDocuments = services.shared.workspace.LangiumDocuments;
11
- const documentBuilder = services.shared.workspace.DocumentBuilder;
12
- const modelBuilder = services.likec4.ModelBuilder;
13
- const workspaceUri = URI.parse(workspace);
14
- const workspaceFolder = {
15
- name: "test",
16
- uri: workspaceUri.toString()
17
- };
18
- let isInitialized = false;
19
- let documentIndex = 1;
20
- const parse = async (input, uri) => {
21
- if (!isInitialized) {
22
- await services.shared.workspace.WorkspaceLock.write(async (_cancelToken) => {
23
- if (isInitialized) {
24
- return;
25
- }
26
- isInitialized = true;
27
- await services.shared.workspace.WorkspaceManager.initializeWorkspace([workspaceFolder]);
28
- Object.assign(services.shared.workspace.WorkspaceManager, {
29
- folders: [workspaceFolder]
30
- });
31
- });
32
- }
33
- const docUri = Utils.resolvePath(
34
- workspaceUri,
35
- "./src/",
36
- uri ?? `${documentIndex++}${metaData.fileExtensions[0]}`
37
- );
38
- const document = services.shared.workspace.LangiumDocumentFactory.fromString(
39
- stripIndent(input),
40
- docUri
41
- );
42
- langiumDocuments.addDocument(document);
43
- await services.shared.workspace.WorkspaceLock.write(async (_cancelToken) => {
44
- await documentBuilder.build([document], { validation: false });
45
- });
46
- return document;
47
- };
48
- const validate = async (input, uri) => {
49
- const document = typeof input === "string" ? await parse(input, uri) : input;
50
- await services.shared.workspace.WorkspaceLock.write(async (_cancelToken) => {
51
- await documentBuilder.build([document], { validation: true });
52
- });
53
- const diagnostics = document.diagnostics ?? [];
54
- const warnings = diagnostics.flatMap((d) => d.severity === DiagnosticSeverity.Warning ? d.message : []);
55
- const errors = diagnostics.flatMap((d) => d.severity === DiagnosticSeverity.Error ? d.message : []);
56
- return {
57
- document,
58
- diagnostics,
59
- warnings,
60
- errors
61
- };
62
- };
63
- let previousPromise = Promise.resolve();
64
- const validateAll = async () => {
65
- await services.shared.workspace.WorkspaceLock.write(async (_cancelToken) => {
66
- const docs2 = langiumDocuments.all.toArray();
67
- await documentBuilder.build(docs2, { validation: true });
68
- });
69
- await documentBuilder.waitUntil(DocumentState.Validated);
70
- const docs = langiumDocuments.all.toArray();
71
- assert.ok(docs.length > 0, "no documents to validate");
72
- const diagnostics = docs.flatMap((doc) => doc.diagnostics ?? []);
73
- const warnings = diagnostics.flatMap((d) => d.severity === DiagnosticSeverity.Warning ? d.message : []);
74
- const errors = diagnostics.flatMap((d) => d.severity === DiagnosticSeverity.Error ? d.message : []);
75
- return {
76
- diagnostics,
77
- errors,
78
- warnings
79
- };
80
- };
81
- const buildModel = async () => {
82
- await validateAll();
83
- const model = await modelBuilder.buildComputedModel();
84
- if (!model)
85
- throw new Error("No model found");
86
- return model;
87
- };
88
- const resetState = async () => {
89
- await services.shared.workspace.WorkspaceLock.write(async (cancelToken) => {
90
- const docs = langiumDocuments.all.toArray().map((doc) => doc.uri);
91
- await documentBuilder.update([], docs, cancelToken);
92
- });
93
- };
94
- return {
95
- services,
96
- parse,
97
- validate,
98
- validateAll,
99
- buildModel,
100
- resetState
101
- };
102
- }
@@ -1,2 +0,0 @@
1
- export * from './stringHash';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- export * from "./stringHash.js";
@@ -1,3 +0,0 @@
1
- import type { LangiumDocument } from 'langium';
2
- export declare const printDocs: (docs: LangiumDocument[]) => string;
3
- //# sourceMappingURL=printDocs.d.ts.map
@@ -1 +0,0 @@
1
- export const printDocs = (docs) => docs.map((d) => " - " + d.uri.toString(true)).join("\n");
@@ -1,2 +0,0 @@
1
- export declare function stringHash(...str: [string, ...string[]]): string;
2
- //# sourceMappingURL=stringHash.d.ts.map
@@ -1,5 +0,0 @@
1
- import hash from "string-hash";
2
- export function stringHash(...str) {
3
- var s = str.length > 1 ? str.join(":::") : str[0];
4
- return hash(s).toString(36);
5
- }
@@ -1,6 +0,0 @@
1
- /// <reference types="react" />
2
- import { type ValidationCheck } from 'langium';
3
- import type { ast } from '../ast';
4
- import type { LikeC4Services } from '../module';
5
- export declare const elementChecks: (services: LikeC4Services) => ValidationCheck<ast.Element>;
6
- //# sourceMappingURL=element.d.ts.map
@@ -1,38 +0,0 @@
1
- import { AstUtils } from "langium";
2
- const { getDocument } = AstUtils;
3
- export const elementChecks = (services) => {
4
- const fqnIndex = services.likec4.FqnIndex;
5
- return (el, accept) => {
6
- const fqn = fqnIndex.getFqn(el);
7
- if (!fqn) {
8
- accept("error", "Not indexed element", {
9
- node: el,
10
- property: "name"
11
- });
12
- return;
13
- }
14
- const withSameFqn = fqnIndex.byFqn(fqn).filter((v) => v.el !== el).head();
15
- if (withSameFqn) {
16
- const isAnotherDoc = withSameFqn.doc.uri !== getDocument(el).uri;
17
- accept(
18
- "error",
19
- `Duplicate element name ${el.name !== fqn ? el.name + " (" + fqn + ")" : el.name}`,
20
- {
21
- node: el,
22
- property: "name",
23
- ...isAnotherDoc && {
24
- relatedInformation: [
25
- {
26
- location: {
27
- range: withSameFqn.el.$cstNode.range,
28
- uri: withSameFqn.doc.uri.toString()
29
- },
30
- message: `conflicting element`
31
- }
32
- ]
33
- }
34
- }
35
- );
36
- }
37
- };
38
- };
@@ -1,3 +0,0 @@
1
- import type { LikeC4Services } from '../module';
2
- export declare function registerValidationChecks(services: LikeC4Services): void;
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,5 +0,0 @@
1
- import type { ValidationCheck } from 'langium';
2
- import type { ast } from '../ast';
3
- import type { LikeC4Services } from '../module';
4
- export declare const opacityPropertyRuleChecks: (_: LikeC4Services) => ValidationCheck<ast.OpacityProperty>;
5
- //# sourceMappingURL=property-checks.d.ts.map
@@ -1,11 +0,0 @@
1
- export const opacityPropertyRuleChecks = (_) => {
2
- return (node, accept) => {
3
- const opacity = parseFloat(node.value);
4
- if (isNaN(opacity) || opacity < 0 || opacity > 100) {
5
- accept("warning", `Value ignored, must be between 0% and 100%`, {
6
- node,
7
- property: "value"
8
- });
9
- }
10
- };
11
- };
@@ -1,5 +0,0 @@
1
- import type { ValidationCheck } from 'langium';
2
- import { ast } from '../ast';
3
- import type { LikeC4Services } from '../module';
4
- export declare const relationChecks: (services: LikeC4Services) => ValidationCheck<ast.Relation>;
5
- //# sourceMappingURL=relation.d.ts.map
@@ -1,50 +0,0 @@
1
- import { isSameHierarchy } from "@likec4/core";
2
- import { ast } from "../ast.js";
3
- import { elementRef } from "../elementRef.js";
4
- import { logError } from "../logger.js";
5
- export const relationChecks = (services) => {
6
- const fqnIndex = services.likec4.FqnIndex;
7
- return (el, accept) => {
8
- try {
9
- const targetEl = elementRef(el.target);
10
- const target = targetEl && fqnIndex.getFqn(targetEl);
11
- if (!target) {
12
- accept("error", "Target not found (not parsed/indexed yet)", {
13
- node: el,
14
- property: "target"
15
- });
16
- }
17
- let sourceEl;
18
- if (ast.isExplicitRelation(el)) {
19
- sourceEl = elementRef(el.source);
20
- if (!sourceEl) {
21
- return accept("error", "Source not found (not parsed/indexed yet)", {
22
- node: el,
23
- property: "source"
24
- });
25
- }
26
- } else {
27
- sourceEl = el.$container.$container;
28
- }
29
- const source = fqnIndex.getFqn(sourceEl);
30
- if (!source) {
31
- accept("error", "Source not found (not parsed/indexed yet)", {
32
- node: el
33
- });
34
- }
35
- if (source && target && isSameHierarchy(source, target)) {
36
- accept("error", "Invalid parent-child relationship", {
37
- node: el
38
- });
39
- }
40
- if (el.tags?.value && el.body?.tags?.value) {
41
- accept("error", "Relation cannot have tags in both header and body", {
42
- node: el,
43
- property: "tags"
44
- });
45
- }
46
- } catch (e) {
47
- logError(e);
48
- }
49
- };
50
- };
@@ -1,10 +0,0 @@
1
- import { type ValidationCheck } from 'langium';
2
- import { ast } from '../ast';
3
- import type { LikeC4Services } from '../module';
4
- export declare const specificationRuleChecks: (_: LikeC4Services) => ValidationCheck<ast.SpecificationRule>;
5
- export declare const modelRuleChecks: (_: LikeC4Services) => ValidationCheck<ast.Model>;
6
- export declare const modelViewsChecks: (_: LikeC4Services) => ValidationCheck<ast.ModelViews>;
7
- export declare const elementKindChecks: (services: LikeC4Services) => ValidationCheck<ast.ElementKind>;
8
- export declare const tagChecks: (services: LikeC4Services) => ValidationCheck<ast.Tag>;
9
- export declare const relationshipChecks: (services: LikeC4Services) => ValidationCheck<ast.RelationshipKind>;
10
- //# sourceMappingURL=specification.d.ts.map
@@ -1,97 +0,0 @@
1
- import { AstUtils } from "langium";
2
- import { ast } from "../ast.js";
3
- export const specificationRuleChecks = (_) => {
4
- return (node, accept) => {
5
- if (node.$containerIndex && node.$containerIndex > 0) {
6
- accept("error", `Only one specification per document is allowed`, {
7
- node,
8
- property: "name"
9
- });
10
- }
11
- };
12
- };
13
- export const modelRuleChecks = (_) => {
14
- return (node, accept) => {
15
- if (node.$containerIndex && node.$containerIndex > 0) {
16
- accept("error", `Only one model per document is allowed`, {
17
- node,
18
- property: "name"
19
- });
20
- }
21
- };
22
- };
23
- export const modelViewsChecks = (_) => {
24
- return (node, accept) => {
25
- if (node.$containerIndex && node.$containerIndex > 0) {
26
- accept("error", `Only one views block per document is allowed`, {
27
- node,
28
- property: "name"
29
- });
30
- }
31
- };
32
- };
33
- export const elementKindChecks = (services) => {
34
- const index = services.shared.workspace.IndexManager;
35
- return (node, accept) => {
36
- const sameKind = index.allElements(ast.ElementKind).filter((n) => n.name === node.name && n.node !== node).head();
37
- if (sameKind) {
38
- const isAnotherDoc = sameKind.documentUri !== AstUtils.getDocument(node).uri;
39
- accept("error", `Duplicate element kind '${node.name}'`, {
40
- node,
41
- property: "name",
42
- ...isAnotherDoc && {
43
- relatedInformation: [
44
- {
45
- location: {
46
- range: sameKind.nameSegment.range,
47
- uri: sameKind.documentUri.toString()
48
- },
49
- message: `conflicting definition`
50
- }
51
- ]
52
- }
53
- });
54
- }
55
- };
56
- };
57
- export const tagChecks = (services) => {
58
- const index = services.shared.workspace.IndexManager;
59
- return (node, accept) => {
60
- const tagname = "#" + node.name;
61
- const sameTag = index.allElements(ast.Tag).filter((n) => n.name === tagname && n.node !== node).head();
62
- if (sameTag) {
63
- const isAnotherDoc = sameTag.documentUri !== AstUtils.getDocument(node).uri;
64
- accept(
65
- "error",
66
- `Duplicate tag '${node.name}'`,
67
- {
68
- node,
69
- property: "name",
70
- ...isAnotherDoc && {
71
- relatedInformation: [
72
- {
73
- location: {
74
- range: sameTag.nameSegment.range,
75
- uri: sameTag.documentUri.toString()
76
- },
77
- message: `conflicting definition`
78
- }
79
- ]
80
- }
81
- }
82
- );
83
- }
84
- };
85
- };
86
- export const relationshipChecks = (services) => {
87
- const index = services.shared.workspace.IndexManager;
88
- return (node, accept) => {
89
- const sameKinds = index.allElements(ast.RelationshipKind).filter((n) => n.name === node.name).limit(2).count();
90
- if (sameKinds > 1) {
91
- accept("error", `Duplicate RelationshipKind '${node.name}'`, {
92
- node,
93
- property: "name"
94
- });
95
- }
96
- };
97
- };
@@ -1,5 +0,0 @@
1
- import type { ValidationCheck } from 'langium';
2
- import { ast } from '../../ast';
3
- import type { LikeC4Services } from '../../module';
4
- export declare const customElementExprChecks: (_services: LikeC4Services) => ValidationCheck<ast.CustomElementExpr>;
5
- //# sourceMappingURL=custom-element-expr.d.ts.map
@@ -1,16 +0,0 @@
1
- import { ast } from "../../ast.js";
2
- export const customElementExprChecks = (_services) => {
3
- return (el, accept) => {
4
- if (ast.isExcludePredicate(el.$container)) {
5
- accept("error", 'Invalid inside "exclude"', {
6
- node: el
7
- });
8
- }
9
- if (!ast.isElementRef(el.target)) {
10
- accept("error", "Invalid target for customization", {
11
- node: el,
12
- property: "target"
13
- });
14
- }
15
- };
16
- };
@@ -1,5 +0,0 @@
1
- import type { ValidationCheck } from 'langium';
2
- import { ast } from '../../ast';
3
- import type { LikeC4Services } from '../../module';
4
- export declare const expandElementExprChecks: (_services: LikeC4Services) => ValidationCheck<ast.ExpandElementExpr>;
5
- //# sourceMappingURL=expanded-element.d.ts.map
@@ -1,28 +0,0 @@
1
- import { nonexhaustive } from "@likec4/core";
2
- import { ast } from "../../ast.js";
3
- export const expandElementExprChecks = (_services) => {
4
- return (el, accept) => {
5
- switch (true) {
6
- case ast.isIncludePredicate(el.$container):
7
- case ast.isViewRuleStyle(el.$container):
8
- return;
9
- case ast.isCustomElementExpr(el.$container):
10
- return accept("warning", `Custom rules apply only to parent`, {
11
- node: el
12
- });
13
- case ast.isExcludePredicate(el.$container):
14
- return accept("warning", `Ignored, as can't be used in exclude`, {
15
- node: el
16
- });
17
- case ast.isInOutExpr(el.$container):
18
- case ast.isIncomingExpr(el.$container):
19
- case ast.isOutgoingExpr(el.$container):
20
- case ast.isRelationExpr(el.$container):
21
- return accept("warning", `Wrong usage of expanded element in relations predicate`, {
22
- node: el
23
- });
24
- default:
25
- nonexhaustive(el.$container);
26
- }
27
- };
28
- };
@@ -1,5 +0,0 @@
1
- import type { ValidationCheck } from 'langium';
2
- import { ast } from '../../ast';
3
- import type { LikeC4Services } from '../../module';
4
- export declare const incomingExpressionChecks: (_services: LikeC4Services) => ValidationCheck<ast.IncomingExpr>;
5
- //# sourceMappingURL=incoming.d.ts.map
@@ -1,14 +0,0 @@
1
- import { isNullish } from "remeda";
2
- import { ast } from "../../ast.js";
3
- export const incomingExpressionChecks = (_services) => {
4
- return (el, accept) => {
5
- if (ast.isWildcardExpr(el.to) && ast.isViewRulePredicate(el.$container)) {
6
- const view = el.$container.$container.$container;
7
- if (isNullish(view.viewOf)) {
8
- accept("warning", "Predicate is ignored as it concerns all relationships", {
9
- node: el
10
- });
11
- }
12
- }
13
- };
14
- };
@@ -1,5 +0,0 @@
1
- export * from './custom-element-expr';
2
- export * from './expanded-element';
3
- export * from './incoming';
4
- export * from './outgoing';
5
- //# sourceMappingURL=index.d.ts.map
@@ -1,4 +0,0 @@
1
- export * from "./custom-element-expr.js";
2
- export * from "./expanded-element.js";
3
- export * from "./incoming.js";
4
- export * from "./outgoing.js";
@@ -1,5 +0,0 @@
1
- import type { ValidationCheck } from 'langium';
2
- import { ast } from '../../ast';
3
- import type { LikeC4Services } from '../../module';
4
- export declare const outgoingExpressionChecks: (_services: LikeC4Services) => ValidationCheck<ast.OutgoingExpr>;
5
- //# sourceMappingURL=outgoing.d.ts.map
@@ -1,14 +0,0 @@
1
- import { isNil } from "remeda";
2
- import { ast } from "../../ast.js";
3
- export const outgoingExpressionChecks = (_services) => {
4
- return (el, accept) => {
5
- if (ast.isWildcardExpr(el.from)) {
6
- const view = el.$container.$container.$container;
7
- if (isNil(view.viewOf)) {
8
- accept("warning", "Predicate is ignored as it concerns all relationships", {
9
- node: el
10
- });
11
- }
12
- }
13
- };
14
- };
@@ -1,5 +0,0 @@
1
- import type { ValidationCheck } from 'langium';
2
- import { ast } from '../ast';
3
- import type { LikeC4Services } from '../module';
4
- export declare const viewChecks: (services: LikeC4Services) => ValidationCheck<ast.ElementView>;
5
- //# sourceMappingURL=view.d.ts.map
@@ -1,18 +0,0 @@
1
- import { ast } from "../ast.js";
2
- export const viewChecks = (services) => {
3
- const index = services.shared.workspace.IndexManager;
4
- return (el, accept) => {
5
- if (el.extends) {
6
- }
7
- if (!el.name) {
8
- return;
9
- }
10
- const anotherViews = index.allElements(ast.ElementView).filter((n) => n.name === el.name).limit(2).count();
11
- if (anotherViews > 1) {
12
- accept("error", `Duplicate view '${el.name}'`, {
13
- node: el,
14
- property: "name"
15
- });
16
- }
17
- };
18
- };
@@ -1,3 +0,0 @@
1
- import type { ComputedView } from '@likec4/core';
2
- export declare function assignNavigateTo<R extends Iterable<ComputedView>>(views: R): R;
3
- //# sourceMappingURL=assignNavigateTo.d.ts.map
@@ -1,23 +0,0 @@
1
- import { find } from "remeda";
2
- export function assignNavigateTo(views) {
3
- const allElementViews = /* @__PURE__ */ new Map();
4
- for (const v of views) {
5
- if (v.viewOf && !v.extends) {
6
- const viewsOf = allElementViews.get(v.viewOf) ?? [];
7
- viewsOf.push(v.id);
8
- allElementViews.set(v.viewOf, viewsOf);
9
- }
10
- }
11
- for (const { id, nodes } of views) {
12
- for (const node of nodes) {
13
- if (node.navigateTo) {
14
- continue;
15
- }
16
- const navigateTo = find(allElementViews.get(node.id) ?? [], (v) => v !== id);
17
- if (navigateTo) {
18
- node.navigateTo = navigateTo;
19
- }
20
- }
21
- }
22
- return views;
23
- }
@@ -1,4 +0,0 @@
1
- export * from './assignNavigateTo';
2
- export * from './resolve-extended-views';
3
- export * from './resolve-relative-paths';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1,3 +0,0 @@
1
- export * from "./assignNavigateTo.js";
2
- export * from "./resolve-extended-views.js";
3
- export * from "./resolve-relative-paths.js";