@likec4/language-server 1.10.0 → 1.11.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.
Files changed (55) hide show
  1. package/dist/browser.cjs +5 -1
  2. package/dist/browser.d.cts +9 -8
  3. package/dist/browser.d.mts +9 -8
  4. package/dist/browser.d.ts +9 -8
  5. package/dist/browser.mjs +3 -2
  6. package/dist/index.cjs +15 -2
  7. package/dist/index.d.cts +14 -11
  8. package/dist/index.d.mts +14 -11
  9. package/dist/index.d.ts +14 -11
  10. package/dist/index.mjs +17 -1
  11. package/dist/likec4lib.cjs +949 -952
  12. package/dist/likec4lib.d.cts +1 -1
  13. package/dist/likec4lib.d.mts +1 -1
  14. package/dist/likec4lib.d.ts +1 -1
  15. package/dist/likec4lib.mjs +949 -952
  16. package/dist/model-graph/index.cjs +1 -1
  17. package/dist/model-graph/index.mjs +1 -1
  18. package/dist/protocol.cjs +1 -1
  19. package/dist/protocol.d.cts +3 -1
  20. package/dist/protocol.d.mts +3 -1
  21. package/dist/protocol.d.ts +3 -1
  22. package/dist/protocol.mjs +1 -1
  23. package/dist/shared/{language-server.JWkqVjGv.cjs → language-server.C8lV6gDw.cjs} +120 -118
  24. package/dist/shared/{language-server.DBJJUUgF.mjs → language-server.CCOotWDz.mjs} +120 -119
  25. package/dist/shared/{language-server.DtBRb9os.mjs → language-server.CbqwHp7Q.mjs} +23 -9
  26. package/dist/shared/{language-server.CtKHXJDD.d.ts → language-server.Cyw-bCtc.d.ts} +145 -138
  27. package/dist/shared/{language-server.D-84I33F.d.mts → language-server.DGjTE7xL.d.mts} +145 -138
  28. package/dist/shared/{language-server.DwyCJvXm.cjs → language-server.DJhoJBWh.cjs} +17 -3
  29. package/dist/shared/{language-server.CjFzaJwI.d.cts → language-server.Ol32Kygo.d.cts} +145 -138
  30. package/package.json +34 -29
  31. package/src/Rpc.ts +10 -6
  32. package/src/ast.ts +1 -1
  33. package/src/browser.ts +5 -0
  34. package/src/formatting/LikeC4Formatter.ts +4 -2
  35. package/src/generated/ast.ts +99 -1
  36. package/src/generated/grammar.ts +1 -1
  37. package/src/generated/module.ts +1 -1
  38. package/src/generated-lib/icons.ts +949 -952
  39. package/src/index.ts +23 -2
  40. package/src/likec4lib.ts +1 -1
  41. package/src/logger.ts +16 -16
  42. package/src/lsp/CompletionProvider.ts +1 -1
  43. package/src/model/model-builder.ts +12 -12
  44. package/src/model-graph/compute-view/compute.ts +9 -4
  45. package/src/model-graph/utils/applyCustomRelationProperties.ts +1 -1
  46. package/src/model-graph/utils/uniqueTags.test.ts +42 -0
  47. package/src/model-graph/utils/uniqueTags.ts +19 -0
  48. package/src/protocol.ts +5 -1
  49. package/src/shared/WorkspaceManager.ts +1 -1
  50. package/dist/node.cjs +0 -18
  51. package/dist/node.d.cts +0 -20
  52. package/dist/node.d.mts +0 -20
  53. package/dist/node.d.ts +0 -20
  54. package/dist/node.mjs +0 -16
  55. package/src/node.ts +0 -20
