dot-language-support 2.2.2 → 2.2.3

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 (89) hide show
  1. package/.github/workflows/CD.yml +4 -1
  2. package/.github/workflows/CI.yml +4 -1
  3. package/.github/workflows/auto-merge.yaml +1 -1
  4. package/biome.json +50 -0
  5. package/lib/cjs/binder.d.ts +1 -1
  6. package/lib/cjs/binder.js +2 -5
  7. package/lib/cjs/checker.d.ts +1 -1
  8. package/lib/cjs/checker.js +34 -30
  9. package/lib/cjs/core.js +2 -3
  10. package/lib/cjs/error.js +3 -5
  11. package/lib/cjs/parser.d.ts +4 -61
  12. package/lib/cjs/parser.js +580 -616
  13. package/lib/cjs/scanner.d.ts +2 -13
  14. package/lib/cjs/scanner.js +316 -317
  15. package/lib/cjs/service/codeAction.d.ts +3 -3
  16. package/lib/cjs/service/codeAction.js +28 -32
  17. package/lib/cjs/service/colorProvider.d.ts +3 -3
  18. package/lib/cjs/service/colorProvider.js +13 -24
  19. package/lib/cjs/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.d.ts +4 -4
  20. package/lib/cjs/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.js +5 -6
  21. package/lib/cjs/service/command/ChangeEdgeOpCommand.d.ts +3 -3
  22. package/lib/cjs/service/command/ChangeEdgeOpCommand.js +5 -8
  23. package/lib/cjs/service/command/ConsolidateDescendantsCommand.d.ts +4 -4
  24. package/lib/cjs/service/command/ConsolidateDescendantsCommand.js +12 -13
  25. package/lib/cjs/service/command/RemoveSemicolons.d.ts +4 -4
  26. package/lib/cjs/service/command/RemoveSemicolons.js +8 -11
  27. package/lib/cjs/service/command/common.d.ts +4 -4
  28. package/lib/cjs/service/command/common.js +12 -10
  29. package/lib/cjs/service/completion.d.ts +2 -2
  30. package/lib/cjs/service/completion.js +17 -18
  31. package/lib/cjs/service/hover.d.ts +2 -2
  32. package/lib/cjs/service/hover.js +12 -16
  33. package/lib/cjs/service/languageFacts.js +1 -6
  34. package/lib/cjs/service/reference.d.ts +2 -2
  35. package/lib/cjs/service/reference.js +4 -8
  36. package/lib/cjs/service/rename.d.ts +3 -3
  37. package/lib/cjs/service/rename.js +10 -8
  38. package/lib/cjs/service/service.d.ts +3 -3
  39. package/lib/cjs/service/service.js +7 -8
  40. package/lib/cjs/service/util.d.ts +1 -1
  41. package/lib/cjs/service/util.js +10 -13
  42. package/lib/cjs/service/validation.d.ts +3 -3
  43. package/lib/cjs/service/validation.js +1 -2
  44. package/lib/cjs/tester.js +1 -1
  45. package/lib/cjs/visitor.d.ts +1 -1
  46. package/lib/cjs/visitor.js +32 -34
  47. package/lib/esm/binder.d.ts +1 -1
  48. package/lib/esm/binder.js +1 -3
  49. package/lib/esm/checker.d.ts +1 -1
  50. package/lib/esm/checker.js +21 -16
  51. package/lib/esm/core.js +1 -1
  52. package/lib/esm/error.js +1 -3
  53. package/lib/esm/parser.d.ts +4 -61
  54. package/lib/esm/parser.js +320 -306
  55. package/lib/esm/scanner.d.ts +2 -13
  56. package/lib/esm/scanner.js +153 -152
  57. package/lib/esm/service/codeAction.d.ts +3 -3
  58. package/lib/esm/service/codeAction.js +26 -29
  59. package/lib/esm/service/colorProvider.d.ts +3 -3
  60. package/lib/esm/service/colorProvider.js +11 -21
  61. package/lib/esm/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.d.ts +4 -4
  62. package/lib/esm/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.js +4 -4
  63. package/lib/esm/service/command/ChangeEdgeOpCommand.d.ts +3 -3
  64. package/lib/esm/service/command/ChangeEdgeOpCommand.js +3 -5
  65. package/lib/esm/service/command/ConsolidateDescendantsCommand.d.ts +4 -4
  66. package/lib/esm/service/command/ConsolidateDescendantsCommand.js +11 -11
  67. package/lib/esm/service/command/RemoveSemicolons.d.ts +4 -4
  68. package/lib/esm/service/command/RemoveSemicolons.js +6 -8
  69. package/lib/esm/service/command/common.d.ts +4 -4
  70. package/lib/esm/service/command/common.js +7 -4
  71. package/lib/esm/service/completion.d.ts +2 -2
  72. package/lib/esm/service/completion.js +16 -16
  73. package/lib/esm/service/hover.d.ts +2 -2
  74. package/lib/esm/service/hover.js +8 -14
  75. package/lib/esm/service/languageFacts.js +1 -6
  76. package/lib/esm/service/reference.d.ts +2 -2
  77. package/lib/esm/service/reference.js +3 -6
  78. package/lib/esm/service/rename.d.ts +3 -3
  79. package/lib/esm/service/rename.js +9 -6
  80. package/lib/esm/service/service.d.ts +3 -3
  81. package/lib/esm/service/service.js +7 -7
  82. package/lib/esm/service/util.d.ts +1 -1
  83. package/lib/esm/service/util.js +5 -7
  84. package/lib/esm/service/validation.d.ts +3 -3
  85. package/lib/esm/service/validation.js +1 -1
  86. package/lib/esm/tester.js +1 -1
  87. package/lib/esm/visitor.d.ts +1 -1
  88. package/lib/esm/visitor.js +32 -33
  89. package/package.json +15 -10
