dot-language-support 1.5.3 → 1.5.6
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/lib/binder.js +9 -9
- package/lib/checker.js +5 -5
- package/lib/index.js +5 -1
- package/lib/parser.js +2 -2
- package/lib/scanner.js +2 -2
- package/lib/service/codeAction.js +25 -25
- package/lib/service/colorProvider.js +1 -1
- package/lib/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.js +5 -5
- package/lib/service/command/ChangeEdgeOpCommand.js +2 -2
- package/lib/service/command/ConsolidateDescendantsCommand.js +5 -5
- package/lib/service/command/RemoveSemicolons.js +2 -2
- package/lib/service/completion.js +10 -10
- package/lib/service/hover.js +14 -14
- package/lib/service/reference.js +6 -6
- package/lib/service/rename.js +3 -3
- package/lib/service/service.js +2 -2
- package/lib/service/util.js +2 -2
- package/lib/service/validation.js +1 -1
- package/package.json +7 -7
package/lib/binder.js
CHANGED
|
@@ -117,7 +117,7 @@ function createBinder() {
|
|
|
117
117
|
function bindIdEqualsIdStatement(node) {
|
|
118
118
|
bind(node.leftId);
|
|
119
119
|
bind(node.rightId);
|
|
120
|
-
if (node.rightId && !checker_1.nodeContainsErrors(node.rightId)) {
|
|
120
|
+
if (node.rightId && !(0, checker_1.nodeContainsErrors)(node.rightId)) {
|
|
121
121
|
if (isAttributeName("color", node.leftId)) {
|
|
122
122
|
ensureGlobalColor(node.rightId);
|
|
123
123
|
}
|
|
@@ -168,7 +168,7 @@ function createBinder() {
|
|
|
168
168
|
if (carrierIdentifier)
|
|
169
169
|
ensureMemberSymbol(node.leftId, carrierIdentifier);
|
|
170
170
|
bind(node.rightId);
|
|
171
|
-
if (node.rightId && !checker_1.nodeContainsErrors(node.rightId)) {
|
|
171
|
+
if (node.rightId && !(0, checker_1.nodeContainsErrors)(node.rightId)) {
|
|
172
172
|
if (isAttributeName("color", node.leftId)) {
|
|
173
173
|
ensureGlobalColor(node.rightId);
|
|
174
174
|
}
|
|
@@ -205,8 +205,8 @@ function createBinder() {
|
|
|
205
205
|
return new Map();
|
|
206
206
|
}
|
|
207
207
|
function ensureMemberSymbol(node, carrier) {
|
|
208
|
-
if (node && carrier && parser_1.isIdentifierNode(node)) {
|
|
209
|
-
const name = checker_1.getIdentifierText(node);
|
|
208
|
+
if (node && carrier && (0, parser_1.isIdentifierNode)(node)) {
|
|
209
|
+
const name = (0, checker_1.getIdentifierText)(node);
|
|
210
210
|
if (name === undefined)
|
|
211
211
|
return;
|
|
212
212
|
const carrierSymbol = carrier.symbol;
|
|
@@ -222,9 +222,9 @@ function createBinder() {
|
|
|
222
222
|
debugger;
|
|
223
223
|
}
|
|
224
224
|
function ensureGlobalSymbol(node) {
|
|
225
|
-
if (node && parser_1.isIdentifierNode(node)) {
|
|
225
|
+
if (node && (0, parser_1.isIdentifierNode)(node)) {
|
|
226
226
|
const symbols = symbolTable;
|
|
227
|
-
const name = checker_1.getIdentifierText(node);
|
|
227
|
+
const name = (0, checker_1.getIdentifierText)(node);
|
|
228
228
|
if (name === undefined)
|
|
229
229
|
return;
|
|
230
230
|
if (symbols === undefined)
|
|
@@ -252,9 +252,9 @@ function createBinder() {
|
|
|
252
252
|
node.symbol = sym;
|
|
253
253
|
}
|
|
254
254
|
function ensureGlobalColor(node) {
|
|
255
|
-
if (node && parser_1.isIdentifierNode(node)) {
|
|
255
|
+
if (node && (0, parser_1.isIdentifierNode)(node)) {
|
|
256
256
|
const colors = colorTable;
|
|
257
|
-
const name = checker_1.getIdentifierText(node);
|
|
257
|
+
const name = (0, checker_1.getIdentifierText)(node);
|
|
258
258
|
if (name === undefined)
|
|
259
259
|
return;
|
|
260
260
|
if (colors === undefined)
|
|
@@ -283,7 +283,7 @@ function createBinder() {
|
|
|
283
283
|
};
|
|
284
284
|
}
|
|
285
285
|
function isAttributeName(name, id) {
|
|
286
|
-
return id ? checker_1.getIdentifierText(id).trim().toLowerCase() === name : false;
|
|
286
|
+
return id ? (0, checker_1.getIdentifierText)(id).trim().toLowerCase() === name : false;
|
|
287
287
|
}
|
|
288
288
|
return {
|
|
289
289
|
bind: file => {
|
package/lib/checker.js
CHANGED
|
@@ -33,7 +33,7 @@ function findNodeAtOffset(root, offset, inclusiveEnd = false) {
|
|
|
33
33
|
if (root.pos === offset && root.pos === root.end)
|
|
34
34
|
return root;
|
|
35
35
|
if (rangeContainsOffset(root, offset, inclusiveEnd)) {
|
|
36
|
-
const narrowerChild = visitor_1.forEachChild(root, child => findNodeAtOffset(child, offset, inclusiveEnd));
|
|
36
|
+
const narrowerChild = (0, visitor_1.forEachChild)(root, child => findNodeAtOffset(child, offset, inclusiveEnd));
|
|
37
37
|
return narrowerChild ? narrowerChild : root;
|
|
38
38
|
}
|
|
39
39
|
return undefined;
|
|
@@ -54,7 +54,7 @@ function checkGraphSemantics(file, root) {
|
|
|
54
54
|
}
|
|
55
55
|
function findAllEdges(node) {
|
|
56
56
|
const allEdges = [];
|
|
57
|
-
visitor_1.forEachChild(node, child => {
|
|
57
|
+
(0, visitor_1.forEachChild)(node, child => {
|
|
58
58
|
if (isEdgeStatement(child)) {
|
|
59
59
|
if (child.rhs && child.rhs.length > 0) {
|
|
60
60
|
for (const edgeRhs of child.rhs)
|
|
@@ -83,7 +83,7 @@ function isStatement(node) {
|
|
|
83
83
|
}
|
|
84
84
|
function findAllStatements(node, kind) {
|
|
85
85
|
const allStatements = [];
|
|
86
|
-
visitor_1.forEachChild(node, child => {
|
|
86
|
+
(0, visitor_1.forEachChild)(node, child => {
|
|
87
87
|
if ((kind === undefined && isStatement(child)) || (child.kind === kind)) {
|
|
88
88
|
allStatements.push(child);
|
|
89
89
|
}
|
|
@@ -113,7 +113,7 @@ function createEdgeViolationDiagnostics(file, expectedEdgeOp, violators) {
|
|
|
113
113
|
const category = types_1.DiagnosticCategory.Error;
|
|
114
114
|
violators.forEach(edge => edge.operation.flags |= 2);
|
|
115
115
|
return violators.map(edge => {
|
|
116
|
-
const start = util_1.getStart(file, edge.operation);
|
|
116
|
+
const start = (0, util_1.getStart)(file, edge.operation);
|
|
117
117
|
const end = edge.operation.end;
|
|
118
118
|
return {
|
|
119
119
|
message,
|
|
@@ -168,7 +168,7 @@ function getIdentifierText(n) {
|
|
|
168
168
|
case types_1.SyntaxKind.QuotedTextIdentifier:
|
|
169
169
|
return n.concatenation;
|
|
170
170
|
default:
|
|
171
|
-
return util_1.assertNever(n);
|
|
171
|
+
return (0, util_1.assertNever)(n);
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
exports.getIdentifierText = getIdentifierText;
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/lib/parser.js
CHANGED
|
@@ -557,13 +557,13 @@ class Parser {
|
|
|
557
557
|
? "identifier"
|
|
558
558
|
: this.token() === types_1.SyntaxKind.EndOfFileToken
|
|
559
559
|
? "end of file"
|
|
560
|
-
: `"${scanner_1.getTokenAsText(this.token())}"`;
|
|
560
|
+
: `"${(0, scanner_1.getTokenAsText)(this.token())}"`;
|
|
561
561
|
const expected = expectedKinds.map(k => {
|
|
562
562
|
if (isIdentifier(k))
|
|
563
563
|
return "identifier";
|
|
564
564
|
else if (k === types_1.SyntaxKind.EndOfFileToken)
|
|
565
565
|
return "end of file";
|
|
566
|
-
return `"${scanner_1.getTokenAsText(k)}"`;
|
|
566
|
+
return `"${(0, scanner_1.getTokenAsText)(k)}"`;
|
|
567
567
|
});
|
|
568
568
|
const lastExpected = expected.pop();
|
|
569
569
|
const expectedJoined = expected.join(", ");
|
package/lib/scanner.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.isLineBreak = exports.skipTrivia = exports.isIdentifierStart = exports.D
|
|
|
4
4
|
const core_1 = require("./core");
|
|
5
5
|
const types_1 = require("./types");
|
|
6
6
|
const util_1 = require("./service/util");
|
|
7
|
-
const textToToken = core_1.createMapFromTemplate({
|
|
7
|
+
const textToToken = (0, core_1.createMapFromTemplate)({
|
|
8
8
|
"digraph": types_1.SyntaxKind.DigraphKeyword,
|
|
9
9
|
"graph": types_1.SyntaxKind.GraphKeyword,
|
|
10
10
|
"edge": types_1.SyntaxKind.EdgeKeyword,
|
|
@@ -481,7 +481,7 @@ function isIdentifierPartOf(ch, idType) {
|
|
|
481
481
|
return ch === 45
|
|
482
482
|
|| ch === 46
|
|
483
483
|
|| 48 <= ch && ch <= 57;
|
|
484
|
-
default: return util_1.assertNever(idType);
|
|
484
|
+
default: return (0, util_1.assertNever)(idType);
|
|
485
485
|
}
|
|
486
486
|
}
|
|
487
487
|
function getIdentifierStart(ch) {
|
|
@@ -44,39 +44,39 @@ function getGeneralRefactorings(doc, file, range) {
|
|
|
44
44
|
const kw = g.keyword;
|
|
45
45
|
const rangeStartOffset = doc.offsetAt(range.start);
|
|
46
46
|
const rangeEndOffset = doc.offsetAt(range.end);
|
|
47
|
-
const keywordStart = util_1.getStart(file, kw);
|
|
47
|
+
const keywordStart = (0, util_1.getStart)(file, kw);
|
|
48
48
|
const res = [];
|
|
49
49
|
if (isInRange(rangeStartOffset, rangeEndOffset, keywordStart, kw.end)) {
|
|
50
50
|
if (!subtreeContainsErrors(g)) {
|
|
51
|
-
const oppositeGraphType = common_1.getOppositeKind(kw.kind);
|
|
51
|
+
const oppositeGraphType = (0, common_1.getOppositeKind)(kw.kind);
|
|
52
52
|
const convertGraph = convertGraphTypeCommand(file, g, oppositeGraphType);
|
|
53
53
|
res.push(convertGraph);
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
if (rangeStartOffset === rangeEndOffset) {
|
|
57
57
|
const candidates = [];
|
|
58
|
-
let clickedNode = checker_1.findNodeAtOffset(g, rangeStartOffset);
|
|
58
|
+
let clickedNode = (0, checker_1.findNodeAtOffset)(g, rangeStartOffset);
|
|
59
59
|
if (clickedNode && !!clickedNode.parent) {
|
|
60
60
|
if (clickedNode.kind === __1.SyntaxKind.SemicolonToken) {
|
|
61
61
|
res.push(RemoveSemicolonsCommand.create());
|
|
62
62
|
}
|
|
63
|
-
if (__1.isIdentifierNode(clickedNode)) {
|
|
63
|
+
if ((0, __1.isIdentifierNode)(clickedNode)) {
|
|
64
64
|
clickedNode = clickedNode.parent;
|
|
65
65
|
}
|
|
66
66
|
const clickedEdgeStatement = clickedNode.parent;
|
|
67
67
|
if (clickedEdgeStatement && !subtreeContainsErrors(clickedEdgeStatement)) {
|
|
68
|
-
if (checker_1.isEdgeStatement(clickedEdgeStatement)
|
|
68
|
+
if ((0, checker_1.isEdgeStatement)(clickedEdgeStatement)
|
|
69
69
|
&& clickedEdgeStatement.rhs.length === 1
|
|
70
|
-
&& checker_1.isNodeId(clickedEdgeStatement.source)
|
|
71
|
-
&& !checker_1.edgeStatementHasAttributes(clickedEdgeStatement)) {
|
|
70
|
+
&& (0, checker_1.isNodeId)(clickedEdgeStatement.source)
|
|
71
|
+
&& !(0, checker_1.edgeStatementHasAttributes)(clickedEdgeStatement)) {
|
|
72
72
|
candidates.push(clickedEdgeStatement);
|
|
73
73
|
const source = clickedEdgeStatement.source;
|
|
74
|
-
const sourceText = checker_1.getIdentifierText(source.id);
|
|
74
|
+
const sourceText = (0, checker_1.getIdentifierText)(source.id);
|
|
75
75
|
const graphParent = clickedEdgeStatement.parent;
|
|
76
76
|
if (graphParent) {
|
|
77
77
|
let hasVisitedStatement = false;
|
|
78
78
|
let hasVisitedNodeModifier = false;
|
|
79
|
-
__1.forEachChild(graphParent, statement => {
|
|
79
|
+
(0, __1.forEachChild)(graphParent, statement => {
|
|
80
80
|
if (statement === clickedEdgeStatement) {
|
|
81
81
|
hasVisitedStatement = true;
|
|
82
82
|
return undefined;
|
|
@@ -85,19 +85,19 @@ function getGeneralRefactorings(doc, file, range) {
|
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
87
|
else if (hasVisitedStatement) {
|
|
88
|
-
if (checker_1.isAttrStatement(statement)
|
|
88
|
+
if ((0, checker_1.isAttrStatement)(statement)
|
|
89
89
|
|| subtreeContainsErrors(statement)) {
|
|
90
90
|
hasVisitedNodeModifier = true;
|
|
91
91
|
return true;
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
if (hasVisitedStatement) {
|
|
95
|
-
if (checker_1.isEdgeStatement(statement)
|
|
95
|
+
if ((0, checker_1.isEdgeStatement)(statement)
|
|
96
96
|
&& statement.rhs.length === 1
|
|
97
|
-
&& !checker_1.edgeStatementHasAttributes(statement)) {
|
|
97
|
+
&& !(0, checker_1.edgeStatementHasAttributes)(statement)) {
|
|
98
98
|
const statementSource = statement.source;
|
|
99
|
-
if (checker_1.isNodeId(statementSource)) {
|
|
100
|
-
const lowerSourceText = checker_1.getIdentifierText(statementSource.id);
|
|
99
|
+
if ((0, checker_1.isNodeId)(statementSource)) {
|
|
100
|
+
const lowerSourceText = (0, checker_1.getIdentifierText)(statementSource.id);
|
|
101
101
|
if (sourceText === lowerSourceText) {
|
|
102
102
|
candidates.push(statement);
|
|
103
103
|
}
|
|
@@ -123,7 +123,7 @@ function getCommandsForDiagnostic(doc, file, d) {
|
|
|
123
123
|
case 1: return getScannerErrorCommand(doc, file, d, d.code);
|
|
124
124
|
case 2: return getParserErrorCommand(doc, file, d, d.code);
|
|
125
125
|
case 4: return getCheckerErrorCommand(doc, file, d, d.code);
|
|
126
|
-
default: return util_1.assertNever(d.code);
|
|
126
|
+
default: return (0, util_1.assertNever)(d.code);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
function getScannerErrorCommand(doc, file, d, code) {
|
|
@@ -144,12 +144,12 @@ function getCheckerErrorCommand(doc, file, d, code) {
|
|
|
144
144
|
const graph = file.graph;
|
|
145
145
|
if (!graph)
|
|
146
146
|
return undefined;
|
|
147
|
-
const allowedOp = checker_1.getAllowedEdgeOperation(graph);
|
|
148
|
-
const wrongOp = common_1.getOppositeEdgeOp(allowedOp);
|
|
147
|
+
const allowedOp = (0, checker_1.getAllowedEdgeOperation)(graph);
|
|
148
|
+
const wrongOp = (0, common_1.getOppositeEdgeOp)(allowedOp);
|
|
149
149
|
const kwk = graph.keyword.kind;
|
|
150
150
|
const fixSingleEdge = ChangeEdgeOpCommand.create(d.start, d.end, allowedOp, wrongOp);
|
|
151
151
|
const fixAll = convertGraphTypeCommand(file, graph, kwk);
|
|
152
|
-
const convertToThisWrongType = convertGraphTypeCommand(file, graph, common_1.getOppositeKind(kwk));
|
|
152
|
+
const convertToThisWrongType = convertGraphTypeCommand(file, graph, (0, common_1.getOppositeKind)(kwk));
|
|
153
153
|
return [
|
|
154
154
|
fixSingleEdge,
|
|
155
155
|
fixAll,
|
|
@@ -159,16 +159,16 @@ function getCheckerErrorCommand(doc, file, d, code) {
|
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
function convertGraphTypeCommand(file, graph, changeToGraphType) {
|
|
162
|
-
const changeToEdgeOp = common_1.getAllowedOp(changeToGraphType);
|
|
163
|
-
const allEdges = checker_1.findAllEdges(graph);
|
|
162
|
+
const changeToEdgeOp = (0, common_1.getAllowedOp)(changeToGraphType);
|
|
163
|
+
const allEdges = (0, checker_1.findAllEdges)(graph);
|
|
164
164
|
const edgeOffsets = allEdges
|
|
165
165
|
.filter(e => e.operation.kind !== changeToEdgeOp)
|
|
166
166
|
.map(e => ({
|
|
167
|
-
start: util_1.getStart(file, e.operation),
|
|
167
|
+
start: (0, util_1.getStart)(file, e.operation),
|
|
168
168
|
end: e.operation.end
|
|
169
169
|
}));
|
|
170
170
|
const graphTypeOffset = {
|
|
171
|
-
start: util_1.getStart(file, graph.keyword),
|
|
171
|
+
start: (0, util_1.getStart)(file, graph.keyword),
|
|
172
172
|
end: graph.keyword.end
|
|
173
173
|
};
|
|
174
174
|
return ChangeAllOtherEdgeOpsAndFixGraphCommand.create(edgeOffsets, changeToEdgeOp, graphTypeOffset, graph.keyword.kind, changeToGraphType);
|
|
@@ -198,11 +198,11 @@ function executeCommand(doc, sourceFile, cmd) {
|
|
|
198
198
|
}
|
|
199
199
|
exports.executeCommand = executeCommand;
|
|
200
200
|
function subtreeContainsErrors(node) {
|
|
201
|
-
if (checker_1.nodeContainsErrors(node))
|
|
201
|
+
if ((0, checker_1.nodeContainsErrors)(node))
|
|
202
202
|
return true;
|
|
203
203
|
let hasError = false;
|
|
204
|
-
__1.forEachChild(node, child => {
|
|
205
|
-
if (checker_1.nodeContainsErrors(child)) {
|
|
204
|
+
(0, __1.forEachChild)(node, child => {
|
|
205
|
+
if ((0, checker_1.nodeContainsErrors)(child)) {
|
|
206
206
|
hasError = true;
|
|
207
207
|
}
|
|
208
208
|
if (!hasError) {
|
|
@@ -32,7 +32,7 @@ function colorTableToColorInformation(doc, sf, colors) {
|
|
|
32
32
|
const color = getColorFromName(name);
|
|
33
33
|
if (color) {
|
|
34
34
|
res.push({
|
|
35
|
-
range: util_1.syntaxNodeToRange(doc, sf, value.node),
|
|
35
|
+
range: (0, util_1.syntaxNodeToRange)(doc, sf, value.node),
|
|
36
36
|
color,
|
|
37
37
|
});
|
|
38
38
|
}
|
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.execute = exports.create = void 0;
|
|
4
4
|
const common_1 = require("./common");
|
|
5
5
|
function create(edgeOffsets, changeEdgesTo, graphOffset, changeFromGraph, changeGraphTo) {
|
|
6
|
-
const toGraph = common_1.getGraphKeywordStr(changeGraphTo);
|
|
6
|
+
const toGraph = (0, common_1.getGraphKeywordStr)(changeGraphTo);
|
|
7
7
|
const title = changeGraphTo === changeFromGraph
|
|
8
8
|
? `Fix all edges to match ${toGraph}`
|
|
9
|
-
: `Convert ${common_1.getGraphKeywordStr(changeFromGraph)} to ${toGraph}`;
|
|
10
|
-
const edgeStr = common_1.getEdgeStr(changeEdgesTo);
|
|
9
|
+
: `Convert ${(0, common_1.getGraphKeywordStr)(changeFromGraph)} to ${toGraph}`;
|
|
10
|
+
const edgeStr = (0, common_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 common_1.createChangeToEdit(startPos, endPos, changeEdgeTo);
|
|
25
|
+
return (0, common_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(common_1.createChangeToEdit(graphStart, graphEnd, changeGraphTo));
|
|
29
|
+
edits.push((0, common_1.createChangeToEdit)(graphStart, graphEnd, changeGraphTo));
|
|
30
30
|
return {
|
|
31
31
|
label: `Convert graph to "${changeGraphTo}"`,
|
|
32
32
|
edit: {
|
|
@@ -4,8 +4,8 @@ exports.execute = exports.create = void 0;
|
|
|
4
4
|
const lst = require("vscode-languageserver-types");
|
|
5
5
|
const common_1 = require("./common");
|
|
6
6
|
function create(startOffset, endOffset, changeTo, changeFrom) {
|
|
7
|
-
const from = common_1.getEdgeStr(changeFrom);
|
|
8
|
-
const to = common_1.getEdgeStr(changeTo);
|
|
7
|
+
const from = (0, common_1.getEdgeStr)(changeFrom);
|
|
8
|
+
const to = (0, common_1.getEdgeStr)(changeTo);
|
|
9
9
|
return {
|
|
10
10
|
title: `Change "${from}" to "${to}".`,
|
|
11
11
|
command: "DOT.changeEdgeOp",
|
|
@@ -16,7 +16,7 @@ const checker_1 = require("../../checker");
|
|
|
16
16
|
const util_1 = require("../util");
|
|
17
17
|
function create(statements, below) {
|
|
18
18
|
const first = statements[0];
|
|
19
|
-
const from = checker_1.getIdentifierText(first.source.id);
|
|
19
|
+
const from = (0, checker_1.getIdentifierText)(first.source.id);
|
|
20
20
|
const title = below
|
|
21
21
|
? `Convert edges below from "${from}" to subgraph`
|
|
22
22
|
: `Convert edges from "${from}" to subgraph`;
|
|
@@ -41,12 +41,12 @@ function execute(doc, sourceFile, cmd) {
|
|
|
41
41
|
if (!g)
|
|
42
42
|
return undefined;
|
|
43
43
|
const candidateIndexes = cmd.arguments;
|
|
44
|
-
const candidates = candidateIndexes.map(i => checker_1.findNodeAtOffset(g, i).parent.parent);
|
|
44
|
+
const candidates = candidateIndexes.map(i => (0, checker_1.findNodeAtOffset)(g, i).parent.parent);
|
|
45
45
|
const first = candidates.shift();
|
|
46
|
-
const from = checker_1.getIdentifierText(first.source.id);
|
|
46
|
+
const from = (0, checker_1.getIdentifierText)(first.source.id);
|
|
47
47
|
const edits = [];
|
|
48
48
|
const firstRight = first.rhs[0];
|
|
49
|
-
const firstRightTargetStart = util_1.getStart(sourceFile, firstRight.target);
|
|
49
|
+
const firstRightTargetStart = (0, util_1.getStart)(sourceFile, firstRight.target);
|
|
50
50
|
const firstRightTargetEnd = firstRight.target.end;
|
|
51
51
|
const contents = [
|
|
52
52
|
sourceFile.content.substring(firstRightTargetStart, firstRightTargetEnd)
|
|
@@ -75,7 +75,7 @@ function execute(doc, sourceFile, cmd) {
|
|
|
75
75
|
edits.push({
|
|
76
76
|
newText: "",
|
|
77
77
|
range: {
|
|
78
|
-
start: doc.positionAt(util_1.getStart(sourceFile, descendant.terminator)),
|
|
78
|
+
start: doc.positionAt((0, util_1.getStart)(sourceFile, descendant.terminator)),
|
|
79
79
|
end: doc.positionAt(descendant.terminator.end),
|
|
80
80
|
}
|
|
81
81
|
});
|
|
@@ -17,11 +17,11 @@ function execute(doc, sourceFile, cmd) {
|
|
|
17
17
|
const g = sourceFile.graph;
|
|
18
18
|
if (!g)
|
|
19
19
|
return undefined;
|
|
20
|
-
const semicolons = checker_1.findOptionalSemicolons(g);
|
|
20
|
+
const semicolons = (0, checker_1.findOptionalSemicolons)(g);
|
|
21
21
|
const edits = semicolons.map(s => {
|
|
22
22
|
const end = s.end;
|
|
23
23
|
const start = end - 1;
|
|
24
|
-
return common_1.createChangeToEdit(doc.positionAt(start), doc.positionAt(end), "");
|
|
24
|
+
return (0, common_1.createChangeToEdit)(doc.positionAt(start), doc.positionAt(end), "");
|
|
25
25
|
});
|
|
26
26
|
return {
|
|
27
27
|
label: `Remove optional semicolons`,
|
|
@@ -15,14 +15,14 @@ function getCompletions(doc, sourceFile, position) {
|
|
|
15
15
|
if (!g)
|
|
16
16
|
return [];
|
|
17
17
|
const offset = doc.offsetAt(position);
|
|
18
|
-
const node = checker_1.findNodeAtOffset(g, offset, true);
|
|
18
|
+
const node = (0, checker_1.findNodeAtOffset)(g, offset, true);
|
|
19
19
|
if (!node)
|
|
20
20
|
return [];
|
|
21
|
-
const prevOffsetNode = checker_1.findNodeAtOffset(g, offset - 1, true);
|
|
21
|
+
const prevOffsetNode = (0, checker_1.findNodeAtOffset)(g, offset - 1, true);
|
|
22
22
|
const parent = node.parent;
|
|
23
23
|
const prevOffsetNodeParent = prevOffsetNode === null || prevOffsetNode === void 0 ? void 0 : prevOffsetNode.parent;
|
|
24
|
-
if (((parent === null || parent === void 0 ? void 0 : parent.parent) && checker_1.isEdgeStatement(parent.parent))
|
|
25
|
-
|| ((prevOffsetNodeParent === null || prevOffsetNodeParent === void 0 ? void 0 : prevOffsetNodeParent.parent) && checker_1.isEdgeStatement(prevOffsetNodeParent.parent))) {
|
|
24
|
+
if (((parent === null || parent === void 0 ? void 0 : parent.parent) && (0, checker_1.isEdgeStatement)(parent.parent))
|
|
25
|
+
|| ((prevOffsetNodeParent === null || prevOffsetNodeParent === void 0 ? void 0 : prevOffsetNodeParent.parent) && (0, checker_1.isEdgeStatement)(prevOffsetNodeParent.parent))) {
|
|
26
26
|
return getNodeCompletions(symbols);
|
|
27
27
|
}
|
|
28
28
|
if (node.kind === types_1.SyntaxKind.AttributeContainer) {
|
|
@@ -44,10 +44,10 @@ function getCompletions(doc, sourceFile, position) {
|
|
|
44
44
|
|| (node.kind == types_1.SyntaxKind.CommaToken && (parent === null || parent === void 0 ? void 0 : parent.kind) === types_1.SyntaxKind.Assignment)) {
|
|
45
45
|
return getAttributeCompletions(position);
|
|
46
46
|
}
|
|
47
|
-
const prevNode = checker_1.findNodeAtOffset(g, node.pos - 1, true);
|
|
47
|
+
const prevNode = (0, checker_1.findNodeAtOffset)(g, node.pos - 1, true);
|
|
48
48
|
if (!prevNode)
|
|
49
49
|
return [];
|
|
50
|
-
if (__1.isIdentifierNode(prevNode)) {
|
|
50
|
+
if ((0, __1.isIdentifierNode)(prevNode)) {
|
|
51
51
|
const p = prevNode.parent;
|
|
52
52
|
if (p) {
|
|
53
53
|
switch (p.kind) {
|
|
@@ -75,7 +75,7 @@ function getCompletions(doc, sourceFile, position) {
|
|
|
75
75
|
}
|
|
76
76
|
exports.getCompletions = getCompletions;
|
|
77
77
|
function getAssignmentCompletion(assignment) {
|
|
78
|
-
const property = checker_1.getIdentifierText(assignment.leftId);
|
|
78
|
+
const property = (0, checker_1.getIdentifierText)(assignment.leftId);
|
|
79
79
|
if (!property)
|
|
80
80
|
return [];
|
|
81
81
|
switch (property.toLowerCase()) {
|
|
@@ -88,7 +88,7 @@ function getShapeCompletions() {
|
|
|
88
88
|
const kind = lst.CompletionItemKind.EnumMember;
|
|
89
89
|
return languageFacts.shapes.map(s => ({
|
|
90
90
|
kind,
|
|
91
|
-
label: util_1.escapeIdentifierText(s),
|
|
91
|
+
label: (0, util_1.escapeIdentifierText)(s),
|
|
92
92
|
}));
|
|
93
93
|
}
|
|
94
94
|
function getColorCompletions() {
|
|
@@ -112,7 +112,7 @@ function getAttributeCompletions(posistion) {
|
|
|
112
112
|
label,
|
|
113
113
|
textEdit: {
|
|
114
114
|
range,
|
|
115
|
-
newText: util_1.escapeIdentifierText(label) + "=",
|
|
115
|
+
newText: (0, util_1.escapeIdentifierText)(label) + "=",
|
|
116
116
|
},
|
|
117
117
|
}));
|
|
118
118
|
}
|
|
@@ -132,7 +132,7 @@ function getNodeCompletions(symbols, exlucdedSymbols) {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
res.push({
|
|
135
|
-
label: util_1.escapeIdentifierText(key),
|
|
135
|
+
label: (0, util_1.escapeIdentifierText)(key),
|
|
136
136
|
kind: kind,
|
|
137
137
|
});
|
|
138
138
|
}
|
package/lib/service/hover.js
CHANGED
|
@@ -11,7 +11,7 @@ function hover(doc, sourceFile, position) {
|
|
|
11
11
|
const g = sourceFile.graph;
|
|
12
12
|
if (!g)
|
|
13
13
|
return undefined;
|
|
14
|
-
const node = checker_1.findNodeAtOffset(g, offset);
|
|
14
|
+
const node = (0, checker_1.findNodeAtOffset)(g, offset);
|
|
15
15
|
if (node === undefined)
|
|
16
16
|
return undefined;
|
|
17
17
|
return getNodeHover(doc, sourceFile, node);
|
|
@@ -22,22 +22,22 @@ function getNodeHover(doc, sf, n) {
|
|
|
22
22
|
if (contents) {
|
|
23
23
|
return {
|
|
24
24
|
contents,
|
|
25
|
-
range: util_1.syntaxNodeToRange(doc, sf, n),
|
|
25
|
+
range: (0, util_1.syntaxNodeToRange)(doc, sf, n),
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
return undefined;
|
|
29
29
|
}
|
|
30
30
|
function getHoverContents(n) {
|
|
31
|
-
if (parser_1.isIdentifierNode(n)) {
|
|
31
|
+
if ((0, parser_1.isIdentifierNode)(n)) {
|
|
32
32
|
const parent = n.parent;
|
|
33
33
|
if (parent) {
|
|
34
34
|
switch (parent.kind) {
|
|
35
35
|
case types_1.SyntaxKind.NodeId:
|
|
36
|
-
return `(node) ${checker_1.getIdentifierText(n)}`;
|
|
36
|
+
return `(node) ${(0, checker_1.getIdentifierText)(n)}`;
|
|
37
37
|
case types_1.SyntaxKind.Assignment: {
|
|
38
38
|
const assignment = parent;
|
|
39
|
-
const left = checker_1.getIdentifierText(assignment.leftId);
|
|
40
|
-
const right = checker_1.getIdentifierText(assignment.rightId);
|
|
39
|
+
const left = (0, checker_1.getIdentifierText)(assignment.leftId);
|
|
40
|
+
const right = (0, checker_1.getIdentifierText)(assignment.rightId);
|
|
41
41
|
return `(assignment) \`${left}\` = \`${right}\``;
|
|
42
42
|
}
|
|
43
43
|
case types_1.SyntaxKind.DirectedGraph:
|
|
@@ -48,19 +48,19 @@ function getHoverContents(n) {
|
|
|
48
48
|
const sgs = parent;
|
|
49
49
|
const sg = sgs.subgraph;
|
|
50
50
|
return !!sg.id
|
|
51
|
-
? `(sub graph) ${checker_1.getIdentifierText(sg.id)}`
|
|
51
|
+
? `(sub graph) ${(0, checker_1.getIdentifierText)(sg.id)}`
|
|
52
52
|
: `(sub graph)`;
|
|
53
53
|
}
|
|
54
54
|
case types_1.SyntaxKind.SubGraph: {
|
|
55
55
|
const sg = parent;
|
|
56
56
|
return !!sg.id
|
|
57
|
-
? `(sub graph) ${checker_1.getIdentifierText(sg.id)}`
|
|
57
|
+
? `(sub graph) ${(0, checker_1.getIdentifierText)(sg.id)}`
|
|
58
58
|
: `(sub graph)`;
|
|
59
59
|
}
|
|
60
60
|
case types_1.SyntaxKind.IdEqualsIdStatement: {
|
|
61
61
|
const idEqId = parent;
|
|
62
|
-
const left = checker_1.getIdentifierText(idEqId.leftId);
|
|
63
|
-
const right = checker_1.getIdentifierText(idEqId.rightId);
|
|
62
|
+
const left = (0, checker_1.getIdentifierText)(idEqId.leftId);
|
|
63
|
+
const right = (0, checker_1.getIdentifierText)(idEqId.rightId);
|
|
64
64
|
return `(graph property) \`${left}\` = \`${right}\``;
|
|
65
65
|
}
|
|
66
66
|
case types_1.SyntaxKind.EdgeRhs:
|
|
@@ -93,7 +93,7 @@ function getGraphHover(g) {
|
|
|
93
93
|
const graphId = g.id;
|
|
94
94
|
const strict = g.strict ? "strict " : "";
|
|
95
95
|
return !!graphId
|
|
96
|
-
? `(${strict}${direction} graph) ${(checker_1.getIdentifierText(graphId))}`
|
|
96
|
+
? `(${strict}${direction} graph) ${((0, checker_1.getIdentifierText)(graphId))}`
|
|
97
97
|
: `(${strict}${direction} graph)`;
|
|
98
98
|
}
|
|
99
99
|
function getEdgeHover(n) {
|
|
@@ -108,16 +108,16 @@ function getEdgeHover(n) {
|
|
|
108
108
|
}
|
|
109
109
|
if (source === undefined)
|
|
110
110
|
source = p.source;
|
|
111
|
-
const edgeOpStr = common_1.getEdgeStr(n.operation.kind);
|
|
111
|
+
const edgeOpStr = (0, common_1.getEdgeStr)(n.operation.kind);
|
|
112
112
|
return source === undefined
|
|
113
113
|
? undefined
|
|
114
114
|
: `(edge) ${getEdgeSourceOrTargetText(source)} ${edgeOpStr} ${getEdgeSourceOrTargetText(n.target)}`;
|
|
115
115
|
}
|
|
116
116
|
function getEdgeSourceOrTargetText(n) {
|
|
117
117
|
return n.kind === types_1.SyntaxKind.NodeId
|
|
118
|
-
? checker_1.getIdentifierText(n.id)
|
|
118
|
+
? (0, checker_1.getIdentifierText)(n.id)
|
|
119
119
|
: n.id !== undefined
|
|
120
|
-
? `${checker_1.getIdentifierText(n.id)}`
|
|
120
|
+
? `${(0, checker_1.getIdentifierText)(n.id)}`
|
|
121
121
|
: "sub graph";
|
|
122
122
|
}
|
|
123
123
|
//# sourceMappingURL=hover.js.map
|
package/lib/service/reference.js
CHANGED
|
@@ -11,10 +11,10 @@ function findReferences(doc, sourceFile, position, context) {
|
|
|
11
11
|
if (!g)
|
|
12
12
|
return [];
|
|
13
13
|
const offset = doc.offsetAt(position);
|
|
14
|
-
const node = checker_1.findNodeAtOffset(g, offset);
|
|
14
|
+
const node = (0, checker_1.findNodeAtOffset)(g, offset);
|
|
15
15
|
if (!node)
|
|
16
16
|
return [];
|
|
17
|
-
if (__1.isIdentifierNode(node)) {
|
|
17
|
+
if ((0, __1.isIdentifierNode)(node)) {
|
|
18
18
|
const nodeSymbol = node.symbol;
|
|
19
19
|
if (!nodeSymbol)
|
|
20
20
|
throw "node.symbol is not bound";
|
|
@@ -34,7 +34,7 @@ function findReferences(doc, sourceFile, position, context) {
|
|
|
34
34
|
];
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
const ranges = util_1.syntaxNodesToRanges(doc, sourceFile, symbolRefs);
|
|
37
|
+
const ranges = (0, util_1.syntaxNodesToRanges)(doc, sourceFile, symbolRefs);
|
|
38
38
|
const uri = doc.uri;
|
|
39
39
|
return ranges.map(range => {
|
|
40
40
|
return { uri, range };
|
|
@@ -51,10 +51,10 @@ function findDefinition(doc, sourceFile, position) {
|
|
|
51
51
|
if (!g)
|
|
52
52
|
return undefined;
|
|
53
53
|
const offset = doc.offsetAt(position);
|
|
54
|
-
const node = checker_1.findNodeAtOffset(g, offset);
|
|
54
|
+
const node = (0, checker_1.findNodeAtOffset)(g, offset);
|
|
55
55
|
if (!node)
|
|
56
56
|
return undefined;
|
|
57
|
-
if (__1.isIdentifierNode(node)) {
|
|
57
|
+
if ((0, __1.isIdentifierNode)(node)) {
|
|
58
58
|
const nodeSymbol = node.symbol;
|
|
59
59
|
if (!nodeSymbol)
|
|
60
60
|
throw "node.symbol is not bound";
|
|
@@ -63,7 +63,7 @@ function findDefinition(doc, sourceFile, position) {
|
|
|
63
63
|
const firstMention = nodeSymbol.firstMention;
|
|
64
64
|
if (!firstMention)
|
|
65
65
|
return undefined;
|
|
66
|
-
const range = util_1.syntaxNodeToRange(doc, sourceFile, firstMention);
|
|
66
|
+
const range = (0, util_1.syntaxNodeToRange)(doc, sourceFile, firstMention);
|
|
67
67
|
return { uri: doc.uri, range };
|
|
68
68
|
}
|
|
69
69
|
debugger;
|
package/lib/service/rename.js
CHANGED
|
@@ -15,17 +15,17 @@ function renameSymbol(doc, sourceFile, position, newName) {
|
|
|
15
15
|
if (!g)
|
|
16
16
|
return undefined;
|
|
17
17
|
const offset = doc.offsetAt(position);
|
|
18
|
-
const node = checker_1.findNodeAtOffset(g, offset);
|
|
18
|
+
const node = (0, checker_1.findNodeAtOffset)(g, offset);
|
|
19
19
|
if (!node)
|
|
20
20
|
return undefined;
|
|
21
21
|
const parent = node.parent;
|
|
22
|
-
if (__1.isIdentifierNode(node) && isRenamableIdentifier(node) && !!parent && isRenameableNode(parent)) {
|
|
22
|
+
if ((0, __1.isIdentifierNode)(node) && isRenamableIdentifier(node) && !!parent && isRenameableNode(parent)) {
|
|
23
23
|
const nodeSymbol = node.symbol;
|
|
24
24
|
if (!nodeSymbol)
|
|
25
25
|
throw "node.symbol is not bound";
|
|
26
26
|
const r = nodeSymbol.references;
|
|
27
27
|
const refs = r ? [nodeSymbol.firstMention, ...r] : [nodeSymbol.firstMention];
|
|
28
|
-
const ranges = util_1.syntaxNodesToRanges(doc, sourceFile, refs);
|
|
28
|
+
const ranges = (0, util_1.syntaxNodesToRanges)(doc, sourceFile, refs);
|
|
29
29
|
const uri = doc.uri;
|
|
30
30
|
const res = {
|
|
31
31
|
changes: {
|
package/lib/service/service.js
CHANGED
|
@@ -15,8 +15,8 @@ function parseDocument(doc) {
|
|
|
15
15
|
const parser = new __1.Parser();
|
|
16
16
|
const content = typeof doc === "string" ? doc : doc.getText();
|
|
17
17
|
const sourceFile = parser.parse(content);
|
|
18
|
-
binder_1.bindSourceFile(sourceFile);
|
|
19
|
-
checker_1.checkSourceFile(sourceFile);
|
|
18
|
+
(0, binder_1.bindSourceFile)(sourceFile);
|
|
19
|
+
(0, checker_1.checkSourceFile)(sourceFile);
|
|
20
20
|
return sourceFile;
|
|
21
21
|
}
|
|
22
22
|
function createService() {
|
package/lib/service/util.js
CHANGED
|
@@ -10,7 +10,7 @@ exports.getStart = getStart;
|
|
|
10
10
|
function getTokenPosOfNode(sourceFile, node) {
|
|
11
11
|
if (nodeIsMissing(node))
|
|
12
12
|
return node.pos;
|
|
13
|
-
return scanner_1.skipTrivia(sourceFile.content, node.pos);
|
|
13
|
+
return (0, scanner_1.skipTrivia)(sourceFile.content, node.pos);
|
|
14
14
|
}
|
|
15
15
|
function nodeIsMissing(node) {
|
|
16
16
|
return node === undefined
|
|
@@ -39,7 +39,7 @@ function escapeIdentifierText(text) {
|
|
|
39
39
|
return quote(esc);
|
|
40
40
|
}
|
|
41
41
|
const ch = text.charCodeAt(0);
|
|
42
|
-
if (!scanner_1.isIdentifierStart(ch) || text.includes(" "))
|
|
42
|
+
if (!(0, scanner_1.isIdentifierStart)(ch) || text.includes(" "))
|
|
43
43
|
return quote(text);
|
|
44
44
|
return text;
|
|
45
45
|
}
|
|
@@ -9,7 +9,7 @@ function convertDiagnostic(document, source) {
|
|
|
9
9
|
end: document.positionAt(source.end),
|
|
10
10
|
},
|
|
11
11
|
severity: source.category,
|
|
12
|
-
code: error_1.formatError(source.code),
|
|
12
|
+
code: (0, error_1.formatError)(source.code),
|
|
13
13
|
source: error_1.diagnosicSource,
|
|
14
14
|
message: source.message,
|
|
15
15
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dot-language-support",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.6",
|
|
4
4
|
"description": "Parser and language service for graphviz (dot) files",
|
|
5
5
|
"author": "Niklas Mollenhauer",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"vscode-languageserver-types": "^3.16.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@types/chai": "^4.
|
|
32
|
-
"@types/mocha": "^9.
|
|
33
|
-
"chai": "^4.3.
|
|
34
|
-
"mocha": "^9.
|
|
35
|
-
"ts-node": "^10.
|
|
36
|
-
"typescript": "^4.3
|
|
31
|
+
"@types/chai": "^4.3.0",
|
|
32
|
+
"@types/mocha": "^9.1.0",
|
|
33
|
+
"chai": "^4.3.6",
|
|
34
|
+
"mocha": "^9.2.2",
|
|
35
|
+
"ts-node": "^10.7.0",
|
|
36
|
+
"typescript": "^4.6.3",
|
|
37
37
|
"vscode-languageserver": "^7.0.0"
|
|
38
38
|
},
|
|
39
39
|
"engines": {
|