@likec4/language-server 1.2.0 → 1.2.1
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/package.json +8 -10
- package/src/Rpc.ts +108 -0
- package/src/ast.ts +443 -0
- package/src/browser/index.ts +30 -0
- package/src/elementRef.ts +26 -0
- package/src/generated/ast.ts +1632 -0
- package/src/generated/grammar.ts +10 -0
- package/src/generated/module.ts +32 -0
- package/src/index.ts +4 -0
- package/src/like-c4.langium +395 -0
- package/src/logger.ts +54 -0
- package/src/lsp/CodeLensProvider.ts +51 -0
- package/src/lsp/DocumentHighlightProvider.ts +12 -0
- package/src/lsp/DocumentLinkProvider.test.ts +66 -0
- package/src/lsp/DocumentLinkProvider.ts +53 -0
- package/src/lsp/DocumentSymbolProvider.ts +201 -0
- package/src/lsp/HoverProvider.ts +58 -0
- package/{dist/lsp/SemanticTokenProvider.js → src/lsp/SemanticTokenProvider.ts} +57 -42
- package/src/lsp/index.ts +6 -0
- package/src/model/fqn-computation.ts +47 -0
- package/src/model/fqn-index.ts +161 -0
- package/src/model/index.ts +5 -0
- package/src/model/model-builder.ts +447 -0
- package/src/model/model-locator.ts +130 -0
- package/src/model/model-parser.ts +580 -0
- package/src/model-change/ModelChanges.ts +120 -0
- package/src/model-change/changeElementStyle.ts +176 -0
- package/src/model-change/changeViewLayout.ts +41 -0
- package/src/module.ts +197 -0
- package/src/node/index.ts +20 -0
- package/src/protocol.ts +87 -0
- package/src/references/index.ts +2 -0
- package/src/references/scope-computation.ts +142 -0
- package/src/references/scope-provider.ts +166 -0
- package/src/shared/NodeKindProvider.ts +67 -0
- package/src/shared/WorkspaceManager.ts +39 -0
- package/src/shared/WorkspaceSymbolProvider.ts +3 -0
- package/src/shared/index.ts +3 -0
- package/src/test/index.ts +1 -0
- package/src/test/testServices.ts +119 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/printDocs.ts +3 -0
- package/src/utils/stringHash.ts +6 -0
- package/{dist/validation/dynamic-view-rule.js → src/validation/dynamic-view-rule.ts} +14 -11
- package/src/validation/dynamic-view-step.ts +39 -0
- package/src/validation/element.ts +52 -0
- package/{dist/validation/index.js → src/validation/index.ts} +22 -18
- package/src/validation/property-checks.ts +17 -0
- package/src/validation/relation.ts +57 -0
- package/src/validation/specification.ts +118 -0
- package/src/validation/view-predicates/custom-element-expr.ts +21 -0
- package/{dist/validation/view-predicates/expanded-element.js → src/validation/view-predicates/expanded-element.ts} +18 -13
- package/src/validation/view-predicates/incoming.ts +19 -0
- package/src/validation/view-predicates/index.ts +4 -0
- package/src/validation/view-predicates/outgoing.ts +19 -0
- package/src/validation/view.ts +26 -0
- package/src/view-utils/assignNavigateTo.ts +30 -0
- package/src/view-utils/index.ts +3 -0
- package/src/view-utils/resolve-extended-views.ts +57 -0
- package/src/view-utils/resolve-relative-paths.ts +84 -0
- package/dist/Rpc.d.ts +0 -10
- package/dist/Rpc.js +0 -98
- package/dist/ast.d.ts +0 -149
- package/dist/ast.js +0 -271
- package/dist/browser/index.d.ts +0 -9
- package/dist/browser/index.js +0 -16
- package/dist/elementRef.d.ts +0 -12
- package/dist/elementRef.js +0 -15
- package/dist/generated/ast.d.ts +0 -615
- package/dist/generated/ast.js +0 -957
- package/dist/generated/grammar.d.ts +0 -7
- package/dist/generated/grammar.js +0 -3
- package/dist/generated/module.d.ts +0 -14
- package/dist/generated/module.js +0 -22
- package/dist/index.d.ts +0 -5
- package/dist/index.js +0 -2
- package/dist/logger.d.ts +0 -12
- package/dist/logger.js +0 -51
- package/dist/lsp/CodeLensProvider.d.ts +0 -10
- package/dist/lsp/CodeLensProvider.js +0 -40
- package/dist/lsp/DocumentHighlightProvider.d.ts +0 -10
- package/dist/lsp/DocumentHighlightProvider.js +0 -10
- package/dist/lsp/DocumentLinkProvider.d.ts +0 -11
- package/dist/lsp/DocumentLinkProvider.js +0 -41
- package/dist/lsp/DocumentLinkProvider.test.d.ts +0 -2
- package/dist/lsp/DocumentLinkProvider.test.js +0 -54
- package/dist/lsp/DocumentSymbolProvider.d.ts +0 -22
- package/dist/lsp/DocumentSymbolProvider.js +0 -189
- package/dist/lsp/HoverProvider.d.ts +0 -10
- package/dist/lsp/HoverProvider.js +0 -36
- package/dist/lsp/SemanticTokenProvider.d.ts +0 -8
- package/dist/lsp/index.d.ts +0 -7
- package/dist/lsp/index.js +0 -6
- package/dist/model/fqn-computation.d.ts +0 -4
- package/dist/model/fqn-computation.js +0 -43
- package/dist/model/fqn-index.d.ts +0 -26
- package/dist/model/fqn-index.js +0 -114
- package/dist/model/index.d.ts +0 -6
- package/dist/model/index.js +0 -5
- package/dist/model/model-builder.d.ts +0 -20
- package/dist/model/model-builder.js +0 -365
- package/dist/model/model-locator.d.ts +0 -22
- package/dist/model/model-locator.js +0 -115
- package/dist/model/model-parser.d.ts +0 -29
- package/dist/model/model-parser.js +0 -520
- package/dist/model-change/ModelChanges.d.ts +0 -16
- package/dist/model-change/ModelChanges.js +0 -106
- package/dist/model-change/changeElementStyle.d.ts +0 -18
- package/dist/model-change/changeElementStyle.js +0 -141
- package/dist/model-change/changeViewLayout.d.ts +0 -13
- package/dist/model-change/changeViewLayout.js +0 -29
- package/dist/module.d.ts +0 -59
- package/dist/module.js +0 -121
- package/dist/node/index.d.ts +0 -6
- package/dist/node/index.js +0 -13
- package/dist/protocol.d.ts +0 -58
- package/dist/protocol.js +0 -14
- package/dist/references/index.d.ts +0 -3
- package/dist/references/index.js +0 -2
- package/dist/references/scope-computation.d.ts +0 -11
- package/dist/references/scope-computation.js +0 -111
- package/dist/references/scope-provider.d.ts +0 -18
- package/dist/references/scope-provider.js +0 -136
- package/dist/shared/NodeKindProvider.d.ts +0 -16
- package/dist/shared/NodeKindProvider.js +0 -60
- package/dist/shared/WorkspaceManager.d.ts +0 -17
- package/dist/shared/WorkspaceManager.js +0 -29
- package/dist/shared/WorkspaceSymbolProvider.d.ts +0 -4
- package/dist/shared/WorkspaceSymbolProvider.js +0 -3
- package/dist/shared/index.d.ts +0 -4
- package/dist/shared/index.js +0 -3
- package/dist/test/index.d.ts +0 -2
- package/dist/test/index.js +0 -1
- package/dist/test/testServices.d.ts +0 -23
- package/dist/test/testServices.js +0 -102
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.js +0 -1
- package/dist/utils/printDocs.d.ts +0 -3
- package/dist/utils/printDocs.js +0 -1
- package/dist/utils/stringHash.d.ts +0 -2
- package/dist/utils/stringHash.js +0 -5
- package/dist/validation/dynamic-view-rule.d.ts +0 -5
- package/dist/validation/dynamic-view-step.d.ts +0 -5
- package/dist/validation/dynamic-view-step.js +0 -33
- package/dist/validation/element.d.ts +0 -6
- package/dist/validation/element.js +0 -38
- package/dist/validation/index.d.ts +0 -3
- package/dist/validation/property-checks.d.ts +0 -5
- package/dist/validation/property-checks.js +0 -11
- package/dist/validation/relation.d.ts +0 -5
- package/dist/validation/relation.js +0 -50
- package/dist/validation/specification.d.ts +0 -10
- package/dist/validation/specification.js +0 -97
- package/dist/validation/view-predicates/custom-element-expr.d.ts +0 -5
- package/dist/validation/view-predicates/custom-element-expr.js +0 -16
- package/dist/validation/view-predicates/expanded-element.d.ts +0 -5
- package/dist/validation/view-predicates/incoming.d.ts +0 -5
- package/dist/validation/view-predicates/incoming.js +0 -14
- package/dist/validation/view-predicates/index.d.ts +0 -5
- package/dist/validation/view-predicates/index.js +0 -4
- package/dist/validation/view-predicates/outgoing.d.ts +0 -5
- package/dist/validation/view-predicates/outgoing.js +0 -14
- package/dist/validation/view.d.ts +0 -5
- package/dist/validation/view.js +0 -16
- package/dist/view-utils/assignNavigateTo.d.ts +0 -3
- package/dist/view-utils/assignNavigateTo.js +0 -24
- package/dist/view-utils/index.d.ts +0 -4
- package/dist/view-utils/index.js +0 -3
- package/dist/view-utils/resolve-extended-views.d.ts +0 -7
- package/dist/view-utils/resolve-extended-views.js +0 -41
- package/dist/view-utils/resolve-relative-paths.d.ts +0 -3
- package/dist/view-utils/resolve-relative-paths.js +0 -75
- /package/{dist → src}/reset.d.ts +0 -0
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { invariant, isAncestor, nonNullable } from "@likec4/core";
|
|
2
|
-
import { GrammarUtils } from "langium";
|
|
3
|
-
import { entries, filter, findLast, last } from "remeda";
|
|
4
|
-
import { TextEdit } from "vscode-languageserver-protocol";
|
|
5
|
-
import { ast } from "../ast.js";
|
|
6
|
-
const { findNodeForKeyword, findNodeForProperty } = GrammarUtils;
|
|
7
|
-
const asViewStyleRule = (target, style, indent = 0) => {
|
|
8
|
-
const indentStr = indent > 0 ? " ".repeat(indent) : "";
|
|
9
|
-
return [
|
|
10
|
-
indentStr + `style ${target} {`,
|
|
11
|
-
...entries.strict(style).map(
|
|
12
|
-
([key, value]) => indentStr + ` ${key} ${key === "opacity" ? value.toString() + "%" : value}`
|
|
13
|
-
),
|
|
14
|
-
indentStr + `}`
|
|
15
|
-
];
|
|
16
|
-
};
|
|
17
|
-
const isMatchingViewRule = (fqn, index) => (rule) => {
|
|
18
|
-
if (!ast.isViewRuleStyle(rule)) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
const [target, ...rest] = rule.targets;
|
|
22
|
-
if (!target || rest.length > 0 || !ast.isElementRef(target)) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
const ref = target.el.ref;
|
|
26
|
-
const _fqn = ref ? index.getFqn(ref) : null;
|
|
27
|
-
return _fqn === fqn;
|
|
28
|
-
};
|
|
29
|
-
export function changeElementStyle(services, {
|
|
30
|
-
view,
|
|
31
|
-
viewAst,
|
|
32
|
-
targets,
|
|
33
|
-
style
|
|
34
|
-
}) {
|
|
35
|
-
const viewCstNode = viewAst.$cstNode;
|
|
36
|
-
invariant(viewCstNode, "viewCstNode");
|
|
37
|
-
const insertPos = last(viewAst.body.rules)?.$cstNode?.range.end ?? viewAst.body.$cstNode?.range.end;
|
|
38
|
-
invariant(insertPos, "insertPos is not defined");
|
|
39
|
-
const indent = viewCstNode.range.start.character + 2;
|
|
40
|
-
const fqnIndex = services.likec4.FqnIndex;
|
|
41
|
-
const styleRules = filter(viewAst.body.rules, ast.isViewRuleStyle);
|
|
42
|
-
const viewOf = view.__ === "element" ? view.viewOf : null;
|
|
43
|
-
const existing = [];
|
|
44
|
-
const insert = [];
|
|
45
|
-
targets.forEach((target) => {
|
|
46
|
-
const rule = findLast(styleRules, isMatchingViewRule(target, fqnIndex));
|
|
47
|
-
const fqn = viewOf && isAncestor(viewOf, target) ? target.substring(viewOf.length + 1) : target;
|
|
48
|
-
if (rule) {
|
|
49
|
-
existing.push({ fqn, rule });
|
|
50
|
-
} else {
|
|
51
|
-
insert.push({ fqn });
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
const modifiedRange = {
|
|
55
|
-
start: insertPos,
|
|
56
|
-
end: insertPos
|
|
57
|
-
};
|
|
58
|
-
const includeRange = (range) => {
|
|
59
|
-
if (range.start.line <= modifiedRange.start.line) {
|
|
60
|
-
if (range.start.line == modifiedRange.start.line) {
|
|
61
|
-
modifiedRange.start.character = Math.min(range.start.character, modifiedRange.start.character);
|
|
62
|
-
} else {
|
|
63
|
-
modifiedRange.start = range.start;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
if (range.end.line >= modifiedRange.end.line) {
|
|
67
|
-
if (range.end.line == modifiedRange.end.line) {
|
|
68
|
-
modifiedRange.end.character = Math.max(range.end.character, modifiedRange.end.character);
|
|
69
|
-
} else {
|
|
70
|
-
modifiedRange.end = range.end;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
const edits = [];
|
|
75
|
-
if (insert.length > 0) {
|
|
76
|
-
const linesToInsert = insert.flatMap(({ fqn }) => asViewStyleRule(fqn, style, indent));
|
|
77
|
-
edits.push(
|
|
78
|
-
TextEdit.insert(
|
|
79
|
-
insertPos,
|
|
80
|
-
"\n" + linesToInsert.join("\n")
|
|
81
|
-
)
|
|
82
|
-
);
|
|
83
|
-
modifiedRange.start = {
|
|
84
|
-
line: insertPos.line + 1,
|
|
85
|
-
character: indent + 1
|
|
86
|
-
};
|
|
87
|
-
modifiedRange.end = {
|
|
88
|
-
line: insertPos.line + linesToInsert.length,
|
|
89
|
-
character: last(linesToInsert)?.length ?? 0
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
if (existing.length > 0) {
|
|
93
|
-
for (const { rule } of existing) {
|
|
94
|
-
const ruleCstNode = rule.$cstNode;
|
|
95
|
-
invariant(ruleCstNode, "RuleCstNode not found");
|
|
96
|
-
for (const [key, _value] of entries.strict(style)) {
|
|
97
|
-
const value = key === "opacity" ? _value.toString() + "%" : _value;
|
|
98
|
-
const ruleProp = rule.styleprops.find((p) => p.key === key);
|
|
99
|
-
if (ruleProp && ruleProp.$cstNode) {
|
|
100
|
-
const { range: { start, end } } = nonNullable(
|
|
101
|
-
findNodeForProperty(ruleProp.$cstNode, "value"),
|
|
102
|
-
"cant find value cst node"
|
|
103
|
-
);
|
|
104
|
-
includeRange({
|
|
105
|
-
start,
|
|
106
|
-
end: {
|
|
107
|
-
line: start.line,
|
|
108
|
-
character: start.character + value.length
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
edits.push(TextEdit.replace({ start, end }, value));
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
const insertPos2 = findNodeForKeyword(ruleCstNode, "{")?.range.end;
|
|
115
|
-
invariant(insertPos2, "Opening brace not found");
|
|
116
|
-
const indentStr = " ".repeat(2 + ruleCstNode.range.start.character);
|
|
117
|
-
const insertKeyValue = indentStr + key + " " + value;
|
|
118
|
-
edits.push(
|
|
119
|
-
TextEdit.insert(
|
|
120
|
-
insertPos2,
|
|
121
|
-
"\n" + insertKeyValue
|
|
122
|
-
)
|
|
123
|
-
);
|
|
124
|
-
includeRange({
|
|
125
|
-
start: {
|
|
126
|
-
line: insertPos2.line + 1,
|
|
127
|
-
character: indentStr.length
|
|
128
|
-
},
|
|
129
|
-
end: {
|
|
130
|
-
line: insertPos2.line + 1,
|
|
131
|
-
character: insertKeyValue.length
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return {
|
|
138
|
-
modifiedRange,
|
|
139
|
-
edits
|
|
140
|
-
};
|
|
141
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type AutoLayoutDirection } from '@likec4/core';
|
|
2
|
-
import { TextEdit } from 'vscode-languageserver-protocol';
|
|
3
|
-
import { ast, type ParsedAstView, type ParsedLikeC4LangiumDocument } from '../ast';
|
|
4
|
-
import type { LikeC4Services } from '../module';
|
|
5
|
-
type ChangeViewLayoutArg = {
|
|
6
|
-
view: ParsedAstView;
|
|
7
|
-
doc: ParsedLikeC4LangiumDocument;
|
|
8
|
-
viewAst: ast.LikeC4View;
|
|
9
|
-
layout: AutoLayoutDirection;
|
|
10
|
-
};
|
|
11
|
-
export declare function changeViewLayout(services: LikeC4Services, { viewAst, layout }: ChangeViewLayoutArg): TextEdit;
|
|
12
|
-
export {};
|
|
13
|
-
//# sourceMappingURL=changeViewLayout.d.ts.map
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { invariant } from "@likec4/core";
|
|
2
|
-
import { GrammarUtils } from "langium";
|
|
3
|
-
import { last } from "remeda";
|
|
4
|
-
import { TextEdit } from "vscode-languageserver-protocol";
|
|
5
|
-
import { ast, toAstViewLayoutDirection } from "../ast.js";
|
|
6
|
-
const { findNodeForProperty } = GrammarUtils;
|
|
7
|
-
export function changeViewLayout(services, {
|
|
8
|
-
viewAst,
|
|
9
|
-
layout
|
|
10
|
-
}) {
|
|
11
|
-
const viewCstNode = viewAst.$cstNode;
|
|
12
|
-
invariant(viewCstNode, "viewCstNode");
|
|
13
|
-
const newlayout = toAstViewLayoutDirection(layout);
|
|
14
|
-
const existingRule = viewAst.body.rules.findLast(ast.isViewRuleAutoLayout);
|
|
15
|
-
if (existingRule && existingRule.$cstNode) {
|
|
16
|
-
const directionCstNode = findNodeForProperty(existingRule.$cstNode, "direction");
|
|
17
|
-
if (directionCstNode) {
|
|
18
|
-
return TextEdit.replace(directionCstNode.range, newlayout);
|
|
19
|
-
}
|
|
20
|
-
return TextEdit.replace(existingRule.$cstNode.range, `autoLayout ${newlayout}`);
|
|
21
|
-
}
|
|
22
|
-
const insertPos = last(viewAst.body.rules)?.$cstNode?.range.end ?? viewAst.body.$cstNode?.range.end;
|
|
23
|
-
invariant(insertPos, "insertPos is not defined");
|
|
24
|
-
const indent = " ".repeat(2 + viewCstNode.range.start.character);
|
|
25
|
-
const insert = `
|
|
26
|
-
|
|
27
|
-
${indent}autoLayout ${newlayout}`;
|
|
28
|
-
return TextEdit.insert(insertPos, insert);
|
|
29
|
-
}
|
package/dist/module.d.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { type Module, WorkspaceCache } from 'langium';
|
|
2
|
-
import { type DefaultSharedModuleContext, type LangiumServices, type LangiumSharedServices, type PartialLangiumServices } from 'langium/lsp';
|
|
3
|
-
import { LikeC4CodeLensProvider, LikeC4DocumentHighlightProvider, LikeC4DocumentLinkProvider, LikeC4DocumentSymbolProvider, LikeC4HoverProvider, LikeC4SemanticTokenProvider } from './lsp';
|
|
4
|
-
import { FqnIndex, LikeC4ModelBuilder, LikeC4ModelLocator, LikeC4ModelParser } from './model';
|
|
5
|
-
import { LikeC4ModelChanges } from './model-change/ModelChanges';
|
|
6
|
-
import { LikeC4ScopeComputation, LikeC4ScopeProvider } from './references';
|
|
7
|
-
import { Rpc } from './Rpc';
|
|
8
|
-
import { LikeC4WorkspaceManager, NodeKindProvider, WorkspaceSymbolProvider } from './shared';
|
|
9
|
-
interface LikeC4AddedSharedServices {
|
|
10
|
-
lsp: {
|
|
11
|
-
NodeKindProvider: NodeKindProvider;
|
|
12
|
-
WorkspaceSymbolProvider: WorkspaceSymbolProvider;
|
|
13
|
-
};
|
|
14
|
-
workspace: {
|
|
15
|
-
WorkspaceManager: LikeC4WorkspaceManager;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
export type LikeC4SharedServices = LangiumSharedServices & LikeC4AddedSharedServices;
|
|
19
|
-
/**
|
|
20
|
-
* Declaration of custom services - add your own service classes here.
|
|
21
|
-
*/
|
|
22
|
-
export interface LikeC4AddedServices {
|
|
23
|
-
WorkspaceCache: WorkspaceCache<string, any>;
|
|
24
|
-
Rpc: Rpc;
|
|
25
|
-
likec4: {
|
|
26
|
-
FqnIndex: FqnIndex;
|
|
27
|
-
ModelParser: LikeC4ModelParser;
|
|
28
|
-
ModelBuilder: LikeC4ModelBuilder;
|
|
29
|
-
ModelLocator: LikeC4ModelLocator;
|
|
30
|
-
ModelChanges: LikeC4ModelChanges;
|
|
31
|
-
};
|
|
32
|
-
lsp: {
|
|
33
|
-
DocumentHighlightProvider: LikeC4DocumentHighlightProvider;
|
|
34
|
-
DocumentSymbolProvider: LikeC4DocumentSymbolProvider;
|
|
35
|
-
SemanticTokenProvider: LikeC4SemanticTokenProvider;
|
|
36
|
-
HoverProvider: LikeC4HoverProvider;
|
|
37
|
-
CodeLensProvider: LikeC4CodeLensProvider;
|
|
38
|
-
DocumentLinkProvider: LikeC4DocumentLinkProvider;
|
|
39
|
-
};
|
|
40
|
-
references: {
|
|
41
|
-
ScopeComputation: LikeC4ScopeComputation;
|
|
42
|
-
ScopeProvider: LikeC4ScopeProvider;
|
|
43
|
-
};
|
|
44
|
-
shared?: LikeC4SharedServices;
|
|
45
|
-
}
|
|
46
|
-
export type LikeC4Services = LangiumServices & LikeC4AddedServices;
|
|
47
|
-
export declare const LikeC4Module: Module<LikeC4Services, PartialLangiumServices & LikeC4AddedServices>;
|
|
48
|
-
export type LanguageServicesContext = Partial<DefaultSharedModuleContext>;
|
|
49
|
-
export declare function createCustomLanguageServices<I1, I2, I3, I extends I1 & I2 & I3 & LikeC4Services>(context: LanguageServicesContext, module: Module<I, I1>, module2?: Module<I, I2>, module3?: Module<I, I3>): {
|
|
50
|
-
shared: LikeC4SharedServices;
|
|
51
|
-
likec4: I;
|
|
52
|
-
};
|
|
53
|
-
export declare function createSharedServices(context?: LanguageServicesContext): LikeC4SharedServices;
|
|
54
|
-
export declare function createLanguageServices(context?: LanguageServicesContext): {
|
|
55
|
-
shared: LikeC4SharedServices;
|
|
56
|
-
likec4: LikeC4Services;
|
|
57
|
-
};
|
|
58
|
-
export {};
|
|
59
|
-
//# sourceMappingURL=module.d.ts.map
|
package/dist/module.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { normalizeError } from "@likec4/core";
|
|
2
|
-
import { EmptyFileSystem, inject, WorkspaceCache } from "langium";
|
|
3
|
-
import {
|
|
4
|
-
createDefaultModule,
|
|
5
|
-
createDefaultSharedModule
|
|
6
|
-
} from "langium/lsp";
|
|
7
|
-
import { LikeC4GeneratedModule, LikeC4GeneratedSharedModule } from "./generated/module.js";
|
|
8
|
-
import { logger } from "./logger.js";
|
|
9
|
-
import {
|
|
10
|
-
LikeC4CodeLensProvider,
|
|
11
|
-
LikeC4DocumentHighlightProvider,
|
|
12
|
-
LikeC4DocumentLinkProvider,
|
|
13
|
-
LikeC4DocumentSymbolProvider,
|
|
14
|
-
LikeC4HoverProvider,
|
|
15
|
-
LikeC4SemanticTokenProvider
|
|
16
|
-
} from "./lsp/index.js";
|
|
17
|
-
import { FqnIndex, LikeC4ModelBuilder, LikeC4ModelLocator, LikeC4ModelParser } from "./model/index.js";
|
|
18
|
-
import { LikeC4ModelChanges } from "./model-change/ModelChanges.js";
|
|
19
|
-
import { LikeC4ScopeComputation, LikeC4ScopeProvider } from "./references/index.js";
|
|
20
|
-
import { Rpc } from "./Rpc.js";
|
|
21
|
-
import { LikeC4WorkspaceManager, NodeKindProvider, WorkspaceSymbolProvider } from "./shared/index.js";
|
|
22
|
-
import { registerValidationChecks } from "./validation/index.js";
|
|
23
|
-
const LikeC4SharedModule = {
|
|
24
|
-
lsp: {
|
|
25
|
-
NodeKindProvider: (services) => new NodeKindProvider(services),
|
|
26
|
-
WorkspaceSymbolProvider: (services) => new WorkspaceSymbolProvider(services)
|
|
27
|
-
},
|
|
28
|
-
workspace: {
|
|
29
|
-
WorkspaceManager: (services) => new LikeC4WorkspaceManager(services)
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
function bind(Type) {
|
|
33
|
-
return (services) => new Type(services);
|
|
34
|
-
}
|
|
35
|
-
export const LikeC4Module = {
|
|
36
|
-
WorkspaceCache: (services) => new WorkspaceCache(services.shared),
|
|
37
|
-
Rpc: bind(Rpc),
|
|
38
|
-
likec4: {
|
|
39
|
-
ModelChanges: bind(LikeC4ModelChanges),
|
|
40
|
-
FqnIndex: bind(FqnIndex),
|
|
41
|
-
ModelParser: bind(LikeC4ModelParser),
|
|
42
|
-
ModelBuilder: bind(LikeC4ModelBuilder),
|
|
43
|
-
ModelLocator: bind(LikeC4ModelLocator)
|
|
44
|
-
},
|
|
45
|
-
lsp: {
|
|
46
|
-
DocumentHighlightProvider: bind(LikeC4DocumentHighlightProvider),
|
|
47
|
-
DocumentSymbolProvider: bind(LikeC4DocumentSymbolProvider),
|
|
48
|
-
SemanticTokenProvider: bind(LikeC4SemanticTokenProvider),
|
|
49
|
-
HoverProvider: bind(LikeC4HoverProvider),
|
|
50
|
-
CodeLensProvider: bind(LikeC4CodeLensProvider),
|
|
51
|
-
DocumentLinkProvider: bind(LikeC4DocumentLinkProvider)
|
|
52
|
-
},
|
|
53
|
-
references: {
|
|
54
|
-
ScopeComputation: bind(LikeC4ScopeComputation),
|
|
55
|
-
ScopeProvider: bind(LikeC4ScopeProvider)
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
export function createCustomLanguageServices(context, module, module2, module3) {
|
|
59
|
-
const shared = createSharedServices(context);
|
|
60
|
-
const modules = [
|
|
61
|
-
createDefaultModule({ shared }),
|
|
62
|
-
LikeC4GeneratedModule,
|
|
63
|
-
LikeC4Module,
|
|
64
|
-
module,
|
|
65
|
-
module2,
|
|
66
|
-
module3
|
|
67
|
-
].reduce(_merge, {});
|
|
68
|
-
const likec4 = inject(modules);
|
|
69
|
-
shared.ServiceRegistry.register(likec4);
|
|
70
|
-
registerValidationChecks(likec4);
|
|
71
|
-
likec4.Rpc.init();
|
|
72
|
-
return { shared, likec4 };
|
|
73
|
-
}
|
|
74
|
-
export function createSharedServices(context = {}) {
|
|
75
|
-
const connection = context.connection;
|
|
76
|
-
if (connection) {
|
|
77
|
-
const original = logger.error.bind(logger);
|
|
78
|
-
logger.error = (arg) => {
|
|
79
|
-
if (typeof arg === "string") {
|
|
80
|
-
original(arg);
|
|
81
|
-
connection.telemetry.logEvent({ eventName: "error", error: arg });
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
const error = normalizeError(arg);
|
|
85
|
-
original(error);
|
|
86
|
-
connection.telemetry.logEvent({ eventName: "error", error: error.stack ?? error.message });
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
const moduleContext = {
|
|
90
|
-
...EmptyFileSystem,
|
|
91
|
-
...context
|
|
92
|
-
};
|
|
93
|
-
return inject(
|
|
94
|
-
createDefaultSharedModule(moduleContext),
|
|
95
|
-
LikeC4GeneratedSharedModule,
|
|
96
|
-
LikeC4SharedModule
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
export function createLanguageServices(context = {}) {
|
|
100
|
-
const shared = createSharedServices(context);
|
|
101
|
-
const likec4 = inject(createDefaultModule({ shared }), LikeC4GeneratedModule, LikeC4Module);
|
|
102
|
-
shared.ServiceRegistry.register(likec4);
|
|
103
|
-
registerValidationChecks(likec4);
|
|
104
|
-
likec4.Rpc.init();
|
|
105
|
-
return { shared, likec4 };
|
|
106
|
-
}
|
|
107
|
-
function _merge(target, source) {
|
|
108
|
-
if (source) {
|
|
109
|
-
for (const [key, value2] of Object.entries(source)) {
|
|
110
|
-
if (value2 !== void 0) {
|
|
111
|
-
const value1 = target[key];
|
|
112
|
-
if (value1 !== null && value2 !== null && typeof value1 === "object" && typeof value2 === "object") {
|
|
113
|
-
target[key] = _merge(value1, value2);
|
|
114
|
-
} else {
|
|
115
|
-
target[key] = value2;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return target;
|
|
121
|
-
}
|
package/dist/node/index.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare function startLanguageServer(): {
|
|
2
|
-
connection: import("vscode-languageserver/node")._Connection<import("vscode-languageserver/node")._, import("vscode-languageserver/node")._, import("vscode-languageserver/node")._, import("vscode-languageserver/node")._, import("vscode-languageserver/node")._, import("vscode-languageserver/node")._, import("vscode-languageserver/lib/common/inlineCompletion.proposed").InlineCompletionFeatureShape, import("vscode-languageserver/node")._>;
|
|
3
|
-
shared: import("../module").LikeC4SharedServices;
|
|
4
|
-
likec4: import("../module").LikeC4Services;
|
|
5
|
-
};
|
|
6
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/node/index.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { startLanguageServer as startLanguim } from "langium/lsp";
|
|
2
|
-
import { NodeFileSystem } from "langium/node";
|
|
3
|
-
import { createConnection, ProposedFeatures } from "vscode-languageserver/node";
|
|
4
|
-
import { createLanguageServices } from "../module.js";
|
|
5
|
-
export function startLanguageServer() {
|
|
6
|
-
const connection = createConnection(ProposedFeatures.all);
|
|
7
|
-
const services = createLanguageServices({ connection, ...NodeFileSystem });
|
|
8
|
-
startLanguim(services.shared);
|
|
9
|
-
return {
|
|
10
|
-
...services,
|
|
11
|
-
connection
|
|
12
|
-
};
|
|
13
|
-
}
|
package/dist/protocol.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { AutoLayoutDirection, BorderStyle, ComputedView, ElementShape, Fqn, LikeC4ComputedModel, LikeC4Model, NonEmptyArray, RelationID, ThemeColor, ViewID } from '@likec4/core';
|
|
2
|
-
import type { DocumentUri, Location } from 'vscode-languageserver-protocol';
|
|
3
|
-
import { NotificationType, RequestType, RequestType0 } from 'vscode-languageserver-protocol';
|
|
4
|
-
export declare const onDidChangeModel: NotificationType<string>;
|
|
5
|
-
export type OnDidChangeModelNotification = typeof onDidChangeModel;
|
|
6
|
-
export declare const fetchModel: RequestType0<{
|
|
7
|
-
model: LikeC4Model | null;
|
|
8
|
-
}, void>;
|
|
9
|
-
export type FetchModelRequest = typeof fetchModel;
|
|
10
|
-
export declare const fetchComputedModel: RequestType0<{
|
|
11
|
-
model: LikeC4ComputedModel | null;
|
|
12
|
-
}, void>;
|
|
13
|
-
export type FetchComputedModelRequest = typeof fetchComputedModel;
|
|
14
|
-
export declare const computeView: RequestType<{
|
|
15
|
-
viewId: ViewID;
|
|
16
|
-
}, {
|
|
17
|
-
view: ComputedView | null;
|
|
18
|
-
}, void>;
|
|
19
|
-
export type ComputeViewRequest = typeof computeView;
|
|
20
|
-
export interface BuildDocumentsParams {
|
|
21
|
-
docs: DocumentUri[];
|
|
22
|
-
}
|
|
23
|
-
export declare const buildDocuments: RequestType<BuildDocumentsParams, void, void>;
|
|
24
|
-
export type BuildDocumentsRequest = typeof buildDocuments;
|
|
25
|
-
export type LocateParams = {
|
|
26
|
-
element: Fqn;
|
|
27
|
-
property?: string;
|
|
28
|
-
} | {
|
|
29
|
-
relation: RelationID;
|
|
30
|
-
} | {
|
|
31
|
-
view: ViewID;
|
|
32
|
-
};
|
|
33
|
-
export declare const locate: RequestType<LocateParams, Location | null, void>;
|
|
34
|
-
export type LocateRequest = typeof locate;
|
|
35
|
-
export declare namespace ChangeView {
|
|
36
|
-
interface ChangeAutoLayout {
|
|
37
|
-
op: 'change-autolayout';
|
|
38
|
-
layout: AutoLayoutDirection;
|
|
39
|
-
}
|
|
40
|
-
interface ChangeElementStyle {
|
|
41
|
-
op: 'change-element-style';
|
|
42
|
-
style: {
|
|
43
|
-
border?: BorderStyle;
|
|
44
|
-
opacity?: number;
|
|
45
|
-
shape?: ElementShape;
|
|
46
|
-
color?: ThemeColor;
|
|
47
|
-
};
|
|
48
|
-
targets: NonEmptyArray<Fqn>;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
export type ChangeView = ChangeView.ChangeAutoLayout | ChangeView.ChangeElementStyle;
|
|
52
|
-
export interface ChangeViewRequestParams {
|
|
53
|
-
viewId: ViewID;
|
|
54
|
-
changes: NonEmptyArray<ChangeView>;
|
|
55
|
-
}
|
|
56
|
-
export declare const changeView: RequestType<ChangeViewRequestParams, Location | null, void>;
|
|
57
|
-
export type ChangeViewRequest = typeof changeView;
|
|
58
|
-
//# sourceMappingURL=protocol.d.ts.map
|
package/dist/protocol.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { NotificationType, RequestType, RequestType0 } from "vscode-languageserver-protocol";
|
|
2
|
-
export const onDidChangeModel = new NotificationType("likec4/onDidChangeModel");
|
|
3
|
-
export const fetchModel = new RequestType0(
|
|
4
|
-
"likec4/fetchModel"
|
|
5
|
-
);
|
|
6
|
-
export const fetchComputedModel = new RequestType0(
|
|
7
|
-
"likec4/fetchComputedModel"
|
|
8
|
-
);
|
|
9
|
-
export const computeView = new RequestType(
|
|
10
|
-
"likec4/computeView"
|
|
11
|
-
);
|
|
12
|
-
export const buildDocuments = new RequestType("likec4/build");
|
|
13
|
-
export const locate = new RequestType("likec4/locate");
|
|
14
|
-
export const changeView = new RequestType("likec4/change-view");
|
package/dist/references/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type AstNodeDescription, DefaultScopeComputation, MultiMap, type PrecomputedScopes } from 'langium';
|
|
2
|
-
import type { CancellationToken } from 'vscode-languageserver';
|
|
3
|
-
import { ast, type LikeC4LangiumDocument } from '../ast';
|
|
4
|
-
type ElementsContainer = ast.Model | ast.ElementBody | ast.ExtendElementBody;
|
|
5
|
-
export declare class LikeC4ScopeComputation extends DefaultScopeComputation {
|
|
6
|
-
computeExports(document: LikeC4LangiumDocument, _cancelToken?: CancellationToken): Promise<AstNodeDescription[]>;
|
|
7
|
-
computeLocalScopes(document: LikeC4LangiumDocument, _cancelToken?: CancellationToken): Promise<PrecomputedScopes>;
|
|
8
|
-
protected processContainer(container: ElementsContainer, scopes: PrecomputedScopes, document: LikeC4LangiumDocument): MultiMap<string, AstNodeDescription>;
|
|
9
|
-
}
|
|
10
|
-
export {};
|
|
11
|
-
//# sourceMappingURL=scope-computation.d.ts.map
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DefaultScopeComputation,
|
|
3
|
-
MultiMap
|
|
4
|
-
} from "langium";
|
|
5
|
-
import { isTruthy } from "remeda";
|
|
6
|
-
import { ast } from "../ast.js";
|
|
7
|
-
import { logError } from "../logger.js";
|
|
8
|
-
export class LikeC4ScopeComputation extends DefaultScopeComputation {
|
|
9
|
-
async computeExports(document, _cancelToken) {
|
|
10
|
-
const docExports = [];
|
|
11
|
-
try {
|
|
12
|
-
const { specifications, models, views } = document.parseResult.value;
|
|
13
|
-
for (const spec of specifications.flatMap((s) => [
|
|
14
|
-
...s.elements,
|
|
15
|
-
...s.relationships,
|
|
16
|
-
...s.tags
|
|
17
|
-
])) {
|
|
18
|
-
try {
|
|
19
|
-
if (ast.isSpecificationTag(spec)) {
|
|
20
|
-
if (spec.tag && isTruthy(spec.tag.name)) {
|
|
21
|
-
docExports.push(
|
|
22
|
-
this.descriptions.createDescription(spec.tag, "#" + spec.tag.name, document)
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
if (spec.kind && isTruthy(spec.kind.name)) {
|
|
28
|
-
docExports.push(
|
|
29
|
-
this.descriptions.createDescription(spec.kind, spec.kind.name, document)
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
} catch (e) {
|
|
33
|
-
logError(e);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
for (const elAst of models.flatMap((m) => m.elements)) {
|
|
37
|
-
try {
|
|
38
|
-
if (ast.isElement(elAst) && isTruthy(elAst.name)) {
|
|
39
|
-
docExports.push(this.descriptions.createDescription(elAst, elAst.name, document));
|
|
40
|
-
}
|
|
41
|
-
} catch (e) {
|
|
42
|
-
logError(e);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
for (const viewAst of views.flatMap((v) => v.views)) {
|
|
46
|
-
try {
|
|
47
|
-
if (isTruthy(viewAst.name)) {
|
|
48
|
-
docExports.push(this.descriptions.createDescription(viewAst, viewAst.name, document));
|
|
49
|
-
}
|
|
50
|
-
} catch (e) {
|
|
51
|
-
logError(e);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
} catch (e) {
|
|
55
|
-
logError(e);
|
|
56
|
-
}
|
|
57
|
-
return docExports;
|
|
58
|
-
}
|
|
59
|
-
computeLocalScopes(document, _cancelToken) {
|
|
60
|
-
return new Promise((resolve) => {
|
|
61
|
-
const root = document.parseResult.value;
|
|
62
|
-
const scopes = new MultiMap();
|
|
63
|
-
for (const model of root.models) {
|
|
64
|
-
try {
|
|
65
|
-
const nested = this.processContainer(model, scopes, document);
|
|
66
|
-
scopes.addAll(root, nested.values());
|
|
67
|
-
} catch (e) {
|
|
68
|
-
logError(e);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
resolve(scopes);
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
processContainer(container, scopes, document) {
|
|
75
|
-
const localScope = new MultiMap();
|
|
76
|
-
const nestedScopes = new MultiMap();
|
|
77
|
-
for (const el of container.elements) {
|
|
78
|
-
if (ast.isRelation(el)) {
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
let subcontainer;
|
|
82
|
-
if (ast.isElement(el)) {
|
|
83
|
-
if (isTruthy(el.name)) {
|
|
84
|
-
localScope.add(el.name, this.descriptions.createDescription(el, el.name, document));
|
|
85
|
-
}
|
|
86
|
-
subcontainer = el.body;
|
|
87
|
-
} else if (ast.isExtendElement(el)) {
|
|
88
|
-
subcontainer = el.body;
|
|
89
|
-
}
|
|
90
|
-
if (subcontainer && subcontainer.elements.length > 0) {
|
|
91
|
-
try {
|
|
92
|
-
const nested = this.processContainer(subcontainer, scopes, document);
|
|
93
|
-
for (const [nestedName, desc] of nested) {
|
|
94
|
-
nestedScopes.add(nestedName, desc);
|
|
95
|
-
}
|
|
96
|
-
} catch (e) {
|
|
97
|
-
logError(e);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
if (nestedScopes.size > 0) {
|
|
102
|
-
for (const [name, descriptions] of nestedScopes.entriesGroupedByKey()) {
|
|
103
|
-
if (!localScope.has(name) && descriptions.length === 1) {
|
|
104
|
-
localScope.add(name, descriptions[0]);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
scopes.addAll(container, localScope.values());
|
|
109
|
-
return localScope;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { DefaultScopeProvider, type ReferenceInfo, type Scope } from 'langium';
|
|
2
|
-
import type { LikeC4Services } from '../module';
|
|
3
|
-
export declare class LikeC4ScopeProvider extends DefaultScopeProvider {
|
|
4
|
-
private fqnIndex;
|
|
5
|
-
constructor(services: LikeC4Services);
|
|
6
|
-
private directChildrenOf;
|
|
7
|
-
private uniqueDescedants;
|
|
8
|
-
private scopeElementRef;
|
|
9
|
-
private scopeExtendElement;
|
|
10
|
-
private scopeElementView;
|
|
11
|
-
getScope(context: ReferenceInfo): Scope;
|
|
12
|
-
protected computeScope(context: ReferenceInfo): Scope;
|
|
13
|
-
/**
|
|
14
|
-
* Create a global scope filtered for the given reference type.
|
|
15
|
-
*/
|
|
16
|
-
protected getGlobalScope(referenceType: string): Scope;
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=scope-provider.d.ts.map
|