@@ -1,6 +1,6 @@
1
1
  import type * as lst from "vscode-languageserver-types";
2
- import { DocumentLike, SourceFile, CommandApplication } from "../index.js";
3
- import { ExecutableCommand } from "./command/common.js";
2
+ import { type CommandApplication, type DocumentLike, type SourceFile } from "../index.js";
3
+ import { type ExecutableCommand } from "./command/common.js";
4
4
  export declare function getCodeActions(doc: DocumentLike, sourceFile: SourceFile, range: lst.Range, _context?: lst.CodeActionContext): lst.Command[] | undefined;
5
5
  export declare const enum CommandIds {
6
6
  ChangeEdgeOp = "DOT.changeEdgeOp",
@@ -9,4 +9,4 @@ export declare const enum CommandIds {
9
9
  RemoveSemicolons = "DOT.removeSemicolons"
10
10
  }
11
11
  export declare function getAvailableCommands(): string[];
12
- export declare function executeCommand(doc: DocumentLike, sourceFile: SourceFile, cmd: ExecutableCommand): CommandApplication | undefined;
12
+ export declare function executeCommand(doc: DocumentLike, sourceFile: SourceFile, cmd: ExecutableCommand<unknown[]>): CommandApplication | undefined;
@@ -23,15 +23,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.executeCommand = exports.getAvailableCommands = exports.getCodeActions = void 0;
27
- const index_js_1 = require("../index.js");
28
- const util_js_1 = require("./util.js");
26
+ exports.getCodeActions = getCodeActions;
27
+ exports.getAvailableCommands = getAvailableCommands;
28
+ exports.executeCommand = executeCommand;
29
29
  const checker_js_1 = require("../checker.js");
30
- const ChangeEdgeOpCommand = __importStar(require("./command/ChangeEdgeOpCommand.js"));
30
+ const index_js_1 = require("../index.js");
31
31
  const ChangeAllOtherEdgeOpsAndFixGraphCommand = __importStar(require("./command/ChangeAllOtherEdgeOpsAndFixGraphCommand.js"));
32
+ const ChangeEdgeOpCommand = __importStar(require("./command/ChangeEdgeOpCommand.js"));
32
33
  const ConsolidateDescendantsCommand = __importStar(require("./command/ConsolidateDescendantsCommand.js"));
33
34
  const RemoveSemicolonsCommand = __importStar(require("./command/RemoveSemicolons.js"));
34
35
  const common_js_1 = require("./command/common.js");
36
+ const util_js_1 = require("./util.js");
35
37
  function getCodeActions(doc, sourceFile, range, _context) {
36
38
  let actions = getActionsFromDiagnostics(doc, sourceFile, range);
37
39
  const general = getGeneralRefactorings(doc, sourceFile, range);
@@ -43,7 +45,6 @@ function getCodeActions(doc, sourceFile, range, _context) {
43
45
  }
44
46
  return actions;
45
47
  }
46
- exports.getCodeActions = getCodeActions;
47
48
  function getActionsFromDiagnostics(doc, file, range) {
48
49
  const ds = file.diagnostics;
49
50
  if (!ds || ds.length === 0)
@@ -88,10 +89,10 @@ function getGeneralRefactorings(doc, file, range) {
88
89
  }
89
90
  const clickedEdgeStatement = clickedNode.parent;
90
91
  if (clickedEdgeStatement && !subtreeContainsErrors(clickedEdgeStatement)) {
91
- if ((0, checker_js_1.isEdgeStatement)(clickedEdgeStatement)
92
- && clickedEdgeStatement.rhs.length === 1
93
- && (0, checker_js_1.isNodeId)(clickedEdgeStatement.source)
94
- && !(0, checker_js_1.edgeStatementHasAttributes)(clickedEdgeStatement)) {
92
+ if ((0, checker_js_1.isEdgeStatement)(clickedEdgeStatement) &&
93
+ clickedEdgeStatement.rhs.length === 1 &&
94
+ (0, checker_js_1.isNodeId)(clickedEdgeStatement.source) &&
95
+ !(0, checker_js_1.edgeStatementHasAttributes)(clickedEdgeStatement)) {
95
96
  candidates.push(clickedEdgeStatement);
96
97
  const source = clickedEdgeStatement.source;
97
98
  const sourceText = (0, checker_js_1.getIdentifierText)(source.id);
@@ -107,17 +108,17 @@ function getGeneralRefactorings(doc, file, range) {
107
108
  if (hasVisitedNodeModifier) {
108
109
  return;
109
110
  }
110
- else if (hasVisitedStatement) {
111
- if ((0, checker_js_1.isAttrStatement)(statement)
112
- || subtreeContainsErrors(statement)) {
111
+ if (hasVisitedStatement) {
112
+ if ((0, checker_js_1.isAttrStatement)(statement) ||
113
+ subtreeContainsErrors(statement)) {
113
114
  hasVisitedNodeModifier = true;
114
115
  return true;
115
116
  }
116
117
  }
117
118
  if (hasVisitedStatement) {
118
- if ((0, checker_js_1.isEdgeStatement)(statement)
119
- && statement.rhs.length === 1
120
- && !(0, checker_js_1.edgeStatementHasAttributes)(statement)) {
119
+ if ((0, checker_js_1.isEdgeStatement)(statement) &&
120
+ statement.rhs.length === 1 &&
121
+ !(0, checker_js_1.edgeStatementHasAttributes)(statement)) {
121
122
  const statementSource = statement.source;
122
123
  if ((0, checker_js_1.isNodeId)(statementSource)) {
123
124
  const lowerSourceText = (0, checker_js_1.getIdentifierText)(statementSource.id);
@@ -139,14 +140,17 @@ function getGeneralRefactorings(doc, file, range) {
139
140
  }
140
141
  }
141
142
  return res.length === 0 ? undefined : res;
142
- ;
143
143
  }
144
144
  function getCommandsForDiagnostic(doc, file, d) {
145
145
  switch (d.code.source) {
146
- case 1: return getScannerErrorCommand(doc, file, d, d.code);
147
- case 2: return getParserErrorCommand(doc, file, d, d.code);
148
- case 4: return getCheckerErrorCommand(doc, file, d, d.code);
149
- default: return (0, util_js_1.assertNever)(d.code);
146
+ case 1:
147
+ return getScannerErrorCommand(doc, file, d, d.code);
148
+ case 2:
149
+ return getParserErrorCommand(doc, file, d, d.code);
150
+ case 4:
151
+ return getCheckerErrorCommand(doc, file, d, d.code);
152
+ default:
153
+ return (0, util_js_1.assertNever)(d.code);
150
154
  }
151
155
  }
152
156
  function getScannerErrorCommand(_doc, _file, d, code) {
@@ -173,11 +177,7 @@ function getCheckerErrorCommand(_doc, file, d, code) {
173
177
  const fixSingleEdge = ChangeEdgeOpCommand.create(d.start, d.end, allowedOp, wrongOp);
174
178
  const fixAll = convertGraphTypeCommand(file, graph, kwk);
175
179
  const convertToThisWrongType = convertGraphTypeCommand(file, graph, (0, common_js_1.getOppositeKind)(kwk));
176
- return [
177
- fixSingleEdge,
178
- fixAll,
179
- convertToThisWrongType,
180
- ];
180
+ return [fixSingleEdge, fixAll, convertToThisWrongType];
181
181
  }
182
182
  case 1:
183
183
  return undefined;
@@ -190,11 +190,11 @@ function convertGraphTypeCommand(file, graph, changeToGraphType) {
190
190
  .filter(e => e.operation.kind !== changeToEdgeOp)
191
191
  .map(e => ({
192
192
  start: (0, util_js_1.getStart)(file, e.operation),
193
- end: e.operation.end
193
+ end: e.operation.end,
194
194
  }));
195
195
  const graphTypeOffset = {
196
196
  start: (0, util_js_1.getStart)(file, graph.keyword),
197
- end: graph.keyword.end
197
+ end: graph.keyword.end,
198
198
  };
199
199
  return ChangeAllOtherEdgeOpsAndFixGraphCommand.create(edgeOffsets, changeToEdgeOp, graphTypeOffset, graph.keyword.kind, changeToGraphType);
200
200
  }
@@ -214,14 +214,10 @@ const commandHandlers = {
214
214
  function getAvailableCommands() {
215
215
  return Object.keys(commandHandlers);
216
216
  }
217
- exports.getAvailableCommands = getAvailableCommands;
218
217
  function executeCommand(doc, sourceFile, cmd) {
219
218
  const handler = commandHandlers[cmd.command];
220
- return handler === undefined
221
- ? undefined
222
- : handler(doc, sourceFile, cmd);
219
+ return handler === undefined ? undefined : handler(doc, sourceFile, cmd);
223
220
  }
224
- exports.executeCommand = executeCommand;
225
221
  function subtreeContainsErrors(node) {
226
222
  if ((0, checker_js_1.nodeContainsErrors)(node))
227
223
  return true;
@@ -1,5 +1,5 @@
1
- import type { ColorInformation, ColorPresentation, Range, Color } from "vscode-languageserver-types";
2
- import { SourceFile } from "../types.js";
3
- import { DocumentLike } from "../index.js";
1
+ import type { Color, ColorInformation, ColorPresentation, Range } from "vscode-languageserver-types";
2
+ import type { DocumentLike } from "../index.js";
3
+ import type { SourceFile } from "../types.js";
4
4
  export declare function getDocumentColors(doc: DocumentLike, sourceFile: SourceFile): ColorInformation[] | undefined;
5
5
  export declare function getColorRepresentations(_doc: DocumentLike, _sourceFile: SourceFile, color: Color, range: Range): ColorPresentation[] | undefined;
@@ -23,23 +23,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getColorRepresentations = exports.getDocumentColors = void 0;
27
- const util_js_1 = require("./util.js");
26
+ exports.getDocumentColors = getDocumentColors;
27
+ exports.getColorRepresentations = getColorRepresentations;
28
28
  const languageFacts = __importStar(require("./languageFacts.js"));
29
+ const util_js_1 = require("./util.js");
29
30
  const colorMap = languageFacts.colors;
30
31
  function getDocumentColors(doc, sourceFile) {
31
32
  const cs = sourceFile.colors;
32
- return cs
33
- ? colorTableToColorInformation(doc, sourceFile, cs)
34
- : undefined;
33
+ return cs ? colorTableToColorInformation(doc, sourceFile, cs) : undefined;
35
34
  }
36
- exports.getDocumentColors = getDocumentColors;
37
35
  function getColorRepresentations(_doc, _sourceFile, color, range) {
38
- return !color || !range
39
- ? undefined
40
- : [{ label: '"' + getColorStringFromColor(color) + '"', }];
36
+ return !color || !range ? undefined : [{ label: `"${getColorStringFromColor(color)}"` }];
41
37
  }
42
- exports.getColorRepresentations = getColorRepresentations;
43
38
  function colorTableToColorInformation(doc, sf, colors) {
44
39
  if (!colors || colors.size === 0)
45
40
  return [];
@@ -61,32 +56,26 @@ function getColorFromName(name) {
61
56
  if (name.charAt(0) === "#")
62
57
  return getHexCodeColor(name);
63
58
  const colorAlias = colorMap[name.toLowerCase()];
64
- return colorAlias
65
- ? getHexCodeColor(colorAlias)
66
- : undefined;
59
+ return colorAlias ? getHexCodeColor(colorAlias) : undefined;
67
60
  }
68
61
  function getHexCodeColor(colorCode) {
69
- const hexCode = colorCode.charAt(0) === "#"
70
- ? colorCode.substring(1)
71
- : colorCode;
72
- const colorInt = parseInt(hexCode, 16);
62
+ const hexCode = colorCode.charAt(0) === "#" ? colorCode.substring(1) : colorCode;
63
+ const colorInt = Number.parseInt(hexCode, 16);
73
64
  return {
74
- red: (colorInt >> 16 & 0xff) / 255.0,
75
- green: (colorInt >> 8 & 0xff) / 255.0,
65
+ red: ((colorInt >> 16) & 0xff) / 255.0,
66
+ green: ((colorInt >> 8) & 0xff) / 255.0,
76
67
  blue: (colorInt & 0xff) / 255.0,
77
- alpha: hexCode.length === 8 ? (colorInt >> 24 & 0xff) / 255.0 : 1.0,
68
+ alpha: hexCode.length === 8 ? ((colorInt >> 24) & 0xff) / 255.0 : 1.0,
78
69
  };
79
70
  }
80
71
  function getColorStringFromColor(c) {
81
72
  const red = (c.red * 255) | 0;
82
73
  const green = (c.green * 255) | 0;
83
74
  const blue = (c.blue * 255) | 0;
84
- return "#" + numberToPaddedString(red) + numberToPaddedString(green) + numberToPaddedString(blue);
75
+ return `#${numberToPaddedString(red)}${numberToPaddedString(green)}${numberToPaddedString(blue)}`;
85
76
  }
86
77
  function numberToPaddedString(n) {
87
78
  const s = n.toString(16);
88
- return (s.length === 1
89
- ? "0" + s
90
- : s).toLowerCase();
79
+ return (s.length === 1 ? `0${s}` : s).toLowerCase();
91
80
  }
92
81
  //# sourceMappingURL=colorProvider.js.map
@@ -1,10 +1,10 @@
1
- import * as lst from "vscode-languageserver-types";
1
+ import type * as lst from "vscode-languageserver-types";
2
+ import type { CommandApplication, DocumentLike, SourceFile } from "../../index.js";
2
3
  import { CommandIds } from "../codeAction.js";
3
- import { GraphTypeStr, Offset, EdgeOpStr, ExecutableCommand, EdgeType, GraphType } from "./common.js";
4
- import { DocumentLike, SourceFile, CommandApplication } from "../../index.js";
4
+ import { type EdgeOpStr, type EdgeType, type ExecutableCommand, type GraphType, type GraphTypeStr, type Offset } from "./common.js";
5
5
  export interface ChangeAllOtherEdgeOpsAndFixGraphCommand extends lst.Command {
6
6
  command: CommandIds.ConvertGraphType;
7
7
  arguments: [Offset[], EdgeOpStr, Offset, GraphTypeStr];
8
8
  }
9
9
  export declare function create(edgeOffsets: Offset[], changeEdgesTo: EdgeType, graphOffset: Offset, changeFromGraph: GraphType, changeGraphTo: GraphType): ChangeAllOtherEdgeOpsAndFixGraphCommand;
10
- export declare function execute(doc: DocumentLike, _sourceFile: SourceFile, cmd: ExecutableCommand): CommandApplication | undefined;
10
+ export declare function execute(doc: DocumentLike, _sourceFile: SourceFile, cmd: ExecutableCommand<unknown[]>): CommandApplication | undefined;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.execute = exports.create = void 0;
3
+ exports.create = create;
4
+ exports.execute = execute;
4
5
  const common_js_1 = require("./common.js");
5
6
  function create(edgeOffsets, changeEdgesTo, graphOffset, changeFromGraph, changeGraphTo) {
6
7
  const toGraph = (0, common_js_1.getGraphKeywordStr)(changeGraphTo);
@@ -14,7 +15,6 @@ function create(edgeOffsets, changeEdgesTo, graphOffset, changeFromGraph, change
14
15
  arguments: [edgeOffsets, edgeStr, graphOffset, toGraph],
15
16
  };
16
17
  }
17
- exports.create = create;
18
18
  function execute(doc, _sourceFile, cmd) {
19
19
  if (!isChangeAllOtherEdgeOpsAndFixGraphCommand(cmd))
20
20
  return undefined;
@@ -32,12 +32,11 @@ function execute(doc, _sourceFile, cmd) {
32
32
  edit: {
33
33
  changes: {
34
34
  [doc.uri]: edits,
35
- }
36
- }
35
+ },
36
+ },
37
37
  };
38
38
  }
39
- exports.execute = execute;
40
39
  function isChangeAllOtherEdgeOpsAndFixGraphCommand(cmd) {
41
- return cmd.command === "DOT.convertGraphType" && !!cmd.arguments && cmd.arguments.length === 4;
40
+ return (cmd.command === "DOT.convertGraphType" && !!cmd.arguments && cmd.arguments.length === 4);
42
41
  }
43
42
  //# sourceMappingURL=ChangeAllOtherEdgeOpsAndFixGraphCommand.js.map
@@ -1,10 +1,10 @@
1
1
  import * as lst from "vscode-languageserver-types";
2
+ import type { CommandApplication, DocumentLike, SourceFile } from "../../index.js";
2
3
  import { CommandIds } from "../codeAction.js";
3
- import { EdgeOpStr, ExecutableCommand, EdgeType } from "./common.js";
4
- import { DocumentLike, SourceFile, CommandApplication } from "../../index.js";
4
+ import { type EdgeOpStr, type EdgeType, type ExecutableCommand } from "./common.js";
5
5
  export interface ChangeEdgeOpCommand extends lst.Command {
6
6
  command: CommandIds.ChangeEdgeOp;
7
7
  arguments: [number, number, EdgeOpStr];
8
8
  }
9
9
  export declare function create(startOffset: number, endOffset: number, changeTo: EdgeType, changeFrom: EdgeType): ChangeEdgeOpCommand;
10
- export declare function execute(doc: DocumentLike, _sourceFile: SourceFile, cmd: ExecutableCommand): CommandApplication | undefined;
10
+ export declare function execute(doc: DocumentLike, _sourceFile: SourceFile, cmd: ExecutableCommand<unknown[]>): CommandApplication | undefined;
@@ -23,7 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.execute = exports.create = void 0;
26
+ exports.create = create;
27
+ exports.execute = execute;
27
28
  const lst = __importStar(require("vscode-languageserver-types"));
28
29
  const common_js_1 = require("./common.js");
29
30
  function create(startOffset, endOffset, changeTo, changeFrom) {
@@ -35,7 +36,6 @@ function create(startOffset, endOffset, changeTo, changeFrom) {
35
36
  arguments: [startOffset, endOffset, to],
36
37
  };
37
38
  }
38
- exports.create = create;
39
39
  function execute(doc, _sourceFile, cmd) {
40
40
  if (!isChangeEdgeOpCommand(cmd))
41
41
  return undefined;
@@ -46,14 +46,11 @@ function execute(doc, _sourceFile, cmd) {
46
46
  label: `Change of invalid edge to "${changeTo}"'"`,
47
47
  edit: {
48
48
  changes: {
49
- [doc.uri]: [
50
- lst.TextEdit.replace(lst.Range.create(startPos, endPos), changeTo),
51
- ],
52
- }
53
- }
49
+ [doc.uri]: [lst.TextEdit.replace(lst.Range.create(startPos, endPos), changeTo)],
50
+ },
51
+ },
54
52
  };
55
53
  }
56
- exports.execute = execute;
57
54
  function isChangeEdgeOpCommand(cmd) {
58
55
  return cmd.command === "DOT.changeEdgeOp" && !!cmd.arguments && cmd.arguments.length === 3;
59
56
  }
@@ -1,10 +1,10 @@
1
- import * as lst from "vscode-languageserver-types";
1
+ import type * as lst from "vscode-languageserver-types";
2
+ import type { CommandApplication, DocumentLike, EdgeStatement, SourceFile } from "../../index.js";
2
3
  import { CommandIds } from "../codeAction.js";
3
- import { ExecutableCommand } from "./common.js";
4
- import { DocumentLike, SourceFile, CommandApplication, EdgeStatement } from "../../index.js";
4
+ import type { ExecutableCommand } from "./common.js";
5
5
  export interface ConsolidateDescendantsCommand extends lst.Command {
6
6
  command: CommandIds.ConsolidateDescendants;
7
7
  arguments: number[];
8
8
  }
9
9
  export declare function create(statements: EdgeStatement[], below: boolean): ConsolidateDescendantsCommand;
10
- export declare function execute(doc: DocumentLike, sourceFile: SourceFile, cmd: ExecutableCommand): CommandApplication | undefined;
10
+ export declare function execute(doc: DocumentLike, sourceFile: SourceFile, cmd: ExecutableCommand<unknown[]>): CommandApplication | undefined;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.execute = exports.create = void 0;
3
+ exports.create = create;
4
+ exports.execute = execute;
4
5
  const checker_js_1 = require("../../checker.js");
5
6
  const util_js_1 = require("../util.js");
6
7
  function create(statements, below) {
@@ -15,7 +16,6 @@ function create(statements, below) {
15
16
  arguments: statements.map(s => s.pos),
16
17
  };
17
18
  }
18
- exports.create = create;
19
19
  function execute(doc, sourceFile, cmd) {
20
20
  if (!isConsolidateDescendantsCommand(cmd))
21
21
  return undefined;
@@ -30,9 +30,7 @@ function execute(doc, sourceFile, cmd) {
30
30
  const firstRight = first.rhs[0];
31
31
  const firstRightTargetStart = (0, util_js_1.getStart)(sourceFile, firstRight.target);
32
32
  const firstRightTargetEnd = firstRight.target.end;
33
- const contents = [
34
- sourceFile.content.substring(firstRightTargetStart, firstRightTargetEnd)
35
- ];
33
+ const contents = [sourceFile.content.substring(firstRightTargetStart, firstRightTargetEnd)];
36
34
  for (const descendant of candidates) {
37
35
  const rightItem = descendant.rhs[0];
38
36
  const rightItemTarget = rightItem.target;
@@ -44,14 +42,14 @@ function execute(doc, sourceFile, cmd) {
44
42
  range: {
45
43
  start: doc.positionAt(descendant.pos),
46
44
  end: doc.positionAt(rightItemTargetStart),
47
- }
45
+ },
48
46
  });
49
47
  edits.push({
50
48
  newText: "",
51
49
  range: {
52
50
  start: doc.positionAt(rightItemTargetStart),
53
51
  end: doc.positionAt(rightItemTargetEnd),
54
- }
52
+ },
55
53
  });
56
54
  if (descendant.terminator !== undefined) {
57
55
  edits.push({
@@ -59,7 +57,7 @@ function execute(doc, sourceFile, cmd) {
59
57
  range: {
60
58
  start: doc.positionAt((0, util_js_1.getStart)(sourceFile, descendant.terminator)),
61
59
  end: doc.positionAt(descendant.terminator.end),
62
- }
60
+ },
63
61
  });
64
62
  }
65
63
  contents.push(rightItemContent);
@@ -70,19 +68,20 @@ function execute(doc, sourceFile, cmd) {
70
68
  range: {
71
69
  start: doc.positionAt(firstRightTargetStart),
72
70
  end: doc.positionAt(firstRightTargetEnd),
73
- }
71
+ },
74
72
  });
75
73
  return {
76
74
  label: `Convert edges from "${from}" to subgraph.`,
77
75
  edit: {
78
76
  changes: {
79
77
  [doc.uri]: edits,
80
- }
81
- }
78
+ },
79
+ },
82
80
  };
83
81
  }
84
- exports.execute = execute;
85
82
  function isConsolidateDescendantsCommand(cmd) {
86
- return cmd.command === "DOT.consolidateDescendants" && !!cmd.arguments && cmd.arguments.length > 1;
83
+ return (cmd.command === "DOT.consolidateDescendants" &&
84
+ !!cmd.arguments &&
85
+ cmd.arguments.length > 1);
87
86
  }
88
87
  //# sourceMappingURL=ConsolidateDescendantsCommand.js.map
@@ -1,10 +1,10 @@
1
- import * as lst from "vscode-languageserver-types";
1
+ import type * as lst from "vscode-languageserver-types";
2
+ import type { CommandApplication, DocumentLike, SourceFile } from "../../index.js";
2
3
  import { CommandIds } from "../codeAction.js";
3
- import { ExecutableCommand } from "./common.js";
4
- import { DocumentLike, SourceFile, CommandApplication } from "../../index.js";
4
+ import { type ExecutableCommand } from "./common.js";
5
5
  export interface RemoveSemicolonsCommand extends lst.Command {
6
6
  command: CommandIds.RemoveSemicolons;
7
7
  arguments: undefined;
8
8
  }
9
9
  export declare function create(): RemoveSemicolonsCommand;
10
- export declare function execute(doc: DocumentLike, sourceFile: SourceFile, cmd: ExecutableCommand): CommandApplication | undefined;
10
+ export declare function execute(doc: DocumentLike, sourceFile: SourceFile, cmd: ExecutableCommand<unknown[]>): CommandApplication | undefined;
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.execute = exports.create = void 0;
4
- const common_js_1 = require("./common.js");
3
+ exports.create = create;
4
+ exports.execute = execute;
5
5
  const checker_js_1 = require("../../checker.js");
6
+ const common_js_1 = require("./common.js");
6
7
  function create() {
7
8
  return {
8
9
  title: "Remove optional semicolons",
@@ -10,7 +11,6 @@ function create() {
10
11
  arguments: undefined,
11
12
  };
12
13
  }
13
- exports.create = create;
14
14
  function execute(doc, sourceFile, cmd) {
15
15
  if (!isRemoveSemicolonsCommand(cmd))
16
16
  return undefined;
@@ -24,19 +24,16 @@ function execute(doc, sourceFile, cmd) {
24
24
  return (0, common_js_1.createChangeToEdit)(doc.positionAt(start), doc.positionAt(end), "");
25
25
  });
26
26
  return {
27
- label: `Remove optional semicolons`,
27
+ label: "Remove optional semicolons",
28
28
  edit: {
29
29
  changes: {
30
30
  [doc.uri]: edits,
31
- }
32
- }
31
+ },
32
+ },
33
33
  };
34
34
  }
35
- exports.execute = execute;
36
35
  function isRemoveSemicolonsCommand(cmd) {
37
- return cmd.command === "DOT.removeSemicolons"
38
- && (!cmd.arguments
39
- || cmd.arguments.length === 0
40
- || cmd.arguments.every(e => e === undefined));
36
+ return (cmd.command === "DOT.removeSemicolons" &&
37
+ (!cmd.arguments || cmd.arguments.length === 0 || cmd.arguments.every(e => e === undefined)));
41
38
  }
42
39
  //# sourceMappingURL=RemoveSemicolons.js.map
@@ -1,14 +1,14 @@
1
- import { TextEdit, type Position } from "vscode-languageserver-types";
1
+ import { type Position, TextEdit } from "vscode-languageserver-types";
2
2
  import { SyntaxKind } from "../../index.js";
3
- import { CommandIds } from "../codeAction.js";
3
+ import type { CommandIds } from "../codeAction.js";
4
4
  export declare function createChangeToEdit(start: Position, end: Position, changeTo: string): TextEdit;
5
5
  export interface Offset {
6
6
  start: number;
7
7
  end: number;
8
8
  }
9
- export type ExecutableCommand = {
9
+ export type ExecutableCommand<TArgs> = {
10
10
  command: CommandIds;
11
- arguments?: any[];
11
+ arguments?: TArgs;
12
12
  };
13
13
  export type EdgeOpStr = "--" | "->";
14
14
  export declare function getEdgeStr(op: SyntaxKind.UndirectedEdgeOp): "--";
@@ -1,31 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAllowedOp = exports.getOppositeEdgeOp = exports.getOppositeKind = exports.getGraphKeywordStr = exports.getEdgeStr = exports.createChangeToEdit = void 0;
3
+ exports.createChangeToEdit = createChangeToEdit;
4
+ exports.getEdgeStr = getEdgeStr;
5
+ exports.getGraphKeywordStr = getGraphKeywordStr;
6
+ exports.getOppositeKind = getOppositeKind;
7
+ exports.getOppositeEdgeOp = getOppositeEdgeOp;
8
+ exports.getAllowedOp = getAllowedOp;
4
9
  const vscode_languageserver_types_1 = require("vscode-languageserver-types");
5
10
  const index_js_1 = require("../../index.js");
6
11
  function createChangeToEdit(start, end, changeTo) {
7
12
  return vscode_languageserver_types_1.TextEdit.replace(vscode_languageserver_types_1.Range.create(start, end), changeTo);
8
13
  }
9
- exports.createChangeToEdit = createChangeToEdit;
10
- ;
11
14
  function getEdgeStr(op) {
12
15
  return op === index_js_1.SyntaxKind.DirectedEdgeOp ? "->" : "--";
13
16
  }
14
- exports.getEdgeStr = getEdgeStr;
15
17
  function getGraphKeywordStr(g) {
16
18
  return g === index_js_1.SyntaxKind.DigraphKeyword ? "digraph" : "graph";
17
19
  }
18
- exports.getGraphKeywordStr = getGraphKeywordStr;
19
20
  function getOppositeKind(g) {
20
21
  return g === index_js_1.SyntaxKind.DigraphKeyword ? index_js_1.SyntaxKind.GraphKeyword : index_js_1.SyntaxKind.DigraphKeyword;
21
22
  }
22
- exports.getOppositeKind = getOppositeKind;
23
23
  function getOppositeEdgeOp(g) {
24
- return g === index_js_1.SyntaxKind.DirectedEdgeOp ? index_js_1.SyntaxKind.UndirectedEdgeOp : index_js_1.SyntaxKind.DirectedEdgeOp;
24
+ return g === index_js_1.SyntaxKind.DirectedEdgeOp
25
+ ? index_js_1.SyntaxKind.UndirectedEdgeOp
26
+ : index_js_1.SyntaxKind.DirectedEdgeOp;
25
27
  }
26
- exports.getOppositeEdgeOp = getOppositeEdgeOp;
27
28
  function getAllowedOp(g) {
28
- return g === index_js_1.SyntaxKind.DigraphKeyword ? index_js_1.SyntaxKind.DirectedEdgeOp : index_js_1.SyntaxKind.UndirectedEdgeOp;
29
+ return g === index_js_1.SyntaxKind.DigraphKeyword
30
+ ? index_js_1.SyntaxKind.DirectedEdgeOp
31
+ : index_js_1.SyntaxKind.UndirectedEdgeOp;
29
32
  }
30
- exports.getAllowedOp = getAllowedOp;
31
33
  //# sourceMappingURL=common.js.map
@@ -1,4 +1,4 @@
1
1
  import * as lst from "vscode-languageserver-types";
2
- import { SourceFile } from "../types.js";
3
- import { DocumentLike } from "../index.js";
2
+ import { type DocumentLike } from "../index.js";
3
+ import { type SourceFile } from "../types.js";
4
4
  export declare function getCompletions(doc: DocumentLike, sourceFile: SourceFile, position: lst.Position): lst.CompletionItem[];
@@ -23,13 +23,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getCompletions = void 0;
26
+ exports.getCompletions = getCompletions;
27
27
  const lst = __importStar(require("vscode-languageserver-types"));
28
- const types_js_1 = require("../types.js");
29
28
  const checker_js_1 = require("../checker.js");
30
- const util_js_1 = require("./util.js");
31
29
  const index_js_1 = require("../index.js");
30
+ const types_js_1 = require("../types.js");
32
31
  const languageFacts = __importStar(require("./languageFacts.js"));
32
+ const util_js_1 = require("./util.js");
33
33
  function getCompletions(doc, sourceFile, position) {
34
34
  const symbols = sourceFile.symbols;
35
35
  if (!symbols)
@@ -44,8 +44,8 @@ function getCompletions(doc, sourceFile, position) {
44
44
  const prevOffsetNode = (0, checker_js_1.findNodeAtOffset)(g, offset - 1, true);
45
45
  const parent = node.parent;
46
46
  const prevOffsetNodeParent = prevOffsetNode === null || prevOffsetNode === void 0 ? void 0 : prevOffsetNode.parent;
47
- if (((parent === null || parent === void 0 ? void 0 : parent.parent) && (0, checker_js_1.isEdgeStatement)(parent.parent))
48
- || ((prevOffsetNodeParent === null || prevOffsetNodeParent === void 0 ? void 0 : prevOffsetNodeParent.parent) && (0, checker_js_1.isEdgeStatement)(prevOffsetNodeParent.parent))) {
47
+ if (((parent === null || parent === void 0 ? void 0 : parent.parent) && (0, checker_js_1.isEdgeStatement)(parent.parent)) ||
48
+ ((prevOffsetNodeParent === null || prevOffsetNodeParent === void 0 ? void 0 : prevOffsetNodeParent.parent) && (0, checker_js_1.isEdgeStatement)(prevOffsetNodeParent.parent))) {
49
49
  return getNodeCompletions(symbols);
50
50
  }
51
51
  if (node.kind === types_js_1.SyntaxKind.AttributeContainer) {
@@ -58,13 +58,11 @@ function getCompletions(doc, sourceFile, position) {
58
58
  }
59
59
  }
60
60
  if (node.kind === types_js_1.SyntaxKind.TextIdentifier && (parent === null || parent === void 0 ? void 0 : parent.kind) === types_js_1.SyntaxKind.NodeId) {
61
- const exclusions = node.symbol
62
- ? [node.symbol.name]
63
- : undefined;
61
+ const exclusions = node.symbol ? [node.symbol.name] : undefined;
64
62
  return getNodeCompletions(symbols, exclusions);
65
63
  }
66
- if (node.kind === types_js_1.SyntaxKind.AttributeContainer
67
- || (node.kind == types_js_1.SyntaxKind.CommaToken && (parent === null || parent === void 0 ? void 0 : parent.kind) === types_js_1.SyntaxKind.Assignment)) {
64
+ if (node.kind === types_js_1.SyntaxKind.AttributeContainer ||
65
+ (node.kind === types_js_1.SyntaxKind.CommaToken && (parent === null || parent === void 0 ? void 0 : parent.kind) === types_js_1.SyntaxKind.Assignment)) {
68
66
  return getAttributeCompletions(position);
69
67
  }
70
68
  const prevNode = (0, checker_js_1.findNodeAtOffset)(g, node.pos - 1, true);
@@ -83,7 +81,7 @@ function getCompletions(doc, sourceFile, position) {
83
81
  }
84
82
  }
85
83
  }
86
- if ((node.flags & 2) || node.end === node.pos) {
84
+ if (node.flags & 2 || node.end === node.pos) {
87
85
  const attribute = prevNode;
88
86
  if (!attribute)
89
87
  return [];
@@ -96,15 +94,17 @@ function getCompletions(doc, sourceFile, position) {
96
94
  }
97
95
  return [];
98
96
  }
99
- exports.getCompletions = getCompletions;
100
97
  function getAssignmentCompletion(assignment) {
101
98
  const property = (0, checker_js_1.getIdentifierText)(assignment.leftId);
102
99
  if (!property)
103
100
  return [];
104
101
  switch (property.toLowerCase()) {
105
- case "shape": return getShapeCompletions();
106
- case "color": return getColorCompletions();
107
- default: return [];
102
+ case "shape":
103
+ return getShapeCompletions();
104
+ case "color":
105
+ return getColorCompletions();
106
+ default:
107
+ return [];
108
108
  }
109
109
  }
110
110
  function getShapeCompletions() {
@@ -117,8 +117,7 @@ function getShapeCompletions() {
117
117
  function getColorCompletions() {
118
118
  const kind = lst.CompletionItemKind.Color;
119
119
  const colors = languageFacts.colors;
120
- return Object.keys(colors)
121
- .map(label => ({
120
+ return Object.keys(colors).map(label => ({
122
121
  kind,
123
122
  label,
124
123
  documentation: colors[label],
@@ -135,7 +134,7 @@ function getAttributeCompletions(posistion) {
135
134
  label,
136
135
  textEdit: {
137
136
  range,
138
- newText: (0, util_js_1.escapeIdentifierText)(label) + "=",
137
+ newText: `${(0, util_js_1.escapeIdentifierText)(label)}=`,
139
138
  },
140
139
  }));
141
140
  }