@@ -373,6 +373,16 @@ function sortNodes({
373
373
  return sorted;
374
374
  }
375
375
 
376
+ function uniqueTags(elements) {
377
+ const tags = remeda.pipe(
378
+ elements,
379
+ remeda.flatMap((e) => e.tags ?? []),
380
+ remeda.unique(),
381
+ remeda.sort(core.compareNatural)
382
+ );
383
+ return core.hasAtLeast(tags, 1) ? tags : null;
384
+ }
385
+
376
386
  const NoFilter = () => true;
377
387
  const Identity = (x) => x;
378
388
  const filterBy = (pred) => pred === NoFilter ? Identity : remeda.filter(pred);
@@ -885,7 +895,11 @@ class ComputeCtx {
885
895
  relations: relations.map((r) => r.id)
886
896
  };
887
897
  let relation;
888
- relation = relations.length === 1 ? relations[0] : relations.find((r) => r.source === source && r.target === target);
898
+ relation = remeda.only(relations) ?? remeda.pipe(
899
+ relations,
900
+ remeda.filter((r) => r.source === source && r.target === target),
901
+ remeda.only()
902
+ );
889
903
  if (!relation) {
890
904
  const allprops = remeda.pipe(
891
905
  relations,
@@ -942,7 +956,7 @@ class ComputeCtx {
942
956
  navigateTo: remeda.only(allprops.navigateTo)
943
957
  };
944
958
  }
945
- const tags = remeda.unique(remeda.flatMap(relations, (r) => r.tags ?? []));
959
+ const tags = uniqueTags(relations);
946
960
  return Object.assign(
947
961
  edge,
948
962
  this.getEdgeLabel(relation),
@@ -954,7 +968,7 @@ class ComputeCtx {
954
968
  relation.head && { head: relation.head },
955
969
  relation.tail && { tail: relation.tail },
956
970
  relation.navigateTo && { navigateTo: relation.navigateTo },
957
- remeda.hasAtLeast(tags, 1) && { tags }
971
+ tags && { tags }
958
972
  );
959
973
  });
960
974
  }
@@ -1,15 +1,44 @@
1
+ import { LangiumDocument, ReferenceDescription, MaybePromise, AstNode, Reference, MultiMap, AstNodeDescription, DiagnosticInfo, LangiumDocuments, Stream, Cancellation, Disposable, URI, DefaultScopeComputation, PrecomputedScopes, DefaultScopeProvider, ReferenceInfo, Scope, DefaultWorkspaceManager, WorkspaceCache, Module } from 'langium';
2
+ import { CodeLensProvider, DefaultCompletionProvider, DefaultDocumentHighlightProvider, DocumentLinkProvider, DocumentSymbolProvider, NodeKindProvider as NodeKindProvider$1, AstNodeHoverProvider, AbstractSemanticTokenProvider, SemanticTokenAcceptor, LangiumSharedServices, DefaultWorkspaceSymbolProvider, LangiumServices, PartialLangiumServices, DefaultSharedModuleContext } from 'langium/lsp';
3
+ import { CodeLensParams, CancellationToken, CodeLens, DocumentHighlight, DocumentLinkParams, DocumentLink, WorkspaceFolder } from 'vscode-languageserver';
4
+ import { Diagnostic, DocumentSymbol, SymbolKind, Hover, Location, Range, TextEdit, CompletionItemKind } from 'vscode-languageserver-types';
1
5
  import * as c4 from '@likec4/core';
2
6
  import { Fqn, ViewID } from '@likec4/core';
3
- import { AstNode, Reference, LangiumDocument, MultiMap, AstNodeDescription, DiagnosticInfo, ReferenceDescription, MaybePromise, DefaultScopeComputation, PrecomputedScopes, DefaultScopeProvider, ReferenceInfo, Scope, Disposable, DefaultWorkspaceManager, WorkspaceCache, Module, LangiumDocuments, Stream, Cancellation, URI as URI$1 } from 'langium';
4
7
  import { SetRequired, ValueOf, ConditionalPick } from 'type-fest';
5
- import { Diagnostic, DocumentSymbol, SymbolKind, Hover, Location, Range, TextEdit, CompletionItemKind } from 'vscode-languageserver-types';
6
- import { CodeLensProvider, DefaultCompletionProvider, DefaultDocumentHighlightProvider, DocumentLinkProvider, DocumentSymbolProvider, NodeKindProvider as NodeKindProvider$1, AstNodeHoverProvider, AbstractSemanticTokenProvider, SemanticTokenAcceptor, LangiumSharedServices, DefaultWorkspaceSymbolProvider, LangiumServices, PartialLangiumServices, DefaultSharedModuleContext } from 'langium/lsp';
7
- import { CodeLensParams, CancellationToken, CodeLens, DocumentHighlight, DocumentLinkParams, DocumentLink, WorkspaceFolder } from 'vscode-languageserver';
8
8
  import { ChangeViewRequestParams } from '../protocol.cjs';
