@likec4/language-server 1.21.1 → 1.22.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/README.md +4 -1
- package/bin/likec4-language-server.mjs +5 -2
- package/dist/LikeC4FileSystem.js +2 -2
- package/dist/browser.d.ts +3 -3
- package/dist/browser.js +17 -2
- package/dist/bundled.d.ts +8 -0
- package/dist/bundled.js +25 -0
- package/dist/bundled.mjs +2555 -4022
- package/dist/index.d.ts +3 -3
- package/dist/index.js +23 -2
- package/dist/logger.d.ts +9 -3
- package/dist/logger.js +35 -55
- package/dist/model/fqn-computation.js +2 -2
- package/dist/model/model-builder.js +13 -14
- package/dist/model-change/ModelChanges.js +2 -2
- package/dist/module.js +1 -4
- package/dist/references/scope-provider.js +3 -3
- package/dist/view-utils/manual-layout.js +2 -2
- package/dist/views/configurable-layouter.js +4 -4
- package/dist/views/likec4-views.d.ts +2 -1
- package/dist/views/likec4-views.js +2 -2
- package/package.json +14 -12
- package/dist/test/setup.d.ts +0 -1
- package/dist/test/setup.js +0 -7
- package/src/LikeC4FileSystem.ts +0 -38
- package/src/Rpc.ts +0 -134
- package/src/ast.ts +0 -556
- package/src/browser.ts +0 -35
- package/src/documentation/documentation-provider.ts +0 -52
- package/src/documentation/index.ts +0 -1
- package/src/formatting/LikeC4Formatter.ts +0 -639
- package/src/formatting/utils.ts +0 -26
- package/src/generated/ast.ts +0 -3735
- package/src/generated/grammar.ts +0 -10
- package/src/generated/module.ts +0 -33
- package/src/generated-lib/icons.ts +0 -1538
- package/src/index.ts +0 -30
- package/src/like-c4.langium +0 -901
- package/src/likec4lib.ts +0 -6
- package/src/logger.ts +0 -80
- package/src/lsp/CodeLensProvider.ts +0 -50
- package/src/lsp/CompletionProvider.ts +0 -147
- package/src/lsp/DocumentHighlightProvider.ts +0 -12
- package/src/lsp/DocumentLinkProvider.ts +0 -65
- package/src/lsp/DocumentSymbolProvider.ts +0 -313
- package/src/lsp/HoverProvider.ts +0 -92
- package/src/lsp/RenameProvider.ts +0 -8
- package/src/lsp/SemanticTokenProvider.ts +0 -383
- package/src/lsp/index.ts +0 -8
- package/src/model/deployments-index.ts +0 -209
- package/src/model/fqn-computation.ts +0 -83
- package/src/model/fqn-index.ts +0 -138
- package/src/model/index.ts +0 -6
- package/src/model/model-builder.ts +0 -724
- package/src/model/model-locator.ts +0 -146
- package/src/model/model-parser-where.ts +0 -84
- package/src/model/model-parser.ts +0 -86
- package/src/model/parser/Base.ts +0 -113
- package/src/model/parser/DeploymentModelParser.ts +0 -192
- package/src/model/parser/DeploymentViewParser.ts +0 -122
- package/src/model/parser/FqnRefParser.ts +0 -143
- package/src/model/parser/GlobalsParser.ts +0 -96
- package/src/model/parser/ModelParser.ts +0 -170
- package/src/model/parser/PredicatesParser.ts +0 -315
- package/src/model/parser/SpecificationParser.ts +0 -133
- package/src/model/parser/ViewsParser.ts +0 -428
- package/src/model-change/ModelChanges.ts +0 -101
- package/src/model-change/changeElementStyle.ts +0 -172
- package/src/model-change/changeViewLayout.ts +0 -47
- package/src/model-change/saveManualLayout.ts +0 -41
- package/src/module.ts +0 -255
- package/src/protocol.ts +0 -93
- package/src/references/index.ts +0 -3
- package/src/references/name-provider.ts +0 -37
- package/src/references/scope-computation.ts +0 -364
- package/src/references/scope-provider.ts +0 -201
- package/src/shared/NodeKindProvider.ts +0 -121
- package/src/shared/WorkspaceManager.ts +0 -48
- package/src/shared/WorkspaceSymbolProvider.ts +0 -3
- package/src/shared/index.ts +0 -3
- package/src/test/index.ts +0 -1
- package/src/test/setup.ts +0 -8
- package/src/test/testServices.ts +0 -152
- package/src/utils/disposable.ts +0 -30
- package/src/utils/elementRef.ts +0 -26
- package/src/utils/fqnRef.ts +0 -56
- package/src/utils/index.ts +0 -2
- package/src/utils/printDocs.ts +0 -3
- package/src/utils/stringHash.ts +0 -6
- package/src/validation/_shared.ts +0 -29
- package/src/validation/deployment-checks.ts +0 -131
- package/src/validation/dynamic-view-rule.ts +0 -23
- package/src/validation/dynamic-view-step.ts +0 -36
- package/src/validation/element.ts +0 -56
- package/src/validation/index.ts +0 -171
- package/src/validation/property-checks.ts +0 -52
- package/src/validation/relation.ts +0 -63
- package/src/validation/specification.ts +0 -205
- package/src/validation/view-predicates/element-with.ts +0 -36
- package/src/validation/view-predicates/expanded-element.ts +0 -16
- package/src/validation/view-predicates/expression-v2.ts +0 -101
- package/src/validation/view-predicates/incoming.ts +0 -20
- package/src/validation/view-predicates/index.ts +0 -6
- package/src/validation/view-predicates/outgoing.ts +0 -20
- package/src/validation/view-predicates/relation-with.ts +0 -17
- package/src/validation/view.ts +0 -37
- package/src/view-utils/assignNavigateTo.ts +0 -31
- package/src/view-utils/index.ts +0 -2
- package/src/view-utils/manual-layout.ts +0 -116
- package/src/view-utils/resolve-relative-paths.ts +0 -90
- package/src/views/configurable-layouter.ts +0 -65
- package/src/views/index.ts +0 -1
- package/src/views/likec4-views.ts +0 -139
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { invariant, type ViewChange } from '@likec4/core'
|
|
2
|
-
import { GrammarUtils } from 'langium'
|
|
3
|
-
import { findLast, isNumber } from 'remeda'
|
|
4
|
-
import { TextEdit } from 'vscode-languageserver-types'
|
|
5
|
-
import { ast, type ParsedAstView, type ParsedLikeC4LangiumDocument, toAstViewLayoutDirection } from '../ast'
|
|
6
|
-
import type { LikeC4Services } from '../module'
|
|
7
|
-
|
|
8
|
-
const { findNodeForProperty, findNodeForKeyword } = GrammarUtils
|
|
9
|
-
|
|
10
|
-
type ChangeViewLayoutArg = {
|
|
11
|
-
view: ParsedAstView
|
|
12
|
-
doc: ParsedLikeC4LangiumDocument
|
|
13
|
-
viewAst: ast.LikeC4View
|
|
14
|
-
layout: ViewChange.ChangeAutoLayout['layout']
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function changeViewLayout(_services: LikeC4Services, {
|
|
18
|
-
view,
|
|
19
|
-
viewAst,
|
|
20
|
-
layout
|
|
21
|
-
}: ChangeViewLayoutArg): TextEdit {
|
|
22
|
-
// Should never happen
|
|
23
|
-
invariant(viewAst.body, `View ${view.id} has no body`)
|
|
24
|
-
const viewCstNode = viewAst.$cstNode
|
|
25
|
-
invariant(viewCstNode, 'viewCstNode')
|
|
26
|
-
const newdirection = toAstViewLayoutDirection(layout.direction)
|
|
27
|
-
const existingRule = findLast(viewAst.body.rules, ast.isViewRuleAutoLayout) as ast.ViewRuleAutoLayout | undefined
|
|
28
|
-
|
|
29
|
-
let newRule = `autoLayout ${newdirection}`
|
|
30
|
-
|
|
31
|
-
if (isNumber(layout.rankSep)) {
|
|
32
|
-
newRule += ` ${layout.rankSep}`
|
|
33
|
-
if (isNumber(layout.nodeSep)) {
|
|
34
|
-
newRule += ` ${layout.nodeSep}`
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (existingRule && existingRule.$cstNode) {
|
|
39
|
-
return TextEdit.replace(existingRule.$cstNode.range, newRule)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const insertPos = findNodeForKeyword(viewAst.body.$cstNode, '}')?.range.start
|
|
43
|
-
invariant(insertPos, 'Closing brace not found')
|
|
44
|
-
const insert = `\t${newRule}\n\t`
|
|
45
|
-
|
|
46
|
-
return TextEdit.insert(insertPos, insert)
|
|
47
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { invariant, type ViewChange } from '@likec4/core'
|
|
2
|
-
import indentString from 'indent-string'
|
|
3
|
-
import { CstUtils, GrammarUtils } from 'langium'
|
|
4
|
-
import { TextEdit } from 'vscode-languageserver-types'
|
|
5
|
-
import { ast, type ParsedAstView, type ParsedLikeC4LangiumDocument } from '../ast'
|
|
6
|
-
import type { LikeC4Services } from '../module'
|
|
7
|
-
import { serializeToComment } from '../view-utils/manual-layout'
|
|
8
|
-
|
|
9
|
-
const { findNodeForProperty } = GrammarUtils
|
|
10
|
-
|
|
11
|
-
export type ManualLayoutArg = {
|
|
12
|
-
view: ParsedAstView
|
|
13
|
-
doc: ParsedLikeC4LangiumDocument
|
|
14
|
-
viewAst: ast.LikeC4View
|
|
15
|
-
layout: ViewChange.SaveManualLayout['layout']
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function saveManualLayout(_services: LikeC4Services, {
|
|
19
|
-
viewAst,
|
|
20
|
-
layout
|
|
21
|
-
}: ManualLayoutArg): TextEdit {
|
|
22
|
-
invariant(viewAst.$cstNode, 'invalid view.$cstNode')
|
|
23
|
-
const commentCst = CstUtils.findCommentNode(viewAst.$cstNode, ['BLOCK_COMMENT'])
|
|
24
|
-
let txt = serializeToComment(layout)
|
|
25
|
-
if (viewAst.$cstNode.range.start.character > 0) {
|
|
26
|
-
txt = indentString(txt, viewAst.$cstNode.range.start.character)
|
|
27
|
-
// const indent = ' '.repeat(viewAst.$cstNode.range.start.character)
|
|
28
|
-
// txt = txt.split('\n').map(l => indent + l).join('\n')
|
|
29
|
-
}
|
|
30
|
-
if (commentCst) {
|
|
31
|
-
// Do not indent the first line
|
|
32
|
-
return TextEdit.replace(commentCst.range, txt.trimStart())
|
|
33
|
-
}
|
|
34
|
-
return TextEdit.insert(
|
|
35
|
-
{
|
|
36
|
-
line: viewAst.$cstNode.range.start.line,
|
|
37
|
-
character: 0
|
|
38
|
-
},
|
|
39
|
-
txt + '\n'
|
|
40
|
-
)
|
|
41
|
-
}
|
package/src/module.ts
DELETED
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
import { GraphvizLayouter, GraphvizWasmAdapter } from '@likec4/layouts'
|
|
2
|
-
import {
|
|
3
|
-
type Module,
|
|
4
|
-
DocumentCache,
|
|
5
|
-
EmptyFileSystem,
|
|
6
|
-
inject,
|
|
7
|
-
WorkspaceCache,
|
|
8
|
-
} from 'langium'
|
|
9
|
-
import {
|
|
10
|
-
type DefaultSharedModuleContext,
|
|
11
|
-
type LangiumServices,
|
|
12
|
-
type LangiumSharedServices,
|
|
13
|
-
type PartialLangiumServices,
|
|
14
|
-
type PartialLangiumSharedServices,
|
|
15
|
-
createDefaultModule,
|
|
16
|
-
createDefaultSharedModule,
|
|
17
|
-
} from 'langium/lsp'
|
|
18
|
-
import { LikeC4DocumentationProvider } from './documentation'
|
|
19
|
-
import { LikeC4Formatter } from './formatting/LikeC4Formatter'
|
|
20
|
-
import {
|
|
21
|
-
LikeC4GeneratedModule,
|
|
22
|
-
LikeC4GeneratedSharedModule,
|
|
23
|
-
} from './generated/module'
|
|
24
|
-
import { logger, logToLspConnection } from './logger'
|
|
25
|
-
import {
|
|
26
|
-
LikeC4CodeLensProvider,
|
|
27
|
-
LikeC4CompletionProvider,
|
|
28
|
-
LikeC4DocumentHighlightProvider,
|
|
29
|
-
LikeC4DocumentLinkProvider,
|
|
30
|
-
LikeC4DocumentSymbolProvider,
|
|
31
|
-
LikeC4HoverProvider,
|
|
32
|
-
LikeC4SemanticTokenProvider,
|
|
33
|
-
} from './lsp'
|
|
34
|
-
import {
|
|
35
|
-
DeploymentsIndex,
|
|
36
|
-
FqnIndex,
|
|
37
|
-
LikeC4ModelBuilder,
|
|
38
|
-
LikeC4ModelLocator,
|
|
39
|
-
LikeC4ModelParser,
|
|
40
|
-
} from './model'
|
|
41
|
-
import { LikeC4ModelChanges } from './model-change/ModelChanges'
|
|
42
|
-
import {
|
|
43
|
-
LikeC4NameProvider,
|
|
44
|
-
LikeC4ScopeComputation,
|
|
45
|
-
LikeC4ScopeProvider,
|
|
46
|
-
} from './references'
|
|
47
|
-
import { Rpc } from './Rpc'
|
|
48
|
-
import {
|
|
49
|
-
LikeC4WorkspaceManager,
|
|
50
|
-
NodeKindProvider,
|
|
51
|
-
WorkspaceSymbolProvider,
|
|
52
|
-
} from './shared'
|
|
53
|
-
import { registerValidationChecks } from './validation'
|
|
54
|
-
import { LikeC4Views } from './views'
|
|
55
|
-
|
|
56
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
|
-
type Constructor<T, Arguments extends unknown[] = any[]> = new(...arguments_: Arguments) => T
|
|
58
|
-
|
|
59
|
-
interface LikeC4AddedSharedServices {
|
|
60
|
-
lsp: {
|
|
61
|
-
NodeKindProvider: NodeKindProvider
|
|
62
|
-
WorkspaceSymbolProvider: WorkspaceSymbolProvider
|
|
63
|
-
}
|
|
64
|
-
workspace: {
|
|
65
|
-
WorkspaceManager: LikeC4WorkspaceManager
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export type LikeC4SharedServices = LangiumSharedServices & LikeC4AddedSharedServices
|
|
70
|
-
|
|
71
|
-
const LikeC4SharedModule: Module<
|
|
72
|
-
LikeC4SharedServices,
|
|
73
|
-
PartialLangiumSharedServices & LikeC4AddedSharedServices
|
|
74
|
-
> = {
|
|
75
|
-
lsp: {
|
|
76
|
-
NodeKindProvider: services => new NodeKindProvider(services),
|
|
77
|
-
WorkspaceSymbolProvider: services => new WorkspaceSymbolProvider(services),
|
|
78
|
-
},
|
|
79
|
-
workspace: {
|
|
80
|
-
WorkspaceManager: services => new LikeC4WorkspaceManager(services),
|
|
81
|
-
},
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Declaration of custom services - add your own service classes here.
|
|
86
|
-
*/
|
|
87
|
-
export interface LikeC4AddedServices {
|
|
88
|
-
documentation: {
|
|
89
|
-
DocumentationProvider: LikeC4DocumentationProvider
|
|
90
|
-
}
|
|
91
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
|
-
WorkspaceCache: WorkspaceCache<string, any>
|
|
93
|
-
DocumentCache: DocumentCache<string, any>
|
|
94
|
-
Rpc: Rpc
|
|
95
|
-
likec4: {
|
|
96
|
-
Views: LikeC4Views
|
|
97
|
-
Layouter: GraphvizLayouter
|
|
98
|
-
DeploymentsIndex: DeploymentsIndex
|
|
99
|
-
FqnIndex: FqnIndex
|
|
100
|
-
ModelParser: LikeC4ModelParser
|
|
101
|
-
ModelBuilder: LikeC4ModelBuilder
|
|
102
|
-
ModelLocator: LikeC4ModelLocator
|
|
103
|
-
ModelChanges: LikeC4ModelChanges
|
|
104
|
-
}
|
|
105
|
-
lsp: {
|
|
106
|
-
// RenameProvider: LikeC4RenameProvider
|
|
107
|
-
CompletionProvider: LikeC4CompletionProvider
|
|
108
|
-
DocumentHighlightProvider: LikeC4DocumentHighlightProvider
|
|
109
|
-
DocumentSymbolProvider: LikeC4DocumentSymbolProvider
|
|
110
|
-
SemanticTokenProvider: LikeC4SemanticTokenProvider
|
|
111
|
-
HoverProvider: LikeC4HoverProvider
|
|
112
|
-
CodeLensProvider: LikeC4CodeLensProvider
|
|
113
|
-
DocumentLinkProvider: LikeC4DocumentLinkProvider
|
|
114
|
-
}
|
|
115
|
-
references: {
|
|
116
|
-
NameProvider: LikeC4NameProvider
|
|
117
|
-
ScopeComputation: LikeC4ScopeComputation
|
|
118
|
-
ScopeProvider: LikeC4ScopeProvider
|
|
119
|
-
}
|
|
120
|
-
shared?: LikeC4SharedServices
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export type LikeC4Services = LangiumServices & LikeC4AddedServices
|
|
124
|
-
|
|
125
|
-
function bind<T>(Type: Constructor<T, [LikeC4Services]>) {
|
|
126
|
-
return (services: LikeC4Services) => new Type(services)
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export const LikeC4Module: Module<LikeC4Services, PartialLangiumServices & LikeC4AddedServices> = {
|
|
130
|
-
documentation: {
|
|
131
|
-
DocumentationProvider: bind(LikeC4DocumentationProvider),
|
|
132
|
-
},
|
|
133
|
-
WorkspaceCache: (services: LikeC4Services) => new WorkspaceCache(services.shared),
|
|
134
|
-
DocumentCache: (services: LikeC4Services) => new DocumentCache(services.shared),
|
|
135
|
-
Rpc: bind(Rpc),
|
|
136
|
-
likec4: {
|
|
137
|
-
Layouter: (_services: LikeC4Services) => {
|
|
138
|
-
logger.debug('Creating GraphvizLayouter with GraphvizWasmAdapter')
|
|
139
|
-
return new GraphvizLayouter(new GraphvizWasmAdapter())
|
|
140
|
-
},
|
|
141
|
-
Views: bind(LikeC4Views),
|
|
142
|
-
DeploymentsIndex: bind(DeploymentsIndex),
|
|
143
|
-
ModelChanges: bind(LikeC4ModelChanges),
|
|
144
|
-
FqnIndex: bind(FqnIndex),
|
|
145
|
-
ModelParser: bind(LikeC4ModelParser),
|
|
146
|
-
ModelBuilder: bind(LikeC4ModelBuilder),
|
|
147
|
-
ModelLocator: bind(LikeC4ModelLocator),
|
|
148
|
-
},
|
|
149
|
-
lsp: {
|
|
150
|
-
// RenameProvider: bind(LikeC4RenameProvider),
|
|
151
|
-
CompletionProvider: bind(LikeC4CompletionProvider),
|
|
152
|
-
DocumentHighlightProvider: bind(LikeC4DocumentHighlightProvider),
|
|
153
|
-
DocumentSymbolProvider: bind(LikeC4DocumentSymbolProvider),
|
|
154
|
-
SemanticTokenProvider: bind(LikeC4SemanticTokenProvider),
|
|
155
|
-
HoverProvider: bind(LikeC4HoverProvider),
|
|
156
|
-
CodeLensProvider: bind(LikeC4CodeLensProvider),
|
|
157
|
-
DocumentLinkProvider: bind(LikeC4DocumentLinkProvider),
|
|
158
|
-
Formatter: bind(LikeC4Formatter),
|
|
159
|
-
},
|
|
160
|
-
references: {
|
|
161
|
-
NameProvider: bind(LikeC4NameProvider),
|
|
162
|
-
ScopeComputation: bind(LikeC4ScopeComputation),
|
|
163
|
-
ScopeProvider: bind(LikeC4ScopeProvider),
|
|
164
|
-
},
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export type LanguageServicesContext = Partial<DefaultSharedModuleContext>
|
|
168
|
-
|
|
169
|
-
export function createCustomLanguageServices<I1, I2, I3, I extends I1 & I2 & I3 & LikeC4Services>(
|
|
170
|
-
context: LanguageServicesContext,
|
|
171
|
-
module?: Module<I, I1>,
|
|
172
|
-
module2?: Module<I, I2>,
|
|
173
|
-
module3?: Module<I, I3>,
|
|
174
|
-
): { shared: LikeC4SharedServices; likec4: I } {
|
|
175
|
-
const shared = createSharedServices(context)
|
|
176
|
-
const modules = [
|
|
177
|
-
createDefaultModule({ shared }),
|
|
178
|
-
LikeC4GeneratedModule,
|
|
179
|
-
LikeC4Module,
|
|
180
|
-
module,
|
|
181
|
-
module2,
|
|
182
|
-
module3,
|
|
183
|
-
].reduce(_merge, {}) as Module<I>
|
|
184
|
-
|
|
185
|
-
const likec4 = inject(modules)
|
|
186
|
-
shared.ServiceRegistry.register(likec4)
|
|
187
|
-
registerValidationChecks(likec4)
|
|
188
|
-
|
|
189
|
-
if (!context.connection) {
|
|
190
|
-
// We don't run inside a language server
|
|
191
|
-
// Therefore, initialize the configuration provider instantly
|
|
192
|
-
shared.workspace.ConfigurationProvider.initialized({})
|
|
193
|
-
} else {
|
|
194
|
-
likec4.Rpc.init()
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return { shared, likec4 }
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
export function createSharedServices(context: LanguageServicesContext = {}): LikeC4SharedServices {
|
|
201
|
-
const moduleContext: DefaultSharedModuleContext = {
|
|
202
|
-
...EmptyFileSystem,
|
|
203
|
-
...context,
|
|
204
|
-
}
|
|
205
|
-
if (context.connection) {
|
|
206
|
-
logToLspConnection(context.connection)
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
return inject(
|
|
210
|
-
createDefaultSharedModule(moduleContext),
|
|
211
|
-
LikeC4GeneratedSharedModule,
|
|
212
|
-
LikeC4SharedModule,
|
|
213
|
-
)
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
export function createLanguageServices(context: LanguageServicesContext = {}): {
|
|
217
|
-
shared: LikeC4SharedServices
|
|
218
|
-
likec4: LikeC4Services
|
|
219
|
-
} {
|
|
220
|
-
const shared = createSharedServices(context)
|
|
221
|
-
const likec4 = inject(
|
|
222
|
-
createDefaultModule({ shared }),
|
|
223
|
-
LikeC4GeneratedModule,
|
|
224
|
-
LikeC4Module,
|
|
225
|
-
)
|
|
226
|
-
shared.ServiceRegistry.register(likec4)
|
|
227
|
-
registerValidationChecks(likec4)
|
|
228
|
-
|
|
229
|
-
if (!context.connection) {
|
|
230
|
-
// We don't run inside a language server
|
|
231
|
-
// Therefore, initialize the configuration provider instantly
|
|
232
|
-
shared.workspace.ConfigurationProvider.initialized({})
|
|
233
|
-
} else {
|
|
234
|
-
likec4.Rpc.init()
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
return { shared, likec4 }
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// Copied from langium/src/dependency-injection.ts as it is not exported
|
|
241
|
-
function _merge(target: Module<any>, source?: Module<any>): Module<unknown> {
|
|
242
|
-
if (source) {
|
|
243
|
-
for (const [key, value2] of Object.entries(source)) {
|
|
244
|
-
if (value2 !== undefined) {
|
|
245
|
-
const value1 = target[key]
|
|
246
|
-
if (value1 !== null && value2 !== null && typeof value1 === 'object' && typeof value2 === 'object') {
|
|
247
|
-
target[key] = _merge(value1, value2)
|
|
248
|
-
} else {
|
|
249
|
-
target[key] = value2
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
return target
|
|
255
|
-
}
|
package/src/protocol.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ComputedLikeC4Model,
|
|
3
|
-
ComputedView,
|
|
4
|
-
DiagramView,
|
|
5
|
-
Fqn,
|
|
6
|
-
ParsedLikeC4Model,
|
|
7
|
-
RelationId,
|
|
8
|
-
ViewChange,
|
|
9
|
-
ViewId,
|
|
10
|
-
} from '@likec4/core'
|
|
11
|
-
import { NotificationType, RequestType, RequestType0 } from 'vscode-jsonrpc'
|
|
12
|
-
import type { DocumentUri, Location } from 'vscode-languageserver-types'
|
|
13
|
-
|
|
14
|
-
// #region From server
|
|
15
|
-
export const onDidChangeModel = new NotificationType<string>('likec4/onDidChangeModel')
|
|
16
|
-
export type OnDidChangeModelNotification = typeof onDidChangeModel
|
|
17
|
-
// #endregion
|
|
18
|
-
|
|
19
|
-
// #region To server
|
|
20
|
-
|
|
21
|
-
export const fetchModel = new RequestType0<{ model: ParsedLikeC4Model | null }, void>(
|
|
22
|
-
'likec4/fetchModel',
|
|
23
|
-
)
|
|
24
|
-
export type FetchModelRequest = typeof fetchModel
|
|
25
|
-
|
|
26
|
-
export const fetchComputedModel = new RequestType<
|
|
27
|
-
{ cleanCaches?: boolean | undefined },
|
|
28
|
-
{ model: ComputedLikeC4Model | null },
|
|
29
|
-
void
|
|
30
|
-
>(
|
|
31
|
-
'likec4/fetchComputedModel',
|
|
32
|
-
)
|
|
33
|
-
export type FetchComputedModelRequest = typeof fetchComputedModel
|
|
34
|
-
|
|
35
|
-
export const computeView = new RequestType<{ viewId: ViewId }, { view: ComputedView | null }, void>(
|
|
36
|
-
'likec4/computeView',
|
|
37
|
-
)
|
|
38
|
-
export type ComputeViewRequest = typeof computeView
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Request to layout a view.
|
|
42
|
-
*/
|
|
43
|
-
export const layoutView = new RequestType<
|
|
44
|
-
{ viewId: ViewId },
|
|
45
|
-
{
|
|
46
|
-
result:
|
|
47
|
-
| {
|
|
48
|
-
dot: string
|
|
49
|
-
diagram: DiagramView
|
|
50
|
-
}
|
|
51
|
-
| null
|
|
52
|
-
},
|
|
53
|
-
void
|
|
54
|
-
>('likec4/layout-view')
|
|
55
|
-
export type LayoutViewRequest = typeof layoutView
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Request to build documents.
|
|
59
|
-
*/
|
|
60
|
-
export interface BuildDocumentsParams {
|
|
61
|
-
docs: DocumentUri[]
|
|
62
|
-
}
|
|
63
|
-
export const buildDocuments = new RequestType<BuildDocumentsParams, void, void>('likec4/build')
|
|
64
|
-
export type BuildDocumentsRequest = typeof buildDocuments
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Request to locate an element, relation, deployment or view.
|
|
68
|
-
*/
|
|
69
|
-
export type LocateParams =
|
|
70
|
-
| {
|
|
71
|
-
element: Fqn
|
|
72
|
-
property?: string
|
|
73
|
-
}
|
|
74
|
-
| {
|
|
75
|
-
relation: RelationId
|
|
76
|
-
}
|
|
77
|
-
| {
|
|
78
|
-
deployment: Fqn
|
|
79
|
-
property?: string
|
|
80
|
-
}
|
|
81
|
-
| {
|
|
82
|
-
view: ViewId
|
|
83
|
-
}
|
|
84
|
-
export const locate = new RequestType<LocateParams, Location | null, void>('likec4/locate')
|
|
85
|
-
export type LocateRequest = typeof locate
|
|
86
|
-
// #endregion
|
|
87
|
-
|
|
88
|
-
export interface ChangeViewRequestParams {
|
|
89
|
-
viewId: ViewId
|
|
90
|
-
change: ViewChange
|
|
91
|
-
}
|
|
92
|
-
export const changeView = new RequestType<ChangeViewRequestParams, Location | null, void>('likec4/change-view')
|
|
93
|
-
export type ChangeViewRequest = typeof changeView
|
package/src/references/index.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { nonNullable } from '@likec4/core'
|
|
2
|
-
import { type AstNode, type CstNode, DefaultNameProvider, isNamed, type NamedAstNode } from 'langium'
|
|
3
|
-
import { ast } from '../ast'
|
|
4
|
-
import type { LikeC4Services } from '../module'
|
|
5
|
-
|
|
6
|
-
export class LikeC4NameProvider extends DefaultNameProvider {
|
|
7
|
-
constructor(protected services: LikeC4Services) {
|
|
8
|
-
super()
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
public getNameStrict(node: AstNode): string {
|
|
12
|
-
return nonNullable(
|
|
13
|
-
this.getName(node),
|
|
14
|
-
`Failed getName for ${this.services.workspace.AstNodeLocator.getAstNodePath(node)}`
|
|
15
|
-
)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
override getName(node: AstNode): string | undefined {
|
|
19
|
-
if (isNamed(node)) {
|
|
20
|
-
return node.name
|
|
21
|
-
}
|
|
22
|
-
if (ast.isDeployedInstance(node)) {
|
|
23
|
-
return node.element.el.$refText
|
|
24
|
-
}
|
|
25
|
-
return undefined
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
override getNameNode(node: AstNode): CstNode | undefined {
|
|
29
|
-
if (isNamed(node)) {
|
|
30
|
-
return super.getNameNode(node)
|
|
31
|
-
}
|
|
32
|
-
if (ast.isDeployedInstance(node)) {
|
|
33
|
-
return node.element.el.$refNode
|
|
34
|
-
}
|
|
35
|
-
return undefined
|
|
36
|
-
}
|
|
37
|
-
}
|