@likec4/language-server 1.8.1 → 1.10.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/contrib/likec4.tmLanguage.json +1 -1
- package/dist/browser.cjs +21 -0
- package/dist/browser.d.cts +22 -0
- package/dist/browser.d.mts +22 -0
- package/dist/browser.d.ts +22 -0
- package/dist/browser.mjs +19 -0
- package/dist/index.cjs +10 -0
- package/dist/index.d.cts +18 -0
- package/dist/index.d.mts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.mjs +1 -0
- package/dist/likec4lib.cjs +961 -0
- package/dist/likec4lib.d.cts +6 -0
- package/dist/likec4lib.d.mts +6 -0
- package/dist/likec4lib.d.ts +6 -0
- package/dist/likec4lib.mjs +957 -0
- package/dist/model-graph/index.cjs +10 -0
- package/dist/model-graph/index.d.cts +79 -0
- package/dist/model-graph/index.d.mts +79 -0
- package/dist/model-graph/index.d.ts +79 -0
- package/dist/model-graph/index.mjs +1 -0
- package/dist/node.cjs +18 -0
- package/dist/node.d.cts +20 -0
- package/dist/node.d.mts +20 -0
- package/dist/node.d.ts +20 -0
- package/dist/node.mjs +16 -0
- package/dist/protocol.cjs +25 -0
- package/dist/protocol.d.cts +43 -0
- package/dist/protocol.d.mts +43 -0
- package/dist/protocol.d.ts +43 -0
- package/dist/protocol.mjs +17 -0
- package/dist/shared/language-server.CjFzaJwI.d.cts +1223 -0
- package/dist/shared/language-server.CtKHXJDD.d.ts +1223 -0
- package/dist/shared/language-server.D-84I33F.d.mts +1223 -0
- package/dist/shared/language-server.DBJJUUgF.mjs +5737 -0
- package/dist/shared/language-server.DtBRb9os.mjs +1656 -0
- package/dist/shared/language-server.DwyCJvXm.cjs +1669 -0
- package/dist/shared/language-server.JWkqVjGv.cjs +5748 -0
- package/package.json +36 -20
- package/src/ast.ts +48 -36
- package/src/browser.ts +0 -3
- package/src/elementRef.ts +1 -1
- package/src/formatting/LikeC4Formatter.ts +388 -0
- package/src/formatting/utils.ts +26 -0
- package/src/generated/ast.ts +170 -12
- package/src/generated/grammar.ts +1 -1
- package/src/generated-lib/icons.ts +1 -1
- package/src/like-c4.langium +49 -8
- package/src/likec4lib.ts +2 -3
- package/src/logger.ts +9 -1
- package/src/lsp/DocumentLinkProvider.ts +27 -15
- package/src/lsp/RenameProvider.ts +8 -0
- package/src/lsp/SemanticTokenProvider.ts +20 -2
- package/src/lsp/index.ts +1 -0
- package/src/model/fqn-computation.ts +33 -23
- package/src/model/fqn-index.ts +5 -21
- package/src/model/model-builder.ts +180 -112
- package/src/model/model-locator.ts +1 -1
- package/src/model/model-parser-where.ts +3 -2
- package/src/model/model-parser.ts +99 -39
- package/src/model-graph/LikeC4ModelGraph.ts +42 -21
- package/src/model-graph/compute-view/__test__/fixture.ts +16 -14
- package/src/model-graph/compute-view/compute.ts +110 -81
- package/src/model-graph/compute-view/predicates.ts +6 -8
- package/src/model-graph/dynamic-view/__test__/fixture.ts +1 -0
- package/src/model-graph/dynamic-view/compute.ts +98 -61
- package/src/model-graph/utils/buildElementNotations.ts +1 -1
- package/src/model-graph/utils/elementExpressionToPredicate.ts +1 -1
- package/src/model-graph/utils/sortNodes.ts +2 -6
- package/src/module.ts +21 -4
- package/src/protocol.ts +4 -5
- package/src/references/scope-computation.ts +10 -1
- package/src/references/scope-provider.ts +2 -1
- package/src/shared/NodeKindProvider.ts +73 -34
- package/src/test/setup.ts +3 -8
- package/src/test/testServices.ts +27 -7
- package/src/utils/graphlib.ts +11 -0
- package/src/validation/index.ts +2 -1
- package/src/validation/property-checks.ts +13 -1
- package/src/validation/specification.ts +3 -3
- package/src/view-utils/manual-layout.ts +1 -1
- package/src/view-utils/resolve-extended-views.ts +19 -10
- package/src/view-utils/resolve-relative-paths.ts +19 -24
- package/src/view-utils/view-hash.ts +1 -1
- package/src/reset.d.ts +0 -2
package/src/like-c4.langium
CHANGED
|
@@ -31,12 +31,16 @@ Tag:
|
|
|
31
31
|
RelationshipKind:
|
|
32
32
|
name=Id;
|
|
33
33
|
|
|
34
|
+
CustomColor:
|
|
35
|
+
name=CustomColorId;
|
|
36
|
+
|
|
34
37
|
SpecificationRule:
|
|
35
38
|
name='specification' '{'
|
|
36
39
|
(
|
|
37
40
|
elements+=SpecificationElementKind |
|
|
38
41
|
tags+=SpecificationTag |
|
|
39
|
-
relationships+=SpecificationRelationshipKind
|
|
42
|
+
relationships+=SpecificationRelationshipKind |
|
|
43
|
+
colors+=SpecificationColor
|
|
40
44
|
)*
|
|
41
45
|
'}';
|
|
42
46
|
|
|
@@ -54,6 +58,9 @@ SpecificationElementStringProperty:
|
|
|
54
58
|
SpecificationTag:
|
|
55
59
|
'tag' tag=Tag;
|
|
56
60
|
|
|
61
|
+
SpecificationColor:
|
|
62
|
+
'color' name=CustomColor color=CustomColorValue;
|
|
63
|
+
|
|
57
64
|
SpecificationRelationshipKind:
|
|
58
65
|
'relationship' kind=RelationshipKind ('{'
|
|
59
66
|
props+=(
|
|
@@ -155,7 +162,12 @@ RelationBody: '{'
|
|
|
155
162
|
;
|
|
156
163
|
|
|
157
164
|
RelationProperty:
|
|
158
|
-
RelationStringProperty |
|
|
165
|
+
RelationStringProperty |
|
|
166
|
+
RelationNavigateToProperty |
|
|
167
|
+
RelationStyleProperty |
|
|
168
|
+
LinkProperty |
|
|
169
|
+
MetadataProperty
|
|
170
|
+
;
|
|
159
171
|
|
|
160
172
|
RelationStringProperty:
|
|
161
173
|
key=('title' | 'technology' | 'description') ':'? value=String ';'?;
|
|
@@ -176,7 +188,7 @@ MetadataBody: '{'
|
|
|
176
188
|
;
|
|
177
189
|
|
|
178
190
|
MetadataAttribute:
|
|
179
|
-
key=IdTerminal value=String
|
|
191
|
+
key=IdTerminal ':'? value=String ';'?
|
|
180
192
|
;
|
|
181
193
|
|
|
182
194
|
// Views -------------------------------------
|
|
@@ -208,6 +220,9 @@ ViewRef:
|
|
|
208
220
|
ElementViewRef:
|
|
209
221
|
view=[ElementView];
|
|
210
222
|
|
|
223
|
+
DynamicViewRef:
|
|
224
|
+
view=[DynamicView];
|
|
225
|
+
|
|
211
226
|
ElementViewBody: '{'
|
|
212
227
|
tags=Tags?
|
|
213
228
|
props+=ViewProperty*
|
|
@@ -218,8 +233,11 @@ ElementViewBody: '{'
|
|
|
218
233
|
DynamicViewBody: '{'
|
|
219
234
|
tags=Tags?
|
|
220
235
|
props+=ViewProperty*
|
|
221
|
-
(
|
|
222
|
-
|
|
236
|
+
(
|
|
237
|
+
steps+=(DynamicViewParallelSteps | DynamicViewStep) |
|
|
238
|
+
rules+=DynamicViewRule
|
|
239
|
+
)*
|
|
240
|
+
'}'
|
|
223
241
|
;
|
|
224
242
|
|
|
225
243
|
|
|
@@ -230,7 +248,8 @@ type StringProperty =
|
|
|
230
248
|
MetadataAttribute |
|
|
231
249
|
SpecificationElementStringProperty |
|
|
232
250
|
SpecificationRelationshipStringProperty |
|
|
233
|
-
NotationProperty
|
|
251
|
+
NotationProperty |
|
|
252
|
+
NotesProperty
|
|
234
253
|
;
|
|
235
254
|
|
|
236
255
|
ViewProperty:
|
|
@@ -255,6 +274,12 @@ DynamicViewRule:
|
|
|
255
274
|
ViewRuleAutoLayout
|
|
256
275
|
;
|
|
257
276
|
|
|
277
|
+
DynamicViewParallelSteps:
|
|
278
|
+
('parallel'|'par') '{'
|
|
279
|
+
(steps+=DynamicViewStep)*
|
|
280
|
+
'}'
|
|
281
|
+
;
|
|
282
|
+
|
|
258
283
|
DynamicViewStep:
|
|
259
284
|
source=ElementRef
|
|
260
285
|
(isBackward?='<-' | '->' | '-[' kind=[RelationshipKind] ']->' | kind=[RelationshipKind:DotId] )
|
|
@@ -419,6 +444,9 @@ ViewRuleAutoLayout:
|
|
|
419
444
|
NotationProperty:
|
|
420
445
|
key='notation' ':'? value=String ';'?
|
|
421
446
|
;
|
|
447
|
+
NotesProperty:
|
|
448
|
+
key='notes' ':'? value=String ';'?
|
|
449
|
+
;
|
|
422
450
|
|
|
423
451
|
CustomElementProperties: '{'
|
|
424
452
|
props+=(
|
|
@@ -432,8 +460,10 @@ CustomElementProperties: '{'
|
|
|
432
460
|
|
|
433
461
|
CustomRelationProperties: '{'
|
|
434
462
|
props+=(
|
|
463
|
+
RelationNavigateToProperty |
|
|
435
464
|
RelationStringProperty |
|
|
436
465
|
NotationProperty |
|
|
466
|
+
NotesProperty |
|
|
437
467
|
RelationshipStyleProperty
|
|
438
468
|
)*
|
|
439
469
|
'}'
|
|
@@ -442,12 +472,15 @@ CustomRelationProperties: '{'
|
|
|
442
472
|
NavigateToProperty:
|
|
443
473
|
key='navigateTo' value=ViewRef;
|
|
444
474
|
|
|
475
|
+
RelationNavigateToProperty:
|
|
476
|
+
key='navigateTo' value=DynamicViewRef;
|
|
477
|
+
|
|
445
478
|
// Common properties -------------------------------------
|
|
446
479
|
|
|
447
480
|
LinkProperty:
|
|
448
481
|
key='link' ':'? value=Uri title=String? ';'?;
|
|
449
482
|
ColorProperty:
|
|
450
|
-
key='color' ':'?
|
|
483
|
+
key='color' ':'? (themeColor=ThemeColor | customColor=[CustomColor:CustomColorId]) ';'?;
|
|
451
484
|
|
|
452
485
|
OpacityProperty:
|
|
453
486
|
key='opacity' ':'? value=Percent ';'?;
|
|
@@ -513,6 +546,9 @@ ThemeColor returns string:
|
|
|
513
546
|
ElementShape returns string:
|
|
514
547
|
'rectangle' | 'person' | 'browser' | 'mobile' | 'cylinder' | 'storage' | 'queue';
|
|
515
548
|
|
|
549
|
+
CustomColorValue returns string:
|
|
550
|
+
Hash (Id | Hex);
|
|
551
|
+
|
|
516
552
|
IconId returns string:
|
|
517
553
|
LIB_ICON;
|
|
518
554
|
|
|
@@ -525,6 +561,9 @@ TagId returns string:
|
|
|
525
561
|
DotId returns string:
|
|
526
562
|
Dot Id;
|
|
527
563
|
|
|
564
|
+
CustomColorId returns string:
|
|
565
|
+
IdTerminal | ElementShape | ArrowType | LineOptions | 'element' | 'model';
|
|
566
|
+
|
|
528
567
|
Id returns string:
|
|
529
568
|
IdTerminal | ElementShape | ThemeColor | ArrowType | LineOptions | 'element' | 'model';
|
|
530
569
|
|
|
@@ -552,7 +591,8 @@ fragment IsEqual:
|
|
|
552
591
|
// Comments
|
|
553
592
|
hidden terminal BLOCK_COMMENT: /\/\*[\s\S]*?\*\//;
|
|
554
593
|
hidden terminal LINE_COMMENT: /\/\/[^\n\r]*/;
|
|
555
|
-
hidden terminal WS:
|
|
594
|
+
hidden terminal WS: /[\t ]+/;
|
|
595
|
+
hidden terminal NL: /[\r\n]+/;
|
|
556
596
|
|
|
557
597
|
// -----------------------------------
|
|
558
598
|
// Terminals
|
|
@@ -580,3 +620,4 @@ terminal String: /"[^"]*"|'[^']*'/;
|
|
|
580
620
|
// terminal TagId: HASH LETTER (LETTER | DIGIT | UNDERSCORE | DASH)*;
|
|
581
621
|
// terminal IdTerminal: (LETTER | UNDERSCORE+ (LETTER | DIGIT)) (LETTER | DIGIT | UNDERSCORE | DASH)*;
|
|
582
622
|
terminal IdTerminal: /[_]*[a-zA-Z][-\w]*/;
|
|
623
|
+
terminal Hex: /[a-zA-Z0-9]+/;
|
package/src/likec4lib.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { LibIcons } from './generated-lib/icons'
|
|
2
2
|
|
|
3
|
-
export const Scheme = '
|
|
4
|
-
export const
|
|
5
|
-
export const Uri = `${Scheme}://${Path}`
|
|
3
|
+
export const Scheme = 'likec4builtin'
|
|
4
|
+
export const Uri = `${Scheme}:///likec4/lib/icons.c4`
|
|
6
5
|
|
|
7
6
|
export { LibIcons as Content }
|
package/src/logger.ts
CHANGED
|
@@ -65,14 +65,22 @@ export function logToLspConnection(connection: Connection): void {
|
|
|
65
65
|
}
|
|
66
66
|
const message = parts.join(' ')
|
|
67
67
|
switch (true) {
|
|
68
|
+
case level >= LogLevels.trace: {
|
|
69
|
+
connection.tracer.log(message)
|
|
70
|
+
break
|
|
71
|
+
}
|
|
68
72
|
case level >= LogLevels.debug: {
|
|
69
73
|
connection.console.debug(message)
|
|
70
74
|
break
|
|
71
75
|
}
|
|
72
|
-
case level >= LogLevels.
|
|
76
|
+
case level >= LogLevels.info: {
|
|
73
77
|
connection.console.info(message)
|
|
74
78
|
break
|
|
75
79
|
}
|
|
80
|
+
case level >= LogLevels.log: {
|
|
81
|
+
connection.console.log(message)
|
|
82
|
+
break
|
|
83
|
+
}
|
|
76
84
|
case level >= LogLevels.warn: {
|
|
77
85
|
connection.console.warn(message)
|
|
78
86
|
break
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { LangiumDocument, MaybePromise } from 'langium'
|
|
2
2
|
import { AstUtils, GrammarUtils } from 'langium'
|
|
3
3
|
import type { DocumentLinkProvider } from 'langium/lsp'
|
|
4
|
-
import { hasProtocol, isRelative,
|
|
4
|
+
import { hasLeadingSlash, hasProtocol, isRelative, withoutBase, withoutLeadingSlash } from 'ufo'
|
|
5
5
|
import type { DocumentLink, DocumentLinkParams } from 'vscode-languageserver'
|
|
6
6
|
import { ast, isParsedLikeC4LangiumDocument } from '../ast'
|
|
7
|
-
import {
|
|
7
|
+
import { logWarnError } from '../logger'
|
|
8
8
|
import type { LikeC4Services } from '../module'
|
|
9
9
|
|
|
10
10
|
export class LikeC4DocumentLinkProvider implements DocumentLinkProvider {
|
|
@@ -20,34 +20,46 @@ export class LikeC4DocumentLinkProvider implements DocumentLinkProvider {
|
|
|
20
20
|
}
|
|
21
21
|
return AstUtils.streamAllContents(doc.parseResult.value)
|
|
22
22
|
.filter(ast.isLinkProperty)
|
|
23
|
-
.
|
|
23
|
+
.map((n): DocumentLink | null => {
|
|
24
24
|
try {
|
|
25
25
|
const range = GrammarUtils.findNodeForProperty(n.$cstNode, 'value')?.range
|
|
26
|
-
if (!range) {
|
|
27
|
-
return []
|
|
28
|
-
}
|
|
29
26
|
const target = this.resolveLink(doc, n.value)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
if (range && hasProtocol(target)) {
|
|
28
|
+
return {
|
|
29
|
+
range,
|
|
30
|
+
target
|
|
31
|
+
}
|
|
33
32
|
}
|
|
34
33
|
} catch (e) {
|
|
35
|
-
|
|
36
|
-
return []
|
|
34
|
+
logWarnError(e)
|
|
37
35
|
}
|
|
36
|
+
return null
|
|
38
37
|
})
|
|
38
|
+
.nonNullable()
|
|
39
39
|
.toArray()
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
resolveLink(doc: LangiumDocument, link: string): string {
|
|
43
|
-
if (hasProtocol(link)) {
|
|
43
|
+
if (hasProtocol(link) || hasLeadingSlash(link)) {
|
|
44
44
|
return link
|
|
45
45
|
}
|
|
46
|
+
const base = isRelative(link)
|
|
47
|
+
? new URL(doc.uri.toString(true))
|
|
48
|
+
: this.services.shared.workspace.WorkspaceManager.workspaceURL
|
|
49
|
+
return new URL(link, base).toString()
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
relativeLink(doc: LangiumDocument, link: string): string | null {
|
|
53
|
+
if (hasLeadingSlash(link)) {
|
|
54
|
+
return withoutLeadingSlash(link)
|
|
55
|
+
}
|
|
46
56
|
if (isRelative(link)) {
|
|
47
57
|
const base = new URL(doc.uri.toString(true))
|
|
48
|
-
|
|
58
|
+
const linkURL = new URL(link, base).toString()
|
|
59
|
+
return withoutLeadingSlash(
|
|
60
|
+
withoutBase(linkURL, this.services.shared.workspace.WorkspaceManager.workspaceURL.toString())
|
|
61
|
+
)
|
|
49
62
|
}
|
|
50
|
-
|
|
51
|
-
return withBase(link, workspace.toString())
|
|
63
|
+
return null
|
|
52
64
|
}
|
|
53
65
|
}
|
|
@@ -42,7 +42,7 @@ export class LikeC4SemanticTokenProvider extends AbstractSemanticTokenProvider {
|
|
|
42
42
|
type: SemanticTokenTypes.function
|
|
43
43
|
})
|
|
44
44
|
}
|
|
45
|
-
if (ast.isNavigateToProperty(node)) {
|
|
45
|
+
if (ast.isNavigateToProperty(node) || ast.isRelationNavigateToProperty(node)) {
|
|
46
46
|
acceptor({
|
|
47
47
|
node,
|
|
48
48
|
property: 'key',
|
|
@@ -118,6 +118,23 @@ export class LikeC4SemanticTokenProvider extends AbstractSemanticTokenProvider {
|
|
|
118
118
|
})
|
|
119
119
|
return !node.parent ? 'prune' : undefined
|
|
120
120
|
}
|
|
121
|
+
if (ast.isSpecificationColor(node)) {
|
|
122
|
+
acceptor({
|
|
123
|
+
node,
|
|
124
|
+
keyword: 'color',
|
|
125
|
+
type: SemanticTokenTypes.keyword
|
|
126
|
+
})
|
|
127
|
+
acceptor({
|
|
128
|
+
node,
|
|
129
|
+
property: 'name',
|
|
130
|
+
type: SemanticTokenTypes.type,
|
|
131
|
+
modifier: [
|
|
132
|
+
SemanticTokenModifiers.declaration,
|
|
133
|
+
SemanticTokenModifiers.readonly
|
|
134
|
+
]
|
|
135
|
+
})
|
|
136
|
+
return
|
|
137
|
+
}
|
|
121
138
|
if (ast.isSpecificationElementKind(node) || ast.isSpecificationRelationshipKind(node)) {
|
|
122
139
|
acceptor({
|
|
123
140
|
node,
|
|
@@ -188,7 +205,8 @@ export class LikeC4SemanticTokenProvider extends AbstractSemanticTokenProvider {
|
|
|
188
205
|
acceptor({
|
|
189
206
|
node,
|
|
190
207
|
property: 'libicon',
|
|
191
|
-
type: SemanticTokenTypes.enum
|
|
208
|
+
type: SemanticTokenTypes.enum,
|
|
209
|
+
modifier: [SemanticTokenModifiers.defaultLibrary]
|
|
192
210
|
})
|
|
193
211
|
}
|
|
194
212
|
return 'prune'
|
package/src/lsp/index.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { AsFqn,
|
|
1
|
+
import { AsFqn, nonexhaustive } from '@likec4/core'
|
|
2
|
+
import type * as c4 from '@likec4/core'
|
|
2
3
|
import { type AstNodeDescription, type AstNodeLocator, AstUtils, CstUtils, GrammarUtils, MultiMap } from 'langium'
|
|
3
|
-
import {
|
|
4
|
+
import { isDefined, isEmpty } from 'remeda'
|
|
4
5
|
import { ast, ElementOps, type LikeC4LangiumDocument } from '../ast'
|
|
5
6
|
import { getFqnElementRef } from '../elementRef'
|
|
7
|
+
import { logError } from '../logger'
|
|
6
8
|
import type { LikeC4Services } from '../module'
|
|
7
9
|
|
|
8
10
|
const { findNodeForProperty } = GrammarUtils
|
|
@@ -41,29 +43,37 @@ export function computeDocumentFqn(document: LikeC4LangiumDocument, services: Li
|
|
|
41
43
|
const traverseStack: TraversePair[] = elements.map(el => [el, null])
|
|
42
44
|
let pair
|
|
43
45
|
while ((pair = traverseStack.shift())) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (ast.isExtendElement(el)) {
|
|
49
|
-
if (!isNil(el.body) && !isEmpty(el.body.elements)) {
|
|
50
|
-
const fqn = getFqnElementRef(el.element)
|
|
51
|
-
el.body.elements.forEach(child => traverseStack.push([child, fqn]))
|
|
46
|
+
try {
|
|
47
|
+
const [el, parent] = pair
|
|
48
|
+
if (ast.isRelation(el)) {
|
|
49
|
+
continue
|
|
52
50
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (
|
|
63
|
-
|
|
51
|
+
if (ast.isExtendElement(el)) {
|
|
52
|
+
if (isDefined(el.body) && !isEmpty(el.body.elements)) {
|
|
53
|
+
const fqn = getFqnElementRef(el.element)
|
|
54
|
+
for (const child of el.body.elements) {
|
|
55
|
+
traverseStack.push([child, fqn])
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
continue
|
|
59
|
+
}
|
|
60
|
+
if (ast.isElement(el)) {
|
|
61
|
+
const fqn = AsFqn(el.name, parent)
|
|
62
|
+
c4fqnIndex.add(fqn, {
|
|
63
|
+
...toAstNodeDescription(locator, el, document),
|
|
64
|
+
fqn
|
|
65
|
+
})
|
|
66
|
+
ElementOps.writeId(el, fqn)
|
|
67
|
+
if (isDefined(el.body) && !isEmpty(el.body.elements)) {
|
|
68
|
+
for (const child of el.body.elements) {
|
|
69
|
+
traverseStack.push([child, fqn])
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
continue
|
|
64
73
|
}
|
|
65
|
-
|
|
74
|
+
nonexhaustive(el)
|
|
75
|
+
} catch (e) {
|
|
76
|
+
logError(e)
|
|
66
77
|
}
|
|
67
|
-
nonexhaustive(el)
|
|
68
78
|
}
|
|
69
79
|
}
|
package/src/model/fqn-index.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { AstNodeDescription, LangiumDocuments, Stream } from 'langium'
|
|
|
4
4
|
import { DocumentState, DONE_RESULT, MultiMap, stream, StreamImpl } from 'langium'
|
|
5
5
|
import type { ast, DocFqnIndexAstNodeDescription, FqnIndexedDocument } from '../ast'
|
|
6
6
|
import { ElementOps, isFqnIndexedDocument, isLikeC4LangiumDocument } from '../ast'
|
|
7
|
-
import {
|
|
7
|
+
import { logger, logWarnError } from '../logger'
|
|
8
8
|
import type { LikeC4Services } from '../module'
|
|
9
9
|
import { printDocs } from '../utils/printDocs'
|
|
10
10
|
import { computeDocumentFqn } from './fqn-computation'
|
|
@@ -26,7 +26,6 @@ export class FqnIndex {
|
|
|
26
26
|
services.shared.workspace.DocumentBuilder.onBuildPhase(
|
|
27
27
|
DocumentState.IndexedContent,
|
|
28
28
|
async (docs, _cancelToken) => {
|
|
29
|
-
logger.debug(`[FqnIndex] onIndexedContent ${docs.length}:\n` + printDocs(docs))
|
|
30
29
|
for (const doc of docs) {
|
|
31
30
|
if (isLikeC4LangiumDocument(doc)) {
|
|
32
31
|
delete doc.c4fqnIndex
|
|
@@ -37,11 +36,11 @@ export class FqnIndex {
|
|
|
37
36
|
try {
|
|
38
37
|
computeDocumentFqn(doc, services)
|
|
39
38
|
} catch (e) {
|
|
40
|
-
|
|
39
|
+
logWarnError(e)
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
|
-
return Promise.resolve()
|
|
43
|
+
return await Promise.resolve()
|
|
45
44
|
}
|
|
46
45
|
)
|
|
47
46
|
logger.debug(`[FqnIndex] Created`)
|
|
@@ -51,29 +50,14 @@ export class FqnIndex {
|
|
|
51
50
|
return this.langiumDocuments.all.filter(isFqnIndexedDocument)
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
private entries(filterByFqn
|
|
53
|
+
private entries(filterByFqn: (fqn: Fqn) => boolean): Stream<DocFqnIndexAstNodeDescription> {
|
|
55
54
|
return this.documents.flatMap(doc => {
|
|
56
|
-
|
|
57
|
-
return doc.c4fqnIndex.keys().filter(filterByFqn).flatMap(fqn => doc.c4fqnIndex.get(fqn))
|
|
58
|
-
}
|
|
59
|
-
return doc.c4fqnIndex.values()
|
|
55
|
+
return doc.c4fqnIndex.keys().filter(filterByFqn).flatMap(fqn => doc.c4fqnIndex.get(fqn))
|
|
60
56
|
})
|
|
61
57
|
}
|
|
62
58
|
|
|
63
59
|
public getFqn(el: ast.Element): Fqn | null {
|
|
64
60
|
return ElementOps.readId(el) ?? null
|
|
65
|
-
// let fqn = ElementOps.readId(el) ?? null
|
|
66
|
-
// if (fqn) {
|
|
67
|
-
// const doc = getDocument(el)
|
|
68
|
-
// if (isFqnIndexedDocument(doc) && doc.c4fqns.has(fqn)) {
|
|
69
|
-
// return fqn
|
|
70
|
-
// }
|
|
71
|
-
// const path = this.services.workspace.AstNodeLocator.getAstNodePath(el)
|
|
72
|
-
// logError(`Clean cached FQN ${fqn} at ${path}`)
|
|
73
|
-
// ElementOps.writeId(el, null)
|
|
74
|
-
// fqn = null
|
|
75
|
-
// }
|
|
76
|
-
// return fqn
|
|
77
61
|
}
|
|
78
62
|
|
|
79
63
|
public byFqn(fqn: Fqn): Stream<AstNodeDescription> {
|