@likec4/language-server 1.46.3 → 1.47.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.
Files changed (53) hide show
  1. package/dist/LikeC4LanguageServices.d.ts +27 -21
  2. package/dist/LikeC4LanguageServices.js +24 -14
  3. package/dist/Rpc.js +9 -3
  4. package/dist/ast.d.ts +1 -1
  5. package/dist/browser.d.ts +0 -1
  6. package/dist/browser.js +0 -1
  7. package/dist/bundled.mjs +3773 -3536
  8. package/dist/filesystem/ChokidarWatcher.d.ts +3 -0
  9. package/dist/filesystem/ChokidarWatcher.js +67 -42
  10. package/dist/filesystem/LikeC4FileSystem.d.ts +1 -1
  11. package/dist/filesystem/LikeC4FileSystem.js +16 -6
  12. package/dist/generated/ast.d.ts +2 -2
  13. package/dist/generated/ast.js +3 -3
  14. package/dist/generated/grammar.js +1 -1
  15. package/dist/generated-lib/icons.js +7 -1
  16. package/dist/index.d.ts +0 -1
  17. package/dist/index.js +0 -1
  18. package/dist/lsp/CodeLensProvider.js +1 -1
  19. package/dist/lsp/CompletionProvider.d.ts +4 -2
  20. package/dist/lsp/CompletionProvider.js +41 -3
  21. package/dist/lsp/DocumentSymbolProvider.js +1 -1
  22. package/dist/lsp/SemanticTokenProvider.d.ts +8 -1
  23. package/dist/lsp/SemanticTokenProvider.js +52 -11
  24. package/dist/mcp/interfaces.d.ts +1 -1
  25. package/dist/mcp/interfaces.js +0 -1
  26. package/dist/mcp/server/StreamableLikeC4MCPServer.js +27 -51
  27. package/dist/mcp/tools/_common.d.ts +2 -2
  28. package/dist/mcp/tools/find-relationships.d.ts +195 -5
  29. package/dist/mcp/tools/list-projects.d.ts +191 -3
  30. package/dist/mcp/tools/open-view.d.ts +194 -4
  31. package/dist/mcp/tools/read-deployment.d.ts +194 -4
  32. package/dist/mcp/tools/read-element.d.ts +194 -4
  33. package/dist/mcp/tools/read-project-summary.d.ts +193 -3
  34. package/dist/mcp/tools/read-view.d.ts +194 -4
  35. package/dist/mcp/tools/search-element.d.ts +193 -3
  36. package/dist/model/model-builder.d.ts +4 -2
  37. package/dist/model/model-builder.js +58 -57
  38. package/dist/model/model-parser.d.ts +6 -6
  39. package/dist/model/parser/Base.js +58 -48
  40. package/dist/model/parser/GlobalsParser.d.ts +3 -3
  41. package/dist/model/parser/ViewsParser.js +2 -2
  42. package/dist/protocol.d.ts +5 -0
  43. package/dist/references/scope-provider.d.ts +1 -1
  44. package/dist/references/scope-provider.js +18 -21
  45. package/dist/utils/elementRef.js +10 -4
  46. package/dist/validation/index.d.ts +1 -1
  47. package/dist/workspace/IndexManager.js +4 -2
  48. package/dist/workspace/LangiumDocuments.d.ts +4 -0
  49. package/dist/workspace/LangiumDocuments.js +26 -9
  50. package/dist/workspace/ProjectsManager.d.ts +9 -3
  51. package/dist/workspace/ProjectsManager.js +141 -102
  52. package/package.json +16 -15
  53. package/lib/package.json +0 -159
