dot-language-support 1.7.0 → 2.0.3
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 +3 -3
- package/.github/workflows/CI.yml +2 -2
- package/README.md +5 -4
- package/jest.config.mjs +19 -0
- package/lib/{binder.d.ts → cjs/binder.d.ts} +1 -1
- package/lib/{binder.js → cjs/binder.js} +34 -34
- package/lib/{checker.d.ts → cjs/checker.d.ts} +1 -1
- package/lib/{checker.js → cjs/checker.js} +28 -28
- package/lib/{core.d.ts → cjs/core.d.ts} +0 -0
- package/lib/{core.js → cjs/core.js} +0 -0
- package/lib/{error.d.ts → cjs/error.d.ts} +1 -1
- package/lib/{error.js → cjs/error.js} +0 -0
- package/lib/cjs/index.d.ts +5 -0
- package/lib/{index.js → cjs/index.js} +5 -5
- package/lib/{parser.d.ts → cjs/parser.d.ts} +1 -1
- package/lib/{parser.js → cjs/parser.js} +11 -11
- package/lib/{scanner.d.ts → cjs/scanner.d.ts} +1 -1
- package/lib/{scanner.js → cjs/scanner.js} +67 -67
- package/lib/{service → cjs/service}/codeAction.d.ts +2 -2
- package/lib/{service → cjs/service}/codeAction.js +34 -34
- package/lib/cjs/service/colorProvider.d.ts +5 -0
- package/lib/{service → cjs/service}/colorProvider.js +7 -12
- package/lib/{service → cjs/service}/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.d.ts +3 -3
- package/lib/{service → cjs/service}/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.js +6 -6
- package/lib/{service → cjs/service}/command/ChangeEdgeOpCommand.d.ts +3 -3
- package/lib/{service → cjs/service}/command/ChangeEdgeOpCommand.js +3 -3
- package/lib/{service → cjs/service}/command/ConsolidateDescendantsCommand.d.ts +3 -3
- package/lib/{service → cjs/service}/command/ConsolidateDescendantsCommand.js +7 -7
- package/lib/{service → cjs/service}/command/RemoveSemicolons.d.ts +3 -3
- package/lib/{service → cjs/service}/command/RemoveSemicolons.js +4 -4
- package/lib/{service → cjs/service}/command/common.d.ts +2 -2
- package/lib/{service → cjs/service}/command/common.js +6 -6
- package/lib/{service → cjs/service}/completion.d.ts +2 -2
- package/lib/{service → cjs/service}/completion.js +25 -25
- package/lib/{service → cjs/service}/hover.d.ts +2 -2
- package/lib/{service → cjs/service}/hover.js +38 -38
- package/lib/{service → cjs/service}/languageFacts.d.ts +0 -0
- package/lib/{service → cjs/service}/languageFacts.js +0 -0
- package/lib/{service → cjs/service}/reference.d.ts +2 -2
- package/lib/{service → cjs/service}/reference.js +9 -9
- package/lib/{service → cjs/service}/rename.d.ts +2 -2
- package/lib/{service → cjs/service}/rename.js +11 -11
- package/lib/{service → cjs/service}/service.d.ts +2 -2
- package/lib/cjs/service/service.js +39 -0
- package/lib/{service → cjs/service}/util.d.ts +2 -2
- package/lib/{service → cjs/service}/util.js +5 -5
- package/lib/{service → cjs/service}/validation.d.ts +2 -2
- package/lib/{service → cjs/service}/validation.js +3 -3
- package/lib/cjs/tester.d.ts +1 -0
- package/lib/cjs/tester.js +23 -0
- package/lib/{types.d.ts → cjs/types.d.ts} +0 -0
- package/lib/{types.js → cjs/types.js} +0 -0
- package/lib/{visitor.d.ts → cjs/visitor.d.ts} +1 -1
- package/lib/{visitor.js → cjs/visitor.js} +17 -17
- package/lib/esm/binder.d.ts +2 -0
- package/lib/esm/binder.js +296 -0
- package/lib/esm/checker.d.ts +14 -0
- package/lib/esm/checker.js +169 -0
- package/lib/esm/core.d.ts +1 -0
- package/lib/esm/core.js +10 -0
- package/lib/esm/error.d.ts +3 -0
- package/lib/esm/error.js +10 -0
- package/lib/esm/index.d.ts +5 -0
- package/lib/esm/index.js +6 -0
- package/lib/esm/parser.d.ts +84 -0
- package/lib/esm/parser.js +700 -0
- package/lib/esm/scanner.d.ts +52 -0
- package/lib/esm/scanner.js +581 -0
- package/lib/esm/service/codeAction.d.ts +12 -0
- package/lib/esm/service/codeAction.js +208 -0
- package/lib/esm/service/colorProvider.d.ts +5 -0
- package/lib/esm/service/colorProvider.js +64 -0
- package/lib/esm/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.d.ts +10 -0
- package/lib/esm/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.js +38 -0
- package/lib/esm/service/command/ChangeEdgeOpCommand.d.ts +10 -0
- package/lib/esm/service/command/ChangeEdgeOpCommand.js +32 -0
- package/lib/esm/service/command/ConsolidateDescendantsCommand.d.ts +10 -0
- package/lib/esm/service/command/ConsolidateDescendantsCommand.js +83 -0
- package/lib/esm/service/command/RemoveSemicolons.d.ts +10 -0
- package/lib/esm/service/command/RemoveSemicolons.js +37 -0
- package/lib/esm/service/command/common.d.ts +31 -0
- package/lib/esm/service/command/common.js +22 -0
- package/lib/esm/service/completion.d.ts +4 -0
- package/lib/esm/service/completion.js +137 -0
- package/lib/esm/service/hover.d.ts +4 -0
- package/lib/esm/service/hover.js +119 -0
- package/lib/esm/service/languageFacts.d.ts +683 -0
- package/lib/esm/service/languageFacts.js +997 -0
- package/lib/esm/service/reference.d.ts +5 -0
- package/lib/esm/service/reference.js +66 -0
- package/lib/esm/service/rename.d.ts +4 -0
- package/lib/esm/service/rename.js +45 -0
- package/lib/esm/service/service.d.ts +28 -0
- package/lib/esm/service/service.js +35 -0
- package/lib/esm/service/util.d.ts +11 -0
- package/lib/esm/service/util.js +44 -0
- package/lib/esm/service/validation.d.ts +4 -0
- package/lib/esm/service/validation.js +20 -0
- package/lib/esm/tester.d.ts +1 -0
- package/lib/esm/tester.js +21 -0
- package/lib/esm/types.d.ts +396 -0
- package/lib/esm/types.js +71 -0
- package/lib/esm/visitor.d.ts +2 -0
- package/lib/esm/visitor.js +74 -0
- package/package.json +14 -12
- package/lib/index.d.ts +0 -5
- package/lib/service/colorProvider.d.ts +0 -6
- package/lib/service/polyfill.d.ts +0 -16
- package/lib/service/polyfill.js +0 -3
- package/lib/service/service.js +0 -39
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isLineBreak = exports.skipTrivia = exports.isIdentifierStart = exports.DefaultScanner = exports.getTextAsToken = exports.getTokenAsText = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const textToToken = (0,
|
|
8
|
-
"digraph":
|
|
9
|
-
"graph":
|
|
10
|
-
"edge":
|
|
11
|
-
"node":
|
|
12
|
-
"strict":
|
|
13
|
-
"subgraph":
|
|
14
|
-
"n":
|
|
15
|
-
"ne":
|
|
16
|
-
"e":
|
|
17
|
-
"se":
|
|
18
|
-
"s":
|
|
19
|
-
"sw":
|
|
20
|
-
"w":
|
|
21
|
-
"nw":
|
|
22
|
-
"c":
|
|
23
|
-
"+":
|
|
24
|
-
"=":
|
|
25
|
-
"->":
|
|
26
|
-
"--":
|
|
27
|
-
"{":
|
|
28
|
-
"}":
|
|
29
|
-
"[":
|
|
30
|
-
"]":
|
|
31
|
-
";":
|
|
32
|
-
":":
|
|
33
|
-
"_":
|
|
34
|
-
",":
|
|
35
|
-
"<":
|
|
36
|
-
">":
|
|
4
|
+
const core_js_1 = require("./core.js");
|
|
5
|
+
const types_js_1 = require("./types.js");
|
|
6
|
+
const util_js_1 = require("./service/util.js");
|
|
7
|
+
const textToToken = (0, core_js_1.createMapFromTemplate)({
|
|
8
|
+
"digraph": types_js_1.SyntaxKind.DigraphKeyword,
|
|
9
|
+
"graph": types_js_1.SyntaxKind.GraphKeyword,
|
|
10
|
+
"edge": types_js_1.SyntaxKind.EdgeKeyword,
|
|
11
|
+
"node": types_js_1.SyntaxKind.NodeKeyword,
|
|
12
|
+
"strict": types_js_1.SyntaxKind.StrictKeyword,
|
|
13
|
+
"subgraph": types_js_1.SyntaxKind.SubgraphKeyword,
|
|
14
|
+
"n": types_js_1.SyntaxKind.CompassNorthToken,
|
|
15
|
+
"ne": types_js_1.SyntaxKind.CompassNorthEastToken,
|
|
16
|
+
"e": types_js_1.SyntaxKind.CompassEastToken,
|
|
17
|
+
"se": types_js_1.SyntaxKind.CompassSouthEastToken,
|
|
18
|
+
"s": types_js_1.SyntaxKind.CompassSouthToken,
|
|
19
|
+
"sw": types_js_1.SyntaxKind.CompassSouthWestToken,
|
|
20
|
+
"w": types_js_1.SyntaxKind.CompassWestToken,
|
|
21
|
+
"nw": types_js_1.SyntaxKind.CompassNorthWestToken,
|
|
22
|
+
"c": types_js_1.SyntaxKind.CompassCenterToken,
|
|
23
|
+
"+": types_js_1.SyntaxKind.PlusToken,
|
|
24
|
+
"=": types_js_1.SyntaxKind.EqualsToken,
|
|
25
|
+
"->": types_js_1.SyntaxKind.DirectedEdgeOp,
|
|
26
|
+
"--": types_js_1.SyntaxKind.UndirectedEdgeOp,
|
|
27
|
+
"{": types_js_1.SyntaxKind.OpenBraceToken,
|
|
28
|
+
"}": types_js_1.SyntaxKind.CloseBraceToken,
|
|
29
|
+
"[": types_js_1.SyntaxKind.OpenBracketToken,
|
|
30
|
+
"]": types_js_1.SyntaxKind.CloseBracketToken,
|
|
31
|
+
";": types_js_1.SyntaxKind.SemicolonToken,
|
|
32
|
+
":": types_js_1.SyntaxKind.ColonToken,
|
|
33
|
+
"_": types_js_1.SyntaxKind.UnderscoreToken,
|
|
34
|
+
",": types_js_1.SyntaxKind.CommaToken,
|
|
35
|
+
"<": types_js_1.SyntaxKind.LessThan,
|
|
36
|
+
">": types_js_1.SyntaxKind.GreaterThan,
|
|
37
37
|
});
|
|
38
38
|
function makeReverseMap(source) {
|
|
39
39
|
const result = new Map();
|
|
@@ -65,7 +65,7 @@ class DefaultScanner {
|
|
|
65
65
|
this.pos = textPos;
|
|
66
66
|
this.startPos = textPos;
|
|
67
67
|
this.tokenPos = textPos;
|
|
68
|
-
this.token =
|
|
68
|
+
this.token = types_js_1.SyntaxKind.Unknown;
|
|
69
69
|
this.tokenValue = undefined;
|
|
70
70
|
this.tokenFlags = 0;
|
|
71
71
|
}
|
|
@@ -76,7 +76,7 @@ class DefaultScanner {
|
|
|
76
76
|
while (true) {
|
|
77
77
|
this.tokenPos = this.pos;
|
|
78
78
|
if (this.pos >= this.end) {
|
|
79
|
-
return this.token =
|
|
79
|
+
return this.token = types_js_1.SyntaxKind.EndOfFileToken;
|
|
80
80
|
}
|
|
81
81
|
let ch = this.text.charCodeAt(this.pos);
|
|
82
82
|
switch (ch) {
|
|
@@ -95,7 +95,7 @@ class DefaultScanner {
|
|
|
95
95
|
else {
|
|
96
96
|
this.pos++;
|
|
97
97
|
}
|
|
98
|
-
return this.token =
|
|
98
|
+
return this.token = types_js_1.SyntaxKind.NewLineTrivia;
|
|
99
99
|
case 9:
|
|
100
100
|
case 11:
|
|
101
101
|
case 12:
|
|
@@ -106,13 +106,13 @@ class DefaultScanner {
|
|
|
106
106
|
}
|
|
107
107
|
while (this.pos < this.end && this.isWhiteSpaceSingleLine(this.text.charCodeAt(this.pos)))
|
|
108
108
|
this.pos++;
|
|
109
|
-
return this.token =
|
|
109
|
+
return this.token = types_js_1.SyntaxKind.WhitespaceTrivia;
|
|
110
110
|
case 35: {
|
|
111
111
|
const content = this.scanHashCommentTrivia(skipTrivia);
|
|
112
112
|
if (skipTrivia)
|
|
113
113
|
continue;
|
|
114
114
|
this.tokenValue = content;
|
|
115
|
-
return this.token =
|
|
115
|
+
return this.token = types_js_1.SyntaxKind.HashCommentTrivia;
|
|
116
116
|
}
|
|
117
117
|
case 47: {
|
|
118
118
|
if (this.pos + 1 < this.end) {
|
|
@@ -123,14 +123,14 @@ class DefaultScanner {
|
|
|
123
123
|
if (skipTrivia)
|
|
124
124
|
continue;
|
|
125
125
|
this.tokenValue = commentContent;
|
|
126
|
-
return this.token =
|
|
126
|
+
return this.token = types_js_1.SyntaxKind.SingleLineCommentTrivia;
|
|
127
127
|
}
|
|
128
128
|
case 42: {
|
|
129
129
|
const commentContent = this.scanMultiLineCommentTrivia(skipTrivia);
|
|
130
130
|
if (skipTrivia)
|
|
131
131
|
continue;
|
|
132
132
|
this.tokenValue = commentContent;
|
|
133
|
-
return this.token =
|
|
133
|
+
return this.token = types_js_1.SyntaxKind.MultiLineCommentTrivia;
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
}
|
|
@@ -140,22 +140,22 @@ class DefaultScanner {
|
|
|
140
140
|
}
|
|
141
141
|
case 123:
|
|
142
142
|
this.pos++;
|
|
143
|
-
return this.token =
|
|
143
|
+
return this.token = types_js_1.SyntaxKind.OpenBraceToken;
|
|
144
144
|
case 125:
|
|
145
145
|
this.pos++;
|
|
146
|
-
return this.token =
|
|
146
|
+
return this.token = types_js_1.SyntaxKind.CloseBraceToken;
|
|
147
147
|
case 91:
|
|
148
148
|
this.pos++;
|
|
149
|
-
return this.token =
|
|
149
|
+
return this.token = types_js_1.SyntaxKind.OpenBracketToken;
|
|
150
150
|
case 93:
|
|
151
151
|
this.pos++;
|
|
152
|
-
return this.token =
|
|
152
|
+
return this.token = types_js_1.SyntaxKind.CloseBracketToken;
|
|
153
153
|
case 43:
|
|
154
154
|
this.pos++;
|
|
155
|
-
return this.token =
|
|
155
|
+
return this.token = types_js_1.SyntaxKind.PlusToken;
|
|
156
156
|
case 61:
|
|
157
157
|
this.pos++;
|
|
158
|
-
return this.token =
|
|
158
|
+
return this.token = types_js_1.SyntaxKind.EqualsToken;
|
|
159
159
|
case 48:
|
|
160
160
|
case 49:
|
|
161
161
|
case 50:
|
|
@@ -168,14 +168,14 @@ class DefaultScanner {
|
|
|
168
168
|
case 57:
|
|
169
169
|
case 46:
|
|
170
170
|
this.tokenValue = this.scanNumber();
|
|
171
|
-
return this.token =
|
|
171
|
+
return this.token = types_js_1.SyntaxKind.NumericIdentifier;
|
|
172
172
|
case 45: {
|
|
173
173
|
const nextChar = this.text.charCodeAt(this.pos + 1);
|
|
174
174
|
switch (nextChar) {
|
|
175
175
|
case 45:
|
|
176
|
-
return this.pos += 2, this.token =
|
|
176
|
+
return this.pos += 2, this.token = types_js_1.SyntaxKind.UndirectedEdgeOp;
|
|
177
177
|
case 62:
|
|
178
|
-
return this.pos += 2, this.token =
|
|
178
|
+
return this.pos += 2, this.token = types_js_1.SyntaxKind.DirectedEdgeOp;
|
|
179
179
|
case 48:
|
|
180
180
|
case 49:
|
|
181
181
|
case 50:
|
|
@@ -188,7 +188,7 @@ class DefaultScanner {
|
|
|
188
188
|
case 57:
|
|
189
189
|
case 46:
|
|
190
190
|
this.tokenValue = this.scanNumber();
|
|
191
|
-
return this.token =
|
|
191
|
+
return this.token = types_js_1.SyntaxKind.NumericIdentifier;
|
|
192
192
|
default:
|
|
193
193
|
const chr = this.text.charAt(this.pos + 1);
|
|
194
194
|
this.error(`Unexpected "${chr}". Did you mean to define an edge? Depending on the type of graph you are defining, use "->" or "--".`, 0);
|
|
@@ -199,22 +199,22 @@ class DefaultScanner {
|
|
|
199
199
|
}
|
|
200
200
|
case 95:
|
|
201
201
|
this.pos++;
|
|
202
|
-
return this.token =
|
|
202
|
+
return this.token = types_js_1.SyntaxKind.UnderscoreToken;
|
|
203
203
|
case 59:
|
|
204
204
|
this.pos++;
|
|
205
|
-
return this.token =
|
|
205
|
+
return this.token = types_js_1.SyntaxKind.SemicolonToken;
|
|
206
206
|
case 58:
|
|
207
207
|
this.pos++;
|
|
208
|
-
return this.token =
|
|
208
|
+
return this.token = types_js_1.SyntaxKind.ColonToken;
|
|
209
209
|
case 44:
|
|
210
210
|
this.pos++;
|
|
211
|
-
return this.token =
|
|
211
|
+
return this.token = types_js_1.SyntaxKind.CommaToken;
|
|
212
212
|
case 60:
|
|
213
213
|
this.tokenValue = this.scanHtml();
|
|
214
|
-
return this.token =
|
|
214
|
+
return this.token = types_js_1.SyntaxKind.HtmlIdentifier;
|
|
215
215
|
case 34:
|
|
216
216
|
this.tokenValue = this.scanString();
|
|
217
|
-
return this.token =
|
|
217
|
+
return this.token = types_js_1.SyntaxKind.StringLiteral;
|
|
218
218
|
default:
|
|
219
219
|
{
|
|
220
220
|
if (isIdentifierStart(ch)) {
|
|
@@ -237,7 +237,7 @@ class DefaultScanner {
|
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
|
-
error(message, sub, category =
|
|
240
|
+
error(message, sub, category = types_js_1.DiagnosticCategory.Error, errPos = this.pos, length = 0) {
|
|
241
241
|
const cb = this.onError;
|
|
242
242
|
if (cb) {
|
|
243
243
|
const posSave = this.pos;
|
|
@@ -425,7 +425,7 @@ class DefaultScanner {
|
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
427
|
}
|
|
428
|
-
return this.token =
|
|
428
|
+
return this.token = types_js_1.SyntaxKind.TextIdentifier;
|
|
429
429
|
}
|
|
430
430
|
lookAhead(callback) {
|
|
431
431
|
return this.speculationHelper(callback, true);
|
|
@@ -455,12 +455,12 @@ class DefaultScanner {
|
|
|
455
455
|
exports.DefaultScanner = DefaultScanner;
|
|
456
456
|
function isIdentifierPartOf(ch, idType) {
|
|
457
457
|
switch (idType) {
|
|
458
|
-
case
|
|
458
|
+
case types_js_1.SyntaxKind.TextIdentifier:
|
|
459
459
|
return ch === 95
|
|
460
460
|
|| 65 <= ch && ch <= 90
|
|
461
461
|
|| 97 <= ch && ch <= 122
|
|
462
462
|
|| 48 <= ch && ch <= 57;
|
|
463
|
-
case
|
|
463
|
+
case types_js_1.SyntaxKind.HtmlIdentifier:
|
|
464
464
|
return ch === 95
|
|
465
465
|
|| ch === 60
|
|
466
466
|
|| ch === 61
|
|
@@ -468,7 +468,7 @@ function isIdentifierPartOf(ch, idType) {
|
|
|
468
468
|
|| 65 <= ch && ch <= 90
|
|
469
469
|
|| 97 <= ch && ch <= 122
|
|
470
470
|
|| 48 <= ch && ch <= 57;
|
|
471
|
-
case
|
|
471
|
+
case types_js_1.SyntaxKind.StringLiteral:
|
|
472
472
|
return ch === 95
|
|
473
473
|
|| ch === 92
|
|
474
474
|
|| ch === 60
|
|
@@ -477,26 +477,26 @@ function isIdentifierPartOf(ch, idType) {
|
|
|
477
477
|
|| 65 <= ch && ch <= 90
|
|
478
478
|
|| 97 <= ch && ch <= 122
|
|
479
479
|
|| 48 <= ch && ch <= 57;
|
|
480
|
-
case
|
|
480
|
+
case types_js_1.SyntaxKind.NumericIdentifier:
|
|
481
481
|
return ch === 45
|
|
482
482
|
|| ch === 46
|
|
483
483
|
|| 48 <= ch && ch <= 57;
|
|
484
|
-
default: return (0,
|
|
484
|
+
default: return (0, util_js_1.assertNever)(idType);
|
|
485
485
|
}
|
|
486
486
|
}
|
|
487
487
|
function getIdentifierStart(ch) {
|
|
488
488
|
if (ch === 60)
|
|
489
|
-
return
|
|
489
|
+
return types_js_1.SyntaxKind.HtmlIdentifier;
|
|
490
490
|
if (ch === 34)
|
|
491
|
-
return
|
|
491
|
+
return types_js_1.SyntaxKind.StringLiteral;
|
|
492
492
|
if (ch === 95
|
|
493
493
|
|| 65 <= ch && ch <= 90
|
|
494
494
|
|| 97 <= ch && ch <= 122)
|
|
495
|
-
return
|
|
495
|
+
return types_js_1.SyntaxKind.TextIdentifier;
|
|
496
496
|
if (ch === 45
|
|
497
497
|
|| ch === 46
|
|
498
498
|
|| 48 <= ch && ch <= 57)
|
|
499
|
-
return
|
|
499
|
+
return types_js_1.SyntaxKind.NumericIdentifier;
|
|
500
500
|
return undefined;
|
|
501
501
|
}
|
|
502
502
|
function isIdentifierStart(ch) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as lst from "vscode-languageserver-types";
|
|
2
|
-
import { DocumentLike, SourceFile, CommandApplication } from "../";
|
|
3
|
-
import { ExecutableCommand } from "./command/common";
|
|
2
|
+
import { DocumentLike, SourceFile, CommandApplication } from "../index.js";
|
|
3
|
+
import { ExecutableCommand } from "./command/common.js";
|
|
4
4
|
export declare function getCodeActions(doc: DocumentLike, sourceFile: SourceFile, range: lst.Range, _context?: lst.CodeActionContext): lst.Command[] | undefined;
|
|
5
5
|
export declare const enum CommandIds {
|
|
6
6
|
ChangeEdgeOp = "DOT.changeEdgeOp",
|
|
@@ -24,14 +24,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.executeCommand = exports.getAvailableCommands = exports.getCodeActions = void 0;
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const ChangeEdgeOpCommand = __importStar(require("./command/ChangeEdgeOpCommand"));
|
|
31
|
-
const ChangeAllOtherEdgeOpsAndFixGraphCommand = __importStar(require("./command/ChangeAllOtherEdgeOpsAndFixGraphCommand"));
|
|
32
|
-
const ConsolidateDescendantsCommand = __importStar(require("./command/ConsolidateDescendantsCommand"));
|
|
33
|
-
const RemoveSemicolonsCommand = __importStar(require("./command/RemoveSemicolons"));
|
|
34
|
-
const
|
|
27
|
+
const index_js_1 = require("../index.js");
|
|
28
|
+
const util_js_1 = require("./util.js");
|
|
29
|
+
const checker_js_1 = require("../checker.js");
|
|
30
|
+
const ChangeEdgeOpCommand = __importStar(require("./command/ChangeEdgeOpCommand.js"));
|
|
31
|
+
const ChangeAllOtherEdgeOpsAndFixGraphCommand = __importStar(require("./command/ChangeAllOtherEdgeOpsAndFixGraphCommand.js"));
|
|
32
|
+
const ConsolidateDescendantsCommand = __importStar(require("./command/ConsolidateDescendantsCommand.js"));
|
|
33
|
+
const RemoveSemicolonsCommand = __importStar(require("./command/RemoveSemicolons.js"));
|
|
34
|
+
const common_js_1 = require("./command/common.js");
|
|
35
35
|
function getCodeActions(doc, sourceFile, range, _context) {
|
|
36
36
|
let actions = getActionsFromDiagnostics(doc, sourceFile, range);
|
|
37
37
|
const general = getGeneralRefactorings(doc, sourceFile, range);
|
|
@@ -67,39 +67,39 @@ function getGeneralRefactorings(doc, file, range) {
|
|
|
67
67
|
const kw = g.keyword;
|
|
68
68
|
const rangeStartOffset = doc.offsetAt(range.start);
|
|
69
69
|
const rangeEndOffset = doc.offsetAt(range.end);
|
|
70
|
-
const keywordStart = (0,
|
|
70
|
+
const keywordStart = (0, util_js_1.getStart)(file, kw);
|
|
71
71
|
const res = [];
|
|
72
72
|
if (isInRange(rangeStartOffset, rangeEndOffset, keywordStart, kw.end)) {
|
|
73
73
|
if (!subtreeContainsErrors(g)) {
|
|
74
|
-
const oppositeGraphType = (0,
|
|
74
|
+
const oppositeGraphType = (0, common_js_1.getOppositeKind)(kw.kind);
|
|
75
75
|
const convertGraph = convertGraphTypeCommand(file, g, oppositeGraphType);
|
|
76
76
|
res.push(convertGraph);
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
if (rangeStartOffset === rangeEndOffset) {
|
|
80
80
|
const candidates = [];
|
|
81
|
-
let clickedNode = (0,
|
|
81
|
+
let clickedNode = (0, checker_js_1.findNodeAtOffset)(g, rangeStartOffset);
|
|
82
82
|
if (clickedNode && !!clickedNode.parent) {
|
|
83
|
-
if (clickedNode.kind ===
|
|
83
|
+
if (clickedNode.kind === index_js_1.SyntaxKind.SemicolonToken) {
|
|
84
84
|
res.push(RemoveSemicolonsCommand.create());
|
|
85
85
|
}
|
|
86
|
-
if ((0,
|
|
86
|
+
if ((0, index_js_1.isIdentifierNode)(clickedNode)) {
|
|
87
87
|
clickedNode = clickedNode.parent;
|
|
88
88
|
}
|
|
89
89
|
const clickedEdgeStatement = clickedNode.parent;
|
|
90
90
|
if (clickedEdgeStatement && !subtreeContainsErrors(clickedEdgeStatement)) {
|
|
91
|
-
if ((0,
|
|
91
|
+
if ((0, checker_js_1.isEdgeStatement)(clickedEdgeStatement)
|
|
92
92
|
&& clickedEdgeStatement.rhs.length === 1
|
|
93
|
-
&& (0,
|
|
94
|
-
&& !(0,
|
|
93
|
+
&& (0, checker_js_1.isNodeId)(clickedEdgeStatement.source)
|
|
94
|
+
&& !(0, checker_js_1.edgeStatementHasAttributes)(clickedEdgeStatement)) {
|
|
95
95
|
candidates.push(clickedEdgeStatement);
|
|
96
96
|
const source = clickedEdgeStatement.source;
|
|
97
|
-
const sourceText = (0,
|
|
97
|
+
const sourceText = (0, checker_js_1.getIdentifierText)(source.id);
|
|
98
98
|
const graphParent = clickedEdgeStatement.parent;
|
|
99
99
|
if (graphParent) {
|
|
100
100
|
let hasVisitedStatement = false;
|
|
101
101
|
let hasVisitedNodeModifier = false;
|
|
102
|
-
(0,
|
|
102
|
+
(0, index_js_1.forEachChild)(graphParent, statement => {
|
|
103
103
|
if (statement === clickedEdgeStatement) {
|
|
104
104
|
hasVisitedStatement = true;
|
|
105
105
|
return undefined;
|
|
@@ -108,19 +108,19 @@ function getGeneralRefactorings(doc, file, range) {
|
|
|
108
108
|
return;
|
|
109
109
|
}
|
|
110
110
|
else if (hasVisitedStatement) {
|
|
111
|
-
if ((0,
|
|
111
|
+
if ((0, checker_js_1.isAttrStatement)(statement)
|
|
112
112
|
|| subtreeContainsErrors(statement)) {
|
|
113
113
|
hasVisitedNodeModifier = true;
|
|
114
114
|
return true;
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
if (hasVisitedStatement) {
|
|
118
|
-
if ((0,
|
|
118
|
+
if ((0, checker_js_1.isEdgeStatement)(statement)
|
|
119
119
|
&& statement.rhs.length === 1
|
|
120
|
-
&& !(0,
|
|
120
|
+
&& !(0, checker_js_1.edgeStatementHasAttributes)(statement)) {
|
|
121
121
|
const statementSource = statement.source;
|
|
122
|
-
if ((0,
|
|
123
|
-
const lowerSourceText = (0,
|
|
122
|
+
if ((0, checker_js_1.isNodeId)(statementSource)) {
|
|
123
|
+
const lowerSourceText = (0, checker_js_1.getIdentifierText)(statementSource.id);
|
|
124
124
|
if (sourceText === lowerSourceText) {
|
|
125
125
|
candidates.push(statement);
|
|
126
126
|
}
|
|
@@ -146,7 +146,7 @@ function getCommandsForDiagnostic(doc, file, d) {
|
|
|
146
146
|
case 1: return getScannerErrorCommand(doc, file, d, d.code);
|
|
147
147
|
case 2: return getParserErrorCommand(doc, file, d, d.code);
|
|
148
148
|
case 4: return getCheckerErrorCommand(doc, file, d, d.code);
|
|
149
|
-
default: return (0,
|
|
149
|
+
default: return (0, util_js_1.assertNever)(d.code);
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
function getScannerErrorCommand(_doc, _file, d, code) {
|
|
@@ -167,12 +167,12 @@ function getCheckerErrorCommand(_doc, file, d, code) {
|
|
|
167
167
|
const graph = file.graph;
|
|
168
168
|
if (!graph)
|
|
169
169
|
return undefined;
|
|
170
|
-
const allowedOp = (0,
|
|
171
|
-
const wrongOp = (0,
|
|
170
|
+
const allowedOp = (0, checker_js_1.getAllowedEdgeOperation)(graph);
|
|
171
|
+
const wrongOp = (0, common_js_1.getOppositeEdgeOp)(allowedOp);
|
|
172
172
|
const kwk = graph.keyword.kind;
|
|
173
173
|
const fixSingleEdge = ChangeEdgeOpCommand.create(d.start, d.end, allowedOp, wrongOp);
|
|
174
174
|
const fixAll = convertGraphTypeCommand(file, graph, kwk);
|
|
175
|
-
const convertToThisWrongType = convertGraphTypeCommand(file, graph, (0,
|
|
175
|
+
const convertToThisWrongType = convertGraphTypeCommand(file, graph, (0, common_js_1.getOppositeKind)(kwk));
|
|
176
176
|
return [
|
|
177
177
|
fixSingleEdge,
|
|
178
178
|
fixAll,
|
|
@@ -182,16 +182,16 @@ function getCheckerErrorCommand(_doc, file, d, code) {
|
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
function convertGraphTypeCommand(file, graph, changeToGraphType) {
|
|
185
|
-
const changeToEdgeOp = (0,
|
|
186
|
-
const allEdges = (0,
|
|
185
|
+
const changeToEdgeOp = (0, common_js_1.getAllowedOp)(changeToGraphType);
|
|
186
|
+
const allEdges = (0, checker_js_1.findAllEdges)(graph);
|
|
187
187
|
const edgeOffsets = allEdges
|
|
188
188
|
.filter(e => e.operation.kind !== changeToEdgeOp)
|
|
189
189
|
.map(e => ({
|
|
190
|
-
start: (0,
|
|
190
|
+
start: (0, util_js_1.getStart)(file, e.operation),
|
|
191
191
|
end: e.operation.end
|
|
192
192
|
}));
|
|
193
193
|
const graphTypeOffset = {
|
|
194
|
-
start: (0,
|
|
194
|
+
start: (0, util_js_1.getStart)(file, graph.keyword),
|
|
195
195
|
end: graph.keyword.end
|
|
196
196
|
};
|
|
197
197
|
return ChangeAllOtherEdgeOpsAndFixGraphCommand.create(edgeOffsets, changeToEdgeOp, graphTypeOffset, graph.keyword.kind, changeToGraphType);
|
|
@@ -221,11 +221,11 @@ function executeCommand(doc, sourceFile, cmd) {
|
|
|
221
221
|
}
|
|
222
222
|
exports.executeCommand = executeCommand;
|
|
223
223
|
function subtreeContainsErrors(node) {
|
|
224
|
-
if ((0,
|
|
224
|
+
if ((0, checker_js_1.nodeContainsErrors)(node))
|
|
225
225
|
return true;
|
|
226
226
|
let hasError = false;
|
|
227
|
-
(0,
|
|
228
|
-
if ((0,
|
|
227
|
+
(0, index_js_1.forEachChild)(node, child => {
|
|
228
|
+
if ((0, checker_js_1.nodeContainsErrors)(child)) {
|
|
229
229
|
hasError = true;
|
|
230
230
|
}
|
|
231
231
|
if (!hasError) {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ColorInformation, ColorPresentation, Range, Color } from "vscode-languageserver-types";
|
|
2
|
+
import { SourceFile } from "../types.js";
|
|
3
|
+
import { DocumentLike } from "../index.js";
|
|
4
|
+
export declare function getDocumentColors(doc: DocumentLike, sourceFile: SourceFile): ColorInformation[] | undefined;
|
|
5
|
+
export declare function getColorRepresentations(_doc: DocumentLike, _sourceFile: SourceFile, color: Color, range: Range): ColorPresentation[] | undefined;
|
|
@@ -24,8 +24,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.getColorRepresentations = exports.getDocumentColors = void 0;
|
|
27
|
-
const
|
|
28
|
-
const languageFacts = __importStar(require("./languageFacts"));
|
|
27
|
+
const util_js_1 = require("./util.js");
|
|
28
|
+
const languageFacts = __importStar(require("./languageFacts.js"));
|
|
29
29
|
const colorMap = languageFacts.colors;
|
|
30
30
|
function getDocumentColors(doc, sourceFile) {
|
|
31
31
|
const cs = sourceFile.colors;
|
|
@@ -35,14 +35,9 @@ function getDocumentColors(doc, sourceFile) {
|
|
|
35
35
|
}
|
|
36
36
|
exports.getDocumentColors = getDocumentColors;
|
|
37
37
|
function getColorRepresentations(_doc, _sourceFile, color, range) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return [
|
|
42
|
-
{
|
|
43
|
-
label: '"' + hexColor + '"',
|
|
44
|
-
}
|
|
45
|
-
];
|
|
38
|
+
return !color || !range
|
|
39
|
+
? undefined
|
|
40
|
+
: [{ label: '"' + getColorStringFromColor(color) + '"', }];
|
|
46
41
|
}
|
|
47
42
|
exports.getColorRepresentations = getColorRepresentations;
|
|
48
43
|
function colorTableToColorInformation(doc, sf, colors) {
|
|
@@ -55,7 +50,7 @@ function colorTableToColorInformation(doc, sf, colors) {
|
|
|
55
50
|
const color = getColorFromName(name);
|
|
56
51
|
if (color) {
|
|
57
52
|
res.push({
|
|
58
|
-
range: (0,
|
|
53
|
+
range: (0, util_js_1.syntaxNodeToRange)(doc, sf, value.node),
|
|
59
54
|
color,
|
|
60
55
|
});
|
|
61
56
|
}
|
|
@@ -65,7 +60,7 @@ function colorTableToColorInformation(doc, sf, colors) {
|
|
|
65
60
|
function getColorFromName(name) {
|
|
66
61
|
if (name.charAt(0) === "#")
|
|
67
62
|
return getHexCodeColor(name);
|
|
68
|
-
const colorAlias = colorMap[name];
|
|
63
|
+
const colorAlias = colorMap[name.toLowerCase()];
|
|
69
64
|
return colorAlias
|
|
70
65
|
? getHexCodeColor(colorAlias)
|
|
71
66
|
: undefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as lst from "vscode-languageserver-types";
|
|
2
|
-
import { CommandIds } from "../codeAction";
|
|
3
|
-
import { GraphTypeStr, Offset, EdgeOpStr, ExecutableCommand, EdgeType, GraphType } from "./common";
|
|
4
|
-
import { DocumentLike, SourceFile, CommandApplication } from "../../";
|
|
2
|
+
import { CommandIds } from "../codeAction.js";
|
|
3
|
+
import { GraphTypeStr, Offset, EdgeOpStr, ExecutableCommand, EdgeType, GraphType } from "./common.js";
|
|
4
|
+
import { DocumentLike, SourceFile, CommandApplication } from "../../index.js";
|
|
5
5
|
export interface ChangeAllOtherEdgeOpsAndFixGraphCommand extends lst.Command {
|
|
6
6
|
command: CommandIds.ConvertGraphType;
|
|
7
7
|
arguments: [Offset[], EdgeOpStr, Offset, GraphTypeStr];
|
|
@@ -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
|
|
4
|
+
const common_js_1 = require("./common.js");
|
|
5
5
|
function create(edgeOffsets, changeEdgesTo, graphOffset, changeFromGraph, changeGraphTo) {
|
|
6
|
-
const toGraph = (0,
|
|
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,
|
|
10
|
-
const edgeStr = (0,
|
|
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",
|
|
@@ -22,11 +22,11 @@ function execute(doc, _sourceFile, cmd) {
|
|
|
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,
|
|
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,
|
|
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,7 +1,7 @@
|
|
|
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];
|
|
@@ -25,10 +25,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.execute = exports.create = void 0;
|
|
27
27
|
const lst = __importStar(require("vscode-languageserver-types"));
|
|
28
|
-
const
|
|
28
|
+
const common_js_1 = require("./common.js");
|
|
29
29
|
function create(startOffset, endOffset, changeTo, changeFrom) {
|
|
30
|
-
const from = (0,
|
|
31
|
-
const to = (0,
|
|
30
|
+
const from = (0, common_js_1.getEdgeStr)(changeFrom);
|
|
31
|
+
const to = (0, common_js_1.getEdgeStr)(changeTo);
|
|
32
32
|
return {
|
|
33
33
|
title: `Change "${from}" to "${to}".`,
|
|
34
34
|
command: "DOT.changeEdgeOp",
|
|
@@ -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,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.execute = exports.create = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const checker_js_1 = require("../../checker.js");
|
|
5
|
+
const util_js_1 = require("../util.js");
|
|
6
6
|
function create(statements, below) {
|
|
7
7
|
const first = statements[0];
|
|
8
|
-
const from = (0,
|
|
8
|
+
const from = (0, checker_js_1.getIdentifierText)(first.source.id);
|
|
9
9
|
const title = below
|
|
10
10
|
? `Convert edges below from "${from}" to subgraph`
|
|
11
11
|
: `Convert edges from "${from}" to subgraph`;
|
|
@@ -23,12 +23,12 @@ function execute(doc, sourceFile, cmd) {
|
|
|
23
23
|
if (!g)
|
|
24
24
|
return undefined;
|
|
25
25
|
const candidateIndexes = cmd.arguments;
|
|
26
|
-
const candidates = candidateIndexes.map(i => (0,
|
|
26
|
+
const candidates = candidateIndexes.map(i => (0, checker_js_1.findNodeAtOffset)(g, i).parent.parent);
|
|
27
27
|
const first = candidates.shift();
|
|
28
|
-
const from = (0,
|
|
28
|
+
const from = (0, checker_js_1.getIdentifierText)(first.source.id);
|
|
29
29
|
const edits = [];
|
|
30
30
|
const firstRight = first.rhs[0];
|
|
31
|
-
const firstRightTargetStart = (0,
|
|
31
|
+
const firstRightTargetStart = (0, util_js_1.getStart)(sourceFile, firstRight.target);
|
|
32
32
|
const firstRightTargetEnd = firstRight.target.end;
|
|
33
33
|
const contents = [
|
|
34
34
|
sourceFile.content.substring(firstRightTargetStart, firstRightTargetEnd)
|
|
@@ -57,7 +57,7 @@ function execute(doc, sourceFile, cmd) {
|
|
|
57
57
|
edits.push({
|
|
58
58
|
newText: "",
|
|
59
59
|
range: {
|
|
60
|
-
start: doc.positionAt((0,
|
|
60
|
+
start: doc.positionAt((0, util_js_1.getStart)(sourceFile, descendant.terminator)),
|
|
61
61
|
end: doc.positionAt(descendant.terminator.end),
|
|
62
62
|
}
|
|
63
63
|
});
|