9
- import { URI } from 'vscode-uri';
9
+ import { URI as URI$1 } from 'vscode-uri';
10
+ import * as _likec4_log from '@likec4/log';
11
+ import { LogLevels } from '@likec4/log';
12
+
13
+ declare class LikeC4CodeLensProvider implements CodeLensProvider {
14
+ private services;
15
+ constructor(services: LikeC4Services);
16
+ provideCodeLens(doc: LangiumDocument, _params: CodeLensParams, cancelToken?: CancellationToken): Promise<CodeLens[] | undefined>;
17
+ }
18
+
19
+ declare class LikeC4CompletionProvider extends DefaultCompletionProvider {
20
+ readonly completionOptions: {
21
+ triggerCharacters: string[];
22
+ };
23
+ }
24
+
25
+ declare class LikeC4DocumentHighlightProvider extends DefaultDocumentHighlightProvider {
26
+ /**
27
+ * Override this method to determine the highlight kind of the given reference.
28
+ */
29
+ protected createDocumentHighlight(reference: ReferenceDescription): DocumentHighlight;
30
+ }
31
+
32
+ declare class LikeC4DocumentLinkProvider implements DocumentLinkProvider {
33
+ private services;
34
+ constructor(services: LikeC4Services);
35
+ getDocumentLinks(doc: LangiumDocument, _params: DocumentLinkParams): MaybePromise<DocumentLink[]>;
36
+ resolveLink(doc: LangiumDocument, link: string): string;
37
+ relativeLink(doc: LangiumDocument, link: string): string | null;
38
+ }
10
39
 
11
40
  /******************************************************************************
12
- * This file was generated by langium-cli 3.1.1.
41
+ * This file was generated by langium-cli 3.2.0.
13
42
  * DO NOT EDIT MANUALLY!
14
43
  ******************************************************************************/
15
44
 
@@ -923,7 +952,7 @@ interface ParsedLikeC4LangiumDocument extends Omit<LangiumDocument<LikeC4Grammar
923
952
  }
924
953
  type Guard<N extends AstNode> = (n: AstNode) => n is N;
925
954
  type Guarded<G> = G extends Guard<infer N> ? N : never;
926
- declare const isValidatableAstNode: (n: AstNode) => n is Guarded<typeof isLikeC4View | typeof isRelation | typeof isExtendElement | typeof isElement | typeof isDynamicViewPredicateIterator | typeof isElementPredicateWith | typeof isRelationPredicateWith | typeof isElementExpression | typeof isRelationExpression | typeof isDynamicViewParallelSteps | typeof isDynamicViewStep | typeof isViewProperty | typeof isStyleProperty | typeof isTags | typeof isViewRule | typeof isDynamicViewRule | typeof isElementViewBody | typeof isDynamicViewBody | typeof isRelationProperty | typeof isRelationBody | typeof isElementProperty | typeof isElementBody | typeof isExtendElementBody | typeof isSpecificationElementKind | typeof isSpecificationRelationshipKind | typeof isSpecificationTag | typeof isSpecificationColor | typeof isSpecificationRule | typeof isModelViews | typeof isModel>;
955
+ declare const isValidatableAstNode: (n: AstNode) => n is Guarded<typeof isRelation | typeof isExtendElement | typeof isElement | typeof isLikeC4View | typeof isDynamicViewPredicateIterator | typeof isElementPredicateWith | typeof isRelationPredicateWith | typeof isElementExpression | typeof isRelationExpression | typeof isDynamicViewParallelSteps | typeof isDynamicViewStep | typeof isViewProperty | typeof isStyleProperty | typeof isTags | typeof isViewRule | typeof isDynamicViewRule | typeof isElementViewBody | typeof isDynamicViewBody | typeof isRelationProperty | typeof isRelationBody | typeof isElementProperty | typeof isElementBody | typeof isExtendElementBody | typeof isSpecificationElementKind | typeof isSpecificationRelationshipKind | typeof isSpecificationTag | typeof isSpecificationColor | typeof isSpecificationRule | typeof isModelViews | typeof isModel>;
927
956
  type ValidatableAstNode = Guarded<typeof isValidatableAstNode>;