@@ -3,6 +3,196 @@ export declare const searchElement: (languageServices: import("../..").LikeC4Lan
3
3
  inputSchema?: {
4
4
  search: z.ZodString;
5
5
  };
6
- }, (args: {
7
- search: string;
8
- }, extra: import("@modelcontextprotocol/sdk/shared/protocol.js").RequestHandlerExtra<import("@modelcontextprotocol/sdk/types.js").ServerRequest, import("@modelcontextprotocol/sdk/types.js").ServerNotification>) => import("@modelcontextprotocol/sdk/types.js").CallToolResult | Promise<import("@modelcontextprotocol/sdk/types.js").CallToolResult>];
6
+ }, (args: import("@modelcontextprotocol/sdk/server/zod-compat.js").ShapeOutput<{
7
+ search: z.ZodString;
8
+ }>, extra: import("@modelcontextprotocol/sdk/shared/protocol.js").RequestHandlerExtra<import("@modelcontextprotocol/sdk/types.js").ServerRequest, import("@modelcontextprotocol/sdk/types.js").ServerNotification>) => {
9
+ [x: string]: unknown;
10
+ content: ({
11
+ type: "text";
12
+ text: string;
13
+ annotations?: {
14
+ audience?: ("user" | "assistant")[] | undefined;
15
+ priority?: number | undefined;
16
+ lastModified?: string | undefined;
17
+ } | undefined;
18
+ _meta?: {
19
+ [x: string]: unknown;
20
+ } | undefined;
21
+ } | {
22
+ type: "image";
23
+ data: string;
24
+ mimeType: string;
25
+ annotations?: {
26
+ audience?: ("user" | "assistant")[] | undefined;
27
+ priority?: number | undefined;
28
+ lastModified?: string | undefined;
29
+ } | undefined;
30
+ _meta?: {
31
+ [x: string]: unknown;
32
+ } | undefined;
33
+ } | {
34
+ type: "audio";
35
+ data: string;
36
+ mimeType: string;
37
+ annotations?: {
38
+ audience?: ("user" | "assistant")[] | undefined;
39
+ priority?: number | undefined;
40
+ lastModified?: string | undefined;
41
+ } | undefined;
42
+ _meta?: {
43
+ [x: string]: unknown;
44
+ } | undefined;
45
+ } | {
46
+ uri: string;
47
+ name: string;
48
+ type: "resource_link";
49
+ description?: string | undefined;
50
+ mimeType?: string | undefined;
51
+ annotations?: {
52
+ audience?: ("user" | "assistant")[] | undefined;
53
+ priority?: number | undefined;
54
+ lastModified?: string | undefined;
55
+ } | undefined;
56
+ _meta?: {
57
+ [x: string]: unknown;
58
+ } | undefined;
59
+ icons?: {
60
+ src: string;
61
+ mimeType?: string | undefined;
62
+ sizes?: string[] | undefined;
63
+ theme?: "light" | "dark" | undefined;
64
+ }[] | undefined;
65
+ title?: string | undefined;
66
+ } | {
67
+ type: "resource";
68
+ resource: {
69
+ uri: string;
70
+ text: string;
71
+ mimeType?: string | undefined;
72
+ _meta?: {
73
+ [x: string]: unknown;
74
+ } | undefined;
75
+ } | {
76
+ uri: string;
77
+ blob: string;
78
+ mimeType?: string | undefined;
79
+ _meta?: {
80
+ [x: string]: unknown;
81
+ } | undefined;
82
+ };
83
+ annotations?: {
84
+ audience?: ("user" | "assistant")[] | undefined;
85
+ priority?: number | undefined;
86
+ lastModified?: string | undefined;
87
+ } | undefined;
88
+ _meta?: {
89
+ [x: string]: unknown;
90
+ } | undefined;
91
+ })[];
92
+ _meta?: {
93
+ [x: string]: unknown;
94
+ progressToken?: string | number | undefined;
95
+ "io.modelcontextprotocol/related-task"?: {
96
+ taskId: string;
97
+ } | undefined;
98
+ } | undefined;
99
+ structuredContent?: {
100
+ [x: string]: unknown;
101
+ } | undefined;
102
+ isError?: boolean | undefined;
103
+ } | Promise<{
104
+ [x: string]: unknown;
105
+ content: ({
106
+ type: "text";
107
+ text: string;
108
+ annotations?: {
109
+ audience?: ("user" | "assistant")[] | undefined;
110
+ priority?: number | undefined;
111
+ lastModified?: string | undefined;
112
+ } | undefined;
113
+ _meta?: {
114
+ [x: string]: unknown;
115
+ } | undefined;
116
+ } | {
117
+ type: "image";
118
+ data: string;
119
+ mimeType: string;
120
+ annotations?: {
121
+ audience?: ("user" | "assistant")[] | undefined;
122
+ priority?: number | undefined;
123
+ lastModified?: string | undefined;
124
+ } | undefined;
125
+ _meta?: {
126
+ [x: string]: unknown;
127
+ } | undefined;
128
+ } | {
129
+ type: "audio";
130
+ data: string;
131
+ mimeType: string;
132
+ annotations?: {
133
+ audience?: ("user" | "assistant")[] | undefined;
134
+ priority?: number | undefined;
135
+ lastModified?: string | undefined;
136
+ } | undefined;
137
+ _meta?: {
138
+ [x: string]: unknown;
139
+ } | undefined;
140
+ } | {
141
+ uri: string;
142
+ name: string;
143
+ type: "resource_link";
144
+ description?: string | undefined;
145
+ mimeType?: string | undefined;
146
+ annotations?: {
147
+ audience?: ("user" | "assistant")[] | undefined;
148
+ priority?: number | undefined;
149
+ lastModified?: string | undefined;
150
+ } | undefined;
151
+ _meta?: {
152
+ [x: string]: unknown;
153
+ } | undefined;
154
+ icons?: {
155
+ src: string;
156
+ mimeType?: string | undefined;
157
+ sizes?: string[] | undefined;
158
+ theme?: "light" | "dark" | undefined;
159
+ }[] | undefined;
160
+ title?: string | undefined;
161
+ } | {
162
+ type: "resource";
163
+ resource: {
164
+ uri: string;
165
+ text: string;
166
+ mimeType?: string | undefined;
167
+ _meta?: {
168
+ [x: string]: unknown;
169
+ } | undefined;
170
+ } | {
171
+ uri: string;
172
+ blob: string;
173
+ mimeType?: string | undefined;
174
+ _meta?: {
175
+ [x: string]: unknown;
176
+ } | undefined;
177
+ };
178
+ annotations?: {
179
+ audience?: ("user" | "assistant")[] | undefined;
180
+ priority?: number | undefined;
181
+ lastModified?: string | undefined;
182
+ } | undefined;
183
+ _meta?: {
184
+ [x: string]: unknown;
185
+ } | undefined;
186
+ })[];
187
+ _meta?: {
188
+ [x: string]: unknown;
189
+ progressToken?: string | number | undefined;
190
+ "io.modelcontextprotocol/related-task"?: {
191
+ taskId: string;
192
+ } | undefined;
193
+ } | undefined;
194
+ structuredContent?: {
195
+ [x: string]: unknown;
196
+ } | undefined;
197
+ isError?: boolean | undefined;
198
+ }>];
@@ -34,13 +34,15 @@ export declare class DefaultLikeC4ModelBuilder extends ADisposable implements Li
34
34
  /**
35
35
  * To avoid circular dependencies, first we parse all documents and then we join them.
36
36
  */
