dot-language-support 2.3.0 → 3.0.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 (109) hide show
  1. package/dist/index.d.ts +497 -0
  2. package/dist/index.js +3853 -0
  3. package/package.json +10 -11
  4. package/.github/dependabot.yml +0 -15
  5. package/.github/workflows/CD.yml +0 -37
  6. package/.github/workflows/CI.yml +0 -28
  7. package/.github/workflows/auto-merge.yaml +0 -26
  8. package/CITATION.cff +0 -14
  9. package/biome.json +0 -48
  10. package/lib/cjs/binder.d.ts +0 -2
  11. package/lib/cjs/binder.js +0 -297
  12. package/lib/cjs/checker.d.ts +0 -15
  13. package/lib/cjs/checker.js +0 -228
  14. package/lib/cjs/core.d.ts +0 -1
  15. package/lib/cjs/core.js +0 -13
  16. package/lib/cjs/error.d.ts +0 -3
  17. package/lib/cjs/error.js +0 -12
  18. package/lib/cjs/index.d.ts +0 -5
  19. package/lib/cjs/index.js +0 -22
  20. package/lib/cjs/parser.d.ts +0 -27
  21. package/lib/cjs/parser.js +0 -664
  22. package/lib/cjs/scanner.d.ts +0 -41
  23. package/lib/cjs/scanner.js +0 -578
  24. package/lib/cjs/service/codeAction.d.ts +0 -12
  25. package/lib/cjs/service/codeAction.js +0 -245
  26. package/lib/cjs/service/colorProvider.d.ts +0 -5
  27. package/lib/cjs/service/colorProvider.js +0 -91
  28. package/lib/cjs/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.d.ts +0 -10
  29. package/lib/cjs/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.js +0 -42
  30. package/lib/cjs/service/command/ChangeEdgeOpCommand.d.ts +0 -10
  31. package/lib/cjs/service/command/ChangeEdgeOpCommand.js +0 -67
  32. package/lib/cjs/service/command/ConsolidateDescendantsCommand.d.ts +0 -10
  33. package/lib/cjs/service/command/ConsolidateDescendantsCommand.js +0 -87
  34. package/lib/cjs/service/command/RemoveSemicolons.d.ts +0 -10
  35. package/lib/cjs/service/command/RemoveSemicolons.js +0 -39
  36. package/lib/cjs/service/command/common.d.ts +0 -31
  37. package/lib/cjs/service/command/common.js +0 -33
  38. package/lib/cjs/service/completion.d.ts +0 -4
  39. package/lib/cjs/service/completion.js +0 -173
  40. package/lib/cjs/service/hover.d.ts +0 -4
  41. package/lib/cjs/service/hover.js +0 -142
  42. package/lib/cjs/service/languageFacts.d.ts +0 -683
  43. package/lib/cjs/service/languageFacts.js +0 -996
  44. package/lib/cjs/service/reference.d.ts +0 -5
  45. package/lib/cjs/service/reference.js +0 -67
  46. package/lib/cjs/service/rename.d.ts +0 -4
  47. package/lib/cjs/service/rename.js +0 -51
  48. package/lib/cjs/service/service.d.ts +0 -28
  49. package/lib/cjs/service/service.js +0 -38
  50. package/lib/cjs/service/util.d.ts +0 -11
  51. package/lib/cjs/service/util.js +0 -49
  52. package/lib/cjs/service/validation.d.ts +0 -4
  53. package/lib/cjs/service/validation.js +0 -23
  54. package/lib/cjs/tester.d.ts +0 -1
  55. package/lib/cjs/tester.js +0 -23
  56. package/lib/cjs/types.d.ts +0 -397
  57. package/lib/cjs/types.js +0 -74
  58. package/lib/cjs/visitor.d.ts +0 -2
  59. package/lib/cjs/visitor.js +0 -76
  60. package/lib/esm/binder.d.ts +0 -2
  61. package/lib/esm/binder.js +0 -294
  62. package/lib/esm/checker.d.ts +0 -15
  63. package/lib/esm/checker.js +0 -212
  64. package/lib/esm/core.d.ts +0 -1
  65. package/lib/esm/core.js +0 -10
  66. package/lib/esm/error.d.ts +0 -3
  67. package/lib/esm/error.js +0 -8
  68. package/lib/esm/index.d.ts +0 -5
  69. package/lib/esm/index.js +0 -6
  70. package/lib/esm/parser.d.ts +0 -27
  71. package/lib/esm/parser.js +0 -714
  72. package/lib/esm/scanner.d.ts +0 -41
  73. package/lib/esm/scanner.js +0 -581
  74. package/lib/esm/service/codeAction.d.ts +0 -12
  75. package/lib/esm/service/codeAction.js +0 -207
  76. package/lib/esm/service/colorProvider.d.ts +0 -5
  77. package/lib/esm/service/colorProvider.js +0 -54
  78. package/lib/esm/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.d.ts +0 -10
  79. package/lib/esm/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.js +0 -38
  80. package/lib/esm/service/command/ChangeEdgeOpCommand.d.ts +0 -10
  81. package/lib/esm/service/command/ChangeEdgeOpCommand.js +0 -30
  82. package/lib/esm/service/command/ConsolidateDescendantsCommand.d.ts +0 -10
  83. package/lib/esm/service/command/ConsolidateDescendantsCommand.js +0 -83
  84. package/lib/esm/service/command/RemoveSemicolons.d.ts +0 -10
  85. package/lib/esm/service/command/RemoveSemicolons.js +0 -35
  86. package/lib/esm/service/command/common.d.ts +0 -31
  87. package/lib/esm/service/command/common.js +0 -25
  88. package/lib/esm/service/completion.d.ts +0 -4
  89. package/lib/esm/service/completion.js +0 -137
  90. package/lib/esm/service/hover.d.ts +0 -4
  91. package/lib/esm/service/hover.js +0 -135
  92. package/lib/esm/service/languageFacts.d.ts +0 -683
  93. package/lib/esm/service/languageFacts.js +0 -993
  94. package/lib/esm/service/reference.d.ts +0 -5
  95. package/lib/esm/service/reference.js +0 -63
  96. package/lib/esm/service/rename.d.ts +0 -4
  97. package/lib/esm/service/rename.js +0 -48
  98. package/lib/esm/service/service.d.ts +0 -28
  99. package/lib/esm/service/service.js +0 -35
  100. package/lib/esm/service/util.d.ts +0 -11
  101. package/lib/esm/service/util.js +0 -42
  102. package/lib/esm/service/validation.d.ts +0 -4
  103. package/lib/esm/service/validation.js +0 -20
  104. package/lib/esm/tester.d.ts +0 -1
  105. package/lib/esm/tester.js +0 -21
  106. package/lib/esm/types.d.ts +0 -397
  107. package/lib/esm/types.js +0 -71
  108. package/lib/esm/visitor.d.ts +0 -2
  109. package/lib/esm/visitor.js +0 -73
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createChangeToEdit = createChangeToEdit;
4
- exports.getEdgeStr = getEdgeStr;
5
- exports.getGraphKeywordStr = getGraphKeywordStr;
6
- exports.getOppositeKind = getOppositeKind;
7
- exports.getOppositeEdgeOp = getOppositeEdgeOp;
8
- exports.getAllowedOp = getAllowedOp;
9
- const vscode_languageserver_types_1 = require("vscode-languageserver-types");
10
- const index_js_1 = require("../../index.js");
11
- function createChangeToEdit(start, end, changeTo) {
12
- return vscode_languageserver_types_1.TextEdit.replace(vscode_languageserver_types_1.Range.create(start, end), changeTo);
13
- }
14
- function getEdgeStr(op) {
15
- return op === index_js_1.SyntaxKind.DirectedEdgeOp ? "->" : "--";
16
- }
17
- function getGraphKeywordStr(g) {
18
- return g === index_js_1.SyntaxKind.DigraphKeyword ? "digraph" : "graph";
19
- }
20
- function getOppositeKind(g) {
21
- return g === index_js_1.SyntaxKind.DigraphKeyword ? index_js_1.SyntaxKind.GraphKeyword : index_js_1.SyntaxKind.DigraphKeyword;
22
- }
23
- function getOppositeEdgeOp(g) {
24
- return g === index_js_1.SyntaxKind.DirectedEdgeOp
25
- ? index_js_1.SyntaxKind.UndirectedEdgeOp
26
- : index_js_1.SyntaxKind.DirectedEdgeOp;
27
- }
28
- function getAllowedOp(g) {
29
- return g === index_js_1.SyntaxKind.DigraphKeyword
30
- ? index_js_1.SyntaxKind.DirectedEdgeOp
31
- : index_js_1.SyntaxKind.UndirectedEdgeOp;
32
- }
33
- //# sourceMappingURL=common.js.map
@@ -1,4 +0,0 @@
1
- import * as lst from "vscode-languageserver-types";
2
- import { type DocumentLike } from "../index.js";
3
- import { type SourceFile } from "../types.js";
4
- export declare function getCompletions(doc: DocumentLike, sourceFile: SourceFile, position: lst.Position): lst.CompletionItem[];
@@ -1,173 +0,0 @@
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 () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.getCompletions = getCompletions;
37
- const lst = __importStar(require("vscode-languageserver-types"));
38
- const checker_js_1 = require("../checker.js");
39
- const index_js_1 = require("../index.js");
40
- const types_js_1 = require("../types.js");
41
- const languageFacts = __importStar(require("./languageFacts.js"));
42
- const util_js_1 = require("./util.js");
43
- function getCompletions(doc, sourceFile, position) {
44
- const symbols = sourceFile.symbols;
45
- if (!symbols)
46
- throw "sourceFile is not bound";
47
- const g = sourceFile.graph;
48
- if (!g)
49
- return [];
50
- const offset = doc.offsetAt(position);
51
- const node = (0, checker_js_1.findNodeAtOffset)(g, offset, true);
52
- if (!node)
53
- return [];
54
- const prevOffsetNode = (0, checker_js_1.findNodeAtOffset)(g, offset - 1, true);
55
- const parent = node.parent;
56
- const prevOffsetNodeParent = prevOffsetNode === null || prevOffsetNode === void 0 ? void 0 : prevOffsetNode.parent;
57
- if (((parent === null || parent === void 0 ? void 0 : parent.parent) && (0, checker_js_1.isEdgeStatement)(parent.parent)) ||
58
- ((prevOffsetNodeParent === null || prevOffsetNodeParent === void 0 ? void 0 : prevOffsetNodeParent.parent) && (0, checker_js_1.isEdgeStatement)(prevOffsetNodeParent.parent))) {
59
- return getNodeCompletions(symbols);
60
- }
61
- if (node.kind === types_js_1.SyntaxKind.AttributeContainer) {
62
- const openingBracket = node.openBracket;
63
- if (openingBracket.end - 1 > offset - 1) {
64
- const exclusions = (prevOffsetNode === null || prevOffsetNode === void 0 ? void 0 : prevOffsetNode.kind) === types_js_1.SyntaxKind.TextIdentifier && prevOffsetNode.symbol
65
- ? [prevOffsetNode.symbol.name]
66
- : undefined;
67
- return getNodeCompletions(symbols, exclusions);
68
- }
69
- }
70
- if (node.kind === types_js_1.SyntaxKind.TextIdentifier && (parent === null || parent === void 0 ? void 0 : parent.kind) === types_js_1.SyntaxKind.NodeId) {
71
- const exclusions = node.symbol ? [node.symbol.name] : undefined;
72
- return getNodeCompletions(symbols, exclusions);
73
- }
74
- if (node.kind === types_js_1.SyntaxKind.AttributeContainer ||
75
- (node.kind === types_js_1.SyntaxKind.CommaToken && (parent === null || parent === void 0 ? void 0 : parent.kind) === types_js_1.SyntaxKind.Assignment)) {
76
- return getAttributeCompletions(position);
77
- }
78
- const prevNode = (0, checker_js_1.findNodeAtOffset)(g, node.pos - 1, true);
79
- if (!prevNode)
80
- return [];
81
- if ((0, index_js_1.isIdentifierNode)(prevNode)) {
82
- const p = prevNode.parent;
83
- if (p) {
84
- switch (p.kind) {
85
- case types_js_1.SyntaxKind.NodeId: {
86
- return getNodeCompletions(symbols);
87
- }
88
- case types_js_1.SyntaxKind.Assignment: {
89
- return getAssignmentCompletion(p);
90
- }
91
- }
92
- }
93
- }
94
- if (node.flags & 2 || node.end === node.pos) {
95
- const attribute = prevNode;
96
- if (!attribute)
97
- return [];
98
- if (!attribute.parent)
99
- throw "sourceFile is not bound";
100
- const parent = attribute.parent;
101
- if (parent.kind === types_js_1.SyntaxKind.Assignment) {
102
- return getAssignmentCompletion(parent);
103
- }
104
- }
105
- return [];
106
- }
107
- function getAssignmentCompletion(assignment) {
108
- const property = (0, checker_js_1.getIdentifierText)(assignment.leftId);
109
- if (!property)
110
- return [];
111
- switch (property.toLowerCase()) {
112
- case "shape":
113
- return getShapeCompletions();
114
- case "color":
115
- return getColorCompletions();
116
- default:
117
- return [];
118
- }
119
- }
120
- function getShapeCompletions() {
121
- const kind = lst.CompletionItemKind.EnumMember;
122
- return languageFacts.shapes.map(s => ({
123
- kind,
124
- label: (0, util_js_1.escapeIdentifierText)(s),
125
- }));
126
- }
127
- function getColorCompletions() {
128
- const kind = lst.CompletionItemKind.Color;
129
- const colors = languageFacts.colors;
130
- return Object.keys(colors).map(label => ({
131
- kind,
132
- label,
133
- documentation: colors[label],
134
- }));
135
- }
136
- function getAttributeCompletions(posistion) {
137
- const kind = lst.CompletionItemKind.Property;
138
- const range = {
139
- start: posistion,
140
- end: posistion,
141
- };
142
- return languageFacts.attributes.map(label => ({
143
- kind,
144
- label,
145
- textEdit: {
146
- range,
147
- newText: `${(0, util_js_1.escapeIdentifierText)(label)}=`,
148
- },
149
- }));
150
- }
151
- function getNodeCompletions(symbols, exlucdedSymbols) {
152
- const res = [];
153
- for (const [key, value] of symbols) {
154
- if (exlucdedSymbols === null || exlucdedSymbols === void 0 ? void 0 : exlucdedSymbols.includes(key))
155
- continue;
156
- let kind = lst.CompletionItemKind.Variable;
157
- const a = value.firstMention.parent;
158
- if (a) {
159
- switch (a.kind) {
160
- case types_js_1.SyntaxKind.DirectedGraph:
161
- case types_js_1.SyntaxKind.UndirectedGraph:
162
- kind = lst.CompletionItemKind.Class;
163
- break;
164
- }
165
- }
166
- res.push({
167
- label: (0, util_js_1.escapeIdentifierText)(key),
168
- kind: kind,
169
- });
170
- }
171
- return res;
172
- }
173
- //# sourceMappingURL=completion.js.map
@@ -1,4 +0,0 @@
1
- import type * as lst from "vscode-languageserver-types";
2
- import type { DocumentLike } from "../index.js";
3
- import { type SourceFile } from "../types.js";
4
- export declare function hover(doc: DocumentLike, sourceFile: SourceFile, position: lst.Position): lst.Hover | undefined;
@@ -1,142 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hover = hover;
4
- const checker_js_1 = require("../checker.js");
5
- const parser_js_1 = require("../parser.js");
6
- const types_js_1 = require("../types.js");
7
- const common_js_1 = require("./command/common.js");
8
- const util_js_1 = require("./util.js");
9
- function hover(doc, sourceFile, position) {
10
- const offset = doc.offsetAt(position);
11
- const g = sourceFile.graph;
12
- if (!g)
13
- return undefined;
14
- const node = (0, checker_js_1.findNodeAtOffset)(g, offset);
15
- if (node === undefined)
16
- return undefined;
17
- return getNodeHover(doc, sourceFile, node);
18
- }
19
- function getNodeHover(doc, sf, n) {
20
- const contents = getHoverContents(n);
21
- if (contents) {
22
- return {
23
- contents,
24
- range: (0, util_js_1.syntaxNodeToRange)(doc, sf, n),
25
- };
26
- }
27
- return undefined;
28
- }
29
- function getAssignedLabel(statement) {
30
- const assignments = statement.attributes.flatMap(a => a.assignments);
31
- const assignedLabel = assignments === null || assignments === void 0 ? void 0 : assignments.find(a => (0, checker_js_1.getIdentifierText)(a.leftId) === "label");
32
- return (assignedLabel === null || assignedLabel === void 0 ? void 0 : assignedLabel.rightId) ? (0, checker_js_1.getIdentifierText)(assignedLabel.rightId) : undefined;
33
- }
34
- function getHoverContents(n) {
35
- var _a, _b, _c;
36
- if ((0, parser_js_1.isIdentifierNode)(n)) {
37
- const parent = n.parent;
38
- if (parent) {
39
- switch (parent.kind) {
40
- case types_js_1.SyntaxKind.NodeId: {
41
- if ((_a = n.symbol) === null || _a === void 0 ? void 0 : _a.references) {
42
- const nodeIdentifierRefs = (_b = n.symbol) === null || _b === void 0 ? void 0 : _b.references;
43
- const labelMentions = nodeIdentifierRefs.map(e => {
44
- var _a, _b, _c;
45
- return (_c = (_b = (_a = e.symbol) === null || _a === void 0 ? void 0 : _a.members) === null || _b === void 0 ? void 0 : _b.get("label")) === null || _c === void 0 ? void 0 : _c.firstMention.parent;
46
- });
47
- for (let i = labelMentions.length; i >= 0; i--) {
48
- const s = labelMentions[i];
49
- if (s === null || s === void 0 ? void 0 : s.rightId) {
50
- return `(node) ${(0, checker_js_1.getIdentifierText)(n)}: ${(0, checker_js_1.getIdentifierText)(s.rightId)}`;
51
- }
52
- }
53
- }
54
- else if (((_c = parent.parent) === null || _c === void 0 ? void 0 : _c.kind) === types_js_1.SyntaxKind.NodeStatement) {
55
- const label = getAssignedLabel(parent.parent);
56
- if (label) {
57
- return `(node) ${(0, checker_js_1.getIdentifierText)(n)}: ${label}`;
58
- }
59
- }
60
- return `(node) ${(0, checker_js_1.getIdentifierText)(n)}`;
61
- }
62
- case types_js_1.SyntaxKind.Assignment: {
63
- const assignment = parent;
64
- const left = (0, checker_js_1.getIdentifierText)(assignment.leftId);
65
- const right = (0, checker_js_1.getIdentifierText)(assignment.rightId);
66
- return `(assignment) \`${left}\` = \`${right}\``;
67
- }
68
- case types_js_1.SyntaxKind.DirectedGraph:
69
- return getGraphHover(parent);
70
- case types_js_1.SyntaxKind.UndirectedGraph:
71
- return getGraphHover(parent);
72
- case types_js_1.SyntaxKind.SubGraphStatement: {
73
- const sgs = parent;
74
- const sg = sgs.subgraph;
75
- return sg.id ? `(sub graph) ${(0, checker_js_1.getIdentifierText)(sg.id)}` : "(sub graph)";
76
- }
77
- case types_js_1.SyntaxKind.SubGraph: {
78
- const sg = parent;
79
- return sg.id ? `(sub graph) ${(0, checker_js_1.getIdentifierText)(sg.id)}` : "(sub graph)";
80
- }
81
- case types_js_1.SyntaxKind.IdEqualsIdStatement: {
82
- const idEqId = parent;
83
- const left = (0, checker_js_1.getIdentifierText)(idEqId.leftId);
84
- const right = (0, checker_js_1.getIdentifierText)(idEqId.rightId);
85
- return `(graph property) \`${left}\` = \`${right}\``;
86
- }
87
- case types_js_1.SyntaxKind.EdgeRhs:
88
- return getEdgeHover(parent);
89
- }
90
- return types_js_1.SyntaxKind[parent.kind];
91
- }
92
- const fallback = types_js_1.SyntaxKind[n.kind];
93
- return fallback ? `(${fallback.toLowerCase()})` : undefined;
94
- }
95
- switch (n.kind) {
96
- case types_js_1.SyntaxKind.GraphKeyword:
97
- case types_js_1.SyntaxKind.DigraphKeyword:
98
- case types_js_1.SyntaxKind.StrictKeyword:
99
- return getGraphHover(n.parent);
100
- case types_js_1.SyntaxKind.DirectedGraph:
101
- case types_js_1.SyntaxKind.UndirectedGraph:
102
- return getGraphHover(n);
103
- case types_js_1.SyntaxKind.DirectedEdgeOp:
104
- case types_js_1.SyntaxKind.UndirectedEdgeOp:
105
- return getEdgeHover(n.parent);
106
- default:
107
- return undefined;
108
- }
109
- }
110
- function getGraphHover(g) {
111
- const direction = g.kind === types_js_1.SyntaxKind.DirectedGraph ? "directed" : "undirected";
112
- const graphId = g.id;
113
- const strict = g.strict ? "strict " : "";
114
- return graphId
115
- ? `(${strict}${direction} graph) ${(0, checker_js_1.getIdentifierText)(graphId)}`
116
- : `(${strict}${direction} graph)`;
117
- }
118
- function getEdgeHover(n) {
119
- const p = n.parent;
120
- if (!p || p.rhs.length === 0)
121
- return undefined;
122
- let source;
123
- for (const curr of p.rhs) {
124
- if (curr === n)
125
- break;
126
- source = curr.target;
127
- }
128
- if (source === undefined)
129
- source = p.source;
130
- const edgeOpStr = (0, common_js_1.getEdgeStr)(n.operation.kind);
131
- return source === undefined
132
- ? undefined
133
- : `(edge) ${getEdgeSourceOrTargetText(source)} ${edgeOpStr} ${getEdgeSourceOrTargetText(n.target)}`;
134
- }
135
- function getEdgeSourceOrTargetText(n) {
136
- return n.kind === types_js_1.SyntaxKind.NodeId
137
- ? (0, checker_js_1.getIdentifierText)(n.id)
138
- : n.id !== undefined
139
- ? `${(0, checker_js_1.getIdentifierText)(n.id)}`
140
- : "sub graph";
141
- }
142
- //# sourceMappingURL=hover.js.map