@likec4/language-server 1.33.0 → 1.34.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.
Files changed (59) hide show
  1. package/README.md +27 -1
  2. package/dist/Rpc.d.ts +2 -0
  3. package/dist/Rpc.js +24 -6
  4. package/dist/bundled.mjs +2747 -2892
  5. package/dist/formatting/LikeC4Formatter.d.ts +1 -0
  6. package/dist/formatting/LikeC4Formatter.js +25 -1
  7. package/dist/generated/ast.d.ts +1 -1
  8. package/dist/generated/ast.js +5 -5
  9. package/dist/generated/grammar.js +1 -1
  10. package/dist/index.d.ts +0 -1
  11. package/dist/index.js +1 -2
  12. package/dist/mcp/{LikeC4MCPServerFactory.d.ts → NoopLikeC4MCPServer.d.ts} +1 -9
  13. package/dist/mcp/interfaces.d.ts +11 -0
  14. package/dist/mcp/interfaces.js +0 -0
  15. package/dist/mcp/sseserver/MCPServer.d.ts +1 -1
  16. package/dist/mcp/sseserver/MCPServer.js +5 -5
  17. package/dist/mcp/sseserver/MCPServerFactory.js +30 -58
  18. package/dist/mcp/sseserver/{with-mcp-server.d.ts → WithMCPServer.d.ts} +1 -1
  19. package/dist/mcp/tools/_common.d.ts +68 -0
  20. package/dist/mcp/tools/_common.js +14 -0
  21. package/dist/mcp/tools/list-projects.d.ts +6 -0
  22. package/dist/mcp/tools/list-projects.js +31 -0
  23. package/dist/mcp/tools/open-view.d.ts +10 -0
  24. package/dist/mcp/tools/open-view.js +29 -0
  25. package/dist/mcp/tools/read-element.d.ts +10 -0
  26. package/dist/mcp/tools/read-element.js +135 -0
  27. package/dist/mcp/tools/read-project-elements.d.ts +8 -0
  28. package/dist/mcp/tools/read-project-elements.js +93 -0
  29. package/dist/mcp/tools/read-project-summary.d.ts +8 -0
  30. package/dist/mcp/tools/read-project-summary.js +68 -0
  31. package/dist/mcp/tools/read-view.d.ts +10 -0
  32. package/dist/mcp/tools/read-view.js +164 -0
  33. package/dist/mcp/tools/search-element.d.ts +8 -0
  34. package/dist/mcp/tools/search-element.js +105 -0
  35. package/dist/mcp/utils.d.ts +17 -34
  36. package/dist/mcp/utils.js +41 -101
  37. package/dist/model/model-parser-where.d.ts +1 -0
  38. package/dist/model/model-parser-where.js +30 -24
  39. package/dist/model/model-parser.d.ts +14 -0
  40. package/dist/model/parser/DeploymentModelParser.d.ts +3 -1
  41. package/dist/model/parser/DeploymentViewParser.d.ts +3 -1
  42. package/dist/model/parser/FqnRefParser.d.ts +3 -1
  43. package/dist/model/parser/FqnRefParser.js +34 -10
  44. package/dist/model/parser/GlobalsParser.d.ts +3 -1
  45. package/dist/model/parser/ModelParser.d.ts +3 -1
  46. package/dist/model/parser/PredicatesParser.d.ts +3 -1
  47. package/dist/model/parser/ViewsParser.d.ts +3 -1
  48. package/dist/module.d.ts +1 -3
  49. package/dist/module.js +1 -6
  50. package/dist/protocol.d.ts +16 -0
  51. package/dist/protocol.js +4 -0
  52. package/dist/validation/property-checks.js +1 -1
  53. package/dist/views/likec4-views.d.ts +5 -0
  54. package/dist/views/likec4-views.js +6 -0
  55. package/package.json +7 -7
  56. package/dist/mcp/LikeC4MCPTools.d.ts +0 -96
  57. package/dist/mcp/LikeC4MCPTools.js +0 -293
  58. /package/dist/mcp/{LikeC4MCPServerFactory.js → NoopLikeC4MCPServer.js} +0 -0
  59. /package/dist/mcp/sseserver/{with-mcp-server.js → WithMCPServer.js} +0 -0
