@likec4/language-server 1.46.4 → 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.
- package/dist/LikeC4LanguageServices.d.ts +27 -21
- package/dist/LikeC4LanguageServices.js +24 -14
- package/dist/Rpc.js +7 -1
- package/dist/ast.d.ts +1 -1
- package/dist/browser.d.ts +0 -1
- package/dist/browser.js +0 -1
- package/dist/bundled.mjs +3769 -3597
- package/dist/filesystem/ChokidarWatcher.d.ts +3 -0
- package/dist/filesystem/ChokidarWatcher.js +67 -42
- package/dist/filesystem/LikeC4FileSystem.d.ts +1 -1
- package/dist/filesystem/LikeC4FileSystem.js +16 -6
- package/dist/generated/ast.d.ts +2 -2
- package/dist/generated/ast.js +1 -1
- package/dist/generated/grammar.js +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/lsp/CodeLensProvider.js +1 -1
- package/dist/lsp/CompletionProvider.d.ts +4 -2
- package/dist/lsp/CompletionProvider.js +41 -3
- package/dist/lsp/DocumentSymbolProvider.js +1 -1
- package/dist/lsp/SemanticTokenProvider.d.ts +8 -1
- package/dist/lsp/SemanticTokenProvider.js +52 -11
- package/dist/mcp/interfaces.d.ts +1 -1
- package/dist/mcp/interfaces.js +0 -1
- package/dist/mcp/server/StreamableLikeC4MCPServer.js +27 -51
- package/dist/mcp/tools/_common.d.ts +2 -2
- package/dist/mcp/tools/find-relationships.d.ts +195 -5
- package/dist/mcp/tools/list-projects.d.ts +191 -3
- package/dist/mcp/tools/open-view.d.ts +194 -4
- package/dist/mcp/tools/read-deployment.d.ts +194 -4
- package/dist/mcp/tools/read-element.d.ts +194 -4
- package/dist/mcp/tools/read-project-summary.d.ts +193 -3
- package/dist/mcp/tools/read-view.d.ts +194 -4
- package/dist/mcp/tools/search-element.d.ts +193 -3
- package/dist/model/model-builder.d.ts +4 -2
- package/dist/model/model-builder.js +56 -47
- package/dist/model/model-parser.d.ts +6 -6
- package/dist/model/parser/Base.js +58 -48
- package/dist/model/parser/GlobalsParser.d.ts +3 -3
- package/dist/model/parser/ViewsParser.js +2 -2
- package/dist/protocol.d.ts +5 -0
- package/dist/utils/elementRef.js +10 -4
- package/dist/validation/index.d.ts +1 -1
- package/dist/workspace/LangiumDocuments.d.ts +4 -0
- package/dist/workspace/LangiumDocuments.js +11 -5
- package/dist/workspace/ProjectsManager.d.ts +4 -0
- package/dist/workspace/ProjectsManager.js +89 -84
- package/package.json +16 -15
|
@@ -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:
|
|
8
|
-
}
|
|
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
|
|
38
|
-
parseModel(projectId?: c4.ProjectId | undefined, cancelToken?: CancellationToken): Promise<LikeC4Model<UnknownParsed
|
|
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 {
|
|
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,12 +52,9 @@ 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);
|
|
@@ -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
|
-
|
|
77
|
+
unsafeSyncJoinedModelData(projectId) {
|
|
81
78
|
const logger = builderLogger.getChild(projectId);
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
logger.debug `unsafeSyncJoinedModel from cache`;
|
|
79
|
+
const result = this.unsafeSyncParseModelData(projectId);
|
|
80
|
+
if (!result) {
|
|
81
|
+
return null;
|
|
86
82
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
93
|
-
if (
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
|
122
|
-
|
|
123
|
-
|
|
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
|
|
142
|
-
|
|
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(
|
|
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,14 +169,14 @@ export class DefaultLikeC4ModelBuilder extends ADisposable {
|
|
|
165
169
|
return [v.id, view];
|
|
166
170
|
});
|
|
167
171
|
const data = {
|
|
168
|
-
...
|
|
172
|
+
...parsedModelData,
|
|
169
173
|
[_stage]: 'computed',
|
|
170
174
|
views,
|
|
171
175
|
};
|
|
172
176
|
if (hasManualLayouts) {
|
|
173
177
|
data.manualLayouts = manualLayouts;
|
|
174
178
|
}
|
|
175
|
-
logger.debug
|
|
179
|
+
logger.debug(`unsafeSyncComputeModel${hasManualLayouts ? ' with manual layouts' : ''}: completed`);
|
|
176
180
|
return LikeC4Model.create(data);
|
|
177
181
|
});
|
|
178
182
|
}
|
|
@@ -187,7 +191,12 @@ export class DefaultLikeC4ModelBuilder extends ADisposable {
|
|
|
187
191
|
const project = this.projects.getProject(projectId);
|
|
188
192
|
const manualLayouts = await this.manualLayouts.read(project);
|
|
189
193
|
const result = this.unsafeSyncComputeModel(projectId, manualLayouts);
|
|
190
|
-
|
|
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
|
+
}
|
|
191
200
|
return result;
|
|
192
201
|
});
|
|
193
202
|
}
|
|
@@ -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").
|
|
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").
|
|
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").
|
|
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").
|
|
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").
|
|
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").
|
|
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
|
-
|
|
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
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
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
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
302
|
+
case ast.isColorProperty(prop): {
|
|
303
|
+
const color = toColor(prop);
|
|
304
|
+
if (isTruthy(color)) {
|
|
305
|
+
result.color = color;
|
|
306
|
+
}
|
|
307
|
+
break;
|
|
300
308
|
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
309
|
+
case ast.isShapeProperty(prop): {
|
|
310
|
+
if (isTruthy(prop.value)) {
|
|
311
|
+
result.shape = prop.value;
|
|
312
|
+
}
|
|
313
|
+
break;
|
|
306
314
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
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
|
-
|
|
315
|
-
|
|
316
|
-
|
|
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
|
-
|
|
329
|
-
|
|
330
|
-
|
|
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
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
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
|
-
|
|
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
|
-
|
|
343
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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>';
|
package/dist/protocol.d.ts
CHANGED
|
@@ -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;
|
package/dist/utils/elementRef.js
CHANGED
|
@@ -3,11 +3,17 @@ import { ast } from '../ast';
|
|
|
3
3
|
* Returns referenced AST Element
|
|
4
4
|
*/
|
|
5
5
|
export function elementRef(node) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
el
|
|
6
|
+
try {
|
|
7
|
+
let el = ast.isStrictFqnElementRef(node) ? node.el.ref : node.modelElement.value.ref;
|
|
8
|
+
if (el?.$type === 'Imported') {
|
|
9
|
+
el = el.imported.ref;
|
|
10
|
+
}
|
|
11
|
+
return el?.$type === 'Element' ? el : undefined;
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
// ignore reference errors
|
|
15
|
+
return undefined;
|
|
9
16
|
}
|
|
10
|
-
return el?.$type === 'Element' ? el : undefined;
|
|
11
17
|
}
|
|
12
18
|
/**
|
|
13
19
|
* Returns FQN of StrictFqnElementRef
|