dot-language-support 1.6.2 → 2.0.2

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 (112) hide show
  1. package/.github/workflows/CD.yml +3 -3
  2. package/.github/workflows/CI.yml +2 -2
  3. package/README.md +5 -4
  4. package/jest.config.mjs +19 -0
  5. package/lib/{binder.d.ts → cjs/binder.d.ts} +1 -1
  6. package/lib/{binder.js → cjs/binder.js} +34 -34
  7. package/lib/{checker.d.ts → cjs/checker.d.ts} +1 -1
  8. package/lib/{checker.js → cjs/checker.js} +28 -28
  9. package/lib/{core.d.ts → cjs/core.d.ts} +0 -0
  10. package/lib/{core.js → cjs/core.js} +0 -0
  11. package/lib/{error.d.ts → cjs/error.d.ts} +1 -1
  12. package/lib/{error.js → cjs/error.js} +0 -0
  13. package/lib/cjs/index.d.ts +5 -0
  14. package/lib/{index.js → cjs/index.js} +5 -5
  15. package/lib/{parser.d.ts → cjs/parser.d.ts} +2 -2
  16. package/lib/{parser.js → cjs/parser.js} +14 -12
  17. package/lib/{scanner.d.ts → cjs/scanner.d.ts} +1 -1
  18. package/lib/{scanner.js → cjs/scanner.js} +67 -67
  19. package/lib/{service → cjs/service}/codeAction.d.ts +3 -3
  20. package/lib/cjs/service/codeAction.js +237 -0
  21. package/lib/cjs/service/colorProvider.d.ts +5 -0
  22. package/lib/cjs/service/colorProvider.js +92 -0
  23. package/lib/{service → cjs/service}/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.d.ts +4 -4
  24. package/lib/{service → cjs/service}/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.js +7 -7
  25. package/lib/{service → cjs/service}/command/ChangeEdgeOpCommand.d.ts +4 -4
  26. package/lib/cjs/service/command/ChangeEdgeOpCommand.js +60 -0
  27. package/lib/{service → cjs/service}/command/ConsolidateDescendantsCommand.d.ts +3 -3
  28. package/lib/{service → cjs/service}/command/ConsolidateDescendantsCommand.js +7 -25
  29. package/lib/{service → cjs/service}/command/RemoveSemicolons.d.ts +3 -3
  30. package/lib/{service → cjs/service}/command/RemoveSemicolons.js +4 -4
  31. package/lib/{service → cjs/service}/command/common.d.ts +4 -4
  32. package/lib/cjs/service/command/common.js +31 -0
  33. package/lib/{service → cjs/service}/completion.d.ts +2 -2
  34. package/lib/{service → cjs/service}/completion.js +49 -26
  35. package/lib/{service → cjs/service}/hover.d.ts +2 -2
  36. package/lib/{service → cjs/service}/hover.js +38 -38
  37. package/lib/{service → cjs/service}/languageFacts.d.ts +0 -0
  38. package/lib/{service → cjs/service}/languageFacts.js +0 -0
  39. package/lib/{service → cjs/service}/reference.d.ts +2 -2
  40. package/lib/{service → cjs/service}/reference.js +9 -11
  41. package/lib/{service → cjs/service}/rename.d.ts +2 -2
  42. package/lib/{service → cjs/service}/rename.js +11 -11
  43. package/lib/{service → cjs/service}/service.d.ts +2 -2
  44. package/lib/cjs/service/service.js +39 -0
  45. package/lib/cjs/service/util.d.ts +11 -0
  46. package/lib/{service → cjs/service}/util.js +7 -7
  47. package/lib/{service → cjs/service}/validation.d.ts +2 -2
  48. package/lib/{service → cjs/service}/validation.js +3 -3
  49. package/lib/cjs/tester.d.ts +1 -0
  50. package/lib/cjs/tester.js +23 -0
  51. package/lib/{types.d.ts → cjs/types.d.ts} +0 -0
  52. package/lib/{types.js → cjs/types.js} +0 -0
  53. package/lib/{visitor.d.ts → cjs/visitor.d.ts} +1 -1
  54. package/lib/{visitor.js → cjs/visitor.js} +17 -17
  55. package/lib/esm/binder.d.ts +2 -0
  56. package/lib/esm/binder.js +296 -0
  57. package/lib/esm/checker.d.ts +14 -0
  58. package/lib/esm/checker.js +169 -0
  59. package/lib/esm/core.d.ts +1 -0
  60. package/lib/esm/core.js +10 -0
  61. package/lib/esm/error.d.ts +3 -0
  62. package/lib/esm/error.js +10 -0
  63. package/lib/esm/index.d.ts +5 -0
  64. package/lib/esm/index.js +6 -0
  65. package/lib/esm/parser.d.ts +84 -0
  66. package/lib/esm/parser.js +700 -0
  67. package/lib/esm/scanner.d.ts +52 -0
  68. package/lib/esm/scanner.js +581 -0
  69. package/lib/esm/service/codeAction.d.ts +12 -0
  70. package/lib/{service → esm/service}/codeAction.js +40 -46
  71. package/lib/esm/service/colorProvider.d.ts +5 -0
  72. package/lib/{service → esm/service}/colorProvider.js +8 -18
  73. package/lib/esm/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.d.ts +10 -0
  74. package/lib/esm/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.js +38 -0
  75. package/lib/esm/service/command/ChangeEdgeOpCommand.d.ts +10 -0
  76. package/lib/{service → esm/service}/command/ChangeEdgeOpCommand.js +6 -11
  77. package/lib/esm/service/command/ConsolidateDescendantsCommand.d.ts +10 -0
  78. package/lib/esm/service/command/ConsolidateDescendantsCommand.js +83 -0
  79. package/lib/esm/service/command/RemoveSemicolons.d.ts +10 -0
  80. package/lib/esm/service/command/RemoveSemicolons.js +37 -0
  81. package/lib/esm/service/command/common.d.ts +31 -0
  82. package/lib/esm/service/command/common.js +22 -0
  83. package/lib/esm/service/completion.d.ts +4 -0
  84. package/lib/esm/service/completion.js +137 -0
  85. package/lib/esm/service/hover.d.ts +4 -0
  86. package/lib/esm/service/hover.js +119 -0
  87. package/lib/esm/service/languageFacts.d.ts +683 -0
  88. package/lib/esm/service/languageFacts.js +997 -0
  89. package/lib/esm/service/reference.d.ts +5 -0
  90. package/lib/esm/service/reference.js +66 -0
  91. package/lib/esm/service/rename.d.ts +4 -0
  92. package/lib/esm/service/rename.js +45 -0
  93. package/lib/esm/service/service.d.ts +28 -0
  94. package/lib/esm/service/service.js +35 -0
  95. package/lib/esm/service/util.d.ts +11 -0
  96. package/lib/esm/service/util.js +44 -0
  97. package/lib/esm/service/validation.d.ts +4 -0
  98. package/lib/esm/service/validation.js +20 -0
  99. package/lib/esm/tester.d.ts +1 -0
  100. package/lib/esm/tester.js +21 -0
  101. package/lib/esm/types.d.ts +396 -0
  102. package/lib/esm/types.js +71 -0
  103. package/lib/esm/visitor.d.ts +2 -0
  104. package/lib/esm/visitor.js +74 -0
  105. package/package.json +13 -11
  106. package/lib/index.d.ts +0 -5
  107. package/lib/service/colorProvider.d.ts +0 -6
  108. package/lib/service/command/common.js +0 -31
  109. package/lib/service/polyfill.d.ts +0 -16
  110. package/lib/service/polyfill.js +0 -3
  111. package/lib/service/service.js +0 -39
  112. package/lib/service/util.d.ts +0 -11
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.execute = exports.create = void 0;
4
- const common_1 = require("./common");
4
+ const common_js_1 = require("./common.js");
5
5
  function create(edgeOffsets, changeEdgesTo, graphOffset, changeFromGraph, changeGraphTo) {
6
- const toGraph = (0, common_1.getGraphKeywordStr)(changeGraphTo);
6
+ const toGraph = (0, common_js_1.getGraphKeywordStr)(changeGraphTo);
7
7
  const title = changeGraphTo === changeFromGraph
8
8
  ? `Fix all edges to match ${toGraph}`
9
- : `Convert ${(0, common_1.getGraphKeywordStr)(changeFromGraph)} to ${toGraph}`;
10
- const edgeStr = (0, common_1.getEdgeStr)(changeEdgesTo);
9
+ : `Convert ${(0, common_js_1.getGraphKeywordStr)(changeFromGraph)} to ${toGraph}`;
10
+ const edgeStr = (0, common_js_1.getEdgeStr)(changeEdgesTo);
11
11
  return {
12
12
  title,
13
13
  command: "DOT.convertGraphType",
@@ -15,18 +15,18 @@ function create(edgeOffsets, changeEdgesTo, graphOffset, changeFromGraph, change
15
15
  };
16
16
  }
17
17
  exports.create = create;
18
- function execute(doc, sourceFile, cmd) {
18
+ function execute(doc, _sourceFile, cmd) {
19
19
  if (!isChangeAllOtherEdgeOpsAndFixGraphCommand(cmd))
20
20
  return undefined;
21
21
  const [edgeOffsets, changeEdgeTo, graphOffset, changeGraphTo] = cmd.arguments;
22
22
  const edits = edgeOffsets.map(o => {
23
23
  const startPos = doc.positionAt(o.start);
24
24
  const endPos = doc.positionAt(o.end);
25
- return (0, common_1.createChangeToEdit)(startPos, endPos, changeEdgeTo);
25
+ return (0, common_js_1.createChangeToEdit)(startPos, endPos, changeEdgeTo);
26
26
  });
27
27
  const graphStart = doc.positionAt(graphOffset.start);
28
28
  const graphEnd = doc.positionAt(graphOffset.end);
29
- edits.push((0, common_1.createChangeToEdit)(graphStart, graphEnd, changeGraphTo));
29
+ edits.push((0, common_js_1.createChangeToEdit)(graphStart, graphEnd, changeGraphTo));
30
30
  return {
31
31
  label: `Convert graph to "${changeGraphTo}"`,
32
32
  edit: {
@@ -1,10 +1,10 @@
1
1
  import * as lst from "vscode-languageserver-types";
2
- import { CommandIds } from "../codeAction";
3
- import { EdgeOpStr, ExecutableCommand, EdgeType } from "./common";
4
- import { DocumentLike, SourceFile, CommandApplication } from "../../";
2
+ import { CommandIds } from "../codeAction.js";
3
+ import { EdgeOpStr, ExecutableCommand, EdgeType } from "./common.js";
4
+ import { DocumentLike, SourceFile, CommandApplication } from "../../index.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): CommandApplication | undefined;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.execute = exports.create = void 0;
27
+ const lst = __importStar(require("vscode-languageserver-types"));
28
+ const common_js_1 = require("./common.js");
29
+ function create(startOffset, endOffset, changeTo, changeFrom) {
30
+ const from = (0, common_js_1.getEdgeStr)(changeFrom);
31
+ const to = (0, common_js_1.getEdgeStr)(changeTo);
32
+ return {
33
+ title: `Change "${from}" to "${to}".`,
34
+ command: "DOT.changeEdgeOp",
35
+ arguments: [startOffset, endOffset, to],
36
+ };
37
+ }
38
+ exports.create = create;
39
+ function execute(doc, _sourceFile, cmd) {
40
+ if (!isChangeEdgeOpCommand(cmd))
41
+ return undefined;
42
+ const [startOffset, endOffset, changeTo] = cmd.arguments;
43
+ const startPos = doc.positionAt(startOffset);
44
+ const endPos = doc.positionAt(endOffset);
45
+ return {
46
+ label: `Change of invalid edge to "${changeTo}"'"`,
47
+ edit: {
48
+ changes: {
49
+ [doc.uri]: [
50
+ lst.TextEdit.replace(lst.Range.create(startPos, endPos), changeTo),
51
+ ],
52
+ }
53
+ }
54
+ };
55
+ }
56
+ exports.execute = execute;
57
+ function isChangeEdgeOpCommand(cmd) {
58
+ return cmd.command === "DOT.changeEdgeOp" && !!cmd.arguments && cmd.arguments.length === 3;
59
+ }
60
+ //# sourceMappingURL=ChangeEdgeOpCommand.js.map
@@ -1,7 +1,7 @@
1
1
  import * as lst from "vscode-languageserver-types";
2
- import { CommandIds } from "../codeAction";
3
- import { ExecutableCommand } from "./common";
4
- import { DocumentLike, SourceFile, CommandApplication, EdgeStatement } from "../../";
2
+ import { CommandIds } from "../codeAction.js";
3
+ import { ExecutableCommand } from "./common.js";
4
+ import { DocumentLike, SourceFile, CommandApplication, EdgeStatement } from "../../index.js";
5
5
  export interface ConsolidateDescendantsCommand extends lst.Command {
6
6
  command: CommandIds.ConsolidateDescendants;
7
7
  arguments: number[];
@@ -1,22 +1,11 @@
1
1
  "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.execute = exports.create = void 0;
15
- const checker_1 = require("../../checker");
16
- const util_1 = require("../util");
4
+ const checker_js_1 = require("../../checker.js");
5
+ const util_js_1 = require("../util.js");
17
6
  function create(statements, below) {
18
7
  const first = statements[0];
19
- const from = (0, checker_1.getIdentifierText)(first.source.id);
8
+ const from = (0, checker_js_1.getIdentifierText)(first.source.id);
20
9
  const title = below
21
10
  ? `Convert edges below from "${from}" to subgraph`
22
11
  : `Convert edges from "${from}" to subgraph`;
@@ -27,13 +16,6 @@ function create(statements, below) {
27
16
  };
28
17
  }
29
18
  exports.create = create;
30
- function unbind(statements) {
31
- const res = [];
32
- for (const statement of statements) {
33
- const { parent } = statement, copy = __rest(statement, ["parent"]);
34
- }
35
- return res;
36
- }
37
19
  function execute(doc, sourceFile, cmd) {
38
20
  if (!isConsolidateDescendantsCommand(cmd))
39
21
  return undefined;
@@ -41,12 +23,12 @@ function execute(doc, sourceFile, cmd) {
41
23
  if (!g)
42
24
  return undefined;
43
25
  const candidateIndexes = cmd.arguments;
44
- const candidates = candidateIndexes.map(i => (0, checker_1.findNodeAtOffset)(g, i).parent.parent);
26
+ const candidates = candidateIndexes.map(i => (0, checker_js_1.findNodeAtOffset)(g, i).parent.parent);
45
27
  const first = candidates.shift();
46
- const from = (0, checker_1.getIdentifierText)(first.source.id);
28
+ const from = (0, checker_js_1.getIdentifierText)(first.source.id);
47
29
  const edits = [];
48
30
  const firstRight = first.rhs[0];
49
- const firstRightTargetStart = (0, util_1.getStart)(sourceFile, firstRight.target);
31
+ const firstRightTargetStart = (0, util_js_1.getStart)(sourceFile, firstRight.target);
50
32
  const firstRightTargetEnd = firstRight.target.end;
51
33
  const contents = [
52
34
  sourceFile.content.substring(firstRightTargetStart, firstRightTargetEnd)
@@ -75,7 +57,7 @@ function execute(doc, sourceFile, cmd) {
75
57
  edits.push({
76
58
  newText: "",
77
59
  range: {
78
- start: doc.positionAt((0, util_1.getStart)(sourceFile, descendant.terminator)),
60
+ start: doc.positionAt((0, util_js_1.getStart)(sourceFile, descendant.terminator)),
79
61
  end: doc.positionAt(descendant.terminator.end),
80
62
  }
81
63
  });
@@ -1,7 +1,7 @@
1
1
  import * as lst from "vscode-languageserver-types";
2
- import { CommandIds } from "../codeAction";
3
- import { ExecutableCommand } from "./common";
4
- import { DocumentLike, SourceFile, CommandApplication } from "../../";
2
+ import { CommandIds } from "../codeAction.js";
3
+ import { ExecutableCommand } from "./common.js";
4
+ import { DocumentLike, SourceFile, CommandApplication } from "../../index.js";
5
5
  export interface RemoveSemicolonsCommand extends lst.Command {
6
6
  command: CommandIds.RemoveSemicolons;
7
7
  arguments: undefined;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.execute = exports.create = void 0;
4
- const common_1 = require("./common");
5
- const checker_1 = require("../../checker");
4
+ const common_js_1 = require("./common.js");
5
+ const checker_js_1 = require("../../checker.js");
6
6
  function create() {
7
7
  return {
8
8
  title: "Remove optional semicolons",
@@ -17,11 +17,11 @@ function execute(doc, sourceFile, cmd) {
17
17
  const g = sourceFile.graph;
18
18
  if (!g)
19
19
  return undefined;
20
- const semicolons = (0, checker_1.findOptionalSemicolons)(g);
20
+ const semicolons = (0, checker_js_1.findOptionalSemicolons)(g);
21
21
  const edits = semicolons.map(s => {
22
22
  const end = s.end;
23
23
  const start = end - 1;
24
- return (0, common_1.createChangeToEdit)(doc.positionAt(start), doc.positionAt(end), "");
24
+ return (0, common_js_1.createChangeToEdit)(doc.positionAt(start), doc.positionAt(end), "");
25
25
  });
26
26
  return {
27
27
  label: `Remove optional semicolons`,
@@ -1,7 +1,7 @@
1
- import * as lst from "vscode-languageserver-types";
2
- import { SyntaxKind } from "../../";
3
- import { CommandIds } from "../codeAction";
4
- export declare function createChangeToEdit(start: lst.Position, end: lst.Position, changeTo: string): lst.TextEdit;
1
+ import { TextEdit, type Position } from "vscode-languageserver-types";
2
+ import { SyntaxKind } from "../../index.js";
3
+ import { CommandIds } from "../codeAction.js";
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;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAllowedOp = exports.getOppositeEdgeOp = exports.getOppositeKind = exports.getGraphKeywordStr = exports.getEdgeStr = exports.createChangeToEdit = void 0;
4
+ const vscode_languageserver_types_1 = require("vscode-languageserver-types");
5
+ const index_js_1 = require("../../index.js");
6
+ function createChangeToEdit(start, end, changeTo) {
7
+ return vscode_languageserver_types_1.TextEdit.replace(vscode_languageserver_types_1.Range.create(start, end), changeTo);
8
+ }
9
+ exports.createChangeToEdit = createChangeToEdit;
10
+ ;
11
+ function getEdgeStr(op) {
12
+ return op === index_js_1.SyntaxKind.DirectedEdgeOp ? "->" : "--";
13
+ }
14
+ exports.getEdgeStr = getEdgeStr;
15
+ function getGraphKeywordStr(g) {
16
+ return g === index_js_1.SyntaxKind.DigraphKeyword ? "digraph" : "graph";
17
+ }
18
+ exports.getGraphKeywordStr = getGraphKeywordStr;
19
+ function getOppositeKind(g) {
20
+ return g === index_js_1.SyntaxKind.DigraphKeyword ? index_js_1.SyntaxKind.GraphKeyword : index_js_1.SyntaxKind.DigraphKeyword;
21
+ }
22
+ exports.getOppositeKind = getOppositeKind;
23
+ function getOppositeEdgeOp(g) {
24
+ return g === index_js_1.SyntaxKind.DirectedEdgeOp ? index_js_1.SyntaxKind.UndirectedEdgeOp : index_js_1.SyntaxKind.DirectedEdgeOp;
25
+ }
26
+ exports.getOppositeEdgeOp = getOppositeEdgeOp;
27
+ function getAllowedOp(g) {
28
+ return g === index_js_1.SyntaxKind.DigraphKeyword ? index_js_1.SyntaxKind.DirectedEdgeOp : index_js_1.SyntaxKind.UndirectedEdgeOp;
29
+ }
30
+ exports.getAllowedOp = getAllowedOp;
31
+ //# sourceMappingURL=common.js.map
@@ -1,4 +1,4 @@
1
1
  import * as lst from "vscode-languageserver-types";
2
- import { SourceFile } from "../types";
3
- import { DocumentLike } from "../";
2
+ import { SourceFile } from "../types.js";
3
+ import { DocumentLike } from "../index.js";
4
4
  export declare function getCompletions(doc: DocumentLike, sourceFile: SourceFile, position: lst.Position): lst.CompletionItem[];
@@ -1,12 +1,35 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.getCompletions = void 0;
4
- const lst = require("vscode-languageserver-types");
5
- const types_1 = require("../types");
6
- const checker_1 = require("../checker");
7
- const util_1 = require("./util");
8
- const __1 = require("../");
9
- const languageFacts = require("./languageFacts");
27
+ const lst = __importStar(require("vscode-languageserver-types"));
28
+ const types_js_1 = require("../types.js");
29
+ const checker_js_1 = require("../checker.js");
30
+ const util_js_1 = require("./util.js");
31
+ const index_js_1 = require("../index.js");
32
+ const languageFacts = __importStar(require("./languageFacts.js"));
10
33
  function getCompletions(doc, sourceFile, position) {
11
34
  const symbols = sourceFile.symbols;
12
35
  if (!symbols)
@@ -15,46 +38,46 @@ function getCompletions(doc, sourceFile, position) {
15
38
  if (!g)
16
39
  return [];
17
40
  const offset = doc.offsetAt(position);
18
- const node = (0, checker_1.findNodeAtOffset)(g, offset, true);
41
+ const node = (0, checker_js_1.findNodeAtOffset)(g, offset, true);
19
42
  if (!node)
20
43
  return [];
21
- const prevOffsetNode = (0, checker_1.findNodeAtOffset)(g, offset - 1, true);
44
+ const prevOffsetNode = (0, checker_js_1.findNodeAtOffset)(g, offset - 1, true);
22
45
  const parent = node.parent;
23
46
  const prevOffsetNodeParent = prevOffsetNode === null || prevOffsetNode === void 0 ? void 0 : prevOffsetNode.parent;
24
- if (((parent === null || parent === void 0 ? void 0 : parent.parent) && (0, checker_1.isEdgeStatement)(parent.parent))
25
- || ((prevOffsetNodeParent === null || prevOffsetNodeParent === void 0 ? void 0 : prevOffsetNodeParent.parent) && (0, checker_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))) {
26
49
  return getNodeCompletions(symbols);
27
50
  }
28
- if (node.kind === types_1.SyntaxKind.AttributeContainer) {
51
+ if (node.kind === types_js_1.SyntaxKind.AttributeContainer) {
29
52
  const openingBracket = node.openBracket;
30
53
  if (openingBracket.end - 1 > offset - 1) {
31
- const exclusions = (prevOffsetNode === null || prevOffsetNode === void 0 ? void 0 : prevOffsetNode.kind) === types_1.SyntaxKind.TextIdentifier && prevOffsetNode.symbol
54
+ const exclusions = (prevOffsetNode === null || prevOffsetNode === void 0 ? void 0 : prevOffsetNode.kind) === types_js_1.SyntaxKind.TextIdentifier && prevOffsetNode.symbol
32
55
  ? [prevOffsetNode.symbol.name]
33
56
  : undefined;
34
57
  return getNodeCompletions(symbols, exclusions);
35
58
  }
36
59
  }
37
- if (node.kind === types_1.SyntaxKind.TextIdentifier && (parent === null || parent === void 0 ? void 0 : parent.kind) === types_1.SyntaxKind.NodeId) {
60
+ if (node.kind === types_js_1.SyntaxKind.TextIdentifier && (parent === null || parent === void 0 ? void 0 : parent.kind) === types_js_1.SyntaxKind.NodeId) {
38
61
  const exclusions = node.symbol
39
62
  ? [node.symbol.name]
40
63
  : undefined;
41
64
  return getNodeCompletions(symbols, exclusions);
42
65
  }
43
- if (node.kind === types_1.SyntaxKind.AttributeContainer
44
- || (node.kind == types_1.SyntaxKind.CommaToken && (parent === null || parent === void 0 ? void 0 : parent.kind) === types_1.SyntaxKind.Assignment)) {
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)) {
45
68
  return getAttributeCompletions(position);
46
69
  }
47
- const prevNode = (0, checker_1.findNodeAtOffset)(g, node.pos - 1, true);
70
+ const prevNode = (0, checker_js_1.findNodeAtOffset)(g, node.pos - 1, true);
48
71
  if (!prevNode)
49
72
  return [];
50
- if ((0, __1.isIdentifierNode)(prevNode)) {
73
+ if ((0, index_js_1.isIdentifierNode)(prevNode)) {
51
74
  const p = prevNode.parent;
52
75
  if (p) {
53
76
  switch (p.kind) {
54
- case types_1.SyntaxKind.NodeId: {
77
+ case types_js_1.SyntaxKind.NodeId: {
55
78
  return getNodeCompletions(symbols);
56
79
  }
57
- case types_1.SyntaxKind.Assignment: {
80
+ case types_js_1.SyntaxKind.Assignment: {
58
81
  return getAssignmentCompletion(p);
59
82
  }
60
83
  }
@@ -67,7 +90,7 @@ function getCompletions(doc, sourceFile, position) {
67
90
  if (!attribute.parent)
68
91
  throw "sourceFile is not bound";
69
92
  const parent = attribute.parent;
70
- if (parent.kind === types_1.SyntaxKind.Assignment) {
93
+ if (parent.kind === types_js_1.SyntaxKind.Assignment) {
71
94
  return getAssignmentCompletion(parent);
72
95
  }
73
96
  }
@@ -75,7 +98,7 @@ function getCompletions(doc, sourceFile, position) {
75
98
  }
76
99
  exports.getCompletions = getCompletions;
77
100
  function getAssignmentCompletion(assignment) {
78
- const property = (0, checker_1.getIdentifierText)(assignment.leftId);
101
+ const property = (0, checker_js_1.getIdentifierText)(assignment.leftId);
79
102
  if (!property)
80
103
  return [];
81
104
  switch (property.toLowerCase()) {
@@ -88,7 +111,7 @@ function getShapeCompletions() {
88
111
  const kind = lst.CompletionItemKind.EnumMember;
89
112
  return languageFacts.shapes.map(s => ({
90
113
  kind,
91
- label: (0, util_1.escapeIdentifierText)(s),
114
+ label: (0, util_js_1.escapeIdentifierText)(s),
92
115
  }));
93
116
  }
94
117
  function getColorCompletions() {
@@ -112,7 +135,7 @@ function getAttributeCompletions(posistion) {
112
135
  label,
113
136
  textEdit: {
114
137
  range,
115
- newText: (0, util_1.escapeIdentifierText)(label) + "=",
138
+ newText: (0, util_js_1.escapeIdentifierText)(label) + "=",
116
139
  },
117
140
  }));
118
141
  }
@@ -125,14 +148,14 @@ function getNodeCompletions(symbols, exlucdedSymbols) {
125
148
  const a = value.firstMention.parent;
126
149
  if (a) {
127
150
  switch (a.kind) {
128
- case types_1.SyntaxKind.DirectedGraph:
129
- case types_1.SyntaxKind.UndirectedGraph:
151
+ case types_js_1.SyntaxKind.DirectedGraph:
152
+ case types_js_1.SyntaxKind.UndirectedGraph:
130
153
  kind = lst.CompletionItemKind.Class;
131
154
  break;
132
155
  }
133
156
  }
134
157
  res.push({
135
- label: (0, util_1.escapeIdentifierText)(key),
158
+ label: (0, util_js_1.escapeIdentifierText)(key),
136
159
  kind: kind,
137
160
  });
138
161
  }
@@ -1,4 +1,4 @@
1
1
  import type * as lst from "vscode-languageserver-types";
2
- import { SourceFile } from "../types";
3
- import { DocumentLike } from "../";
2
+ import { SourceFile } from "../types.js";
3
+ import { DocumentLike } from "../index.js";
4
4
  export declare function hover(doc: DocumentLike, sourceFile: SourceFile, position: lst.Position): lst.Hover | undefined;
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.hover = void 0;
4
- const types_1 = require("../types");
5
- const checker_1 = require("../checker");
6
- const parser_1 = require("../parser");
7
- const util_1 = require("./util");
8
- const common_1 = require("./command/common");
4
+ const types_js_1 = require("../types.js");
5
+ const checker_js_1 = require("../checker.js");
6
+ const parser_js_1 = require("../parser.js");
7
+ const util_js_1 = require("./util.js");
8
+ const common_js_1 = require("./command/common.js");
9
9
  function hover(doc, sourceFile, position) {
10
10
  const offset = doc.offsetAt(position);
11
11
  const g = sourceFile.graph;
12
12
  if (!g)
13
13
  return undefined;
14
- const node = (0, checker_1.findNodeAtOffset)(g, offset);
14
+ const node = (0, checker_js_1.findNodeAtOffset)(g, offset);
15
15
  if (node === undefined)
16
16
  return undefined;
17
17
  return getNodeHover(doc, sourceFile, node);
@@ -22,78 +22,78 @@ function getNodeHover(doc, sf, n) {
22
22
  if (contents) {
23
23
  return {
24
24
  contents,
25
- range: (0, util_1.syntaxNodeToRange)(doc, sf, n),
25
+ range: (0, util_js_1.syntaxNodeToRange)(doc, sf, n),
26
26
  };
27
27
  }
28
28
  return undefined;
29
29
  }
30
30
  function getHoverContents(n) {
31
- if ((0, parser_1.isIdentifierNode)(n)) {
31
+ if ((0, parser_js_1.isIdentifierNode)(n)) {
32
32
  const parent = n.parent;
33
33
  if (parent) {
34
34
  switch (parent.kind) {
35
- case types_1.SyntaxKind.NodeId:
36
- return `(node) ${(0, checker_1.getIdentifierText)(n)}`;
37
- case types_1.SyntaxKind.Assignment: {
35
+ case types_js_1.SyntaxKind.NodeId:
36
+ return `(node) ${(0, checker_js_1.getIdentifierText)(n)}`;
37
+ case types_js_1.SyntaxKind.Assignment: {
38
38
  const assignment = parent;
39
- const left = (0, checker_1.getIdentifierText)(assignment.leftId);
40
- const right = (0, checker_1.getIdentifierText)(assignment.rightId);
39
+ const left = (0, checker_js_1.getIdentifierText)(assignment.leftId);
40
+ const right = (0, checker_js_1.getIdentifierText)(assignment.rightId);
41
41
  return `(assignment) \`${left}\` = \`${right}\``;
42
42
  }
43
- case types_1.SyntaxKind.DirectedGraph:
43
+ case types_js_1.SyntaxKind.DirectedGraph:
44
44
  return getGraphHover(parent);
45
- case types_1.SyntaxKind.UndirectedGraph:
45
+ case types_js_1.SyntaxKind.UndirectedGraph:
46
46
  return getGraphHover(parent);
47
- case types_1.SyntaxKind.SubGraphStatement: {
47
+ case types_js_1.SyntaxKind.SubGraphStatement: {
48
48
  const sgs = parent;
49
49
  const sg = sgs.subgraph;
50
50
  return !!sg.id
51
- ? `(sub graph) ${(0, checker_1.getIdentifierText)(sg.id)}`
51
+ ? `(sub graph) ${(0, checker_js_1.getIdentifierText)(sg.id)}`
52
52
  : `(sub graph)`;
53
53
  }
54
- case types_1.SyntaxKind.SubGraph: {
54
+ case types_js_1.SyntaxKind.SubGraph: {
55
55
  const sg = parent;
56
56
  return !!sg.id
57
- ? `(sub graph) ${(0, checker_1.getIdentifierText)(sg.id)}`
57
+ ? `(sub graph) ${(0, checker_js_1.getIdentifierText)(sg.id)}`
58
58
  : `(sub graph)`;
59
59
  }
60
- case types_1.SyntaxKind.IdEqualsIdStatement: {
60
+ case types_js_1.SyntaxKind.IdEqualsIdStatement: {
61
61
  const idEqId = parent;
62
- const left = (0, checker_1.getIdentifierText)(idEqId.leftId);
63
- const right = (0, checker_1.getIdentifierText)(idEqId.rightId);
62
+ const left = (0, checker_js_1.getIdentifierText)(idEqId.leftId);
63
+ const right = (0, checker_js_1.getIdentifierText)(idEqId.rightId);
64
64
  return `(graph property) \`${left}\` = \`${right}\``;
65
65
  }
66
- case types_1.SyntaxKind.EdgeRhs:
66
+ case types_js_1.SyntaxKind.EdgeRhs:
67
67
  return getEdgeHover(parent);
68
68
  }
69
- return types_1.SyntaxKind[parent.kind];
69
+ return types_js_1.SyntaxKind[parent.kind];
70
70
  }
71
- const fallback = types_1.SyntaxKind[n.kind];
71
+ const fallback = types_js_1.SyntaxKind[n.kind];
72
72
  return fallback
73
73
  ? "(" + fallback.toLowerCase() + ")"
74
74
  : undefined;
75
75
  }
76
76
  switch (n.kind) {
77
- case types_1.SyntaxKind.GraphKeyword:
78
- case types_1.SyntaxKind.DigraphKeyword:
79
- case types_1.SyntaxKind.StrictKeyword:
77
+ case types_js_1.SyntaxKind.GraphKeyword:
78
+ case types_js_1.SyntaxKind.DigraphKeyword:
79
+ case types_js_1.SyntaxKind.StrictKeyword:
80
80
  return getGraphHover(n.parent);
81
- case types_1.SyntaxKind.DirectedGraph:
82
- case types_1.SyntaxKind.UndirectedGraph:
81
+ case types_js_1.SyntaxKind.DirectedGraph:
82
+ case types_js_1.SyntaxKind.UndirectedGraph:
83
83
  return getGraphHover(n);
84
- case types_1.SyntaxKind.DirectedEdgeOp:
85
- case types_1.SyntaxKind.UndirectedEdgeOp:
84
+ case types_js_1.SyntaxKind.DirectedEdgeOp:
85
+ case types_js_1.SyntaxKind.UndirectedEdgeOp:
86
86
  return getEdgeHover(n.parent);
87
87
  default:
88
88
  return undefined;
89
89
  }
90
90
  }
91
91
  function getGraphHover(g) {
92
- const direction = g.kind === types_1.SyntaxKind.DirectedGraph ? "directed" : "undirected";
92
+ const direction = g.kind === types_js_1.SyntaxKind.DirectedGraph ? "directed" : "undirected";
93
93
  const graphId = g.id;
94
94
  const strict = g.strict ? "strict " : "";
95
95
  return !!graphId
96
- ? `(${strict}${direction} graph) ${((0, checker_1.getIdentifierText)(graphId))}`
96
+ ? `(${strict}${direction} graph) ${((0, checker_js_1.getIdentifierText)(graphId))}`
97
97
  : `(${strict}${direction} graph)`;
98
98
  }
99
99
  function getEdgeHover(n) {
@@ -108,16 +108,16 @@ function getEdgeHover(n) {
108
108
  }
109
109
  if (source === undefined)
110
110
  source = p.source;
111
- const edgeOpStr = (0, common_1.getEdgeStr)(n.operation.kind);
111
+ const edgeOpStr = (0, common_js_1.getEdgeStr)(n.operation.kind);
112
112
  return source === undefined
113
113
  ? undefined
114
114
  : `(edge) ${getEdgeSourceOrTargetText(source)} ${edgeOpStr} ${getEdgeSourceOrTargetText(n.target)}`;
115
115
  }
116
116
  function getEdgeSourceOrTargetText(n) {
117
- return n.kind === types_1.SyntaxKind.NodeId
118
- ? (0, checker_1.getIdentifierText)(n.id)
117
+ return n.kind === types_js_1.SyntaxKind.NodeId
118
+ ? (0, checker_js_1.getIdentifierText)(n.id)
119
119
  : n.id !== undefined
120
- ? `${(0, checker_1.getIdentifierText)(n.id)}`
120
+ ? `${(0, checker_js_1.getIdentifierText)(n.id)}`
121
121
  : "sub graph";
122
122
  }
123
123
  //# sourceMappingURL=hover.js.map
File without changes
File without changes
@@ -1,5 +1,5 @@
1
1
  import type { Position, ReferenceContext, Location } from "vscode-languageserver-types";
2
- import type { SourceFile } from "../types";
3
- import { type DocumentLike } from "../";
2
+ import type { SourceFile } from "../types.js";
3
+ import { type DocumentLike } from "../index.js";
4
4
  export declare function findReferences(doc: DocumentLike, sourceFile: SourceFile, position: Position, context: ReferenceContext): Location[];
5
5
  export declare function findDefinition(doc: DocumentLike, sourceFile: SourceFile, position: Position): Location | undefined;