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,228 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkSourceFile = checkSourceFile;
4
- exports.findNodeAtOffset = findNodeAtOffset;
5
- exports.getAllowedEdgeOperation = getAllowedEdgeOperation;
6
- exports.findAllEdges = findAllEdges;
7
- exports.findOptionalSemicolons = findOptionalSemicolons;
8
- exports.findAllStatements = findAllStatements;
9
- exports.isAttrStatement = isAttrStatement;
10
- exports.isEdgeStatement = isEdgeStatement;
11
- exports.isSubGraphStatement = isSubGraphStatement;
12
- exports.isGraph = isGraph;
13
- exports.isNodeId = isNodeId;
14
- exports.edgeStatementHasAttributes = edgeStatementHasAttributes;
15
- exports.getIdentifierText = getIdentifierText;
16
- exports.nodeContainsErrors = nodeContainsErrors;
17
- const languageFacts_js_1 = require("./service/languageFacts.js");
18
- const util_js_1 = require("./service/util.js");
19
- const types_js_1 = require("./types.js");
20
- const visitor_js_1 = require("./visitor.js");
21
- function checkSourceFile(file) {
22
- const g = file.graph;
23
- if (g) {
24
- const messages = checkGraphSemantics(file, g);
25
- if (messages) {
26
- file.diagnostics.push.apply(file.diagnostics, messages);
27
- }
28
- }
29
- }
30
- function getNarrowerNode(offset, prev, toCheck) {
31
- const prevRange = prev.end - prev.pos;
32
- if (toCheck.pos <= offset && offset <= toCheck.end) {
33
- const nrange = toCheck.end - toCheck.pos;
34
- if (nrange < prevRange) {
35
- return toCheck;
36
- }
37
- }
38
- return prev;
39
- }
40
- function rangeContainsOffset(range, offset, inclusiveEnd) {
41
- return inclusiveEnd
42
- ? range.pos <= offset && offset <= range.end
43
- : range.pos <= offset && offset < range.end;
44
- }
45
- function findNodeAtOffset(root, offset, inclusiveEnd = false) {
46
- if (root.pos === offset && root.pos === root.end)
47
- return root;
48
- if (rangeContainsOffset(root, offset, inclusiveEnd)) {
49
- const narrowerChild = (0, visitor_js_1.forEachChild)(root, child => findNodeAtOffset(child, offset, inclusiveEnd));
50
- return narrowerChild ? narrowerChild : root;
51
- }
52
- return undefined;
53
- }
54
- function getAllowedEdgeOperation(graph) {
55
- return graph.kind === types_js_1.SyntaxKind.DirectedGraph
56
- ? types_js_1.SyntaxKind.DirectedEdgeOp
57
- : types_js_1.SyntaxKind.UndirectedEdgeOp;
58
- }
59
- function checkGraphSemantics(file, root) {
60
- const expectedEdgeOp = getAllowedEdgeOperation(root);
61
- const invalidEdgeRhses = findEdgeErrors(expectedEdgeOp, root);
62
- const invalidShapes = checkShapeLabelValues(root);
63
- const invalidEdgeDiagnostics = invalidEdgeRhses === undefined || invalidEdgeRhses.length === 0
64
- ? []
65
- : createEdgeViolationDiagnostics(file, expectedEdgeOp, invalidEdgeRhses);
66
- return [...invalidEdgeDiagnostics, ...invalidShapes];
67
- }
68
- function forEachAssignmentTransitive(root, cb) {
69
- (0, visitor_js_1.forEachChild)(root, child => {
70
- if (child.kind === types_js_1.SyntaxKind.Assignment) {
71
- cb(child);
72
- return;
73
- }
74
- (0, visitor_js_1.forEachChild)(child, c => forEachAssignmentTransitive(c, cb));
75
- });
76
- }
77
- function checkShapeLabelValues(root) {
78
- const invalidShapes = [];
79
- forEachAssignmentTransitive(root, assignment => {
80
- const { leftId, rightId } = assignment;
81
- if (leftId.kind !== types_js_1.SyntaxKind.TextIdentifier ||
82
- rightId.kind !== types_js_1.SyntaxKind.TextIdentifier) {
83
- return;
84
- }
85
- const leftText = leftId.text.trim();
86
- if (leftText.toLocaleLowerCase() !== "shape") {
87
- return;
88
- }
89
- const rightText = rightId.text.trim();
90
- const shapeCandidate = rightText.toLowerCase();
91
- if (languageFacts_js_1.shapes.includes(shapeCandidate)) {
92
- return;
93
- }
94
- invalidShapes.push({
95
- category: types_js_1.DiagnosticCategory.Warning,
96
- code: createCheckerError(1),
97
- message: `Unknown shape "${rightText}".`,
98
- start: rightId.pos,
99
- end: rightId.end,
100
- });
101
- });
102
- return invalidShapes;
103
- }
104
- function findAllEdges(node) {
105
- const allEdges = [];
106
- (0, visitor_js_1.forEachChild)(node, child => {
107
- if (isEdgeStatement(child)) {
108
- if (child.rhs && child.rhs.length > 0) {
109
- for (const edgeRhs of child.rhs)
110
- allEdges.push(edgeRhs);
111
- }
112
- }
113
- const childEdges = findAllEdges(child);
114
- if (childEdges && childEdges.length > 0)
115
- allEdges.push.apply(allEdges, childEdges);
116
- });
117
- return allEdges;
118
- }
119
- function findOptionalSemicolons(node) {
120
- const statements = findAllStatements(node);
121
- const terminators = statements.map(p => p.terminator);
122
- return terminators.filter(t => !!t);
123
- }
124
- function isStatement(node) {
125
- return (node.kind === types_js_1.SyntaxKind.SubGraphStatement ||
126
- node.kind === types_js_1.SyntaxKind.EdgeStatement ||
127
- node.kind === types_js_1.SyntaxKind.NodeStatement ||
128
- node.kind === types_js_1.SyntaxKind.IdEqualsIdStatement ||
129
- node.kind === types_js_1.SyntaxKind.AttributeStatement);
130
- }
131
- function findAllStatements(node, kind) {
132
- const allStatements = [];
133
- (0, visitor_js_1.forEachChild)(node, child => {
134
- if ((kind === undefined && isStatement(child)) || child.kind === kind) {
135
- allStatements.push(child);
136
- }
137
- const childStatements = findAllStatements(child, kind);
138
- if (childStatements && childStatements.length > 0)
139
- allStatements.push.apply(allStatements, childStatements);
140
- });
141
- return allStatements;
142
- }
143
- function findEdgeErrors(expectedEdgeOp, node) {
144
- const edges = findAllEdges(node);
145
- const wrongEdges = edges && edges.length > 0
146
- ? edges.filter(e => e.operation.kind !== expectedEdgeOp)
147
- : undefined;
148
- if (wrongEdges && wrongEdges.length > 0) {
149
- for (const edge of wrongEdges) {
150
- edge.operation.flags |= 2;
151
- }
152
- return wrongEdges;
153
- }
154
- return undefined;
155
- }
156
- function createEdgeViolationDiagnostics(file, expectedEdgeOp, violators) {
157
- const op = expectedEdgeOp === types_js_1.SyntaxKind.UndirectedEdgeOp ? "--" : "->";
158
- const graphType = expectedEdgeOp === types_js_1.SyntaxKind.UndirectedEdgeOp ? "undirected" : "directed";
159
- const message = `Invalid edge operation, use "${op}" in ${graphType} graph`;
160
- const code = createCheckerError(0);
161
- const category = types_js_1.DiagnosticCategory.Error;
162
- for (const edge of violators) {
163
- edge.operation.flags |= 2;
164
- }
165
- return violators.map(edge => {
166
- const start = (0, util_js_1.getStart)(file, edge.operation);
167
- const end = edge.operation.end;
168
- return {
169
- message,
170
- code,
171
- category,
172
- start,
173
- end,
174
- };
175
- });
176
- }
177
- function getInvalidEdgeRhs(allowedOp, edges) {
178
- const res = [];
179
- for (const e of edges) {
180
- if (e.operation.kind !== allowedOp)
181
- res.push(e);
182
- }
183
- return res;
184
- }
185
- function isAttrStatement(node) {
186
- return node.kind === types_js_1.SyntaxKind.AttributeStatement;
187
- }
188
- function isEdgeStatement(node) {
189
- return node.kind === types_js_1.SyntaxKind.EdgeStatement;
190
- }
191
- function isSubGraphStatement(node) {
192
- return node.kind === types_js_1.SyntaxKind.SubGraphStatement;
193
- }
194
- function isGraph(node) {
195
- return node.kind === types_js_1.SyntaxKind.DirectedGraph || node.kind === types_js_1.SyntaxKind.UndirectedGraph;
196
- }
197
- function isNodeId(node) {
198
- return node.kind === types_js_1.SyntaxKind.NodeId;
199
- }
200
- function edgeStatementHasAttributes(es) {
201
- return (es.attributes &&
202
- es.attributes.length > 0 &&
203
- es.attributes.some(a => a.assignments && a.assignments.length > 0));
204
- }
205
- function getIdentifierText(n) {
206
- switch (n.kind) {
207
- case types_js_1.SyntaxKind.HtmlIdentifier:
208
- return n.htmlContent;
209
- case types_js_1.SyntaxKind.TextIdentifier:
210
- return n.text;
211
- case types_js_1.SyntaxKind.NumericIdentifier:
212
- return n.text;
213
- case types_js_1.SyntaxKind.QuotedTextIdentifier:
214
- return n.concatenation;
215
- default:
216
- return (0, util_js_1.assertNever)(n);
217
- }
218
- }
219
- function createCheckerError(sub) {
220
- return {
221
- source: 4,
222
- sub,
223
- };
224
- }
225
- function nodeContainsErrors(node) {
226
- return (node.flags & 2) === 2;
227
- }
228
- //# sourceMappingURL=checker.js.map
package/lib/cjs/core.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function createMapFromTemplate<T>(template: Record<string, T>): Map<string, T>;
package/lib/cjs/core.js DELETED
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createMapFromTemplate = createMapFromTemplate;
4
- function createMapFromTemplate(template) {
5
- const map = new Map();
6
- for (const key in template) {
7
- if (key in template) {
8
- map.set(key, template[key]);
9
- }
10
- }
11
- return map;
12
- }
13
- //# sourceMappingURL=core.js.map
@@ -1,3 +0,0 @@
1
- import type { ErrorCode } from "./types.js";
2
- export declare const diagnosicSource = "DOT";
3
- export declare function formatError(error: ErrorCode): string;
package/lib/cjs/error.js DELETED
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.diagnosicSource = void 0;
4
- exports.formatError = formatError;
5
- exports.diagnosicSource = "DOT";
6
- const errorCodeLength = 4;
7
- const subErrorCodeLength = errorCodeLength - 1;
8
- function formatError(error) {
9
- const subCode = (error.sub | 0).toString().padStart(subErrorCodeLength, "0");
10
- return exports.diagnosicSource + error.source + subCode;
11
- }
12
- //# sourceMappingURL=error.js.map
@@ -1,5 +0,0 @@
1
- export * from "./parser.js";
2
- export * from "./scanner.js";
3
- export * from "./service/service.js";
4
- export * from "./types.js";
5
- export * from "./visitor.js";
package/lib/cjs/index.js DELETED
@@ -1,22 +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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./parser.js"), exports);
18
- __exportStar(require("./scanner.js"), exports);
19
- __exportStar(require("./service/service.js"), exports);
20
- __exportStar(require("./types.js"), exports);
21
- __exportStar(require("./visitor.js"), exports);
22
- //# sourceMappingURL=index.js.map
@@ -1,27 +0,0 @@
1
- import { type Scanner } from "./scanner.js";
2
- import { type DiagnosticMessage, type Identifier, type SourceFile, SyntaxKind, type SyntaxNode } from "./types";
3
- export declare enum ParsingContext {
4
- None = 0,
5
- StatementList = 1,
6
- AttributeContainerList = 2,
7
- AssignmentList = 3,
8
- EdgeRhsList = 4,
9
- QuotedTextIdentifierConcatenation = 5,
10
- Count = 6
11
- }
12
- export declare class Parser {
13
- #private;
14
- currentToken: SyntaxKind;
15
- nodeCount: number;
16
- identifiers: Set<string>;
17
- identifierCount: number;
18
- sourceText: string;
19
- scanner: Scanner;
20
- currentNodeHasError: boolean;
21
- currentContext: ParsingContext;
22
- diagnostics: DiagnosticMessage[];
23
- constructor();
24
- parse(sourceText: string): SourceFile;
25
- }
26
- export declare function isIdentifier(kind: SyntaxKind): kind is SyntaxKind.HtmlIdentifier | SyntaxKind.TextIdentifier | SyntaxKind.QuotedTextIdentifier | SyntaxKind.NumericIdentifier;
27
- export declare function isIdentifierNode(node: SyntaxNode): node is Identifier;