@@ -52,6 +52,7 @@ export declare class LikeC4Formatter extends AbstractFormatter {
52
52
  private doExtendedFormatting;
53
53
  protected normalizeQuotes(node: AstNode): void;
54
54
  private quotesNormalizerFactory;
55
+ private escapeQuotesInternalQuotes;
55
56
  private getAutoQuoteStyle;
56
57
  private onConfigurationUpdate;
57
58
  }
@@ -429,11 +429,35 @@ export class LikeC4Formatter extends AbstractFormatter {
429
429
  const quotesToInsert = quoteStyle === "single" ? "'" : '"';
430
430
  const newEdits = command.region.nodes.map((node) => ({
431
431
  range: node.range,
432
- newText: node.text.replaceAll(quotesToReplace, quotesToInsert)
432
+ newText: quotesToInsert + this.escapeQuotesInternalQuotes(
433
+ node.text.slice(1, -1),
434
+ quotesToReplace,
435
+ quotesToInsert
436
+ ) + quotesToInsert
433
437
  }));
434
438
  edits.push(...newEdits);
435
439
  };
436
440
  }
441
+ escapeQuotesInternalQuotes(text, quotesToReplace, quoteToInsert) {
442
+ let result = "";
443
+ let start = 0;
444
+ while (start >= 0) {
445
+ let pos = text.indexOf(quoteToInsert, start);
446
+ if (pos < 0) {
447
+ result += text.slice(start);
448
+ break;
449
+ }
450
+ result += text.slice(start, pos);
451
+ start = pos + 1;
452
+ let escaped = false;
453
+ while (pos > 0 && text[pos - 1] == "\\") {
454
+ escaped = !escaped;
455
+ pos--;
456
+ }
457
+ result += escaped ? quoteToInsert : `\\${quoteToInsert}`;
458
+ }
459
+ return result;
460
+ }
437
461
  getAutoQuoteStyle(commands) {
438
462
  const nodes = commands.flatMap((x) => x.region.nodes);
439
463
  const doubleQuotesCount = nodes.filter((x) => x.text[0] == '"').length;
@@ -24,8 +24,8 @@ export declare const LikeC4Terminals: {
24
24
  String: RegExp;
25
25
  Float: RegExp;
26
26
  Number: RegExp;
27
- Hex: RegExp;
28
27
  IdTerminal: RegExp;
28
+ Hex: RegExp;
29
29
  };
30
30
  export type LikeC4TerminalNames = keyof typeof LikeC4Terminals;
31
31
  export type LikeC4KeywordNames = "(" | ")" | "*" | "," | "->" | "-[" | ":" | ";" | "<-" | "<->" | "BottomTop" | "LeftRight" | "RightLeft" | "TopBottom" | "]->" | "amber" | "and" | "autoLayout" | "blue" | "border" | "browser" | "color" | "crow" | "cylinder" | "dashed" | "deployment" | "deploymentNode" | "description" | "diamond" | "dot" | "dotted" | "dynamic" | "dynamicPredicateGroup" | "element" | "element.kind" | "element.tag" | "exclude" | "extend" | "extends" | "from" | "global" | "gray" | "green" | "group" | "head" | "icon" | "icons" | "import" | "include" | "indigo" | "instance" | "instanceOf" | "is" | "kind" | "large" | "lg" | "likec4lib" | "line" | "link" | "md" | "medium" | "metadata" | "mobile" | "model" | "multiple" | "muted" | "navigateTo" | "node" | "none" | "normal" | "not" | "notation" | "notes" | "odiamond" | "odot" | "of" | "onormal" | "opacity" | "open" | "or" | "padding" | "par" | "parallel" | "person" | "predicate" | "predicateGroup" | "primary" | "queue" | "rectangle" | "red" | "relationship" | "rgb" | "rgba" | "secondary" | "shape" | "size" | "sky" | "slate" | "sm" | "small" | "solid" | "source" | "specification" | "storage" | "style" | "styleGroup" | "tag" | "tail" | "target" | "technology" | "textSize" | "title" | "vee" | "view" | "views" | "where" | "with" | "xl" | "xlarge" | "xs" | "xsmall" | "{" | "}";
@@ -4,7 +4,7 @@ export const LikeC4Terminals = {
4
4
  LINE_COMMENT: /\/\/[^\n\r]*/,
5
5
  WS: /[\t ]+/,
6
6
  NL: /[\r\n]+/,
7
- BOOLEAN: /true|false/,
7
+ BOOLEAN: /\b(true|false)\b/,
8
8
  LIB_ICON: /(aws|azure|gcp|tech):[-\w]*/,
9
9
  URI_WITH_SCHEMA: /\w+:\/{2}\S+/,
10
10
  URI_RELATIVE: /\.{0,2}\/[^\/]\S+/,
@@ -20,8 +20,8 @@ export const LikeC4Terminals = {
20
20
  String: /"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/,
21
21
  Float: /\b\d+\.\d+\b/,
22
22
  Number: /\b\d+\b/,
23
- Hex: /\b[a-fA-F0-9]{3,}\b/,
24
- IdTerminal: /[_]*[a-zA-Z][-\w]*/
23
+ IdTerminal: /[_]*[a-zA-Z][-\w]*/,
24
+ Hex: /[a-fA-F0-9]{3,}(?![-_g-zG-Z])/
25
25
  };
26
26
  export function isArrowType(item) {
27
27
  return item === "none" || item === "normal" || item === "onormal" || item === "dot" || item === "odot" || item === "diamond" || item === "odiamond" || item === "crow" || item === "open" || item === "vee";
@@ -34,7 +34,7 @@ export function isColorLiteral(item) {
34
34
  return reflection.isInstance(item, ColorLiteral);
35
35
  }
36
36
  export function isCustomColorId(item) {
37
- return isElementShape(item) || isArrowType(item) || isLineOptions(item) || item === "element" || item === "model" || typeof item === "string" && (/\b[a-fA-F0-9]{3,}\b/.test(item) || /[_]*[a-zA-Z][-\w]*/.test(item));
37
+ return isElementShape(item) || isArrowType(item) || isLineOptions(item) || item === "element" || item === "model" || typeof item === "string" && /[_]*[a-zA-Z][-\w]*/.test(item);
38
38
  }
39
39
  export const DeploymentElement = "DeploymentElement";
40
40
  export function isDeploymentElement(item) {
@@ -87,7 +87,7 @@ export function isIconId(item) {
87
87
  return typeof item === "string" && /(aws|azure|gcp|tech):[-\w]*/.test(item);
88
88
  }
89
89
  export function isId(item) {
90
- return isElementShape(item) || isThemeColor(item) || isArrowType(item) || isLineOptions(item) || isParticipant(item) || isSizeValue(item) || item === "element" || item === "model" || item === "group" || item === "node" || item === "deployment" || item === "instance" || typeof item === "string" && (/\b[a-fA-F0-9]{3,}\b/.test(item) || /[_]*[a-zA-Z][-\w]*/.test(item));
90
+ return isElementShape(item) || isThemeColor(item) || isArrowType(item) || isLineOptions(item) || isParticipant(item) || isSizeValue(item) || item === "element" || item === "model" || item === "group" || item === "node" || item === "deployment" || item === "instance" || typeof item === "string" && /[_]*[a-zA-Z][-\w]*/.test(item);
91
91
  }
92
92
  export const LikeC4View = "LikeC4View";
93
93
  export function isLikeC4View(item) {