928
957
  declare function checksFromDiagnostics(doc: LikeC4LangiumDocument): {
929
958
  isValid: (n: ValidatableAstNode) => boolean;
@@ -931,33 +960,6 @@ declare function checksFromDiagnostics(doc: LikeC4LangiumDocument): {
931
960
  };
932
961
  type ChecksFromDiagnostics = ReturnType<typeof checksFromDiagnostics>;
933
962
 
934
- declare class LikeC4CodeLensProvider implements CodeLensProvider {
935
- private services;
936
- constructor(services: LikeC4Services);
937
- provideCodeLens(doc: LangiumDocument, _params: CodeLensParams, cancelToken?: CancellationToken): Promise<CodeLens[] | undefined>;
938
- }
939
-
940
- declare class LikeC4CompletionProvider extends DefaultCompletionProvider {
941
- readonly completionOptions: {
942
- triggerCharacters: string[];
943
- };
944
- }
945
-
946
- declare class LikeC4DocumentHighlightProvider extends DefaultDocumentHighlightProvider {
947
- /**
948
- * Override this method to determine the highlight kind of the given reference.
949
- */
950
- protected createDocumentHighlight(reference: ReferenceDescription): DocumentHighlight;
951
- }
952
-
953
- declare class LikeC4DocumentLinkProvider implements DocumentLinkProvider {
954
- private services;
955
- constructor(services: LikeC4Services);
956
- getDocumentLinks(doc: LangiumDocument, _params: DocumentLinkParams): MaybePromise<DocumentLink[]>;
957
- resolveLink(doc: LangiumDocument, link: string): string;
958
- relativeLink(doc: LangiumDocument, link: string): string | null;
959
- }
960
-
961
963
  declare class LikeC4DocumentSymbolProvider implements DocumentSymbolProvider {
962
964
  private services;
963
965
  protected readonly nodeKindProvider: NodeKindProvider$1;
@@ -989,6 +991,111 @@ declare class LikeC4SemanticTokenProvider extends AbstractSemanticTokenProvider
989
991
  private highlightView;
990
992
  }
991
993
 
994
+ declare function computeDocumentFqn(document: LikeC4LangiumDocument, services: LikeC4Services): void;
995
+
996
+ interface FqnIndexEntry {
997
+ fqn: Fqn;
998
+ name: string;
999
+ el: Element;
1000
+ doc: FqnIndexedDocument;
1001
+ path: string;
1002
+ }
1003
+ declare class FqnIndex {
1004
+ private services;
1005
+ protected langiumDocuments: LangiumDocuments;
1006
+ constructor(services: LikeC4Services);
1007
+ get documents(): Stream<FqnIndexedDocument>;
1008
+ private entries;
1009
+ getFqn(el: Element): Fqn | null;
1010
+ byFqn(fqn: Fqn): Stream<AstNodeDescription>;
1011
+ directChildrenOf(parent: Fqn): Stream<AstNodeDescription>;
1012
+ /**
1013
+ * Returns descedant elements with unique names in the scope
1014
+ */
1015
+ uniqueDescedants(parent: Fqn): Stream<AstNodeDescription>;
1016
+ }
1017
+
1018
+ type ModelParsedListener$1 = (docs: URI[]) => void;
1019
+ declare class LikeC4ModelBuilder {
1020
+ private services;
1021
+ private langiumDocuments;
1022
+ private listeners;
1023
+ constructor(services: LikeC4Services);
1024
+ /**
1025
+ * WARNING:
1026
+ * This method is internal and should to be called only when all documents are known to be parsed.
1027
+ * Otherwise, the model may be incomplete.
1028
+ */
1029
+ unsafeSyncBuildModel(): c4.ParsedLikeC4Model | null;
1030
+ buildModel(cancelToken?: Cancellation.CancellationToken): Promise<c4.ParsedLikeC4Model | null>;
1031
+ private previousViews;
1032
+ /**
1033
+ * WARNING:
1034
+ * This method is internal and should to be called only when all documents are known to be parsed.
1035
+ * Otherwise, the model may be incomplete.
1036
+ */
1037
+ unsafeSyncBuildComputedModel(model: c4.ParsedLikeC4Model): c4.ComputedLikeC4Model;
1038
+ buildComputedModel(cancelToken?: Cancellation.CancellationToken): Promise<c4.ComputedLikeC4Model | null>;
1039
+ computeView(viewId: ViewID, cancelToken?: Cancellation.CancellationToken): Promise<c4.ComputedView | null>;
1040
+ onModelParsed(callback: ModelParsedListener$1): Disposable;
1041
+ private documents;
1042
+ private notifyListeners;
1043
+ }
1044
+
1045
+ declare class LikeC4ModelLocator {
1046
+ private services;
1047
+ private fqnIndex;
1048
+ private langiumDocuments;
1049
+ constructor(services: LikeC4Services);
1050
+ private documents;
1051
+ getParsedElement(astNode: Element): ParsedAstElement | null;
1052
+ locateElement(fqn: c4.Fqn, _prop?: string): Location | null;
1053
+ locateRelation(relationId: c4.RelationID): Location | null;
1054
+ locateViewAst(viewId: c4.ViewID): {
1055
+ doc: ParsedLikeC4LangiumDocument;
1056
+ view: ParsedAstView;
1057
+ viewAst: LikeC4View;
1058
+ };
1059
+ locateView(viewId: c4.ViewID): Location | null;
1060
+ }
1061
+
1062
+ type ModelParsedListener = () => void;
1063
+ type IsValidFn = ChecksFromDiagnostics['isValid'];
1064
+ declare class LikeC4ModelParser {
1065
+ private services;
1066
+ private fqnIndex;
1067
+ constructor(services: LikeC4Services);
1068
+ parse(doc: LangiumDocument | LangiumDocument[]): ParsedLikeC4LangiumDocument[];
1069
+ protected parseLikeC4Document(_doc: FqnIndexedDocument): ParsedLikeC4LangiumDocument;
1070
+ private parseSpecification;
1071
+ private parseModel;
1072
+ private parseElement;
1073
+ private parseRelation;
1074
+ private parseViews;
1075
+ private parseViewRulePredicate;
1076
+ private parsePredicate;
1077
+ private parseElementExpressionsIterator;
1078
+ private parseElementPredicate;
1079
+ private parseElementExpr;
1080
+ private parseElementPredicateWith;
1081
+ private parseElementPredicateWhere;
1082
+ private parseRelationPredicate;
1083
+ private parseRelationPredicateWhere;
1084
+ private parseRelationPredicateWith;
1085
+ private parseRelationExpr;
1086
+ private parseViewRule;
1087
+ private parseViewManualLaout;
1088
+ private parseDynamicParallelSteps;
1089
+ private parseDynamicStep;
1090
+ private parseElementView;
1091
+ private parseDynamicElementView;
1092
+ protected resolveFqn(node: Element | ExtendElement): c4.Fqn;
1093
+ private getAstNodePath;
1094
+ private getMetadata;
1095
+ private convertTags;
1096
+ private convertLinks;
1097
+ }
1098
+
992
1099
  declare class LikeC4ModelChanges {
993
1100
  private services;
994
1101
  private locator;
@@ -1059,7 +1166,7 @@ declare class LikeC4WorkspaceManager extends DefaultWorkspaceManager {
1059
1166
  */
1060
1167
  protected loadAdditionalDocuments(folders: WorkspaceFolder[], collector: (document: LangiumDocument) => void): Promise<void>;
1061
1168
  workspace(): WorkspaceFolder;
1062
- get workspaceUri(): URI;
1169
+ get workspaceUri(): URI$1;
1063
1170
  get workspaceURL(): URL;
1064
1171
  }
1065
1172
 
@@ -1117,107 +1224,7 @@ declare function createLanguageServices(context?: LanguageServicesContext): {
1117
1224
  likec4: LikeC4Services;
1118
1225
  };
1119
1226
 
1120
- interface FqnIndexEntry {
1121
- fqn: Fqn;
1122
- name: string;
1123
- el: Element;
1124
- doc: FqnIndexedDocument;
1125
- path: string;
1126
- }
1127
- declare class FqnIndex {
1128
- private services;
1129
- protected langiumDocuments: LangiumDocuments;
1130
- constructor(services: LikeC4Services);
1131
- get documents(): Stream<FqnIndexedDocument>;
1132
- private entries;
1133
- getFqn(el: Element): Fqn | null;
1134
- byFqn(fqn: Fqn): Stream<AstNodeDescription>;
1135
- directChildrenOf(parent: Fqn): Stream<AstNodeDescription>;
1136
- /**
1137
- * Returns descedant elements with unique names in the scope
1138
- */
1139
- uniqueDescedants(parent: Fqn): Stream<AstNodeDescription>;
1140
- }
1141
-
1142
- type ModelParsedListener$1 = (docs: URI$1[]) => void;
1143
- declare class LikeC4ModelBuilder {
1144
- private services;
1145
- private langiumDocuments;
1146
- private listeners;
1147
- constructor(services: LikeC4Services);
1148
- /**
1149
- * WARNING:
1150
- * This method is internal and should to be called only when all documents are known to be parsed.
1151
- * Otherwise, the model may be incomplete.
1152
- */
1153
- unsafeSyncBuildModel(): c4.ParsedLikeC4Model | null;
1154
- buildModel(cancelToken?: Cancellation.CancellationToken): Promise<c4.ParsedLikeC4Model | null>;
1155
- private previousViews;
1156
- /**
1157
- * WARNING:
1158
- * This method is internal and should to be called only when all documents are known to be parsed.
1159
- * Otherwise, the model may be incomplete.
1160
- */
1161
- unsafeSyncBuildComputedModel(model: c4.ParsedLikeC4Model): c4.ComputedLikeC4Model;
1162
- buildComputedModel(cancelToken?: Cancellation.CancellationToken): Promise<c4.ComputedLikeC4Model | null>;
1163
- computeView(viewId: ViewID, cancelToken?: Cancellation.CancellationToken): Promise<c4.ComputedView | null>;
1164
- onModelParsed(callback: ModelParsedListener$1): Disposable;
1165
- private documents;
1166
- private notifyListeners;
1167
- }
1168
-
1169
- declare class LikeC4ModelLocator {
1170
- private services;
1171
- private fqnIndex;
1172
- private langiumDocuments;
1173
- constructor(services: LikeC4Services);
1174
- private documents;
1175
- getParsedElement(astNode: Element): ParsedAstElement | null;
1176
- locateElement(fqn: c4.Fqn, _prop?: string): Location | null;
1177
- locateRelation(relationId: c4.RelationID): Location | null;
1178
- locateViewAst(viewId: c4.ViewID): {
1179
- doc: ParsedLikeC4LangiumDocument;
1180
- view: ParsedAstView;
1181
- viewAst: LikeC4View;
1182
- };
1183
- locateView(viewId: c4.ViewID): Location | null;
1184
- }
1185
-
1186
- type ModelParsedListener = () => void;
1187
- type IsValidFn = ChecksFromDiagnostics['isValid'];
1188
- declare class LikeC4ModelParser {
1189
- private services;
1190
- private fqnIndex;
1191
- constructor(services: LikeC4Services);
1192
- parse(doc: LangiumDocument | LangiumDocument[]): ParsedLikeC4LangiumDocument[];
1193
- protected parseLikeC4Document(_doc: FqnIndexedDocument): ParsedLikeC4LangiumDocument;
1194
- private parseSpecification;
1195
- private parseModel;
1196
- private parseElement;
1197
- private parseRelation;
1198
- private parseViews;
1199
- private parseViewRulePredicate;
1200
- private parsePredicate;
1201
- private parseElementExpressionsIterator;
1202
- private parseElementPredicate;
1203
- private parseElementExpr;
1204
- private parseElementPredicateWith;
1205
- private parseElementPredicateWhere;
1206
- private parseRelationPredicate;
1207
- private parseRelationPredicateWhere;
1208
- private parseRelationPredicateWith;
1209
- private parseRelationExpr;
1210
- private parseViewRule;
1211
- private parseViewManualLaout;
1212
- private parseDynamicParallelSteps;
1213
- private parseDynamicStep;
1214
- private parseElementView;
1215
- private parseDynamicElementView;
1216
- protected resolveFqn(node: Element | ExtendElement): c4.Fqn;
1217
- private getAstNodePath;
1218
- private getMetadata;
1219
- private convertTags;
1220
- private convertLinks;
1221
- }
1227
+ declare const logger: _likec4_log.ConsolaInstance;
1228
+ declare function setLogLevel(level: keyof typeof LogLevels): void;
1222
1229
 
1223
- export { type FqnIndexEntry as F, type IsValidFn as I, type LikeC4LangiumDocument as L, type ModelParsedListener as M, type LikeC4Services as a, createLanguageServices as b, createCustomLanguageServices as c, LikeC4Module as d, FqnIndex as e, LikeC4ModelBuilder as f, LikeC4ModelLocator as g, LikeC4ModelParser as h, type LikeC4SharedServices as i, type LikeC4AddedServices as j, type LanguageServicesContext as k, createSharedServices as l };
1230
+ export { type FqnIndexEntry as F, type IsValidFn as I, type LikeC4SharedServices as L, type ModelParsedListener as M, type LikeC4Services as a, createLanguageServices as b, createCustomLanguageServices as c, LikeC4Module as d, computeDocumentFqn as e, FqnIndex as f, LikeC4ModelBuilder as g, LikeC4ModelLocator as h, LikeC4ModelParser as i, type LikeC4AddedServices as j, type LanguageServicesContext as k, createSharedServices as l, logger as m, setLogLevel as s };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@likec4/language-server",
3
3
  "description": "LikeC4 Language Server",
4
- "version": "1.10.0",
4
+ "version": "1.11.0",
5
5
  "license": "MIT",
6
6
  "bugs": "https://github.com/likec4/likec4/issues",
7
7
  "homepage": "https://likec4.dev",
@@ -24,9 +24,16 @@
24
24
  "sideEffects": false,
25
25
  "exports": {
26
26
  ".": {
27
- "types": "./dist/index.d.ts",
28
- "import": "./dist/index.mjs",
29
- "require": "./dist/index.cjs"
27
+ "browser": {
28
+ "types": "./dist/browser.d.ts",
29
+ "import": "./dist/browser.mjs",
30
+ "require": "./dist/browser.cjs"
31
+ },
32
+ "default": {
33
+ "types": "./dist/index.d.ts",
34
+ "import": "./dist/index.mjs",
35
+ "require": "./dist/index.cjs"
36
+ }
30
37
  },
31
38
  "./likec4lib": {
32
39
  "types": "./dist/likec4lib.d.ts",
@@ -43,11 +50,6 @@
43
50
  "import": "./dist/protocol.mjs",
44
51
  "require": "./dist/protocol.cjs"
45
52
  },
46
- "./node": {
47
- "types": "./dist/node.d.ts",
48
- "import": "./dist/node.mjs",
49
- "require": "./dist/node.cjs"
50
- },
51
53
  "./model-graph": {
52
54
  "types": "./dist/model-graph/index.d.ts",
53
55
  "import": "./dist/model-graph/index.mjs",
@@ -59,9 +61,16 @@
59
61
  "access": "public",
60
62
  "exports": {
61
63
  ".": {
62
- "types": "./dist/index.d.ts",
63
- "import": "./dist/index.mjs",
64
- "require": "./dist/index.cjs"
64
+ "browser": {
65
+ "types": "./dist/browser.d.ts",
66
+ "import": "./dist/browser.mjs",
67
+ "require": "./dist/browser.cjs"
68
+ },
69
+ "default": {
70
+ "types": "./dist/index.d.ts",
71
+ "import": "./dist/index.mjs",
72
+ "require": "./dist/index.cjs"
73
+ }
65
74
  },
66
75
  "./likec4lib": {
67
76
  "types": "./dist/likec4lib.d.ts",
@@ -78,11 +87,6 @@
78
87
  "import": "./dist/protocol.mjs",
79
88
  "require": "./dist/protocol.cjs"
80
89
  },
81
- "./node": {
82
- "types": "./dist/node.d.ts",
83
- "import": "./dist/node.mjs",
84
- "require": "./dist/node.cjs"
85
- },
86
90
  "./model-graph": {
87
91
  "types": "./dist/model-graph/index.d.ts",
88
92
  "import": "./dist/model-graph/index.mjs",
@@ -100,7 +104,7 @@
100
104
  "generate": "langium generate && tsx scripts/generate-icons.ts",
101
105
  "dev": "run-p 'watch:*'",
102
106
  "lint": "run -T eslint src/ --fix",
103
- "clean": "run -T rimraf dist contrib",
107
+ "clean": "rm -r -f dist contrib",
104
108
  "test": "vitest run --no-isolate",
105
109
  "test-dbg": "vitest run --no-isolate -t formating",
106
110
  "vitest:ui": "vitest --no-isolate --ui",
@@ -108,20 +112,20 @@
108
112
  },
109
113
  "dependencies": {
110
114
  "@dagrejs/graphlib": "^2.2.4",
111
- "@likec4/core": "1.10.0",
112
- "@likec4/log": "1.10.0",
115
+ "@likec4/core": "1.11.0",
116
+ "@likec4/log": "1.11.0",
113
117
  "@msgpack/msgpack": "^3.0.0-beta2",
114
118
  "@smithy/util-base64": "^3.0.0",
115
119
  "fast-equals": "^5.0.1",
116
120
  "indent-string": "^5.0.0",
117
121
  "json5": "^2.2.3",
118
- "langium": "3.1.3",
122
+ "langium": "3.2.0",
119
123
  "object-hash": "^3.0.0",
120
124
  "p-debounce": "^4.0.0",
121
- "remeda": "^2.11.0",
125
+ "remeda": "^2.14.0",
122
126
  "string-hash": "^1.1.3",
123
127
  "strip-indent": "^4.0.0",
124
- "type-fest": "^4.26.0",
128
+ "type-fest": "4.26.1",
125
129
  "ufo": "^1.5.4",
126
130
  "vscode-jsonrpc": "8.2.0",
127
131
  "vscode-languageserver": "9.0.1",
@@ -129,19 +133,20 @@
129
133
  "vscode-uri": "3.0.8"
130
134
  },
131
135
  "devDependencies": {
132
- "@likec4/icons": "1.10.0",
133
- "@likec4/tsconfig": "1.10.0",
136
+ "@likec4/icons": "1.11.0",
137
+ "@likec4/tsconfig": "1.11.0",
134
138
  "@types/node": "^20.16.1",
135
139
  "@types/object-hash": "^3.0.6",
136
140
  "@types/string-hash": "^1.1.3",
141
+ "@vitest/coverage-v8": "^2.1.1",
137
142
  "execa": "^9.3.1",
138
- "langium-cli": "3.1.1",
143
+ "langium-cli": "3.2.0",
139
144
  "npm-run-all2": "^6.2.2",
140
145
  "tsx": "~4.9.3",
141
146
  "turbo": "^2.1.1",
142
- "typescript": "^5.5.4",
147
+ "typescript": "^5.6.2",
143
148
  "unbuild": "^3.0.0-rc.7",
144
- "vitest": "~2.0.5"
149
+ "vitest": "^2.1.1"
145
150
  },
146
- "packageManager": "yarn@4.3.1"
151
+ "packageManager": "yarn@4.4.1"
147
152
  }
package/src/Rpc.ts CHANGED
@@ -35,15 +35,16 @@ export class Rpc implements Disposable {
35
35
  const DocumentBuilder = this.services.shared.workspace.DocumentBuilder
36
36
 
37
37
  const notifyModelParsed = debounce(
38
- () =>
39
- void connection.sendNotification(onDidChangeModel, '').catch(e => {
38
+ () => {
39
+ connection.sendNotification(onDidChangeModel, '').catch(e => {
40
40
  logger.error(`[ServerRpc] error sending onDidChangeModel: ${e}`)
41
41
  return Promise.resolve()
42
- }),
42
+ })
43
+ },
43
44
  {
44
45
  timing: 'both',
45
- waitMs: 350,
46
- maxWaitMs: 1000
46
+ waitMs: 300,
47
+ maxWaitMs: 600
47
48
  }
48
49
  )
49
50
 
@@ -54,7 +55,10 @@ export class Rpc implements Disposable {
54
55
  notifyModelParsed.cancel()
55
56
  }),
56
57
  modelBuilder.onModelParsed(() => notifyModelParsed.call()),
57
- connection.onRequest(fetchComputedModel, async cancelToken => {
58
+ connection.onRequest(fetchComputedModel, async ({ cleanCaches }, cancelToken) => {
59
+ if (cleanCaches) {
60
+ this.services.WorkspaceCache.clear()
61
+ }
58
62
  const model = await modelBuilder.buildComputedModel(cancelToken)
59
63
  return { model }
60
64
  }),
package/src/ast.ts CHANGED
@@ -288,7 +288,7 @@ export type ChecksFromDiagnostics = ReturnType<typeof checksFromDiagnostics>
288
288
  export type IsValidFn = ChecksFromDiagnostics['isValid']
289
289
 
290
290
  export function* streamModel(doc: LikeC4LangiumDocument, isValid: IsValidFn) {
291
- const traverseStack = doc.parseResult.value.models.flatMap(m => (isValid(m) ? m.elements : []))
291
+ const traverseStack = doc.parseResult.value.models.flatMap(m => m.elements)
292
292
  const relations = [] as ast.Relation[]
293
293
  let el
294
294
  while ((el = traverseStack.shift())) {
package/src/browser.ts CHANGED
@@ -2,6 +2,11 @@ import { startLanguageServer as startLanguim } from 'langium/lsp'
2
2
  import { BrowserMessageReader, BrowserMessageWriter, createConnection } from 'vscode-languageserver/browser'
3
3
  import { createLanguageServices } from './module'
4
4
 
5
+ export { setLogLevel } from './logger'
6
+ export type * from './model'
7
+ export type * from './module'
8
+ export { createCustomLanguageServices, createLanguageServices, LikeC4Module } from './module'
9
+
5
10
  // This is an example copied as is from here:
6
11
  // https://github.com/microsoft/vscode-extension-samples/blob/main/lsp-web-extension-sample/server/src/browserServerMain.ts
7
12
  // the only addition is the following line:
@@ -46,7 +46,9 @@ export class LikeC4Formatter extends AbstractFormatter {
46
46
 
47
47
  protected formatRelation(node: AstNode) {
48
48
  this.on(node, ast.isRelation, (n, f) => {
49
- f.property('source').append(FormattingOptions.oneSpace)
49
+ const sourceNodes = n?.source?.$cstNode ? [n?.source?.$cstNode] : []
50
+
51
+ f.cst(sourceNodes).append(FormattingOptions.oneSpace)
50
52
  f.keywords(']->').prepend(FormattingOptions.noSpace)
51
53
  f.keywords('-[').append(FormattingOptions.noSpace)
52
54
 
@@ -73,7 +75,7 @@ export class LikeC4Formatter extends AbstractFormatter {
73
75
  ?.keywords('->').append(FormattingOptions.oneSpace)
74
76
 
75
77
  this.on(node, ast.isInOutRelationExpression)
76
- ?.property('inout').append(FormattingOptions.oneSpace)
78
+ ?.keyword('->').prepend(FormattingOptions.oneSpace)
77
79
  }
78
80
 
79
81
  protected removeIndentFromTopLevelStatements(node: AstNode) {