37
- private unsafeSyncJoinedModel;
38
- parseModel(projectId?: c4.ProjectId | undefined, cancelToken?: CancellationToken): Promise<LikeC4Model<UnknownParsed> | null>;
37
+ private unsafeSyncJoinedModelData;
38
+ parseModel(projectId?: c4.ProjectId | undefined, cancelToken?: CancellationToken): Promise<LikeC4Model<UnknownParsed>>;
39
39
  private previousViews;
40
40
  /**
41
41
  * WARNING:
42
42
  * This method is internal and should to be called only when all documents are known to be parsed.
43
43
  * Otherwise, the model may be incomplete.
44
+ *
45
+ * @internal
44
46
  */
45
47
  unsafeSyncComputeModel(projectId: c4.ProjectId, manualLayouts?: ManualLayouts): LikeC4Model<UnknownComputed>;
46
48
  computeModel(projectId?: c4.ProjectId | undefined, cancelToken?: CancellationToken): Promise<LikeC4Model<UnknownComputed>>;
@@ -4,7 +4,7 @@ import { LikeC4Model } from '@likec4/core/model';
4
4
  import { loggable } from '@likec4/log';
5
5
  import { deepEqual as eq } from 'fast-equals';
6
6
  import { Disposable, DocumentState, interruptAndCheck, WorkspaceCache, } from 'langium';
7
- import { flatMap, hasAtLeast, isEmpty, mapToObj, pipe, values, } from 'remeda';
7
+ import { hasAtLeast, isEmpty, mapToObj, values, } from 'remeda';
8
8
  import { isLikeC4Builtin } from '../likec4lib';
9
9
  import { logger as mainLogger } from '../logger';
10
10
  import { ADisposable, performanceMark } from '../utils';
