@likec4/language-server 1.17.1 → 1.19.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/LikeC4FileSystem.d.ts +13 -0
- package/dist/LikeC4FileSystem.js +27 -0
- package/dist/Rpc.d.ts +9 -0
- package/dist/Rpc.js +126 -0
- package/dist/ast.d.ts +200 -0
- package/dist/ast.js +276 -0
- package/dist/browser.d.ts +6 -20
- package/dist/browser.js +13 -0
- package/dist/formatting/LikeC4Formatter.d.ts +27 -0
- package/dist/formatting/LikeC4Formatter.js +261 -0
- package/dist/formatting/utils.d.ts +6 -0
- package/dist/formatting/utils.js +15 -0
- package/dist/generated/ast.d.ts +1242 -0
- package/dist/generated/ast.js +1945 -0
- package/dist/generated/grammar.d.ts +6 -0
- package/dist/generated/grammar.js +3 -0
- package/dist/generated/module.d.ts +9 -0
- package/dist/generated/module.js +23 -0
- package/dist/generated-lib/icons.d.ts +1 -0
- package/dist/{likec4lib.mjs → generated-lib/icons.js} +1 -6
- package/dist/index.d.ts +8 -31
- package/dist/index.js +13 -0
- package/dist/like-c4.langium +845 -0
- package/dist/likec4lib.d.ts +4 -6
- package/dist/likec4lib.js +4 -0
- package/dist/logger.d.ts +7 -0
- package/dist/logger.js +73 -0
- package/dist/lsp/CodeLensProvider.d.ts +9 -0
- package/dist/lsp/CodeLensProvider.js +40 -0
- package/dist/lsp/CompletionProvider.d.ts +6 -0
- package/dist/lsp/CompletionProvider.js +135 -0
- package/dist/lsp/DocumentHighlightProvider.d.ts +9 -0
- package/dist/lsp/DocumentHighlightProvider.js +10 -0
- package/dist/lsp/DocumentLinkProvider.d.ts +11 -0
- package/dist/lsp/DocumentLinkProvider.js +49 -0
- package/dist/lsp/DocumentSymbolProvider.d.ts +23 -0
- package/dist/lsp/DocumentSymbolProvider.js +202 -0
- package/dist/lsp/HoverProvider.d.ts +10 -0
- package/dist/lsp/HoverProvider.js +69 -0
- package/dist/lsp/RenameProvider.d.ts +5 -0
- package/dist/lsp/RenameProvider.js +6 -0
- package/dist/lsp/SemanticTokenProvider.d.ts +7 -0
- package/dist/lsp/SemanticTokenProvider.js +297 -0
- package/dist/lsp/index.d.ts +7 -0
- package/dist/lsp/index.js +7 -0
- package/dist/model/deployments-index.d.ts +60 -0
- package/dist/model/deployments-index.js +181 -0
- package/dist/model/fqn-computation.d.ts +3 -0
- package/dist/model/fqn-computation.js +72 -0
- package/dist/model/fqn-index.d.ts +25 -0
- package/dist/model/fqn-index.js +96 -0
- package/dist/model/index.d.ts +6 -0
- package/dist/model/index.js +6 -0
- package/dist/model/model-builder.d.ts +32 -0
- package/dist/model/model-builder.js +598 -0
- package/dist/model/model-locator.d.ts +23 -0
- package/dist/model/model-locator.js +126 -0
- package/dist/model/model-parser-where.d.ts +3 -0
- package/dist/model/model-parser-where.js +70 -0
- package/dist/model/model-parser.d.ts +292 -0
- package/dist/model/model-parser.js +72 -0
- package/dist/model/parser/Base.d.ts +28 -0
- package/dist/model/parser/Base.js +87 -0
- package/dist/model/parser/DeploymentModelParser.d.ts +33 -0
- package/dist/model/parser/DeploymentModelParser.js +162 -0
- package/dist/model/parser/DeploymentViewParser.d.ts +38 -0
- package/dist/model/parser/DeploymentViewParser.js +98 -0
- package/dist/model/parser/FqnRefParser.d.ts +29 -0
- package/dist/model/parser/FqnRefParser.js +108 -0
- package/dist/model/parser/GlobalsParser.d.ts +66 -0
- package/dist/model/parser/GlobalsParser.js +80 -0
- package/dist/model/parser/ModelParser.d.ts +27 -0
- package/dist/model/parser/ModelParser.js +122 -0
- package/dist/model/parser/PredicatesParser.d.ts +34 -0
- package/dist/model/parser/PredicatesParser.js +272 -0
- package/dist/model/parser/SpecificationParser.d.ts +27 -0
- package/dist/model/parser/SpecificationParser.js +120 -0
- package/dist/model/parser/ViewsParser.d.ts +64 -0
- package/dist/model/parser/ViewsParser.js +377 -0
- package/dist/model-change/ModelChanges.d.ts +15 -0
- package/dist/model-change/ModelChanges.js +89 -0
- package/dist/model-change/changeElementStyle.d.ts +16 -0
- package/dist/model-change/changeElementStyle.js +136 -0
- package/dist/model-change/changeViewLayout.d.ts +12 -0
- package/dist/model-change/changeViewLayout.js +32 -0
- package/dist/model-change/saveManualLayout.d.ts +11 -0
- package/dist/model-change/saveManualLayout.js +27 -0
- package/dist/module.d.ts +62 -0
- package/dist/module.js +123 -0
- package/dist/protocol.d.ts +27 -27
- package/dist/protocol.js +14 -0
- package/dist/references/index.d.ts +3 -0
- package/dist/references/index.js +3 -0
- package/dist/references/name-provider.d.ts +9 -0
- package/dist/references/name-provider.js +33 -0
- package/dist/references/scope-computation.d.ts +20 -0
- package/dist/references/scope-computation.js +281 -0
- package/dist/references/scope-provider.d.ts +16 -0
- package/dist/references/scope-provider.js +165 -0
- package/dist/shared/NodeKindProvider.d.ts +15 -0
- package/dist/shared/NodeKindProvider.js +108 -0
- package/dist/shared/WorkspaceManager.d.ts +18 -0
- package/dist/shared/WorkspaceManager.js +36 -0
- package/dist/shared/WorkspaceSymbolProvider.d.ts +3 -0
- package/dist/shared/WorkspaceSymbolProvider.js +3 -0
- package/dist/shared/index.d.ts +3 -0
- package/dist/shared/index.js +3 -0
- package/dist/test/index.d.ts +1 -0
- package/dist/test/index.js +1 -0
- package/dist/test/setup.d.ts +1 -0
- package/dist/test/setup.js +7 -0
- package/dist/test/testServices.d.ts +22 -0
- package/dist/test/testServices.js +119 -0
- package/dist/utils/elementRef.d.ts +11 -0
- package/dist/utils/elementRef.js +15 -0
- package/dist/utils/fqnRef.d.ts +8 -0
- package/dist/utils/fqnRef.js +46 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/printDocs.d.ts +2 -0
- package/dist/utils/printDocs.js +1 -0
- package/dist/utils/stringHash.d.ts +1 -0
- package/dist/utils/stringHash.js +5 -0
- package/dist/validation/_shared.d.ts +3 -0
- package/dist/validation/_shared.js +22 -0
- package/dist/validation/deployment-checks.d.ts +6 -0
- package/dist/validation/deployment-checks.js +114 -0
- package/dist/validation/dynamic-view-rule.d.ts +4 -0
- package/dist/validation/dynamic-view-rule.js +16 -0
- package/dist/validation/dynamic-view-step.d.ts +4 -0
- package/dist/validation/dynamic-view-step.js +33 -0
- package/dist/validation/element.d.ts +4 -0
- package/dist/validation/element.js +49 -0
- package/dist/validation/index.d.ts +15 -0
- package/dist/validation/index.js +152 -0
- package/dist/validation/property-checks.d.ts +6 -0
- package/dist/validation/property-checks.js +38 -0
- package/dist/validation/relation.d.ts +5 -0
- package/dist/validation/relation.js +56 -0
- package/dist/validation/specification.d.ts +11 -0
- package/dist/validation/specification.js +136 -0
- package/dist/validation/view-predicates/element-with.d.ts +4 -0
- package/dist/validation/view-predicates/element-with.js +30 -0
- package/dist/validation/view-predicates/expanded-element.d.ts +4 -0
- package/dist/validation/view-predicates/expanded-element.js +11 -0
- package/dist/validation/view-predicates/expression-v2.d.ts +5 -0
- package/dist/validation/view-predicates/expression-v2.js +83 -0
- package/dist/validation/view-predicates/incoming.d.ts +4 -0
- package/dist/validation/view-predicates/incoming.js +15 -0
- package/dist/validation/view-predicates/index.d.ts +6 -0
- package/dist/validation/view-predicates/index.js +6 -0
- package/dist/validation/view-predicates/outgoing.d.ts +4 -0
- package/dist/validation/view-predicates/outgoing.js +15 -0
- package/dist/validation/view-predicates/relation-with.d.ts +4 -0
- package/dist/validation/view-predicates/relation-with.js +12 -0
- package/dist/validation/view.d.ts +4 -0
- package/dist/validation/view.js +23 -0
- package/dist/view-utils/assignNavigateTo.d.ts +2 -0
- package/dist/view-utils/assignNavigateTo.js +25 -0
- package/dist/view-utils/index.d.ts +2 -0
- package/dist/view-utils/index.js +2 -0
- package/dist/view-utils/manual-layout.d.ts +7 -0
- package/dist/view-utils/manual-layout.js +99 -0
- package/dist/view-utils/resolve-relative-paths.d.ts +2 -0
- package/dist/view-utils/resolve-relative-paths.js +78 -0
- package/package.json +42 -73
- package/src/LikeC4FileSystem.ts +22 -21
- package/src/Rpc.ts +6 -3
- package/src/ast.ts +136 -172
- package/src/browser.ts +10 -11
- package/src/generated/ast.ts +656 -40
- package/src/generated/grammar.ts +1 -1
- package/src/index.ts +11 -8
- package/src/like-c4.langium +173 -22
- package/src/logger.ts +41 -57
- package/src/lsp/CodeLensProvider.ts +0 -1
- package/src/lsp/CompletionProvider.ts +20 -5
- package/src/lsp/DocumentSymbolProvider.ts +5 -2
- package/src/lsp/HoverProvider.ts +37 -3
- package/src/lsp/SemanticTokenProvider.ts +58 -32
- package/src/model/deployments-index.ts +222 -0
- package/src/model/fqn-computation.ts +1 -1
- package/src/model/fqn-index.ts +0 -1
- package/src/model/index.ts +1 -0
- package/src/model/model-builder.ts +176 -39
- package/src/model/model-locator.ts +36 -7
- package/src/model/model-parser.ts +69 -1119
- package/src/model/parser/Base.ts +107 -0
- package/src/model/parser/DeploymentModelParser.ts +192 -0
- package/src/model/parser/DeploymentViewParser.ts +116 -0
- package/src/model/parser/FqnRefParser.ts +118 -0
- package/src/model/parser/GlobalsParser.ts +96 -0
- package/src/model/parser/ModelParser.ts +141 -0
- package/src/model/parser/PredicatesParser.ts +291 -0
- package/src/model/parser/SpecificationParser.ts +133 -0
- package/src/model/parser/ViewsParser.ts +428 -0
- package/src/model-change/changeViewLayout.ts +2 -2
- package/src/module.ts +26 -21
- package/src/protocol.ts +10 -6
- package/src/references/index.ts +1 -0
- package/src/references/name-provider.ts +37 -0
- package/src/references/scope-computation.ts +130 -21
- package/src/references/scope-provider.ts +68 -35
- package/src/shared/NodeKindProvider.ts +15 -3
- package/src/{elementRef.ts → utils/elementRef.ts} +1 -1
- package/src/utils/fqnRef.ts +56 -0
- package/src/utils/stringHash.ts +2 -2
- package/src/validation/_shared.ts +6 -5
- package/src/validation/deployment-checks.ts +131 -0
- package/src/validation/dynamic-view-step.ts +1 -1
- package/src/validation/index.ts +104 -6
- package/src/validation/relation.ts +1 -1
- package/src/validation/view-predicates/expression-v2.ts +101 -0
- package/src/validation/view-predicates/index.ts +1 -0
- package/src/view-utils/assignNavigateTo.ts +6 -5
- package/src/view-utils/index.ts +0 -1
- package/src/view-utils/manual-layout.ts +25 -0
- package/dist/browser.cjs +0 -25
- package/dist/browser.d.cts +0 -23
- package/dist/browser.d.mts +0 -23
- package/dist/browser.mjs +0 -20
- package/dist/index.cjs +0 -53
- package/dist/index.d.cts +0 -34
- package/dist/index.d.mts +0 -34
- package/dist/index.mjs +0 -46
- package/dist/likec4lib.cjs +0 -1546
- package/dist/likec4lib.d.cts +0 -6
- package/dist/likec4lib.d.mts +0 -6
- package/dist/model-graph/index.cjs +0 -10
- package/dist/model-graph/index.d.cts +0 -81
- package/dist/model-graph/index.d.mts +0 -81
- package/dist/model-graph/index.d.ts +0 -81
- package/dist/model-graph/index.mjs +0 -1
- package/dist/protocol.cjs +0 -25
- package/dist/protocol.d.cts +0 -45
- package/dist/protocol.d.mts +0 -45
- package/dist/protocol.mjs +0 -17
- package/dist/shared/language-server.BIbAD1T-.mjs +0 -6292
- package/dist/shared/language-server.BQRvVmE0.d.cts +0 -1303
- package/dist/shared/language-server.BysPcTxr.d.ts +0 -1303
- package/dist/shared/language-server.D2QdbOJO.cjs +0 -1995
- package/dist/shared/language-server.DGrBGmsd.mjs +0 -1981
- package/dist/shared/language-server.DKV_FdPN.cjs +0 -6304
- package/dist/shared/language-server._wkyPgso.d.mts +0 -1303
- package/src/model-graph/LikeC4ModelGraph.ts +0 -338
- package/src/model-graph/compute-view/__test__/fixture.ts +0 -630
- package/src/model-graph/compute-view/compute.ts +0 -788
- package/src/model-graph/compute-view/index.ts +0 -33
- package/src/model-graph/compute-view/predicates.ts +0 -509
- package/src/model-graph/dynamic-view/__test__/fixture.ts +0 -61
- package/src/model-graph/dynamic-view/compute.ts +0 -313
- package/src/model-graph/dynamic-view/index.ts +0 -29
- package/src/model-graph/index.ts +0 -3
- package/src/model-graph/utils/applyCustomElementProperties.ts +0 -65
- package/src/model-graph/utils/applyCustomRelationProperties.ts +0 -41
- package/src/model-graph/utils/applyViewRuleStyles.ts +0 -49
- package/src/model-graph/utils/buildComputeNodes.ts +0 -113
- package/src/model-graph/utils/buildElementNotations.ts +0 -63
- package/src/model-graph/utils/elementExpressionToPredicate.ts +0 -39
- package/src/model-graph/utils/relationExpressionToPredicates.ts +0 -43
- package/src/model-graph/utils/sortNodes.ts +0 -105
- package/src/model-graph/utils/uniqueTags.test.ts +0 -42
- package/src/model-graph/utils/uniqueTags.ts +0 -19
- package/src/utils/graphlib.ts +0 -9
- package/src/view-utils/resolve-extended-views.ts +0 -66
- package/src/view-utils/resolve-global-rules.ts +0 -88
- package/src/view-utils/view-hash.ts +0 -27
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { isAncestor } from '@likec4/core'
|
|
2
2
|
import type { ValidationCheck } from 'langium'
|
|
3
3
|
import { ast } from '../ast'
|
|
4
|
-
import { elementRef } from '../elementRef'
|
|
5
4
|
import { logError } from '../logger'
|
|
6
5
|
import type { LikeC4Services } from '../module'
|
|
6
|
+
import { elementRef } from '../utils/elementRef'
|
|
7
7
|
|
|
8
8
|
export const dynamicViewStep = (services: LikeC4Services): ValidationCheck<ast.DynamicViewStep> => {
|
|
9
9
|
const fqnIndex = services.likec4.FqnIndex
|
package/src/validation/index.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AstNode } from 'langium'
|
|
2
|
+
import { isNullish } from 'remeda'
|
|
3
|
+
import { DiagnosticSeverity } from 'vscode-languageserver-types'
|
|
4
|
+
import { type LikeC4AstNode, type LikeC4LangiumDocument, ast } from '../ast'
|
|
2
5
|
import { logger } from '../logger'
|
|
3
6
|
import type { LikeC4Services } from '../module'
|
|
7
|
+
import { deployedInstanceChecks, deploymentNodeChecks, deploymentRelationChecks } from './deployment-checks'
|
|
4
8
|
import { dynamicViewRulePredicate } from './dynamic-view-rule'
|
|
5
9
|
import { dynamicViewStep } from './dynamic-view-step'
|
|
6
10
|
import { elementChecks } from './element'
|
|
@@ -14,21 +18,115 @@ import {
|
|
|
14
18
|
modelRuleChecks,
|
|
15
19
|
relationshipChecks,
|
|
16
20
|
specificationRuleChecks,
|
|
17
|
-
tagChecks
|
|
21
|
+
tagChecks,
|
|
18
22
|
} from './specification'
|
|
19
23
|
import { viewChecks } from './view'
|
|
20
24
|
import {
|
|
21
25
|
elementPredicateWithChecks,
|
|
22
26
|
expandElementExprChecks,
|
|
27
|
+
fqnRefExprChecks,
|
|
23
28
|
incomingExpressionChecks,
|
|
24
29
|
outgoingExpressionChecks,
|
|
25
|
-
|
|
30
|
+
relationExprChecks,
|
|
31
|
+
relationPredicateWithChecks,
|
|
26
32
|
} from './view-predicates'
|
|
27
33
|
|
|
34
|
+
type Guard<N extends AstNode> = (n: AstNode) => n is N
|
|
35
|
+
type Guarded<G> = G extends Guard<infer N> ? N : never
|
|
36
|
+
|
|
37
|
+
function validatableAstNodeGuards<const Predicates extends Guard<AstNode>[]>(
|
|
38
|
+
predicates: Predicates,
|
|
39
|
+
) {
|
|
40
|
+
return (n: AstNode): n is Guarded<Predicates[number]> => predicates.some(p => p(n))
|
|
41
|
+
}
|
|
42
|
+
const isValidatableAstNode = validatableAstNodeGuards([
|
|
43
|
+
ast.isGlobals,
|
|
44
|
+
ast.isGlobalPredicateGroup,
|
|
45
|
+
ast.isGlobalDynamicPredicateGroup,
|
|
46
|
+
ast.isGlobalStyle,
|
|
47
|
+
ast.isGlobalStyleGroup,
|
|
48
|
+
ast.isDynamicViewPredicateIterator,
|
|
49
|
+
ast.isElementPredicateWith,
|
|
50
|
+
ast.isRelationPredicateWith,
|
|
51
|
+
ast.isElementExpression,
|
|
52
|
+
ast.isRelationExpression,
|
|
53
|
+
ast.isDynamicViewParallelSteps,
|
|
54
|
+
ast.isDynamicViewStep,
|
|
55
|
+
ast.isDeploymentViewRule,
|
|
56
|
+
ast.isDeploymentViewRulePredicate,
|
|
57
|
+
ast.isExpressionV2,
|
|
58
|
+
ast.isRelationExpr,
|
|
59
|
+
ast.isFqnRefExpr,
|
|
60
|
+
ast.isViewProperty,
|
|
61
|
+
ast.isStyleProperty,
|
|
62
|
+
ast.isPredicate,
|
|
63
|
+
ast.isTags,
|
|
64
|
+
ast.isViewRule,
|
|
65
|
+
ast.isDynamicViewRule,
|
|
66
|
+
ast.isLikeC4View,
|
|
67
|
+
ast.isViewRuleStyleOrGlobalRef,
|
|
68
|
+
ast.isDeployedInstance,
|
|
69
|
+
ast.isDeploymentNode,
|
|
70
|
+
ast.isDeploymentRelation,
|
|
71
|
+
ast.isRelationshipStyleProperty,
|
|
72
|
+
ast.isMetadataProperty,
|
|
73
|
+
ast.isRelation,
|
|
74
|
+
ast.isElementProperty,
|
|
75
|
+
ast.isStringProperty,
|
|
76
|
+
ast.isNavigateToProperty,
|
|
77
|
+
ast.isElement,
|
|
78
|
+
ast.isExtendElement,
|
|
79
|
+
ast.isSpecificationElementKind,
|
|
80
|
+
ast.isSpecificationRelationshipKind,
|
|
81
|
+
ast.isSpecificationDeploymentNodeKind,
|
|
82
|
+
ast.isSpecificationTag,
|
|
83
|
+
ast.isSpecificationColor,
|
|
84
|
+
ast.isSpecificationRule,
|
|
85
|
+
])
|
|
86
|
+
type ValidatableAstNode = Guarded<typeof isValidatableAstNode>
|
|
87
|
+
|
|
88
|
+
const findInvalidContainer = (node: LikeC4AstNode): ValidatableAstNode | undefined => {
|
|
89
|
+
let nd = node as LikeC4AstNode['$container']
|
|
90
|
+
while (nd && !ast.isLikeC4Grammar(nd)) {
|
|
91
|
+
if (isValidatableAstNode(nd)) {
|
|
92
|
+
return nd
|
|
93
|
+
}
|
|
94
|
+
nd = nd.$container
|
|
95
|
+
}
|
|
96
|
+
return undefined
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function checksFromDiagnostics(doc: LikeC4LangiumDocument) {
|
|
100
|
+
const errors = doc.diagnostics?.filter(d => d.severity === DiagnosticSeverity.Error) ?? []
|
|
101
|
+
const invalidNodes = new WeakSet()
|
|
102
|
+
for (const { node } of errors) {
|
|
103
|
+
if (isNullish(node) || invalidNodes.has(node)) {
|
|
104
|
+
continue
|
|
105
|
+
}
|
|
106
|
+
invalidNodes.add(node)
|
|
107
|
+
const container = findInvalidContainer(node)
|
|
108
|
+
if (container) {
|
|
109
|
+
invalidNodes.add(container)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const isValid = (n: ValidatableAstNode) => !invalidNodes.has(n)
|
|
113
|
+
return {
|
|
114
|
+
isValid,
|
|
115
|
+
invalidNodes,
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
export type ChecksFromDiagnostics = ReturnType<typeof checksFromDiagnostics>
|
|
119
|
+
export type IsValidFn = ChecksFromDiagnostics['isValid']
|
|
120
|
+
|
|
28
121
|
export function registerValidationChecks(services: LikeC4Services) {
|
|
29
|
-
logger.
|
|
122
|
+
logger.debug('registerValidationChecks')
|
|
30
123
|
const registry = services.validation.ValidationRegistry
|
|
31
124
|
registry.register<ast.LikeC4AstType>({
|
|
125
|
+
DeployedInstance: deployedInstanceChecks(services),
|
|
126
|
+
DeploymentNode: deploymentNodeChecks(services),
|
|
127
|
+
DeploymentRelation: deploymentRelationChecks(services),
|
|
128
|
+
FqnRefExpr: fqnRefExprChecks(services),
|
|
129
|
+
RelationExpr: relationExprChecks(services),
|
|
32
130
|
NotesProperty: notesPropertyRuleChecks(services),
|
|
33
131
|
OpacityProperty: opacityPropertyRuleChecks(services),
|
|
34
132
|
IconProperty: iconPropertyRuleChecks(services),
|
|
@@ -51,7 +149,7 @@ export function registerValidationChecks(services: LikeC4Services) {
|
|
|
51
149
|
ExpandElementExpression: expandElementExprChecks(services),
|
|
52
150
|
RelationshipKind: relationshipChecks(services),
|
|
53
151
|
IncomingRelationExpression: incomingExpressionChecks(services),
|
|
54
|
-
OutgoingRelationExpression: outgoingExpressionChecks(services)
|
|
152
|
+
OutgoingRelationExpression: outgoingExpressionChecks(services),
|
|
55
153
|
})
|
|
56
154
|
const connection = services.shared.lsp.Connection
|
|
57
155
|
if (connection) {
|
|
@@ -61,7 +159,7 @@ export function registerValidationChecks(services: LikeC4Services) {
|
|
|
61
159
|
logger.debug(`clear diagnostics for deleted ${uri.path}`)
|
|
62
160
|
void connection.sendDiagnostics({
|
|
63
161
|
uri: uri.toString(),
|
|
64
|
-
diagnostics: []
|
|
162
|
+
diagnostics: [],
|
|
65
163
|
})
|
|
66
164
|
}
|
|
67
165
|
})
|
|
@@ -2,8 +2,8 @@ import { isSameHierarchy } from '@likec4/core'
|
|
|
2
2
|
import type { ValidationCheck } from 'langium'
|
|
3
3
|
import { isDefined } from 'remeda'
|
|
4
4
|
import { ast } from '../ast'
|
|
5
|
-
import { elementRef } from '../elementRef'
|
|
6
5
|
import type { LikeC4Services } from '../module'
|
|
6
|
+
import { elementRef } from '../utils/elementRef'
|
|
7
7
|
import { tryOrLog } from './_shared'
|
|
8
8
|
|
|
9
9
|
export const relationChecks = (services: LikeC4Services): ValidationCheck<ast.Relation> => {
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { FqnExpr, FqnRef } from '@likec4/core'
|
|
2
|
+
import { AstUtils, type ValidationCheck } from 'langium'
|
|
3
|
+
import { isNonNullish, isNullish } from 'remeda'
|
|
4
|
+
import { ast } from '../../ast'
|
|
5
|
+
import type { LikeC4Services } from '../../module'
|
|
6
|
+
import { tryOrLog } from '../_shared'
|
|
7
|
+
|
|
8
|
+
export const relationExprChecks = (services: LikeC4Services): ValidationCheck<ast.RelationExpr> => {
|
|
9
|
+
const ModelParser = services.likec4.ModelParser
|
|
10
|
+
return tryOrLog((node, accept) => {
|
|
11
|
+
if (node.$container.$type !== 'DeploymentViewRulePredicateExpression') {
|
|
12
|
+
// skip validation for this node, validated by container
|
|
13
|
+
return
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const predicate = AstUtils.getContainerOfType(node, ast.isDeploymentViewRulePredicate)
|
|
17
|
+
if (!predicate || predicate.isInclude !== true) {
|
|
18
|
+
// no restriction for exclude predicate
|
|
19
|
+
return
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const doc = AstUtils.getDocument(node)
|
|
23
|
+
const parser = ModelParser.forDocument(doc)
|
|
24
|
+
|
|
25
|
+
const ModelRefOnlyExclude = 'Model reference is allowed in exclude predicate only'
|
|
26
|
+
|
|
27
|
+
if (ast.isDirectedRelationExpr(node)) {
|
|
28
|
+
if (FqnExpr.isModelRef(parser.parseFqnExpr(node.source.from))) {
|
|
29
|
+
accept('error', ModelRefOnlyExclude, {
|
|
30
|
+
node: node.source,
|
|
31
|
+
property: 'from'
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (FqnExpr.isModelRef(parser.parseFqnExpr(node.target))) {
|
|
36
|
+
accept('error', ModelRefOnlyExclude, {
|
|
37
|
+
node,
|
|
38
|
+
property: 'target'
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let expr: ast.FqnExpr
|
|
45
|
+
if (ast.isIncomingRelationExpr(node)) {
|
|
46
|
+
expr = node.to
|
|
47
|
+
} else if (ast.isOutgoingRelationExpr(node)) {
|
|
48
|
+
expr = node.from
|
|
49
|
+
} else {
|
|
50
|
+
expr = node.inout.to
|
|
51
|
+
}
|
|
52
|
+
if (FqnExpr.isModelRef(parser.parseFqnExpr(expr))) {
|
|
53
|
+
accept('error', ModelRefOnlyExclude, {
|
|
54
|
+
node
|
|
55
|
+
})
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const fqnRefExprChecks = (services: LikeC4Services): ValidationCheck<ast.FqnRefExpr> => {
|
|
62
|
+
const ModelParser = services.likec4.ModelParser
|
|
63
|
+
// const DeploymentsIndex = services.likec4.DeploymentsIndex
|
|
64
|
+
// const Names = services.references.NameProvider as LikeC4NameProvider
|
|
65
|
+
// const Locator = services.workspace.AstNodeLocator
|
|
66
|
+
// const fqnIndex = services.likec4.FqnIndex
|
|
67
|
+
return tryOrLog((node, accept) => {
|
|
68
|
+
const referenceTo = node.ref.value.ref
|
|
69
|
+
if (isNullish(referenceTo)) {
|
|
70
|
+
accept('error', 'Invalid empty reference', {
|
|
71
|
+
node
|
|
72
|
+
})
|
|
73
|
+
return
|
|
74
|
+
}
|
|
75
|
+
const doc = AstUtils.getDocument(node)
|
|
76
|
+
const expr = ModelParser.forDocument(doc).parseFqnRefExpr(node)
|
|
77
|
+
|
|
78
|
+
// This expression is part of element predicate
|
|
79
|
+
if (node.$container.$type === 'DeploymentViewRulePredicateExpression') {
|
|
80
|
+
if (FqnExpr.isModelRef(expr)) {
|
|
81
|
+
accept('error', 'Deployment view predicate must reference deployment model', {
|
|
82
|
+
node
|
|
83
|
+
})
|
|
84
|
+
return
|
|
85
|
+
}
|
|
86
|
+
if (FqnExpr.isDeploymentRef(expr) && FqnRef.isInsideInstanceRef(expr.ref)) {
|
|
87
|
+
accept('error', 'Must reference deployment nodes or instances, but not internals', {
|
|
88
|
+
node
|
|
89
|
+
})
|
|
90
|
+
return
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (!ast.isDeploymentNode(referenceTo) && isNonNullish(node.selector)) {
|
|
95
|
+
accept('warning', `Selector '${node.selector}' applies to deployment nodes only, ignored here`, {
|
|
96
|
+
node,
|
|
97
|
+
property: 'selector'
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComputedNode, ComputedView, type Fqn, type ViewId } from '@likec4/core'
|
|
2
2
|
import { find, isNullish } from 'remeda'
|
|
3
3
|
|
|
4
4
|
export function assignNavigateTo<R extends Iterable<ComputedView>>(views: R): R {
|
|
5
|
-
const allElementViews = new Map<Fqn,
|
|
5
|
+
const allElementViews = new Map<Fqn, ViewId[]>()
|
|
6
6
|
|
|
7
7
|
for (const v of views) {
|
|
8
|
-
if (
|
|
8
|
+
if (ComputedView.isElement(v) && v.viewOf && isNullish(v.extends)) {
|
|
9
9
|
const viewsOf = allElementViews.get(v.viewOf) ?? []
|
|
10
10
|
viewsOf.push(v.id)
|
|
11
11
|
allElementViews.set(v.viewOf, viewsOf)
|
|
@@ -15,11 +15,12 @@ export function assignNavigateTo<R extends Iterable<ComputedView>>(views: R): R
|
|
|
15
15
|
// set default navigateTo
|
|
16
16
|
for (const { id, nodes } of views) {
|
|
17
17
|
for (const node of nodes) {
|
|
18
|
-
|
|
18
|
+
const modelRef = ComputedNode.modelRef(node)
|
|
19
|
+
if (node.navigateTo || !modelRef) {
|
|
19
20
|
continue
|
|
20
21
|
}
|
|
21
22
|
// find first element view that is not the current one
|
|
22
|
-
const navigateTo = find(allElementViews.get(
|
|
23
|
+
const navigateTo = find(allElementViews.get(modelRef) ?? [], v => v !== id)
|
|
23
24
|
if (navigateTo) {
|
|
24
25
|
node.navigateTo = navigateTo
|
|
25
26
|
}
|
package/src/view-utils/index.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import type * as c4 from '@likec4/core'
|
|
1
2
|
import { isAutoLayoutDirection, type ViewManualLayout } from '@likec4/core'
|
|
2
3
|
import { decode, encode } from '@msgpack/msgpack'
|
|
3
4
|
import { fromBase64, toBase64 } from '@smithy/util-base64'
|
|
5
|
+
import { AstUtils, CstUtils } from 'langium'
|
|
4
6
|
import { mapValues } from 'remeda'
|
|
7
|
+
import type { ast } from '../ast'
|
|
8
|
+
import { logger } from '../logger'
|
|
9
|
+
|
|
10
|
+
const { getDocument } = AstUtils
|
|
5
11
|
|
|
6
12
|
function pack({
|
|
7
13
|
nodes,
|
|
@@ -89,3 +95,22 @@ export function deserializeFromComment(comment: string): ViewManualLayout {
|
|
|
89
95
|
const decodedb64 = fromBase64(b64)
|
|
90
96
|
return unpack(decode(decodedb64) as any) as ViewManualLayout
|
|
91
97
|
}
|
|
98
|
+
|
|
99
|
+
export function parseViewManualLayout(node: ast.LikeC4View): c4.ViewManualLayout | undefined {
|
|
100
|
+
const commentNode = CstUtils.findCommentNode(node.$cstNode, ['BLOCK_COMMENT'])
|
|
101
|
+
if (!commentNode || !hasManualLayout(commentNode.text)) {
|
|
102
|
+
return undefined
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
return deserializeFromComment(commentNode.text)
|
|
106
|
+
} catch (e) {
|
|
107
|
+
const doc = getDocument(node)
|
|
108
|
+
logger.warn(e)
|
|
109
|
+
logger.warn(
|
|
110
|
+
`Ignoring manual layout of "${node.name ?? 'unnamed'}" at ${doc.uri.fsPath}:${
|
|
111
|
+
1 + (commentNode.range.start.line || 0)
|
|
112
|
+
}`
|
|
113
|
+
)
|
|
114
|
+
return undefined
|
|
115
|
+
}
|
|
116
|
+
}
|
package/dist/browser.cjs
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const lsp = require('langium/lsp');
|
|
4
|
-
const browser = require('vscode-languageserver/browser');
|
|
5
|
-
const module$1 = require('./shared/language-server.DKV_FdPN.cjs');
|
|
6
|
-
|
|
7
|
-
function startLanguageServer() {
|
|
8
|
-
const messageReader = new browser.BrowserMessageReader(self);
|
|
9
|
-
const messageWriter = new browser.BrowserMessageWriter(self);
|
|
10
|
-
const connection = browser.createConnection(messageReader, messageWriter);
|
|
11
|
-
const services = module$1.createLanguageServices({ connection });
|
|
12
|
-
lsp.startLanguageServer(services.shared);
|
|
13
|
-
return {
|
|
14
|
-
...services,
|
|
15
|
-
connection,
|
|
16
|
-
messageReader,
|
|
17
|
-
messageWriter
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
exports.LikeC4Module = module$1.LikeC4Module;
|
|
22
|
-
exports.createCustomLanguageServices = module$1.createCustomLanguageServices;
|
|
23
|
-
exports.createLanguageServices = module$1.createLanguageServices;
|
|
24
|
-
exports.setLogLevel = module$1.setLogLevel;
|
|
25
|
-
exports.startLanguageServer = startLanguageServer;
|
package/dist/browser.d.cts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { L as LikeC4SharedServices, a as LikeC4Services } from './shared/language-server.BQRvVmE0.cjs';
|
|
2
|
-
export { f as FqnIndex, F as FqnIndexEntry, I as IsValidFn, k as LanguageServicesContext, j as LikeC4AddedServices, g as LikeC4ModelBuilder, h as LikeC4ModelLocator, i as LikeC4ModelParser, d as LikeC4Module, M as ModelParsedListener, e as computeDocumentFqn, c as createCustomLanguageServices, b as createLanguageServices, l as createSharedServices, s as setLogLevel } from './shared/language-server.BQRvVmE0.cjs';
|
|
3
|
-
import * as vscode_languageserver from 'vscode-languageserver';
|
|
4
|
-
import { BrowserMessageReader, BrowserMessageWriter } from 'vscode-languageserver/browser';
|
|
5
|
-
import 'langium';
|
|
6
|
-
import 'langium/lsp';
|
|
7
|
-
import 'vscode-languageserver-types';
|
|
8
|
-
import '@likec4/core';
|
|
9
|
-
import 'type-fest';
|
|
10
|
-
import './protocol.cjs';
|
|
11
|
-
import 'vscode-jsonrpc';
|
|
12
|
-
import 'vscode-uri';
|
|
13
|
-
import '@likec4/log';
|
|
14
|
-
|
|
15
|
-
declare function startLanguageServer(): {
|
|
16
|
-
connection: vscode_languageserver.Connection;
|
|
17
|
-
messageReader: BrowserMessageReader;
|
|
18
|
-
messageWriter: BrowserMessageWriter;
|
|
19
|
-
shared: LikeC4SharedServices;
|
|
20
|
-
likec4: LikeC4Services;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export { LikeC4Services, LikeC4SharedServices, startLanguageServer };
|
package/dist/browser.d.mts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { L as LikeC4SharedServices, a as LikeC4Services } from './shared/language-server._wkyPgso.mjs';
|
|
2
|
-
export { f as FqnIndex, F as FqnIndexEntry, I as IsValidFn, k as LanguageServicesContext, j as LikeC4AddedServices, g as LikeC4ModelBuilder, h as LikeC4ModelLocator, i as LikeC4ModelParser, d as LikeC4Module, M as ModelParsedListener, e as computeDocumentFqn, c as createCustomLanguageServices, b as createLanguageServices, l as createSharedServices, s as setLogLevel } from './shared/language-server._wkyPgso.mjs';
|
|
3
|
-
import * as vscode_languageserver from 'vscode-languageserver';
|
|
4
|
-
import { BrowserMessageReader, BrowserMessageWriter } from 'vscode-languageserver/browser';
|
|
5
|
-
import 'langium';
|
|
6
|
-
import 'langium/lsp';
|
|
7
|
-
import 'vscode-languageserver-types';
|
|
8
|
-
import '@likec4/core';
|
|
9
|
-
import 'type-fest';
|
|
10
|
-
import './protocol.mjs';
|
|
11
|
-
import 'vscode-jsonrpc';
|
|
12
|
-
import 'vscode-uri';
|
|
13
|
-
import '@likec4/log';
|
|
14
|
-
|
|
15
|
-
declare function startLanguageServer(): {
|
|
16
|
-
connection: vscode_languageserver.Connection;
|
|
17
|
-
messageReader: BrowserMessageReader;
|
|
18
|
-
messageWriter: BrowserMessageWriter;
|
|
19
|
-
shared: LikeC4SharedServices;
|
|
20
|
-
likec4: LikeC4Services;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export { LikeC4Services, LikeC4SharedServices, startLanguageServer };
|
package/dist/browser.mjs
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { startLanguageServer as startLanguageServer$1 } from 'langium/lsp';
|
|
2
|
-
import { BrowserMessageReader, BrowserMessageWriter, createConnection } from 'vscode-languageserver/browser';
|
|
3
|
-
import { c as createLanguageServices } from './shared/language-server.BIbAD1T-.mjs';
|
|
4
|
-
export { L as LikeC4Module, a as createCustomLanguageServices, s as setLogLevel } from './shared/language-server.BIbAD1T-.mjs';
|
|
5
|
-
|
|
6
|
-
function startLanguageServer() {
|
|
7
|
-
const messageReader = new BrowserMessageReader(self);
|
|
8
|
-
const messageWriter = new BrowserMessageWriter(self);
|
|
9
|
-
const connection = createConnection(messageReader, messageWriter);
|
|
10
|
-
const services = createLanguageServices({ connection });
|
|
11
|
-
startLanguageServer$1(services.shared);
|
|
12
|
-
return {
|
|
13
|
-
...services,
|
|
14
|
-
connection,
|
|
15
|
-
messageReader,
|
|
16
|
-
messageWriter
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export { createLanguageServices, startLanguageServer };
|
package/dist/index.cjs
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const lsp = require('langium/lsp');
|
|
4
|
-
const node$1 = require('vscode-languageserver/node');
|
|
5
|
-
const langium = require('langium');
|
|
6
|
-
const node = require('langium/node');
|
|
7
|
-
const node_fs = require('node:fs');
|
|
8
|
-
const promises = require('node:fs/promises');
|
|
9
|
-
const node_path = require('node:path');
|
|
10
|
-
const module$1 = require('./shared/language-server.DKV_FdPN.cjs');
|
|
11
|
-
|
|
12
|
-
const LikeC4FileSystem = {
|
|
13
|
-
fileSystemProvider: () => new SymLinkTraversingFileSystemProvider()
|
|
14
|
-
};
|
|
15
|
-
class SymLinkTraversingFileSystemProvider extends node.NodeFileSystemProvider {
|
|
16
|
-
async readDirectory(folderPath) {
|
|
17
|
-
const dirents = await promises.readdir(folderPath.fsPath, { withFileTypes: true });
|
|
18
|
-
return dirents.map((dirent) => this.followUri(langium.UriUtils.joinPath(folderPath, dirent.name)));
|
|
19
|
-
}
|
|
20
|
-
followUri(uri) {
|
|
21
|
-
const directoryPath = node_path.dirname(uri.fsPath);
|
|
22
|
-
const stat = node_fs.lstatSync(uri.fsPath);
|
|
23
|
-
if (stat.isSymbolicLink()) {
|
|
24
|
-
const resolved_link = node_fs.readlinkSync(uri.fsPath);
|
|
25
|
-
const linked_path = node_path.resolve(directoryPath, resolved_link);
|
|
26
|
-
return this.followUri(langium.URI.file(linked_path));
|
|
27
|
-
} else {
|
|
28
|
-
return {
|
|
29
|
-
isFile: stat.isFile(),
|
|
30
|
-
isDirectory: stat.isDirectory(),
|
|
31
|
-
uri
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function startLanguageServer() {
|
|
38
|
-
const connection = node$1.createConnection(node$1.ProposedFeatures.all);
|
|
39
|
-
const services = module$1.createLanguageServices({ connection, ...LikeC4FileSystem });
|
|
40
|
-
lsp.startLanguageServer(services.shared);
|
|
41
|
-
return {
|
|
42
|
-
...services,
|
|
43
|
-
connection
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
exports.LikeC4Module = module$1.LikeC4Module;
|
|
48
|
-
exports.createCustomLanguageServices = module$1.createCustomLanguageServices;
|
|
49
|
-
exports.createLanguageServices = module$1.createLanguageServices;
|
|
50
|
-
exports.lspLogger = module$1.logger;
|
|
51
|
-
exports.setLogLevel = module$1.setLogLevel;
|
|
52
|
-
exports.LikeC4FileSystem = LikeC4FileSystem;
|
|
53
|
-
exports.startLanguageServer = startLanguageServer;
|
package/dist/index.d.cts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { L as LikeC4SharedServices, a as LikeC4Services } from './shared/language-server.BQRvVmE0.cjs';
|
|
2
|
-
export { f as FqnIndex, F as FqnIndexEntry, I as IsValidFn, k as LanguageServicesContext, j as LikeC4AddedServices, g as LikeC4ModelBuilder, h as LikeC4ModelLocator, i as LikeC4ModelParser, d as LikeC4Module, M as ModelParsedListener, e as computeDocumentFqn, c as createCustomLanguageServices, b as createLanguageServices, l as createSharedServices, m as lspLogger, s as setLogLevel } from './shared/language-server.BQRvVmE0.cjs';
|
|
3
|
-
import * as vscode_languageserver_lib_common_inlineCompletion_proposed from 'vscode-languageserver/lib/common/inlineCompletion.proposed';
|
|
4
|
-
import * as vscode_languageserver from 'vscode-languageserver';
|
|
5
|
-
import { URI, FileSystemNode } from 'langium';
|
|
6
|
-
import { NodeFileSystemProvider } from 'langium/node';
|
|
7
|
-
import 'langium/lsp';
|
|
8
|
-
import 'vscode-languageserver-types';
|
|
9
|
-
import '@likec4/core';
|
|
10
|
-
import 'type-fest';
|
|
11
|
-
import './protocol.cjs';
|
|
12
|
-
import 'vscode-jsonrpc';
|
|
13
|
-
import 'vscode-uri';
|
|
14
|
-
import '@likec4/log';
|
|
15
|
-
|
|
16
|
-
declare const LikeC4FileSystem: {
|
|
17
|
-
fileSystemProvider: () => SymLinkTraversingFileSystemProvider;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* A file system provider that follows symbolic links.
|
|
21
|
-
* @see https://github.com/likec4/likec4/pull/1213
|
|
22
|
-
*/
|
|
23
|
-
declare class SymLinkTraversingFileSystemProvider extends NodeFileSystemProvider {
|
|
24
|
-
readDirectory(folderPath: URI): Promise<FileSystemNode[]>;
|
|
25
|
-
followUri(uri: URI): FileSystemNode;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
declare function startLanguageServer(): {
|
|
29
|
-
connection: vscode_languageserver._Connection<vscode_languageserver._, vscode_languageserver._, vscode_languageserver._, vscode_languageserver._, vscode_languageserver._, vscode_languageserver._, vscode_languageserver_lib_common_inlineCompletion_proposed.InlineCompletionFeatureShape, vscode_languageserver._>;
|
|
30
|
-
shared: LikeC4SharedServices;
|
|
31
|
-
likec4: LikeC4Services;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export { LikeC4FileSystem, LikeC4Services, LikeC4SharedServices, startLanguageServer };
|
package/dist/index.d.mts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { L as LikeC4SharedServices, a as LikeC4Services } from './shared/language-server._wkyPgso.mjs';
|
|
2
|
-
export { f as FqnIndex, F as FqnIndexEntry, I as IsValidFn, k as LanguageServicesContext, j as LikeC4AddedServices, g as LikeC4ModelBuilder, h as LikeC4ModelLocator, i as LikeC4ModelParser, d as LikeC4Module, M as ModelParsedListener, e as computeDocumentFqn, c as createCustomLanguageServices, b as createLanguageServices, l as createSharedServices, m as lspLogger, s as setLogLevel } from './shared/language-server._wkyPgso.mjs';
|
|
3
|
-
import * as vscode_languageserver_lib_common_inlineCompletion_proposed from 'vscode-languageserver/lib/common/inlineCompletion.proposed';
|
|
4
|
-
import * as vscode_languageserver from 'vscode-languageserver';
|
|
5
|
-
import { URI, FileSystemNode } from 'langium';
|
|
6
|
-
import { NodeFileSystemProvider } from 'langium/node';
|
|
7
|
-
import 'langium/lsp';
|
|
8
|
-
import 'vscode-languageserver-types';
|
|
9
|
-
import '@likec4/core';
|
|
10
|
-
import 'type-fest';
|
|
11
|
-
import './protocol.mjs';
|
|
12
|
-
import 'vscode-jsonrpc';
|
|
13
|
-
import 'vscode-uri';
|
|
14
|
-
import '@likec4/log';
|
|
15
|
-
|
|
16
|
-
declare const LikeC4FileSystem: {
|
|
17
|
-
fileSystemProvider: () => SymLinkTraversingFileSystemProvider;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* A file system provider that follows symbolic links.
|
|
21
|
-
* @see https://github.com/likec4/likec4/pull/1213
|
|
22
|
-
*/
|
|
23
|
-
declare class SymLinkTraversingFileSystemProvider extends NodeFileSystemProvider {
|
|
24
|
-
readDirectory(folderPath: URI): Promise<FileSystemNode[]>;
|
|
25
|
-
followUri(uri: URI): FileSystemNode;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
declare function startLanguageServer(): {
|
|
29
|
-
connection: vscode_languageserver._Connection<vscode_languageserver._, vscode_languageserver._, vscode_languageserver._, vscode_languageserver._, vscode_languageserver._, vscode_languageserver._, vscode_languageserver_lib_common_inlineCompletion_proposed.InlineCompletionFeatureShape, vscode_languageserver._>;
|
|
30
|
-
shared: LikeC4SharedServices;
|
|
31
|
-
likec4: LikeC4Services;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export { LikeC4FileSystem, LikeC4Services, LikeC4SharedServices, startLanguageServer };
|
package/dist/index.mjs
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { startLanguageServer as startLanguageServer$1 } from 'langium/lsp';
|
|
2
|
-
import { createConnection, ProposedFeatures } from 'vscode-languageserver/node';
|
|
3
|
-
import { UriUtils, URI } from 'langium';
|
|
4
|
-
import { NodeFileSystemProvider } from 'langium/node';
|
|
5
|
-
import { lstatSync, readlinkSync } from 'node:fs';
|
|
6
|
-
import { readdir } from 'node:fs/promises';
|
|
7
|
-
import { dirname, resolve } from 'node:path';
|
|
8
|
-
import { c as createLanguageServices } from './shared/language-server.BIbAD1T-.mjs';
|
|
9
|
-
export { L as LikeC4Module, a as createCustomLanguageServices, l as lspLogger, s as setLogLevel } from './shared/language-server.BIbAD1T-.mjs';
|
|
10
|
-
|
|
11
|
-
const LikeC4FileSystem = {
|
|
12
|
-
fileSystemProvider: () => new SymLinkTraversingFileSystemProvider()
|
|
13
|
-
};
|
|
14
|
-
class SymLinkTraversingFileSystemProvider extends NodeFileSystemProvider {
|
|
15
|
-
async readDirectory(folderPath) {
|
|
16
|
-
const dirents = await readdir(folderPath.fsPath, { withFileTypes: true });
|
|
17
|
-
return dirents.map((dirent) => this.followUri(UriUtils.joinPath(folderPath, dirent.name)));
|
|
18
|
-
}
|
|
19
|
-
followUri(uri) {
|
|
20
|
-
const directoryPath = dirname(uri.fsPath);
|
|
21
|
-
const stat = lstatSync(uri.fsPath);
|
|
22
|
-
if (stat.isSymbolicLink()) {
|
|
23
|
-
const resolved_link = readlinkSync(uri.fsPath);
|
|
24
|
-
const linked_path = resolve(directoryPath, resolved_link);
|
|
25
|
-
return this.followUri(URI.file(linked_path));
|
|
26
|
-
} else {
|
|
27
|
-
return {
|
|
28
|
-
isFile: stat.isFile(),
|
|
29
|
-
isDirectory: stat.isDirectory(),
|
|
30
|
-
uri
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function startLanguageServer() {
|
|
37
|
-
const connection = createConnection(ProposedFeatures.all);
|
|
38
|
-
const services = createLanguageServices({ connection, ...LikeC4FileSystem });
|
|
39
|
-
startLanguageServer$1(services.shared);
|
|
40
|
-
return {
|
|
41
|
-
...services,
|
|
42
|
-
connection
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export { LikeC4FileSystem, createLanguageServices, startLanguageServer };
|