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
|
@@ -15,21 +15,31 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getCompletions =
|
|
36
|
+
exports.getCompletions = getCompletions;
|
|
27
37
|
const lst = __importStar(require("vscode-languageserver-types"));
|
|
28
|
-
const types_js_1 = require("../types.js");
|
|
29
38
|
const checker_js_1 = require("../checker.js");
|
|
30
|
-
const util_js_1 = require("./util.js");
|
|
31
39
|
const index_js_1 = require("../index.js");
|
|
40
|
+
const types_js_1 = require("../types.js");
|
|
32
41
|
const languageFacts = __importStar(require("./languageFacts.js"));
|
|
42
|
+
const util_js_1 = require("./util.js");
|
|
33
43
|
function getCompletions(doc, sourceFile, position) {
|
|
34
44
|
const symbols = sourceFile.symbols;
|
|
35
45
|
if (!symbols)
|
|
@@ -44,8 +54,8 @@ function getCompletions(doc, sourceFile, position) {
|
|
|
44
54
|
const prevOffsetNode = (0, checker_js_1.findNodeAtOffset)(g, offset - 1, true);
|
|
45
55
|
const parent = node.parent;
|
|
46
56
|
const prevOffsetNodeParent = prevOffsetNode === null || prevOffsetNode === void 0 ? void 0 : prevOffsetNode.parent;
|
|
47
|
-
if (((parent === null || parent === void 0 ? void 0 : parent.parent) && (0, checker_js_1.isEdgeStatement)(parent.parent))
|
|
48
|
-
|
|
57
|
+
if (((parent === null || parent === void 0 ? void 0 : parent.parent) && (0, checker_js_1.isEdgeStatement)(parent.parent)) ||
|
|
58
|
+
((prevOffsetNodeParent === null || prevOffsetNodeParent === void 0 ? void 0 : prevOffsetNodeParent.parent) && (0, checker_js_1.isEdgeStatement)(prevOffsetNodeParent.parent))) {
|
|
49
59
|
return getNodeCompletions(symbols);
|
|
50
60
|
}
|
|
51
61
|
if (node.kind === types_js_1.SyntaxKind.AttributeContainer) {
|
|
@@ -58,13 +68,11 @@ function getCompletions(doc, sourceFile, position) {
|
|
|
58
68
|
}
|
|
59
69
|
}
|
|
60
70
|
if (node.kind === types_js_1.SyntaxKind.TextIdentifier && (parent === null || parent === void 0 ? void 0 : parent.kind) === types_js_1.SyntaxKind.NodeId) {
|
|
61
|
-
const exclusions = node.symbol
|
|
62
|
-
? [node.symbol.name]
|
|
63
|
-
: undefined;
|
|
71
|
+
const exclusions = node.symbol ? [node.symbol.name] : undefined;
|
|
64
72
|
return getNodeCompletions(symbols, exclusions);
|
|
65
73
|
}
|
|
66
|
-
if (node.kind === types_js_1.SyntaxKind.AttributeContainer
|
|
67
|
-
|
|
74
|
+
if (node.kind === types_js_1.SyntaxKind.AttributeContainer ||
|
|
75
|
+
(node.kind === types_js_1.SyntaxKind.CommaToken && (parent === null || parent === void 0 ? void 0 : parent.kind) === types_js_1.SyntaxKind.Assignment)) {
|
|
68
76
|
return getAttributeCompletions(position);
|
|
69
77
|
}
|
|
70
78
|
const prevNode = (0, checker_js_1.findNodeAtOffset)(g, node.pos - 1, true);
|
|
@@ -83,7 +91,7 @@ function getCompletions(doc, sourceFile, position) {
|
|
|
83
91
|
}
|
|
84
92
|
}
|
|
85
93
|
}
|
|
86
|
-
if (
|
|
94
|
+
if (node.flags & 2 || node.end === node.pos) {
|
|
87
95
|
const attribute = prevNode;
|
|
88
96
|
if (!attribute)
|
|
89
97
|
return [];
|
|
@@ -96,15 +104,17 @@ function getCompletions(doc, sourceFile, position) {
|
|
|
96
104
|
}
|
|
97
105
|
return [];
|
|
98
106
|
}
|
|
99
|
-
exports.getCompletions = getCompletions;
|
|
100
107
|
function getAssignmentCompletion(assignment) {
|
|
101
108
|
const property = (0, checker_js_1.getIdentifierText)(assignment.leftId);
|
|
102
109
|
if (!property)
|
|
103
110
|
return [];
|
|
104
111
|
switch (property.toLowerCase()) {
|
|
105
|
-
case "shape":
|
|
106
|
-
|
|
107
|
-
|
|
112
|
+
case "shape":
|
|
113
|
+
return getShapeCompletions();
|
|
114
|
+
case "color":
|
|
115
|
+
return getColorCompletions();
|
|
116
|
+
default:
|
|
117
|
+
return [];
|
|
108
118
|
}
|
|
109
119
|
}
|
|
110
120
|
function getShapeCompletions() {
|
|
@@ -117,8 +127,7 @@ function getShapeCompletions() {
|
|
|
117
127
|
function getColorCompletions() {
|
|
118
128
|
const kind = lst.CompletionItemKind.Color;
|
|
119
129
|
const colors = languageFacts.colors;
|
|
120
|
-
return Object.keys(colors)
|
|
121
|
-
.map(label => ({
|
|
130
|
+
return Object.keys(colors).map(label => ({
|
|
122
131
|
kind,
|
|
123
132
|
label,
|
|
124
133
|
documentation: colors[label],
|
|
@@ -135,7 +144,7 @@ function getAttributeCompletions(posistion) {
|
|
|
135
144
|
label,
|
|
136
145
|
textEdit: {
|
|
137
146
|
range,
|
|
138
|
-
newText: (0, util_js_1.escapeIdentifierText)(label)
|
|
147
|
+
newText: `${(0, util_js_1.escapeIdentifierText)(label)}=`,
|
|
139
148
|
},
|
|
140
149
|
}));
|
|
141
150
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type * as lst from "vscode-languageserver-types";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { DocumentLike } from "../index.js";
|
|
3
|
+
import { type SourceFile } from "../types.js";
|
|
4
4
|
export declare function hover(doc: DocumentLike, sourceFile: SourceFile, position: lst.Position): lst.Hover | undefined;
|
package/lib/cjs/service/hover.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hover =
|
|
4
|
-
const types_js_1 = require("../types.js");
|
|
3
|
+
exports.hover = hover;
|
|
5
4
|
const checker_js_1 = require("../checker.js");
|
|
6
5
|
const parser_js_1 = require("../parser.js");
|
|
7
|
-
const
|
|
6
|
+
const types_js_1 = require("../types.js");
|
|
8
7
|
const common_js_1 = require("./command/common.js");
|
|
8
|
+
const util_js_1 = require("./util.js");
|
|
9
9
|
function hover(doc, sourceFile, position) {
|
|
10
10
|
const offset = doc.offsetAt(position);
|
|
11
11
|
const g = sourceFile.graph;
|
|
@@ -16,7 +16,6 @@ function hover(doc, sourceFile, position) {
|
|
|
16
16
|
return undefined;
|
|
17
17
|
return getNodeHover(doc, sourceFile, node);
|
|
18
18
|
}
|
|
19
|
-
exports.hover = hover;
|
|
20
19
|
function getNodeHover(doc, sf, n) {
|
|
21
20
|
const contents = getHoverContents(n);
|
|
22
21
|
if (contents) {
|
|
@@ -41,7 +40,10 @@ function getHoverContents(n) {
|
|
|
41
40
|
case types_js_1.SyntaxKind.NodeId: {
|
|
42
41
|
if ((_a = n.symbol) === null || _a === void 0 ? void 0 : _a.references) {
|
|
43
42
|
const nodeIdentifierRefs = (_b = n.symbol) === null || _b === void 0 ? void 0 : _b.references;
|
|
44
|
-
const labelMentions = nodeIdentifierRefs.map(e => {
|
|
43
|
+
const labelMentions = nodeIdentifierRefs.map(e => {
|
|
44
|
+
var _a, _b, _c;
|
|
45
|
+
return (_c = (_b = (_a = e.symbol) === null || _a === void 0 ? void 0 : _a.members) === null || _b === void 0 ? void 0 : _b.get("label")) === null || _c === void 0 ? void 0 : _c.firstMention.parent;
|
|
46
|
+
});
|
|
45
47
|
for (let i = labelMentions.length; i >= 0; i--) {
|
|
46
48
|
const s = labelMentions[i];
|
|
47
49
|
if (s === null || s === void 0 ? void 0 : s.rightId) {
|
|
@@ -70,15 +72,11 @@ function getHoverContents(n) {
|
|
|
70
72
|
case types_js_1.SyntaxKind.SubGraphStatement: {
|
|
71
73
|
const sgs = parent;
|
|
72
74
|
const sg = sgs.subgraph;
|
|
73
|
-
return
|
|
74
|
-
? `(sub graph) ${(0, checker_js_1.getIdentifierText)(sg.id)}`
|
|
75
|
-
: `(sub graph)`;
|
|
75
|
+
return sg.id ? `(sub graph) ${(0, checker_js_1.getIdentifierText)(sg.id)}` : "(sub graph)";
|
|
76
76
|
}
|
|
77
77
|
case types_js_1.SyntaxKind.SubGraph: {
|
|
78
78
|
const sg = parent;
|
|
79
|
-
return
|
|
80
|
-
? `(sub graph) ${(0, checker_js_1.getIdentifierText)(sg.id)}`
|
|
81
|
-
: `(sub graph)`;
|
|
79
|
+
return sg.id ? `(sub graph) ${(0, checker_js_1.getIdentifierText)(sg.id)}` : "(sub graph)";
|
|
82
80
|
}
|
|
83
81
|
case types_js_1.SyntaxKind.IdEqualsIdStatement: {
|
|
84
82
|
const idEqId = parent;
|
|
@@ -92,9 +90,7 @@ function getHoverContents(n) {
|
|
|
92
90
|
return types_js_1.SyntaxKind[parent.kind];
|
|
93
91
|
}
|
|
94
92
|
const fallback = types_js_1.SyntaxKind[n.kind];
|
|
95
|
-
return fallback
|
|
96
|
-
? "(" + fallback.toLowerCase() + ")"
|
|
97
|
-
: undefined;
|
|
93
|
+
return fallback ? `(${fallback.toLowerCase()})` : undefined;
|
|
98
94
|
}
|
|
99
95
|
switch (n.kind) {
|
|
100
96
|
case types_js_1.SyntaxKind.GraphKeyword:
|
|
@@ -115,8 +111,8 @@ function getGraphHover(g) {
|
|
|
115
111
|
const direction = g.kind === types_js_1.SyntaxKind.DirectedGraph ? "directed" : "undirected";
|
|
116
112
|
const graphId = g.id;
|
|
117
113
|
const strict = g.strict ? "strict " : "";
|
|
118
|
-
return
|
|
119
|
-
? `(${strict}${direction} graph) ${(
|
|
114
|
+
return graphId
|
|
115
|
+
? `(${strict}${direction} graph) ${(0, checker_js_1.getIdentifierText)(graphId)}`
|
|
120
116
|
: `(${strict}${direction} graph)`;
|
|
121
117
|
}
|
|
122
118
|
function getEdgeHover(n) {
|
|
@@ -310,12 +310,7 @@ const clusterAttributes = Object.freeze([
|
|
|
310
310
|
"target",
|
|
311
311
|
"tooltip",
|
|
312
312
|
]);
|
|
313
|
-
exports.attributes = Array.from(new Set([
|
|
314
|
-
...nodeAttributes,
|
|
315
|
-
...edgeAttributes,
|
|
316
|
-
...graphAttributes,
|
|
317
|
-
...clusterAttributes,
|
|
318
|
-
])).sort();
|
|
313
|
+
exports.attributes = Array.from(new Set([...nodeAttributes, ...edgeAttributes, ...graphAttributes, ...clusterAttributes])).sort();
|
|
319
314
|
exports.colors = Object.freeze({
|
|
320
315
|
aliceblue: "#f0f8ff",
|
|
321
316
|
antiquewhite: "#faebd7",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Position, ReferenceContext
|
|
2
|
-
import type { SourceFile } from "../types.js";
|
|
1
|
+
import type { Location, Position, ReferenceContext } from "vscode-languageserver-types";
|
|
3
2
|
import { type DocumentLike } from "../index.js";
|
|
3
|
+
import type { SourceFile } from "../types.js";
|
|
4
4
|
export declare function findReferences(doc: DocumentLike, sourceFile: SourceFile, position: Position, context: ReferenceContext): Location[];
|
|
5
5
|
export declare function findDefinition(doc: DocumentLike, sourceFile: SourceFile, position: Position): Location | undefined;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
3
|
+
exports.findReferences = findReferences;
|
|
4
|
+
exports.findDefinition = findDefinition;
|
|
5
5
|
const checker_js_1 = require("../checker.js");
|
|
6
|
+
const index_js_1 = require("../index.js");
|
|
6
7
|
const util_js_1 = require("./util.js");
|
|
7
8
|
function findReferences(doc, sourceFile, position, context) {
|
|
8
9
|
if (!sourceFile.symbols)
|
|
@@ -28,10 +29,7 @@ function findReferences(doc, sourceFile, position, context) {
|
|
|
28
29
|
symbolRefs = refs;
|
|
29
30
|
}
|
|
30
31
|
else {
|
|
31
|
-
symbolRefs = [
|
|
32
|
-
nodeSymbol.firstMention,
|
|
33
|
-
...refs.filter(r => r !== node),
|
|
34
|
-
];
|
|
32
|
+
symbolRefs = [nodeSymbol.firstMention, ...refs.filter(r => r !== node)];
|
|
35
33
|
}
|
|
36
34
|
}
|
|
37
35
|
const ranges = (0, util_js_1.syntaxNodesToRanges)(doc, sourceFile, symbolRefs);
|
|
@@ -43,7 +41,6 @@ function findReferences(doc, sourceFile, position, context) {
|
|
|
43
41
|
debugger;
|
|
44
42
|
return [];
|
|
45
43
|
}
|
|
46
|
-
exports.findReferences = findReferences;
|
|
47
44
|
function findDefinition(doc, sourceFile, position) {
|
|
48
45
|
if (!sourceFile.symbols)
|
|
49
46
|
throw "sourceFile is not bound";
|
|
@@ -67,5 +64,4 @@ function findDefinition(doc, sourceFile, position) {
|
|
|
67
64
|
debugger;
|
|
68
65
|
return undefined;
|
|
69
66
|
}
|
|
70
|
-
exports.findDefinition = findDefinition;
|
|
71
67
|
//# sourceMappingURL=reference.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Position, WorkspaceEdit } from "vscode-languageserver-types";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { type Position, type WorkspaceEdit } from "vscode-languageserver-types";
|
|
2
|
+
import { type DocumentLike } from "../index.js";
|
|
3
|
+
import { type SourceFile } from "../types.js";
|
|
4
4
|
export declare function renameSymbol(doc: DocumentLike, sourceFile: SourceFile, position: Position, newName: string): WorkspaceEdit | undefined;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.renameSymbol =
|
|
3
|
+
exports.renameSymbol = renameSymbol;
|
|
4
4
|
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
|
5
|
-
const types_js_1 = require("../types.js");
|
|
6
5
|
const checker_js_1 = require("../checker.js");
|
|
7
6
|
const index_js_1 = require("../index.js");
|
|
7
|
+
const types_js_1 = require("../types.js");
|
|
8
8
|
const util_js_1 = require("./util.js");
|
|
9
9
|
function renameSymbol(doc, sourceFile, position, newName) {
|
|
10
10
|
if (!sourceFile.symbols)
|
|
@@ -19,7 +19,10 @@ function renameSymbol(doc, sourceFile, position, newName) {
|
|
|
19
19
|
if (!node)
|
|
20
20
|
return undefined;
|
|
21
21
|
const parent = node.parent;
|
|
22
|
-
if ((0, index_js_1.isIdentifierNode)(node) &&
|
|
22
|
+
if ((0, index_js_1.isIdentifierNode)(node) &&
|
|
23
|
+
isRenamableIdentifier(node) &&
|
|
24
|
+
!!parent &&
|
|
25
|
+
isRenameableNode(parent)) {
|
|
23
26
|
const nodeSymbol = node.symbol;
|
|
24
27
|
if (!nodeSymbol)
|
|
25
28
|
throw "node.symbol is not bound";
|
|
@@ -30,18 +33,17 @@ function renameSymbol(doc, sourceFile, position, newName) {
|
|
|
30
33
|
const res = {
|
|
31
34
|
changes: {
|
|
32
35
|
[uri]: ranges.map(r => vscode_languageserver_types_1.TextEdit.replace(r, newName)),
|
|
33
|
-
}
|
|
36
|
+
},
|
|
34
37
|
};
|
|
35
38
|
return res;
|
|
36
39
|
}
|
|
37
40
|
debugger;
|
|
38
41
|
return undefined;
|
|
39
42
|
}
|
|
40
|
-
exports.renameSymbol = renameSymbol;
|
|
41
43
|
function isRenameableNode(node) {
|
|
42
|
-
return node.kind === types_js_1.SyntaxKind.NodeId
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
return (node.kind === types_js_1.SyntaxKind.NodeId ||
|
|
45
|
+
node.kind === types_js_1.SyntaxKind.DirectedGraph ||
|
|
46
|
+
node.kind === types_js_1.SyntaxKind.UndirectedGraph);
|
|
45
47
|
}
|
|
46
48
|
function isRenamableIdentifier(node) {
|
|
47
49
|
return node.kind !== types_js_1.SyntaxKind.QuotedTextIdentifier;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type * as lst from "vscode-languageserver-types";
|
|
2
|
-
import type { ColorInformation, Color, ColorPresentation } from "vscode-languageserver-types";
|
|
3
1
|
import type { TextDocument } from "vscode-languageserver-textdocument";
|
|
4
|
-
import
|
|
2
|
+
import type * as lst from "vscode-languageserver-types";
|
|
3
|
+
import type { Color, ColorInformation, ColorPresentation } from "vscode-languageserver-types";
|
|
4
|
+
import type { Omit, SourceFile } from "../types.js";
|
|
5
5
|
export interface DocumentLike {
|
|
6
6
|
positionAt(offset: number): lst.Position;
|
|
7
7
|
offsetAt(position: lst.Position): number;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createService =
|
|
4
|
-
const index_js_1 = require("../index.js");
|
|
3
|
+
exports.createService = createService;
|
|
5
4
|
const binder_js_1 = require("../binder.js");
|
|
6
|
-
const hover_js_1 = require("./hover.js");
|
|
7
|
-
const validation_js_1 = require("./validation.js");
|
|
8
|
-
const reference_js_1 = require("./reference.js");
|
|
9
|
-
const rename_js_1 = require("./rename.js");
|
|
10
|
-
const completion_js_1 = require("./completion.js");
|
|
11
5
|
const checker_js_1 = require("../checker.js");
|
|
6
|
+
const index_js_1 = require("../index.js");
|
|
12
7
|
const codeAction_js_1 = require("./codeAction.js");
|
|
13
8
|
const colorProvider_js_1 = require("./colorProvider.js");
|
|
9
|
+
const completion_js_1 = require("./completion.js");
|
|
10
|
+
const hover_js_1 = require("./hover.js");
|
|
11
|
+
const reference_js_1 = require("./reference.js");
|
|
12
|
+
const rename_js_1 = require("./rename.js");
|
|
13
|
+
const validation_js_1 = require("./validation.js");
|
|
14
14
|
function parseDocument(doc) {
|
|
15
15
|
const parser = new index_js_1.Parser();
|
|
16
16
|
const content = typeof doc === "string" ? doc : doc.getText();
|
|
@@ -35,5 +35,4 @@ function createService() {
|
|
|
35
35
|
getAvailableCommands: codeAction_js_1.getAvailableCommands,
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
-
exports.createService = createService;
|
|
39
38
|
//# sourceMappingURL=service.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Range } from "vscode-languageserver-types";
|
|
2
|
-
import { SourceFile, SyntaxNode } from "../types.js";
|
|
3
2
|
import type { DocumentLike } from "../index.js";
|
|
3
|
+
import { type SourceFile, type SyntaxNode } from "../types.js";
|
|
4
4
|
export declare function getStart(sourceFile: SourceFile, node: SyntaxNode): number;
|
|
5
5
|
export declare function syntaxNodesToRanges(doc: DocumentLike, sourceFile: SourceFile, nodes: SyntaxNode[]): Range[];
|
|
6
6
|
export declare function syntaxNodeToRange(doc: DocumentLike, sourceFile: SourceFile, node: SyntaxNode): {
|
package/lib/cjs/service/util.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
3
|
+
exports.getStart = getStart;
|
|
4
|
+
exports.syntaxNodesToRanges = syntaxNodesToRanges;
|
|
5
|
+
exports.syntaxNodeToRange = syntaxNodeToRange;
|
|
6
|
+
exports.escapeIdentifierText = escapeIdentifierText;
|
|
7
|
+
exports.assertNever = assertNever;
|
|
5
8
|
const scanner_js_1 = require("../scanner.js");
|
|
9
|
+
const types_js_1 = require("../types.js");
|
|
6
10
|
function getStart(sourceFile, node) {
|
|
7
11
|
return getTokenPosOfNode(sourceFile, node);
|
|
8
12
|
}
|
|
9
|
-
exports.getStart = getStart;
|
|
10
13
|
function getTokenPosOfNode(sourceFile, node) {
|
|
11
14
|
if (nodeIsMissing(node))
|
|
12
15
|
return node.pos;
|
|
@@ -20,7 +23,6 @@ function nodeIsMissing(node) {
|
|
|
20
23
|
function syntaxNodesToRanges(doc, sourceFile, nodes) {
|
|
21
24
|
return nodes.map(node => syntaxNodeToRange(doc, sourceFile, node));
|
|
22
25
|
}
|
|
23
|
-
exports.syntaxNodesToRanges = syntaxNodesToRanges;
|
|
24
26
|
function syntaxNodeToRange(doc, sourceFile, node) {
|
|
25
27
|
const start = getStart(sourceFile, node);
|
|
26
28
|
return {
|
|
@@ -28,14 +30,11 @@ function syntaxNodeToRange(doc, sourceFile, node) {
|
|
|
28
30
|
end: doc.positionAt(node.end),
|
|
29
31
|
};
|
|
30
32
|
}
|
|
31
|
-
exports.syntaxNodeToRange = syntaxNodeToRange;
|
|
32
33
|
function escapeIdentifierText(text) {
|
|
33
34
|
if (text === "")
|
|
34
35
|
return quote("");
|
|
35
|
-
if (text.includes("
|
|
36
|
-
const esc = text
|
|
37
|
-
.replace(/"/, "\\\"")
|
|
38
|
-
.replace(/\n/, "\\\n");
|
|
36
|
+
if (text.includes('"') || text.includes("\n")) {
|
|
37
|
+
const esc = text.replace(/"/, '\\"').replace(/\n/, "\\\n");
|
|
39
38
|
return quote(esc);
|
|
40
39
|
}
|
|
41
40
|
const ch = text.charCodeAt(0);
|
|
@@ -43,10 +42,8 @@ function escapeIdentifierText(text) {
|
|
|
43
42
|
return quote(text);
|
|
44
43
|
return text;
|
|
45
44
|
}
|
|
46
|
-
|
|
47
|
-
const quote = (s) => "\"" + s + "\"";
|
|
45
|
+
const quote = (s) => `"${s}"`;
|
|
48
46
|
function assertNever(v) {
|
|
49
|
-
throw new Error(
|
|
47
|
+
throw new Error(`Should not have reached this. Value: ${v !== null && v !== void 0 ? v : ""}`);
|
|
50
48
|
}
|
|
51
|
-
exports.assertNever = assertNever;
|
|
52
49
|
//# sourceMappingURL=util.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as lst from "vscode-languageserver-types";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type * as lst from "vscode-languageserver-types";
|
|
2
|
+
import type { DocumentLike } from "../index.js";
|
|
3
|
+
import type { SourceFile } from "../types.js";
|
|
4
4
|
export declare function validateDocument(doc: DocumentLike, sourceFile: SourceFile): lst.Diagnostic[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateDocument =
|
|
3
|
+
exports.validateDocument = validateDocument;
|
|
4
4
|
const error_js_1 = require("../error.js");
|
|
5
5
|
function convertDiagnostic(document, source) {
|
|
6
6
|
return {
|
|
@@ -20,5 +20,4 @@ function validateDocument(doc, sourceFile) {
|
|
|
20
20
|
return [];
|
|
21
21
|
return diagnostics.map(d => convertDiagnostic(doc, d));
|
|
22
22
|
}
|
|
23
|
-
exports.validateDocument = validateDocument;
|
|
24
23
|
//# sourceMappingURL=validation.js.map
|
package/lib/cjs/tester.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
|
|
4
|
-
const parser_js_1 = require("./parser.js");
|
|
5
4
|
const binder_js_1 = require("./binder.js");
|
|
6
5
|
const checker_js_1 = require("./checker.js");
|
|
6
|
+
const parser_js_1 = require("./parser.js");
|
|
7
7
|
const completion_js_1 = require("./service/completion.js");
|
|
8
8
|
const text = `graph {
|
|
9
9
|
node_name_a -- node_name_b [color=blue,
|
package/lib/cjs/visitor.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { SyntaxNode, SyntaxNodeArray } from "./types.js";
|
|
1
|
+
import { type SyntaxNode, type SyntaxNodeArray } from "./types.js";
|
|
2
2
|
export declare function forEachChild<TReturn>(node: SyntaxNode, cbNode: (node: SyntaxNode) => TReturn, cbNodes?: (nodes: SyntaxNodeArray<SyntaxNode>) => TReturn): TReturn | undefined;
|
package/lib/cjs/visitor.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.forEachChild =
|
|
3
|
+
exports.forEachChild = forEachChild;
|
|
4
4
|
const types_js_1 = require("./types.js");
|
|
5
5
|
function visitNode(cbNode, node) {
|
|
6
6
|
return node && cbNode(node);
|
|
@@ -23,56 +23,54 @@ function forEachChild(node, cbNode, cbNodes) {
|
|
|
23
23
|
switch (node.kind) {
|
|
24
24
|
case types_js_1.SyntaxKind.DirectedGraph:
|
|
25
25
|
case types_js_1.SyntaxKind.UndirectedGraph:
|
|
26
|
-
return visitNodes(cbNode, cbNodes, node.statements)
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
return (visitNodes(cbNode, cbNodes, node.statements) ||
|
|
27
|
+
visitNode(cbNode, node.strict) ||
|
|
28
|
+
visitNode(cbNode, node.id));
|
|
29
29
|
case types_js_1.SyntaxKind.AttributeStatement:
|
|
30
|
-
return visitNodes(cbNode, cbNodes, node.attributes)
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
return (visitNodes(cbNode, cbNodes, node.attributes) ||
|
|
31
|
+
visitNode(cbNode, node.subject) ||
|
|
32
|
+
visitNode(cbNode, node.terminator));
|
|
33
33
|
case types_js_1.SyntaxKind.EdgeStatement:
|
|
34
|
-
return visitNodes(cbNode, cbNodes, node.attributes)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
return (visitNodes(cbNode, cbNodes, node.attributes) ||
|
|
35
|
+
visitNodes(cbNode, cbNodes, node.rhs) ||
|
|
36
|
+
visitNode(cbNode, node.source) ||
|
|
37
|
+
visitNode(cbNode, node.terminator));
|
|
38
38
|
case types_js_1.SyntaxKind.NodeStatement:
|
|
39
|
-
return visitNodes(cbNode, cbNodes, node.attributes)
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
return (visitNodes(cbNode, cbNodes, node.attributes) ||
|
|
40
|
+
visitNode(cbNode, node.id) ||
|
|
41
|
+
visitNode(cbNode, node.terminator));
|
|
42
42
|
case types_js_1.SyntaxKind.SubGraph:
|
|
43
|
-
return visitNodes(cbNode, cbNodes, node.statements)
|
|
44
|
-
|
|
43
|
+
return (visitNodes(cbNode, cbNodes, node.statements) ||
|
|
44
|
+
visitNode(cbNode, node.id));
|
|
45
45
|
case types_js_1.SyntaxKind.SubGraphStatement:
|
|
46
|
-
return visitNode(cbNode, node.subgraph)
|
|
47
|
-
|
|
46
|
+
return (visitNode(cbNode, node.subgraph) ||
|
|
47
|
+
visitNode(cbNode, node.terminator));
|
|
48
48
|
case types_js_1.SyntaxKind.IdEqualsIdStatement:
|
|
49
|
-
return visitNode(cbNode, node.leftId)
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
return (visitNode(cbNode, node.leftId) ||
|
|
50
|
+
visitNode(cbNode, node.rightId) ||
|
|
51
|
+
visitNode(cbNode, node.terminator));
|
|
52
52
|
case types_js_1.SyntaxKind.QuotedTextIdentifier:
|
|
53
53
|
return visitNodes(cbNode, cbNodes, node.values);
|
|
54
54
|
case types_js_1.SyntaxKind.EdgeRhs:
|
|
55
|
-
return visitNode(cbNode, node.operation)
|
|
56
|
-
|
|
55
|
+
return (visitNode(cbNode, node.operation) ||
|
|
56
|
+
visitNode(cbNode, node.target));
|
|
57
57
|
case types_js_1.SyntaxKind.AttributeContainer:
|
|
58
58
|
return visitNodes(cbNode, cbNodes, node.assignments);
|
|
59
59
|
case types_js_1.SyntaxKind.Assignment:
|
|
60
|
-
return visitNode(cbNode, node.leftId)
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
return (visitNode(cbNode, node.leftId) ||
|
|
61
|
+
visitNode(cbNode, node.rightId) ||
|
|
62
|
+
visitNode(cbNode, node.terminator));
|
|
63
63
|
case types_js_1.SyntaxKind.NormalPortDeclaration:
|
|
64
|
-
return visitNode(cbNode, node.colon)
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
return (visitNode(cbNode, node.colon) ||
|
|
65
|
+
visitNode(cbNode, node.id) ||
|
|
66
|
+
visitNode(cbNode, node.compassPt));
|
|
67
67
|
case types_js_1.SyntaxKind.CompassPortDeclaration:
|
|
68
|
-
return visitNode(cbNode, node.colon)
|
|
69
|
-
|
|
68
|
+
return (visitNode(cbNode, node.colon) ||
|
|
69
|
+
visitNode(cbNode, node.compassPt));
|
|
70
70
|
case types_js_1.SyntaxKind.NodeId:
|
|
71
|
-
return visitNode(cbNode, node.port)
|
|
72
|
-
|| visitNode(cbNode, node.id);
|
|
71
|
+
return (visitNode(cbNode, node.port) || visitNode(cbNode, node.id));
|
|
73
72
|
default:
|
|
74
73
|
return undefined;
|
|
75
74
|
}
|
|
76
75
|
}
|
|
77
|
-
exports.forEachChild = forEachChild;
|
|
78
76
|
//# sourceMappingURL=visitor.js.map
|
package/lib/esm/binder.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { SourceFile } from "./types.js";
|
|
1
|
+
import { type SourceFile } from "./types.js";
|
|
2
2
|
export declare function bindSourceFile(file: SourceFile): void;
|
package/lib/esm/binder.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SyntaxKind, } from "./types.js";
|
|
2
1
|
import { getIdentifierText, nodeContainsErrors } from "./checker.js";
|
|
3
2
|
import { isIdentifierNode } from "./parser.js";
|
|
3
|
+
import { SyntaxKind, } from "./types.js";
|
|
4
4
|
const binder = createBinder();
|
|
5
5
|
export function bindSourceFile(file) {
|
|
6
6
|
binder.bind(file);
|
|
@@ -74,7 +74,6 @@ function createBinder() {
|
|
|
74
74
|
ensureGlobalSymbol(node.id);
|
|
75
75
|
bind(node.id);
|
|
76
76
|
}
|
|
77
|
-
;
|
|
78
77
|
if (node.strict)
|
|
79
78
|
bind(node.strict);
|
|
80
79
|
bindChildren(node.statements);
|
|
@@ -102,7 +101,6 @@ function createBinder() {
|
|
|
102
101
|
if (node.id) {
|
|
103
102
|
bind(node.id);
|
|
104
103
|
}
|
|
105
|
-
;
|
|
106
104
|
bindChildren(node.statements);
|
|
107
105
|
}
|
|
108
106
|
function bindSubGraphStatement(node) {
|
package/lib/esm/checker.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type AttributeStatement, type EdgeRhs, type EdgeStatement, type Graph, type Identifier, type NodeId, type SourceFile, type Statement, type StatementOf, type SubGraphStatement, SyntaxKind, type SyntaxNode, type Token } from "./types.js";
|
|
2
2
|
export declare function checkSourceFile(file: SourceFile): void;
|
|
3
3
|
export declare function findNodeAtOffset(root: SyntaxNode, offset: number, inclusiveEnd?: boolean): SyntaxNode | undefined;
|
|
4
4
|
export declare function getAllowedEdgeOperation(graph: Graph): SyntaxKind.DirectedEdgeOp | SyntaxKind.UndirectedEdgeOp;
|