@@ -52,20 +52,17 @@ export class DefaultLikeC4ModelBuilder extends ADisposable {
52
52
  */
53
53
  unsafeSyncParseModelData(projectId) {
54
54
  const cache = this.cache;
55
- const logger = builderLogger.getChild(projectId);
56
55
  const key = parsedWithoutImportsCacheKey(projectId);
57
- if (cache.has(key)) {
58
- logger.debug `unsafeSyncParseModelData from cache`;
59
- }
60
56
  return cache.get(key, () => {
57
+ const logger = builderLogger.getChild(projectId);
61
58
  try {
62
59
  const project = this.projects.getProject(projectId);
63
60
  const docs = this.documents(projectId);
64
61
  if (docs.length === 0) {
65
- logger.debug `no documents to build model`;
62
+ logger.debug `unsafeSyncParseModelData: skipped due to no documents`;
66
63
  return null;
67
64
  }
68
- logger.debug `unsafeSyncParseModelData`;
65
+ logger.debug `unsafeSyncParseModelData: completed`;
69
66
  return buildModelData(project, docs);
70
67
  }
71
68
  catch (err) {
@@ -77,50 +74,56 @@ export class DefaultLikeC4ModelBuilder extends ADisposable {
77
74
  /**
78
75
  * To avoid circular dependencies, first we parse all documents and then we join them.
79
76
  */
80
- unsafeSyncJoinedModel(projectId) {
77
+ unsafeSyncJoinedModelData(projectId) {
81
78
  const logger = builderLogger.getChild(projectId);
82
- const cache = this.cache;
83
- const key = parsedModelCacheKey(projectId);
84
- if (cache.has(key)) {
85
- logger.debug `unsafeSyncJoinedModel from cache`;
79
+ const result = this.unsafeSyncParseModelData(projectId);
80
+ if (!result) {
81
+ return null;
86
82
  }
87
- return cache.get(key, () => {
88
- const result = this.unsafeSyncParseModelData(projectId);
89
- if (!result) {
90
- return null;
83
+ if (result.imports.size === 0) {
84
+ return result.data;
85
+ }
86
+ logger.debug `processing imports of ${projectId}`;
87
+ const imports = [...result.imports.associations()].reduce((acc, [projectId, fqns]) => {
88
+ if (fqns.size === 0) {
89
+ return acc;
91
90
  }
92
- let parsedData = result.data;
93
- if (result.imports.size > 0) {
94
- logger.debug `processing imports of ${projectId}`;
95
- const imports = [...result.imports.associations()].reduce((acc, [projectId, fqns]) => {
96
- const anotherProject = this.unsafeSyncParseModelData(projectId);
97
- if (anotherProject) {
98
- const imported = pipe([...fqns], flatMap(fqn => anotherProject.data.elements[fqn] ?? []));
99
- if (hasAtLeast(imported, 1)) {
100
- acc[projectId] = imported;
101
- }
102
- }
103
- return acc;
104
- }, {});
105
- parsedData = {
106
- ...result.data,
107
- imports,
108
- };
109
- }
110
- return LikeC4Model.create(parsedData);
111
- });
91
+ const anotherProject = this.unsafeSyncParseModelData(projectId);
92
+ if (anotherProject) {
93
+ const imported = [...fqns].flatMap(fqn => anotherProject.data.elements[fqn] ?? []);
94
+ if (hasAtLeast(imported, 1)) {
95
+ acc[projectId] = structuredClone(imported);
96
+ }
97
+ }
98
+ return acc;
99
+ }, {});
100
+ return {
101
+ ...result.data,
102
+ imports,
103
+ };
112
104
  }
113
105
  async parseModel(projectId, cancelToken) {
114
106
  projectId = this.projects.ensureProjectId(projectId);
115
107
  const logger = builderLogger.getChild(projectId);
108
+ const cache = this.cache;
116
109
  const t0 = performanceMark();
117
110
  return await this.mutex.read(async () => {
118
111
  if (cancelToken?.isCancellationRequested) {
119
112
  await interruptAndCheck(cancelToken);
120
113
  }
121
- const parsedModel = this.unsafeSyncJoinedModel(projectId);
122
- logger.debug `parseModel in ${t0.pretty}`;
123
- return parsedModel;
114
+ const key = parsedModelCacheKey(projectId);
115
+ if (cache.has(key)) {
116
+ logger.debug `parseModel from cache`;
117
+ }
118
+ return cache.get(key, () => {
119
+ const parsedModel = this.unsafeSyncJoinedModelData(projectId);
120
+ if (!parsedModel) {
121
+ logger.debug `parseModel: returning EMPTY`;
122
+ return LikeC4Model.EMPTY.asParsed;
123
+ }
124
+ logger.debug `parseModel in ${t0.pretty}`;
125
+ return LikeC4Model.create(parsedModel);
126
+ });
124
127
  });
125
128
  }
126
129
  previousViews = {};
@@ -128,22 +131,23 @@ export class DefaultLikeC4ModelBuilder extends ADisposable {
128
131
  * WARNING:
129
132
  * This method is internal and should to be called only when all documents are known to be parsed.
130
133
  * Otherwise, the model may be incomplete.
134
+ *
135
+ * @internal
131
136
  */
132
137
  unsafeSyncComputeModel(projectId, manualLayouts) {
133
- const logger = builderLogger.getChild(projectId);
134
138
  const cache = this.cache;
135
139
  const hasManualLayouts = !!manualLayouts && !isEmpty(manualLayouts);
136
140
  const key = computedModelCacheKey(projectId) + (hasManualLayouts ? '+manualLayouts' : '');
137
- if (cache.has(key)) {
138
- logger.debug `unsafeSyncBuildModel from cache`;
139
- }
140
141
  return cache.get(key, () => {
141
- const parsedModel = this.unsafeSyncJoinedModel(projectId);
142
- if (!parsedModel) {
142
+ const logger = builderLogger.getChild(projectId);
143
+ const parsedModelData = this.unsafeSyncJoinedModelData(projectId);
144
+ if (!parsedModelData) {
145
+ logger.debug `unsafeSyncComputeModel: returning EMPTY`;
143
146
  return LikeC4Model.EMPTY.asComputed;
144
147
  }
148
+ const parsedModel = LikeC4Model.create(parsedModelData);
145
149
  const allViews = [];
146
- for (const view of values(parsedModel.$data.views)) {
150
+ for (const view of values(parsedModelData.views)) {
147
151
  const result = computeView(view, parsedModel);
148
152
  if (!result.isSuccess) {
149
153
  logger.warn(loggable(result.error));
@@ -165,13 +169,14 @@ export class DefaultLikeC4ModelBuilder extends ADisposable {
165
169
  return [v.id, view];
166
170
  });
167
171
  const data = {
168
- ...parsedModel.$data,
172
+ ...parsedModelData,
169
173
  [_stage]: 'computed',
170
174
  views,
171
175
  };
172
176
  if (hasManualLayouts) {
173
177
  data.manualLayouts = manualLayouts;
174
178
  }
179
+ logger.debug(`unsafeSyncComputeModel${hasManualLayouts ? ' with manual layouts' : ''}: completed`);
175
180
  return LikeC4Model.create(data);
176
181
  });
177
182
  }
@@ -186,19 +191,15 @@ export class DefaultLikeC4ModelBuilder extends ADisposable {
186
191
  const project = this.projects.getProject(projectId);
187
192
  const manualLayouts = await this.manualLayouts.read(project);
188
193
  const result = this.unsafeSyncComputeModel(projectId, manualLayouts);
189
- logger.debug(`buildLikeC4Model in ${t0.pretty}`);
194
+ if (result === LikeC4Model.EMPTY) {
195
+ logger.debug(`computeModel returned EMPTY`);
196
+ }
197
+ else if (t0.ms > 10) {
198
+ logger.debug(`computeModel completed in ${t0.pretty}`);
199
+ }
190
200
  return result;
191
201
  });
192
202
  }
193
- // public async rebuildProject(projectId?: c4.ProjectId | undefined): Promise<void> {
194
- // await this.mutex.write(async (token) => {
195
- // projectId = this.projects.ensureProjectId(projectId)
196
- // this.clearCache()
197
- // builderLogger.debug(`rebuildProject ${projectId}`)
198
- // const docs = this.documents(projectId).map(doc => doc.uri)
199
- // await this.DocumentBuilder.update(docs, [], token)
200
- // })
201
- // }
202
203
  onModelParsed(callback) {
203
204
  this.listeners.push(callback);
204
205
  return Disposable.create(() => {
@@ -13,16 +13,16 @@ declare const DocumentParserFromMixins: {
13
13
  parseGlobalDynamicPredicateGroup(astRule: import("../generated/ast").GlobalDynamicPredicateGroup): import("@likec4/core").DynamicViewIncludeRule[];
14
14
  parseGlobalStyleOrGroup(astRule: import("../generated/ast").GlobalStyle | import("../generated/ast").GlobalStyleGroup): import("@likec4/core").ElementViewRuleStyle[];
15
15
  parseViews(): void;
16
- parseElementView(astNode: import("../generated/ast").ElementView, additionalStyles: (import("@likec4/core").ViewRuleGlobalStyle | import("@likec4/core").ElementViewRuleStyle<import("@likec4/core").Any>)[]): import("../ast").ParsedAstElementView;
16
+ parseElementView(astNode: import("../generated/ast").ElementView, additionalStyles: (import("@likec4/core").ElementViewRuleStyle<import("@likec4/core").Any> | import("@likec4/core").ViewRuleGlobalStyle)[]): import("../ast").ParsedAstElementView;
17
17
  parseElementViewRule(astRule: import("../generated/ast").ViewRule): import("@likec4/core").ElementViewRule;
18
18
  parseViewRulePredicate(astNode: import("../generated/ast").ViewRulePredicate): import("@likec4/core").ElementViewPredicate;
19
19
  parseViewRuleGlobalPredicateRef(astRule: import("../generated/ast").ViewRuleGlobalPredicateRef | import("../generated/ast").DynamicViewGlobalPredicateRef): import("@likec4/core").ViewRuleGlobalPredicateRef;
20
- parseViewRuleStyleOrGlobalRef(astRule: import("../generated/ast").ViewRuleStyleOrGlobalRef): import("@likec4/core").ViewRuleGlobalStyle | import("@likec4/core").ElementViewRuleStyle<import("@likec4/core").Any>;
20
+ parseViewRuleStyleOrGlobalRef(astRule: import("../generated/ast").ViewRuleStyleOrGlobalRef): import("@likec4/core").ElementViewRuleStyle<import("@likec4/core").Any> | import("@likec4/core").ViewRuleGlobalStyle;
21
21
  parseViewRuleGroup(astNode: import("../generated/ast").ViewRuleGroup): import("@likec4/core").ElementViewRuleGroup;
22
22
  parseViewRuleRank(astRule: import("../generated/ast").ViewRuleRank): import("@likec4/core").ElementViewRuleRank;
23
23
  parseViewRuleStyle(astRule: import("../generated/ast").ViewRuleStyle | import("../generated/ast").GlobalStyle): import("@likec4/core").ElementViewRuleStyle;
24
24
  parseViewRuleGlobalStyle(astRule: import("../generated/ast").ViewRuleGlobalStyle): import("@likec4/core").ViewRuleGlobalStyle;
25
- parseDynamicElementView(astNode: import("../generated/ast").DynamicView, additionalStyles: (import("@likec4/core").ViewRuleGlobalStyle | import("@likec4/core").ElementViewRuleStyle<import("@likec4/core").Any>)[]): import("../ast").ParsedAstDynamicView;
25
+ parseDynamicElementView(astNode: import("../generated/ast").DynamicView, additionalStyles: (import("@likec4/core").ElementViewRuleStyle<import("@likec4/core").Any> | import("@likec4/core").ViewRuleGlobalStyle)[]): import("../ast").ParsedAstDynamicView;
26
26
  parseDynamicViewRule(astRule: import("../generated/ast").DynamicViewRule): import("@likec4/core").DynamicViewRule;
27
27
  parseDynamicViewIncludePredicate(astRule: import("../generated/ast").DynamicViewIncludePredicate): import("@likec4/core").DynamicViewIncludeRule;
28
28
  parseDynamicParallelSteps(node: import("../generated/ast").DynamicViewParallelSteps): import("@likec4/core").DynamicStepsParallel;
@@ -113,16 +113,16 @@ declare const DocumentParserFromMixins: {
113
113
  } & {
114
114
  new (...args: any[]): {
115
115
  parseViews(): void;
116
- parseElementView(astNode: import("../generated/ast").ElementView, additionalStyles: (import("@likec4/core").ViewRuleGlobalStyle | import("@likec4/core").ElementViewRuleStyle<import("@likec4/core").Any>)[]): import("../ast").ParsedAstElementView;
116
+ parseElementView(astNode: import("../generated/ast").ElementView, additionalStyles: (import("@likec4/core").ElementViewRuleStyle<import("@likec4/core").Any> | import("@likec4/core").ViewRuleGlobalStyle)[]): import("../ast").ParsedAstElementView;
117
117
  parseElementViewRule(astRule: import("../generated/ast").ViewRule): import("@likec4/core").ElementViewRule;
118
118
  parseViewRulePredicate(astNode: import("../generated/ast").ViewRulePredicate): import("@likec4/core").ElementViewPredicate;
119
119
  parseViewRuleGlobalPredicateRef(astRule: import("../generated/ast").ViewRuleGlobalPredicateRef | import("../generated/ast").DynamicViewGlobalPredicateRef): import("@likec4/core").ViewRuleGlobalPredicateRef;
120
- parseViewRuleStyleOrGlobalRef(astRule: import("../generated/ast").ViewRuleStyleOrGlobalRef): import("@likec4/core").ViewRuleGlobalStyle | import("@likec4/core").ElementViewRuleStyle<import("@likec4/core").Any>;
120
+ parseViewRuleStyleOrGlobalRef(astRule: import("../generated/ast").ViewRuleStyleOrGlobalRef): import("@likec4/core").ElementViewRuleStyle<import("@likec4/core").Any> | import("@likec4/core").ViewRuleGlobalStyle;
121
121
  parseViewRuleGroup(astNode: import("../generated/ast").ViewRuleGroup): import("@likec4/core").ElementViewRuleGroup;
122
122
  parseViewRuleRank(astRule: import("../generated/ast").ViewRuleRank): import("@likec4/core").ElementViewRuleRank;
123
123
  parseViewRuleStyle(astRule: import("../generated/ast").ViewRuleStyle | import("../generated/ast").GlobalStyle): import("@likec4/core").ElementViewRuleStyle;
124
124
  parseViewRuleGlobalStyle(astRule: import("../generated/ast").ViewRuleGlobalStyle): import("@likec4/core").ViewRuleGlobalStyle;
125
- parseDynamicElementView(astNode: import("../generated/ast").DynamicView, additionalStyles: (import("@likec4/core").ViewRuleGlobalStyle | import("@likec4/core").ElementViewRuleStyle<import("@likec4/core").Any>)[]): import("../ast").ParsedAstDynamicView;
125
+ parseDynamicElementView(astNode: import("../generated/ast").DynamicView, additionalStyles: (import("@likec4/core").ElementViewRuleStyle<import("@likec4/core").Any> | import("@likec4/core").ViewRuleGlobalStyle)[]): import("../ast").ParsedAstDynamicView;
126
126
  parseDynamicViewRule(astRule: import("../generated/ast").DynamicViewRule): import("@likec4/core").DynamicViewRule;
127
127
  parseDynamicViewIncludePredicate(astRule: import("../generated/ast").DynamicViewIncludePredicate): import("@likec4/core").DynamicViewIncludeRule;
128
128
  parseDynamicParallelSteps(node: import("../generated/ast").DynamicViewParallelSteps): import("@likec4/core").DynamicStepsParallel;
@@ -193,7 +193,12 @@ export class BaseParser {
193
193
  const { libicon, value } = prop;
194
194
  switch (true) {
195
195
  case !!libicon: {
196
- return nonNullable(libicon.ref, `Library icon ${libicon.$refText} has empty ref`).name;
196
+ const name = libicon.ref?.name;
197
+ if (!name) {
198
+ logger.warn(`Library icon ${libicon.$refText} is not a valid library icon`);
199
+ return undefined;
200
+ }
201
+ return name;
197
202
  }
198
203
  case value && value === 'none': {
199
204
  return value;
@@ -286,61 +291,66 @@ export class BaseParser {
286
291
  if (!this.isValid(prop)) {
287
292
  continue;
288
293
  }
289
- switch (true) {
290
- case ast.isBorderProperty(prop): {
291
- if (isTruthy(prop.value)) {
292
- result.border = prop.value;
294
+ try {
295
+ switch (true) {
296
+ case ast.isBorderProperty(prop): {
297
+ if (isTruthy(prop.value)) {
298
+ result.border = prop.value;
299
+ }
300
+ break;
293
301
  }
294
- break;
295
- }
296
- case ast.isColorProperty(prop): {
297
- const color = toColor(prop);
298
- if (isTruthy(color)) {
299
- result.color = color;
302
+ case ast.isColorProperty(prop): {
303
+ const color = toColor(prop);
304
+ if (isTruthy(color)) {
305
+ result.color = color;
306
+ }
307
+ break;
300
308
  }
301
- break;
302
- }
303
- case ast.isShapeProperty(prop): {
304
- if (isTruthy(prop.value)) {
305
- result.shape = prop.value;
309
+ case ast.isShapeProperty(prop): {
310
+ if (isTruthy(prop.value)) {
311
+ result.shape = prop.value;
312
+ }
313
+ break;
306
314
  }
307
- break;
308
- }
309
- case ast.isIconProperty(prop): {
310
- const icon = this.parseIconProperty(prop);
311
- if (isTruthy(icon)) {
312
- result.icon = icon;
315
+ case ast.isIconProperty(prop): {
316
+ const icon = this.parseIconProperty(prop);
317
+ if (isTruthy(icon)) {
318
+ result.icon = icon;
319
+ }
320
+ break;
313
321
  }
314
- break;
315
- }
316
- case ast.isOpacityProperty(prop): {
317
- result.opacity = parseAstOpacityProperty(prop);
318
- break;
319
- }
320
- case ast.isMultipleProperty(prop): {
321
- result.multiple = isBoolean(prop.value) ? prop.value : false;
322
- break;
323
- }
324
- case ast.isShapeSizeProperty(prop): {
325
- if (isTruthy(prop.value)) {
326
- result.size = parseAstSizeValue(prop);
322
+ case ast.isOpacityProperty(prop): {
323
+ result.opacity = parseAstOpacityProperty(prop);
324
+ break;
327
325
  }
328
- break;
329
- }
330
- case ast.isPaddingSizeProperty(prop): {
331
- if (isTruthy(prop.value)) {
332
- result.padding = parseAstSizeValue(prop);
326
+ case ast.isMultipleProperty(prop): {
327
+ result.multiple = isBoolean(prop.value) ? prop.value : false;
328
+ break;
333
329
  }
334
- break;
335
- }
336
- case ast.isTextSizeProperty(prop): {
337
- if (isTruthy(prop.value)) {
338
- result.textSize = parseAstSizeValue(prop);
330
+ case ast.isShapeSizeProperty(prop): {
331
+ if (isTruthy(prop.value)) {
332
+ result.size = parseAstSizeValue(prop);
333
+ }
334
+ break;
335
+ }
336
+ case ast.isPaddingSizeProperty(prop): {
337
+ if (isTruthy(prop.value)) {
338
+ result.padding = parseAstSizeValue(prop);
339
+ }
340
+ break;
339
341
  }
340
- break;
342
+ case ast.isTextSizeProperty(prop): {
343
+ if (isTruthy(prop.value)) {
344
+ result.textSize = parseAstSizeValue(prop);
345
+ }
346
+ break;
347
+ }
348
+ default:
349
+ nonexhaustive(prop);
341
350
  }
342
- default:
343
- nonexhaustive(prop);
351
+ }
352
+ catch (err) {
353
+ logger.warn('Failed to parse style property', { err });
344
354
  }
345
355
  }
346
356
  return exact(result);
@@ -9,16 +9,16 @@ export declare function GlobalsParser<TBase extends WithViewsParser>(B: TBase):
9
9
  parseGlobalDynamicPredicateGroup(astRule: ast.GlobalDynamicPredicateGroup): c4.DynamicViewIncludeRule[];
10
10
  parseGlobalStyleOrGroup(astRule: ast.GlobalStyle | ast.GlobalStyleGroup): c4.ElementViewRuleStyle[];
11
11
  parseViews(): void;
12
- parseElementView(astNode: ast.ElementView, additionalStyles: (c4.ViewRuleGlobalStyle | c4.ElementViewRuleStyle<c4.aux.Any>)[]): import("../../ast").ParsedAstElementView;
12
+ parseElementView(astNode: ast.ElementView, additionalStyles: (c4.ElementViewRuleStyle<c4.aux.Any> | c4.ViewRuleGlobalStyle)[]): import("../../ast").ParsedAstElementView;
13
13
  parseElementViewRule(astRule: ast.ViewRule): c4.ElementViewRule;
14
14
  parseViewRulePredicate(astNode: ast.ViewRulePredicate): c4.ElementViewPredicate;
15
15
  parseViewRuleGlobalPredicateRef(astRule: ast.ViewRuleGlobalPredicateRef | ast.DynamicViewGlobalPredicateRef): c4.ViewRuleGlobalPredicateRef;
16
- parseViewRuleStyleOrGlobalRef(astRule: ast.ViewRuleStyleOrGlobalRef): c4.ViewRuleGlobalStyle | c4.ElementViewRuleStyle<c4.aux.Any>;
16
+ parseViewRuleStyleOrGlobalRef(astRule: ast.ViewRuleStyleOrGlobalRef): c4.ElementViewRuleStyle<c4.aux.Any> | c4.ViewRuleGlobalStyle;
17
17
  parseViewRuleGroup(astNode: ast.ViewRuleGroup): c4.ElementViewRuleGroup;
18
18
  parseViewRuleRank(astRule: ast.ViewRuleRank): c4.ElementViewRuleRank;
19
19
  parseViewRuleStyle(astRule: ast.ViewRuleStyle | ast.GlobalStyle): c4.ElementViewRuleStyle;
20
20
  parseViewRuleGlobalStyle(astRule: ast.ViewRuleGlobalStyle): c4.ViewRuleGlobalStyle;
21
- parseDynamicElementView(astNode: ast.DynamicView, additionalStyles: (c4.ViewRuleGlobalStyle | c4.ElementViewRuleStyle<c4.aux.Any>)[]): import("../../ast").ParsedAstDynamicView;
21
+ parseDynamicElementView(astNode: ast.DynamicView, additionalStyles: (c4.ElementViewRuleStyle<c4.aux.Any> | c4.ViewRuleGlobalStyle)[]): import("../../ast").ParsedAstDynamicView;
22
22
  parseDynamicViewRule(astRule: ast.DynamicViewRule): c4.DynamicViewRule;
23
23
  parseDynamicViewIncludePredicate(astRule: ast.DynamicViewIncludePredicate): c4.DynamicViewIncludeRule;
24
24
  parseDynamicParallelSteps(node: ast.DynamicViewParallelSteps): c4.DynamicStepsParallel;
@@ -4,7 +4,7 @@ import { loggable } from '@likec4/log';
4
4
  import { filter, find, isDefined, isEmpty, isNonNullish, isNumber, isTruthy, last, mapToObj, pipe } from 'remeda';
5
5
  import { ast, parseMarkdownAsString, toAutoLayout, toColor, ViewOps, } from '../../ast';
6
6
  import { logger as mainLogger } from '../../logger';
7
- import { stringHash } from '../../utils';
7
+ import { safeCall, stringHash } from '../../utils';
8
8
  import { elementRef } from '../../utils/elementRef';
9
9
  import { parseViewManualLayout } from '../../view-utils/manual-layout';
10
10
  import { removeIndent, toSingleLine } from './Base';
@@ -62,7 +62,7 @@ export function ViewsParser(B) {
62
62
  let viewOf = null;
63
63
  if ('viewOf' in astNode) {
64
64
  const viewOfEl = elementRef(astNode.viewOf);
65
- const _viewOf = viewOfEl && this.resolveFqn(viewOfEl);
65
+ const _viewOf = viewOfEl && safeCall(() => this.resolveFqn(viewOfEl));
66
66
  if (!_viewOf) {
67
67
  const viewId = astNode.name ?? 'unnamed';
68
68
  const msg = astNode.viewOf.$cstNode?.text ?? '<unknown>';
@@ -154,6 +154,11 @@ export declare namespace RegisterProject {
154
154
  type Params = {
155
155
  folderUri: URI;
156
156
  config: LikeC4ProjectJsonConfig;
157
+ configUri?: never;
158
+ } | {
159
+ configUri: URI;
160
+ folderUri?: never;
161
+ config?: never;
157
162
  };
158
163
  type Res = {
159
164
  id: ProjectId;
@@ -10,7 +10,7 @@ export declare class LikeC4ScopeProvider extends DefaultScopeProvider {
10
10
  protected readonly indexManager: IndexManager;
11
11
  constructor(services: LikeC4Services);
12
12
  getScope(context: ReferenceInfo): Scope;
13
- protected genUniqueDescedants(of: () => ast.Element | ast.DeploymentNode | undefined): Generator<import("../ast").AstNodeDescriptionWithFqn, void, any>;
13
+ protected genUniqueDescedants(element: ast.Element | ast.DeploymentNode | undefined): Generator<import("../ast").AstNodeDescriptionWithFqn, void, any>;
14
14
  protected genScopeExtendElement({ element }: ast.ExtendElement): Generator<AstNodeDescription>;
15
15
  protected genScopeElementView({ viewOf, extends: ext }: ast.ElementView): Generator<AstNodeDescription>;
16
16
  protected getScopeForStrictFqnRef(projectId: ProjectId, container: ast.StrictFqnRef, context: ReferenceInfo): Scope;