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.
- package/.github/workflows/CD.yml +5 -2
- package/.github/workflows/CI.yml +5 -2
- package/.github/workflows/auto-merge.yaml +1 -1
- package/biome.json +50 -0
- package/lib/cjs/binder.d.ts +1 -1
- package/lib/cjs/binder.js +2 -5
- package/lib/cjs/checker.d.ts +1 -1
- package/lib/cjs/checker.js +34 -30
- package/lib/cjs/core.js +2 -3
- package/lib/cjs/error.js +3 -5
- package/lib/cjs/parser.d.ts +4 -61
- package/lib/cjs/parser.js +580 -616
- package/lib/cjs/scanner.d.ts +2 -13
- package/lib/cjs/scanner.js +316 -317
- package/lib/cjs/service/codeAction.d.ts +3 -3
- package/lib/cjs/service/codeAction.js +45 -39
- package/lib/cjs/service/colorProvider.d.ts +3 -3
- package/lib/cjs/service/colorProvider.js +30 -31
- package/lib/cjs/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.d.ts +4 -4
- package/lib/cjs/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.js +5 -6
- package/lib/cjs/service/command/ChangeEdgeOpCommand.d.ts +3 -3
- package/lib/cjs/service/command/ChangeEdgeOpCommand.js +22 -15
- package/lib/cjs/service/command/ConsolidateDescendantsCommand.d.ts +4 -4
- package/lib/cjs/service/command/ConsolidateDescendantsCommand.js +12 -13
- package/lib/cjs/service/command/RemoveSemicolons.d.ts +4 -4
- package/lib/cjs/service/command/RemoveSemicolons.js +8 -11
- package/lib/cjs/service/command/common.d.ts +4 -4
- package/lib/cjs/service/command/common.js +12 -10
- package/lib/cjs/service/completion.d.ts +2 -2
- package/lib/cjs/service/completion.js +34 -25
- package/lib/cjs/service/hover.d.ts +2 -2
- package/lib/cjs/service/hover.js +12 -16
- package/lib/cjs/service/languageFacts.js +1 -6
- package/lib/cjs/service/reference.d.ts +2 -2
- package/lib/cjs/service/reference.js +4 -8
- package/lib/cjs/service/rename.d.ts +3 -3
- package/lib/cjs/service/rename.js +10 -8
- package/lib/cjs/service/service.d.ts +3 -3
- package/lib/cjs/service/service.js +7 -8
- package/lib/cjs/service/util.d.ts +1 -1
- package/lib/cjs/service/util.js +10 -13
- package/lib/cjs/service/validation.d.ts +3 -3
- package/lib/cjs/service/validation.js +1 -2
- package/lib/cjs/tester.js +1 -1
- package/lib/cjs/visitor.d.ts +1 -1
- package/lib/cjs/visitor.js +32 -34
- package/lib/esm/binder.d.ts +1 -1
- package/lib/esm/binder.js +1 -3
- package/lib/esm/checker.d.ts +1 -1
- package/lib/esm/checker.js +21 -16
- package/lib/esm/core.js +1 -1
- package/lib/esm/error.js +1 -3
- package/lib/esm/parser.d.ts +4 -61
- package/lib/esm/parser.js +320 -306
- package/lib/esm/scanner.d.ts +2 -13
- package/lib/esm/scanner.js +153 -152
- package/lib/esm/service/codeAction.d.ts +3 -3
- package/lib/esm/service/codeAction.js +26 -29
- package/lib/esm/service/colorProvider.d.ts +3 -3
- package/lib/esm/service/colorProvider.js +11 -21
- package/lib/esm/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.d.ts +4 -4
- package/lib/esm/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.js +4 -4
- package/lib/esm/service/command/ChangeEdgeOpCommand.d.ts +3 -3
- package/lib/esm/service/command/ChangeEdgeOpCommand.js +3 -5
- package/lib/esm/service/command/ConsolidateDescendantsCommand.d.ts +4 -4
- package/lib/esm/service/command/ConsolidateDescendantsCommand.js +11 -11
- package/lib/esm/service/command/RemoveSemicolons.d.ts +4 -4
- package/lib/esm/service/command/RemoveSemicolons.js +6 -8
- package/lib/esm/service/command/common.d.ts +4 -4
- package/lib/esm/service/command/common.js +7 -4
- package/lib/esm/service/completion.d.ts +2 -2
- package/lib/esm/service/completion.js +16 -16
- package/lib/esm/service/hover.d.ts +2 -2
- package/lib/esm/service/hover.js +8 -14
- package/lib/esm/service/languageFacts.js +1 -6
- package/lib/esm/service/reference.d.ts +2 -2
- package/lib/esm/service/reference.js +3 -6
- package/lib/esm/service/rename.d.ts +3 -3
- package/lib/esm/service/rename.js +9 -6
- package/lib/esm/service/service.d.ts +3 -3
- package/lib/esm/service/service.js +7 -7
- package/lib/esm/service/util.d.ts +1 -1
- package/lib/esm/service/util.js +5 -7
- package/lib/esm/service/validation.d.ts +3 -3
- package/lib/esm/service/validation.js +1 -1
- package/lib/esm/tester.js +1 -1
- package/lib/esm/visitor.d.ts +1 -1
- package/lib/esm/visitor.js +32 -33
- package/package.json +15 -10
package/lib/esm/checker.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
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
|
|
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 ||
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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)) ||
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
182
|
-
|
|
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
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
|
package/lib/esm/parser.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Scanner } from "./scanner.js";
|
|
2
|
-
import {
|
|
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):
|
|
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;
|