dot-language-support 2.2.2 → 2.2.4

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 +5 -2
  2. package/.github/workflows/CI.yml +5 -2
  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 +45 -39
  17. package/lib/cjs/service/colorProvider.d.ts +3 -3
  18. package/lib/cjs/service/colorProvider.js +30 -31
  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 +22 -15
  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 +34 -25
  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,7 +1,7 @@
1
- import { SyntaxKind, DiagnosticCategory, } from "./types.js";
1
+ import { shapes as validShapes } from "./service/languageFacts.js";
2
2
  import { assertNever, getStart } from "./service/util.js";
3
+ import { DiagnosticCategory, SyntaxKind, } from "./types.js";
3
4
  import { forEachChild } from "./visitor.js";
4
- import { shapes as validShapes } from "./service/languageFacts.js";
5
5
  export function checkSourceFile(file) {
6
6
  const g = file.graph;
7
7
  if (g) {
@@ -14,7 +14,7 @@ export function checkSourceFile(file) {
14
14
  function getNarrowerNode(offset, prev, toCheck) {
15
15
  const prevRange = prev.end - prev.pos;
16
16
  if (toCheck.pos <= offset && offset <= toCheck.end) {
17
- let nrange = toCheck.end - toCheck.pos;
17
+ const nrange = toCheck.end - toCheck.pos;
18
18
  if (nrange < prevRange) {
19
19
  return toCheck;
20
20
  }
@@ -44,7 +44,7 @@ function checkGraphSemantics(file, root) {
44
44
  const expectedEdgeOp = getAllowedEdgeOperation(root);
45
45
  const invalidEdgeRhses = findEdgeErrors(expectedEdgeOp, root);
46
46
  const invalidShapes = checkShapeLabelValues(root);
47
- const invalidEdgeDiagnostics = invalidEdgeRhses == undefined || invalidEdgeRhses.length === 0
47
+ const invalidEdgeDiagnostics = invalidEdgeRhses === undefined || invalidEdgeRhses.length === 0
48
48
  ? []
49
49
  : createEdgeViolationDiagnostics(file, expectedEdgeOp, invalidEdgeRhses);
50
50
  return [...invalidEdgeDiagnostics, ...invalidShapes];
@@ -62,7 +62,8 @@ function checkShapeLabelValues(root) {
62
62
  const invalidShapes = [];
63
63
  forEachAssignmentTransitive(root, assignment => {
64
64
  const { leftId, rightId } = assignment;
65
- if (leftId.kind !== SyntaxKind.TextIdentifier || rightId.kind !== SyntaxKind.TextIdentifier) {
65
+ if (leftId.kind !== SyntaxKind.TextIdentifier ||
66
+ rightId.kind !== SyntaxKind.TextIdentifier) {
66
67
  return;
67
68
  }
68
69
  const leftText = leftId.text.trim();
@@ -105,16 +106,16 @@ export function findOptionalSemicolons(node) {
105
106
  return terminators.filter(t => !!t);
106
107
  }
107
108
  function isStatement(node) {
108
- return node.kind === SyntaxKind.SubGraphStatement
109
- || node.kind === SyntaxKind.EdgeStatement
110
- || node.kind === SyntaxKind.NodeStatement
111
- || node.kind === SyntaxKind.IdEqualsIdStatement
112
- || node.kind === SyntaxKind.AttributeStatement;
109
+ return (node.kind === SyntaxKind.SubGraphStatement ||
110
+ node.kind === SyntaxKind.EdgeStatement ||
111
+ node.kind === SyntaxKind.NodeStatement ||
112
+ node.kind === SyntaxKind.IdEqualsIdStatement ||
113
+ node.kind === SyntaxKind.AttributeStatement);
113
114
  }
114
115
  export function findAllStatements(node, kind) {
115
116
  const allStatements = [];
116
117
  forEachChild(node, child => {
117
- if ((kind === undefined && isStatement(child)) || (child.kind === kind)) {
118
+ if ((kind === undefined && isStatement(child)) || child.kind === kind) {
118
119
  allStatements.push(child);
119
120
  }
120
121
  const childStatements = findAllStatements(child, kind);
@@ -129,7 +130,9 @@ function findEdgeErrors(expectedEdgeOp, node) {
129
130
  ? edges.filter(e => e.operation.kind !== expectedEdgeOp)
130
131
  : undefined;
131
132
  if (wrongEdges && wrongEdges.length > 0) {
132
- wrongEdges.forEach(e => e.operation.flags |= 2);
133
+ for (const edge of wrongEdges) {
134
+ edge.operation.flags |= 2;
135
+ }
133
136
  return wrongEdges;
134
137
  }
135
138
  return undefined;
@@ -140,7 +143,9 @@ function createEdgeViolationDiagnostics(file, expectedEdgeOp, violators) {
140
143
  const message = `Invalid edge operation, use "${op}" in ${graphType} graph`;
141
144
  const code = createCheckerError(0);
142
145
  const category = DiagnosticCategory.Error;
143
- violators.forEach(edge => edge.operation.flags |= 2);
146
+ for (const edge of violators) {
147
+ edge.operation.flags |= 2;
148
+ }
144
149
  return violators.map(edge => {
145
150
  const start = getStart(file, edge.operation);
146
151
  const end = edge.operation.end;
@@ -177,9 +182,9 @@ export function isNodeId(node) {
177
182
  return node.kind === SyntaxKind.NodeId;
178
183
  }
179
184
  export function edgeStatementHasAttributes(es) {
180
- return es.attributes
181
- && es.attributes.length > 0
182
- && es.attributes.some(a => a.assignments && a.assignments.length > 0);
185
+ return (es.attributes &&
186
+ es.attributes.length > 0 &&
187
+ es.attributes.some(a => a.assignments && a.assignments.length > 0));
183
188
  }
184
189
  export function getIdentifierText(n) {
185
190
  switch (n.kind) {
package/lib/esm/core.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export function createMapFromTemplate(template) {
2
2
  const map = new Map();
3
3
  for (const key in template) {
4
- if (template.hasOwnProperty(key)) {
4
+ if (key in template) {
5
5
  map.set(key, template[key]);
6
6
  }
7
7
  }
package/lib/esm/error.js CHANGED
@@ -2,9 +2,7 @@ export const diagnosicSource = "DOT";
2
2
  const errorCodeLength = 4;
3
3
  const subErrorCodeLength = errorCodeLength - 1;
4
4
  export function formatError(error) {
5
- const subCode = (error.sub | 0)
6
- .toString()
7
- .padStart(subErrorCodeLength, "0");
5
+ const subCode = (error.sub | 0).toString().padStart(subErrorCodeLength, "0");
8
6
  return diagnosicSource + error.source + subCode;
9
7
  }
10
8
  //# sourceMappingURL=error.js.map
@@ -1,5 +1,5 @@
1
- import { Scanner } from "./scanner.js";
2
- import { SyntaxKind, SourceFile, Identifier, SyntaxNode, DiagnosticMessage } from "./types";
1
+ import { type Scanner } from "./scanner.js";
2
+ import { type DiagnosticMessage, type Identifier, type SourceFile, SyntaxKind, type SyntaxNode } from "./types";
3
3
  export declare enum ParsingContext {
4
4
  None = 0,
5
5
  StatementList = 1,
@@ -10,6 +10,7 @@ export declare enum ParsingContext {
10
10
  Count = 6
11
11
  }
12
12
  export declare class Parser {
13
+ #private;
13
14
  currentToken: SyntaxKind;
14
15
  nodeCount: number;
15
16
  identifiers: Set<string>;
@@ -20,65 +21,7 @@ export declare class Parser {
20
21
  currentContext: ParsingContext;
21
22
  diagnostics: DiagnosticMessage[];
22
23
  constructor();
23
- private resetState;
24
- private nextToken;
25
- private token;
26
- private getLinesFromFile;
27
24
  parse(sourceText: string): SourceFile;
28
- private parseGraph;
29
- private parseIdentifier;
30
- private registerIdentifier;
31
- private parseTextIdentifier;
32
- private parseQuotedTextIdentifierConcatenation;
33
- private parseQuotedTextIdentifier;
34
- private isQuotedStringFollowing;
35
- private parseHtmlIdentifier;
36
- private parseNumericIdentifier;
37
- private parseStatement;
38
- private parseAttributeStatement;
39
- private parseAttributeContainer;
40
- private isAssignmentStart;
41
- private parseIdEqualsIdStatement;
42
- private isIdEqualsIdStatement;
43
- private parseNodeStatement;
44
- private parseEdgeStatement;
45
- private parseEdgeRhs;
46
- private createMissingNode;
47
- private parseAssignment;
48
- private parseSubGraph;
49
- private parseNodeId;
50
- private parseCompassPortDeclaration;
51
- private parseNormalPortDeclaration;
52
- private parsePortDeclaration;
53
- private isCompassPort;
54
- private parseList;
55
- private getContextParseError;
56
- private isInSomeParsingContext;
57
- private abortListParsing;
58
- private isListElement;
59
- private isListTerminator;
60
- private createEmptyArray;
61
- private finishNode;
62
- private createNode;
63
- private createNodeArray;
64
- private parseTokenNode;
65
- private getLastError;
66
- private parseErrorAtPosition;
67
- private parseErrorAtCurrentToken;
68
- private scanError;
69
- private reportExpectedError;
70
- private parseExpectedOneOf;
71
- private parseExpectedTokenOneOf;
72
- private parseExpectedToken;
73
- private parseExpected;
74
- private parseOptionalToken;
75
- private parseOptional;
76
- private isEdgeOp;
77
- private isIdentifier;
78
- private isCompassPortKind;
79
- private speculationHelper;
80
- private lookAhead;
81
- private tryParse;
82
25
  }
83
- export declare function isIdentifier(kind: SyntaxKind): boolean;
26
+ export declare function isIdentifier(kind: SyntaxKind): kind is SyntaxKind.HtmlIdentifier | SyntaxKind.TextIdentifier | SyntaxKind.QuotedTextIdentifier | SyntaxKind.NumericIdentifier;
84
27
  export declare function isIdentifierNode(node: SyntaxNode): node is Identifier;