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,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 } from "../../";
|
|
2
|
+
import { CommandIds } from "../codeAction.js";
|
|
3
|
+
import { ExecutableCommand } from "./common.js";
|
|
4
|
+
import { DocumentLike, SourceFile, CommandApplication } from "../../index.js";
|
|
5
5
|
export interface RemoveSemicolonsCommand extends lst.Command {
|
|
6
6
|
command: CommandIds.RemoveSemicolons;
|
|
7
7
|
arguments: undefined;
|
|
@@ -1,8 +1,8 @@
|
|
|
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 common_js_1 = require("./common.js");
|
|
5
|
+
const checker_js_1 = require("../../checker.js");
|
|
6
6
|
function create() {
|
|
7
7
|
return {
|
|
8
8
|
title: "Remove optional semicolons",
|
|
@@ -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 = (0,
|
|
20
|
+
const semicolons = (0, checker_js_1.findOptionalSemicolons)(g);
|
|
21
21
|
const edits = semicolons.map(s => {
|
|
22
22
|
const end = s.end;
|
|
23
23
|
const start = end - 1;
|
|
24
|
-
return (0,
|
|
24
|
+
return (0, common_js_1.createChangeToEdit)(doc.positionAt(start), doc.positionAt(end), "");
|
|
25
25
|
});
|
|
26
26
|
return {
|
|
27
27
|
label: `Remove optional semicolons`,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TextEdit, type Position } from "vscode-languageserver-types";
|
|
2
|
-
import { SyntaxKind } from "../../";
|
|
3
|
-
import { CommandIds } from "../codeAction";
|
|
2
|
+
import { SyntaxKind } from "../../index.js";
|
|
3
|
+
import { CommandIds } from "../codeAction.js";
|
|
4
4
|
export declare function createChangeToEdit(start: Position, end: Position, changeTo: string): TextEdit;
|
|
5
5
|
export interface Offset {
|
|
6
6
|
start: number;
|
|
@@ -2,30 +2,30 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAllowedOp = exports.getOppositeEdgeOp = exports.getOppositeKind = exports.getGraphKeywordStr = exports.getEdgeStr = exports.createChangeToEdit = void 0;
|
|
4
4
|
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
|
5
|
-
const
|
|
5
|
+
const index_js_1 = require("../../index.js");
|
|
6
6
|
function createChangeToEdit(start, end, changeTo) {
|
|
7
7
|
return vscode_languageserver_types_1.TextEdit.replace(vscode_languageserver_types_1.Range.create(start, end), changeTo);
|
|
8
8
|
}
|
|
9
9
|
exports.createChangeToEdit = createChangeToEdit;
|
|
10
10
|
;
|
|
11
11
|
function getEdgeStr(op) {
|
|
12
|
-
return op ===
|
|
12
|
+
return op === index_js_1.SyntaxKind.DirectedEdgeOp ? "->" : "--";
|
|
13
13
|
}
|
|
14
14
|
exports.getEdgeStr = getEdgeStr;
|
|
15
15
|
function getGraphKeywordStr(g) {
|
|
16
|
-
return g ===
|
|
16
|
+
return g === index_js_1.SyntaxKind.DigraphKeyword ? "digraph" : "graph";
|
|
17
17
|
}
|
|
18
18
|
exports.getGraphKeywordStr = getGraphKeywordStr;
|
|
19
19
|
function getOppositeKind(g) {
|
|
20
|
-
return g ===
|
|
20
|
+
return g === index_js_1.SyntaxKind.DigraphKeyword ? index_js_1.SyntaxKind.GraphKeyword : index_js_1.SyntaxKind.DigraphKeyword;
|
|
21
21
|
}
|
|
22
22
|
exports.getOppositeKind = getOppositeKind;
|
|
23
23
|
function getOppositeEdgeOp(g) {
|
|
24
|
-
return g ===
|
|
24
|
+
return g === index_js_1.SyntaxKind.DirectedEdgeOp ? index_js_1.SyntaxKind.UndirectedEdgeOp : index_js_1.SyntaxKind.DirectedEdgeOp;
|
|
25
25
|
}
|
|
26
26
|
exports.getOppositeEdgeOp = getOppositeEdgeOp;
|
|
27
27
|
function getAllowedOp(g) {
|
|
28
|
-
return g ===
|
|
28
|
+
return g === index_js_1.SyntaxKind.DigraphKeyword ? index_js_1.SyntaxKind.DirectedEdgeOp : index_js_1.SyntaxKind.UndirectedEdgeOp;
|
|
29
29
|
}
|
|
30
30
|
exports.getAllowedOp = getAllowedOp;
|
|
31
31
|
//# sourceMappingURL=common.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as lst from "vscode-languageserver-types";
|
|
2
|
-
import { SourceFile } from "../types";
|
|
3
|
-
import { DocumentLike } from "../";
|
|
2
|
+
import { SourceFile } from "../types.js";
|
|
3
|
+
import { DocumentLike } from "../index.js";
|
|
4
4
|
export declare function getCompletions(doc: DocumentLike, sourceFile: SourceFile, position: lst.Position): lst.CompletionItem[];
|
|
@@ -25,11 +25,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.getCompletions = void 0;
|
|
27
27
|
const lst = __importStar(require("vscode-languageserver-types"));
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const languageFacts = __importStar(require("./languageFacts"));
|
|
28
|
+
const types_js_1 = require("../types.js");
|
|
29
|
+
const checker_js_1 = require("../checker.js");
|
|
30
|
+
const util_js_1 = require("./util.js");
|
|
31
|
+
const index_js_1 = require("../index.js");
|
|
32
|
+
const languageFacts = __importStar(require("./languageFacts.js"));
|
|
33
33
|
function getCompletions(doc, sourceFile, position) {
|
|
34
34
|
const symbols = sourceFile.symbols;
|
|
35
35
|
if (!symbols)
|
|
@@ -38,46 +38,46 @@ function getCompletions(doc, sourceFile, position) {
|
|
|
38
38
|
if (!g)
|
|
39
39
|
return [];
|
|
40
40
|
const offset = doc.offsetAt(position);
|
|
41
|
-
const node = (0,
|
|
41
|
+
const node = (0, checker_js_1.findNodeAtOffset)(g, offset, true);
|
|
42
42
|
if (!node)
|
|
43
43
|
return [];
|
|
44
|
-
const prevOffsetNode = (0,
|
|
44
|
+
const prevOffsetNode = (0, checker_js_1.findNodeAtOffset)(g, offset - 1, true);
|
|
45
45
|
const parent = node.parent;
|
|
46
46
|
const prevOffsetNodeParent = prevOffsetNode === null || prevOffsetNode === void 0 ? void 0 : prevOffsetNode.parent;
|
|
47
|
-
if (((parent === null || parent === void 0 ? void 0 : parent.parent) && (0,
|
|
48
|
-
|| ((prevOffsetNodeParent === null || prevOffsetNodeParent === void 0 ? void 0 : prevOffsetNodeParent.parent) && (0,
|
|
47
|
+
if (((parent === null || parent === void 0 ? void 0 : parent.parent) && (0, checker_js_1.isEdgeStatement)(parent.parent))
|
|
48
|
+
|| ((prevOffsetNodeParent === null || prevOffsetNodeParent === void 0 ? void 0 : prevOffsetNodeParent.parent) && (0, checker_js_1.isEdgeStatement)(prevOffsetNodeParent.parent))) {
|
|
49
49
|
return getNodeCompletions(symbols);
|
|
50
50
|
}
|
|
51
|
-
if (node.kind ===
|
|
51
|
+
if (node.kind === types_js_1.SyntaxKind.AttributeContainer) {
|
|
52
52
|
const openingBracket = node.openBracket;
|
|
53
53
|
if (openingBracket.end - 1 > offset - 1) {
|
|
54
|
-
const exclusions = (prevOffsetNode === null || prevOffsetNode === void 0 ? void 0 : prevOffsetNode.kind) ===
|
|
54
|
+
const exclusions = (prevOffsetNode === null || prevOffsetNode === void 0 ? void 0 : prevOffsetNode.kind) === types_js_1.SyntaxKind.TextIdentifier && prevOffsetNode.symbol
|
|
55
55
|
? [prevOffsetNode.symbol.name]
|
|
56
56
|
: undefined;
|
|
57
57
|
return getNodeCompletions(symbols, exclusions);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
if (node.kind ===
|
|
60
|
+
if (node.kind === types_js_1.SyntaxKind.TextIdentifier && (parent === null || parent === void 0 ? void 0 : parent.kind) === types_js_1.SyntaxKind.NodeId) {
|
|
61
61
|
const exclusions = node.symbol
|
|
62
62
|
? [node.symbol.name]
|
|
63
63
|
: undefined;
|
|
64
64
|
return getNodeCompletions(symbols, exclusions);
|
|
65
65
|
}
|
|
66
|
-
if (node.kind ===
|
|
67
|
-
|| (node.kind ==
|
|
66
|
+
if (node.kind === types_js_1.SyntaxKind.AttributeContainer
|
|
67
|
+
|| (node.kind == types_js_1.SyntaxKind.CommaToken && (parent === null || parent === void 0 ? void 0 : parent.kind) === types_js_1.SyntaxKind.Assignment)) {
|
|
68
68
|
return getAttributeCompletions(position);
|
|
69
69
|
}
|
|
70
|
-
const prevNode = (0,
|
|
70
|
+
const prevNode = (0, checker_js_1.findNodeAtOffset)(g, node.pos - 1, true);
|
|
71
71
|
if (!prevNode)
|
|
72
72
|
return [];
|
|
73
|
-
if ((0,
|
|
73
|
+
if ((0, index_js_1.isIdentifierNode)(prevNode)) {
|
|
74
74
|
const p = prevNode.parent;
|
|
75
75
|
if (p) {
|
|
76
76
|
switch (p.kind) {
|
|
77
|
-
case
|
|
77
|
+
case types_js_1.SyntaxKind.NodeId: {
|
|
78
78
|
return getNodeCompletions(symbols);
|
|
79
79
|
}
|
|
80
|
-
case
|
|
80
|
+
case types_js_1.SyntaxKind.Assignment: {
|
|
81
81
|
return getAssignmentCompletion(p);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
@@ -90,7 +90,7 @@ function getCompletions(doc, sourceFile, position) {
|
|
|
90
90
|
if (!attribute.parent)
|
|
91
91
|
throw "sourceFile is not bound";
|
|
92
92
|
const parent = attribute.parent;
|
|
93
|
-
if (parent.kind ===
|
|
93
|
+
if (parent.kind === types_js_1.SyntaxKind.Assignment) {
|
|
94
94
|
return getAssignmentCompletion(parent);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
@@ -98,7 +98,7 @@ function getCompletions(doc, sourceFile, position) {
|
|
|
98
98
|
}
|
|
99
99
|
exports.getCompletions = getCompletions;
|
|
100
100
|
function getAssignmentCompletion(assignment) {
|
|
101
|
-
const property = (0,
|
|
101
|
+
const property = (0, checker_js_1.getIdentifierText)(assignment.leftId);
|
|
102
102
|
if (!property)
|
|
103
103
|
return [];
|
|
104
104
|
switch (property.toLowerCase()) {
|
|
@@ -111,7 +111,7 @@ function getShapeCompletions() {
|
|
|
111
111
|
const kind = lst.CompletionItemKind.EnumMember;
|
|
112
112
|
return languageFacts.shapes.map(s => ({
|
|
113
113
|
kind,
|
|
114
|
-
label: (0,
|
|
114
|
+
label: (0, util_js_1.escapeIdentifierText)(s),
|
|
115
115
|
}));
|
|
116
116
|
}
|
|
117
117
|
function getColorCompletions() {
|
|
@@ -135,7 +135,7 @@ function getAttributeCompletions(posistion) {
|
|
|
135
135
|
label,
|
|
136
136
|
textEdit: {
|
|
137
137
|
range,
|
|
138
|
-
newText: (0,
|
|
138
|
+
newText: (0, util_js_1.escapeIdentifierText)(label) + "=",
|
|
139
139
|
},
|
|
140
140
|
}));
|
|
141
141
|
}
|
|
@@ -148,14 +148,14 @@ function getNodeCompletions(symbols, exlucdedSymbols) {
|
|
|
148
148
|
const a = value.firstMention.parent;
|
|
149
149
|
if (a) {
|
|
150
150
|
switch (a.kind) {
|
|
151
|
-
case
|
|
152
|
-
case
|
|
151
|
+
case types_js_1.SyntaxKind.DirectedGraph:
|
|
152
|
+
case types_js_1.SyntaxKind.UndirectedGraph:
|
|
153
153
|
kind = lst.CompletionItemKind.Class;
|
|
154
154
|
break;
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
res.push({
|
|
158
|
-
label: (0,
|
|
158
|
+
label: (0, util_js_1.escapeIdentifierText)(key),
|
|
159
159
|
kind: kind,
|
|
160
160
|
});
|
|
161
161
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type * as lst from "vscode-languageserver-types";
|
|
2
|
-
import { SourceFile } from "../types";
|
|
3
|
-
import { DocumentLike } from "../";
|
|
2
|
+
import { SourceFile } from "../types.js";
|
|
3
|
+
import { DocumentLike } from "../index.js";
|
|
4
4
|
export declare function hover(doc: DocumentLike, sourceFile: SourceFile, position: lst.Position): lst.Hover | undefined;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hover = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
4
|
+
const types_js_1 = require("../types.js");
|
|
5
|
+
const checker_js_1 = require("../checker.js");
|
|
6
|
+
const parser_js_1 = require("../parser.js");
|
|
7
|
+
const util_js_1 = require("./util.js");
|
|
8
|
+
const common_js_1 = require("./command/common.js");
|
|
9
9
|
function hover(doc, sourceFile, position) {
|
|
10
10
|
const offset = doc.offsetAt(position);
|
|
11
11
|
const g = sourceFile.graph;
|
|
12
12
|
if (!g)
|
|
13
13
|
return undefined;
|
|
14
|
-
const node = (0,
|
|
14
|
+
const node = (0, checker_js_1.findNodeAtOffset)(g, offset);
|
|
15
15
|
if (node === undefined)
|
|
16
16
|
return undefined;
|
|
17
17
|
return getNodeHover(doc, sourceFile, node);
|
|
@@ -22,78 +22,78 @@ function getNodeHover(doc, sf, n) {
|
|
|
22
22
|
if (contents) {
|
|
23
23
|
return {
|
|
24
24
|
contents,
|
|
25
|
-
range: (0,
|
|
25
|
+
range: (0, util_js_1.syntaxNodeToRange)(doc, sf, n),
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
return undefined;
|
|
29
29
|
}
|
|
30
30
|
function getHoverContents(n) {
|
|
31
|
-
if ((0,
|
|
31
|
+
if ((0, parser_js_1.isIdentifierNode)(n)) {
|
|
32
32
|
const parent = n.parent;
|
|
33
33
|
if (parent) {
|
|
34
34
|
switch (parent.kind) {
|
|
35
|
-
case
|
|
36
|
-
return `(node) ${(0,
|
|
37
|
-
case
|
|
35
|
+
case types_js_1.SyntaxKind.NodeId:
|
|
36
|
+
return `(node) ${(0, checker_js_1.getIdentifierText)(n)}`;
|
|
37
|
+
case types_js_1.SyntaxKind.Assignment: {
|
|
38
38
|
const assignment = parent;
|
|
39
|
-
const left = (0,
|
|
40
|
-
const right = (0,
|
|
39
|
+
const left = (0, checker_js_1.getIdentifierText)(assignment.leftId);
|
|
40
|
+
const right = (0, checker_js_1.getIdentifierText)(assignment.rightId);
|
|
41
41
|
return `(assignment) \`${left}\` = \`${right}\``;
|
|
42
42
|
}
|
|
43
|
-
case
|
|
43
|
+
case types_js_1.SyntaxKind.DirectedGraph:
|
|
44
44
|
return getGraphHover(parent);
|
|
45
|
-
case
|
|
45
|
+
case types_js_1.SyntaxKind.UndirectedGraph:
|
|
46
46
|
return getGraphHover(parent);
|
|
47
|
-
case
|
|
47
|
+
case types_js_1.SyntaxKind.SubGraphStatement: {
|
|
48
48
|
const sgs = parent;
|
|
49
49
|
const sg = sgs.subgraph;
|
|
50
50
|
return !!sg.id
|
|
51
|
-
? `(sub graph) ${(0,
|
|
51
|
+
? `(sub graph) ${(0, checker_js_1.getIdentifierText)(sg.id)}`
|
|
52
52
|
: `(sub graph)`;
|
|
53
53
|
}
|
|
54
|
-
case
|
|
54
|
+
case types_js_1.SyntaxKind.SubGraph: {
|
|
55
55
|
const sg = parent;
|
|
56
56
|
return !!sg.id
|
|
57
|
-
? `(sub graph) ${(0,
|
|
57
|
+
? `(sub graph) ${(0, checker_js_1.getIdentifierText)(sg.id)}`
|
|
58
58
|
: `(sub graph)`;
|
|
59
59
|
}
|
|
60
|
-
case
|
|
60
|
+
case types_js_1.SyntaxKind.IdEqualsIdStatement: {
|
|
61
61
|
const idEqId = parent;
|
|
62
|
-
const left = (0,
|
|
63
|
-
const right = (0,
|
|
62
|
+
const left = (0, checker_js_1.getIdentifierText)(idEqId.leftId);
|
|
63
|
+
const right = (0, checker_js_1.getIdentifierText)(idEqId.rightId);
|
|
64
64
|
return `(graph property) \`${left}\` = \`${right}\``;
|
|
65
65
|
}
|
|
66
|
-
case
|
|
66
|
+
case types_js_1.SyntaxKind.EdgeRhs:
|
|
67
67
|
return getEdgeHover(parent);
|
|
68
68
|
}
|
|
69
|
-
return
|
|
69
|
+
return types_js_1.SyntaxKind[parent.kind];
|
|
70
70
|
}
|
|
71
|
-
const fallback =
|
|
71
|
+
const fallback = types_js_1.SyntaxKind[n.kind];
|
|
72
72
|
return fallback
|
|
73
73
|
? "(" + fallback.toLowerCase() + ")"
|
|
74
74
|
: undefined;
|
|
75
75
|
}
|
|
76
76
|
switch (n.kind) {
|
|
77
|
-
case
|
|
78
|
-
case
|
|
79
|
-
case
|
|
77
|
+
case types_js_1.SyntaxKind.GraphKeyword:
|
|
78
|
+
case types_js_1.SyntaxKind.DigraphKeyword:
|
|
79
|
+
case types_js_1.SyntaxKind.StrictKeyword:
|
|
80
80
|
return getGraphHover(n.parent);
|
|
81
|
-
case
|
|
82
|
-
case
|
|
81
|
+
case types_js_1.SyntaxKind.DirectedGraph:
|
|
82
|
+
case types_js_1.SyntaxKind.UndirectedGraph:
|
|
83
83
|
return getGraphHover(n);
|
|
84
|
-
case
|
|
85
|
-
case
|
|
84
|
+
case types_js_1.SyntaxKind.DirectedEdgeOp:
|
|
85
|
+
case types_js_1.SyntaxKind.UndirectedEdgeOp:
|
|
86
86
|
return getEdgeHover(n.parent);
|
|
87
87
|
default:
|
|
88
88
|
return undefined;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
function getGraphHover(g) {
|
|
92
|
-
const direction = g.kind ===
|
|
92
|
+
const direction = g.kind === types_js_1.SyntaxKind.DirectedGraph ? "directed" : "undirected";
|
|
93
93
|
const graphId = g.id;
|
|
94
94
|
const strict = g.strict ? "strict " : "";
|
|
95
95
|
return !!graphId
|
|
96
|
-
? `(${strict}${direction} graph) ${((0,
|
|
96
|
+
? `(${strict}${direction} graph) ${((0, checker_js_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 = (0,
|
|
111
|
+
const edgeOpStr = (0, common_js_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
|
-
return n.kind ===
|
|
118
|
-
? (0,
|
|
117
|
+
return n.kind === types_js_1.SyntaxKind.NodeId
|
|
118
|
+
? (0, checker_js_1.getIdentifierText)(n.id)
|
|
119
119
|
: n.id !== undefined
|
|
120
|
-
? `${(0,
|
|
120
|
+
? `${(0, checker_js_1.getIdentifierText)(n.id)}`
|
|
121
121
|
: "sub graph";
|
|
122
122
|
}
|
|
123
123
|
//# sourceMappingURL=hover.js.map
|
|
File without changes
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Position, ReferenceContext, Location } from "vscode-languageserver-types";
|
|
2
|
-
import type { SourceFile } from "../types";
|
|
3
|
-
import { type DocumentLike } from "../";
|
|
2
|
+
import type { SourceFile } from "../types.js";
|
|
3
|
+
import { type DocumentLike } from "../index.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,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.findDefinition = exports.findReferences = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
4
|
+
const index_js_1 = require("../index.js");
|
|
5
|
+
const checker_js_1 = require("../checker.js");
|
|
6
|
+
const util_js_1 = require("./util.js");
|
|
7
7
|
function findReferences(doc, sourceFile, position, context) {
|
|
8
8
|
if (!sourceFile.symbols)
|
|
9
9
|
throw "sourceFile is not bound";
|
|
@@ -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 = (0,
|
|
14
|
+
const node = (0, checker_js_1.findNodeAtOffset)(g, offset);
|
|
15
15
|
if (!node)
|
|
16
16
|
return [];
|
|
17
|
-
if ((0,
|
|
17
|
+
if ((0, index_js_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 = (0,
|
|
37
|
+
const ranges = (0, util_js_1.syntaxNodesToRanges)(doc, sourceFile, symbolRefs);
|
|
38
38
|
const uri = doc.uri;
|
|
39
39
|
return ranges.map(range => {
|
|
40
40
|
return { uri, range };
|
|
@@ -51,17 +51,17 @@ function findDefinition(doc, sourceFile, position) {
|
|
|
51
51
|
if (!g)
|
|
52
52
|
return undefined;
|
|
53
53
|
const offset = doc.offsetAt(position);
|
|
54
|
-
const node = (0,
|
|
54
|
+
const node = (0, checker_js_1.findNodeAtOffset)(g, offset);
|
|
55
55
|
if (!node)
|
|
56
56
|
return undefined;
|
|
57
|
-
if ((0,
|
|
57
|
+
if ((0, index_js_1.isIdentifierNode)(node)) {
|
|
58
58
|
const nodeSymbol = node.symbol;
|
|
59
59
|
if (!nodeSymbol)
|
|
60
60
|
throw "node.symbol is not bound";
|
|
61
61
|
const firstMention = nodeSymbol.firstMention;
|
|
62
62
|
if (!firstMention)
|
|
63
63
|
return undefined;
|
|
64
|
-
const range = (0,
|
|
64
|
+
const range = (0, util_js_1.syntaxNodeToRange)(doc, sourceFile, firstMention);
|
|
65
65
|
return { uri: doc.uri, range };
|
|
66
66
|
}
|
|
67
67
|
debugger;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Position, WorkspaceEdit } from "vscode-languageserver-types";
|
|
2
|
-
import { SourceFile } from "../types";
|
|
3
|
-
import { DocumentLike } from "../";
|
|
2
|
+
import { SourceFile } from "../types.js";
|
|
3
|
+
import { DocumentLike } from "../index.js";
|
|
4
4
|
export declare function renameSymbol(doc: DocumentLike, sourceFile: SourceFile, position: Position, newName: string): WorkspaceEdit | undefined;
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.renameSymbol = void 0;
|
|
4
4
|
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
5
|
+
const types_js_1 = require("../types.js");
|
|
6
|
+
const checker_js_1 = require("../checker.js");
|
|
7
|
+
const index_js_1 = require("../index.js");
|
|
8
|
+
const util_js_1 = require("./util.js");
|
|
9
9
|
function renameSymbol(doc, sourceFile, position, newName) {
|
|
10
10
|
if (!sourceFile.symbols)
|
|
11
11
|
throw "sourceFile is not bound";
|
|
@@ -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 = (0,
|
|
18
|
+
const node = (0, checker_js_1.findNodeAtOffset)(g, offset);
|
|
19
19
|
if (!node)
|
|
20
20
|
return undefined;
|
|
21
21
|
const parent = node.parent;
|
|
22
|
-
if ((0,
|
|
22
|
+
if ((0, index_js_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 = (0,
|
|
28
|
+
const ranges = (0, util_js_1.syntaxNodesToRanges)(doc, sourceFile, refs);
|
|
29
29
|
const uri = doc.uri;
|
|
30
30
|
const res = {
|
|
31
31
|
changes: {
|
|
@@ -39,11 +39,11 @@ function renameSymbol(doc, sourceFile, position, newName) {
|
|
|
39
39
|
}
|
|
40
40
|
exports.renameSymbol = renameSymbol;
|
|
41
41
|
function isRenameableNode(node) {
|
|
42
|
-
return node.kind ===
|
|
43
|
-
|| node.kind ===
|
|
44
|
-
|| node.kind ===
|
|
42
|
+
return node.kind === types_js_1.SyntaxKind.NodeId
|
|
43
|
+
|| node.kind === types_js_1.SyntaxKind.DirectedGraph
|
|
44
|
+
|| node.kind === types_js_1.SyntaxKind.UndirectedGraph;
|
|
45
45
|
}
|
|
46
46
|
function isRenamableIdentifier(node) {
|
|
47
|
-
return node.kind !==
|
|
47
|
+
return node.kind !== types_js_1.SyntaxKind.QuotedTextIdentifier;
|
|
48
48
|
}
|
|
49
49
|
//# sourceMappingURL=rename.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type * as lst from "vscode-languageserver-types";
|
|
2
|
+
import type { ColorInformation, Color, ColorPresentation } from "vscode-languageserver-types";
|
|
2
3
|
import type { TextDocument } from "vscode-languageserver-textdocument";
|
|
3
|
-
import {
|
|
4
|
-
import { SourceFile, Omit } from "../types";
|
|
4
|
+
import { SourceFile, Omit } from "../types.js";
|
|
5
5
|
export interface DocumentLike {
|
|
6
6
|
positionAt(offset: number): lst.Position;
|
|
7
7
|
offsetAt(position: lst.Position): number;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createService = void 0;
|
|
4
|
+
const index_js_1 = require("../index.js");
|
|
5
|
+
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
|
+
const checker_js_1 = require("../checker.js");
|
|
12
|
+
const codeAction_js_1 = require("./codeAction.js");
|
|
13
|
+
const colorProvider_js_1 = require("./colorProvider.js");
|
|
14
|
+
function parseDocument(doc) {
|
|
15
|
+
const parser = new index_js_1.Parser();
|
|
16
|
+
const content = typeof doc === "string" ? doc : doc.getText();
|
|
17
|
+
const sourceFile = parser.parse(content);
|
|
18
|
+
(0, binder_js_1.bindSourceFile)(sourceFile);
|
|
19
|
+
(0, checker_js_1.checkSourceFile)(sourceFile);
|
|
20
|
+
return sourceFile;
|
|
21
|
+
}
|
|
22
|
+
function createService() {
|
|
23
|
+
return {
|
|
24
|
+
parseDocument,
|
|
25
|
+
validateDocument: validation_js_1.validateDocument,
|
|
26
|
+
hover: hover_js_1.hover,
|
|
27
|
+
findReferences: reference_js_1.findReferences,
|
|
28
|
+
findDefinition: reference_js_1.findDefinition,
|
|
29
|
+
renameSymbol: rename_js_1.renameSymbol,
|
|
30
|
+
getCompletions: completion_js_1.getCompletions,
|
|
31
|
+
getDocumentColors: colorProvider_js_1.getDocumentColors,
|
|
32
|
+
getColorRepresentations: colorProvider_js_1.getColorRepresentations,
|
|
33
|
+
getCodeActions: codeAction_js_1.getCodeActions,
|
|
34
|
+
executeCommand: codeAction_js_1.executeCommand,
|
|
35
|
+
getAvailableCommands: codeAction_js_1.getAvailableCommands,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
exports.createService = createService;
|
|
39
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Range } from "vscode-languageserver-types";
|
|
2
|
-
import { SourceFile, SyntaxNode } from "../types";
|
|
3
|
-
import type { DocumentLike } from "../";
|
|
2
|
+
import { SourceFile, SyntaxNode } from "../types.js";
|
|
3
|
+
import type { DocumentLike } from "../index.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): {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.assertNever = exports.escapeIdentifierText = exports.syntaxNodeToRange = exports.syntaxNodesToRanges = exports.getStart = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const types_js_1 = require("../types.js");
|
|
5
|
+
const scanner_js_1 = require("../scanner.js");
|
|
6
6
|
function getStart(sourceFile, node) {
|
|
7
7
|
return getTokenPosOfNode(sourceFile, node);
|
|
8
8
|
}
|
|
@@ -10,12 +10,12 @@ exports.getStart = getStart;
|
|
|
10
10
|
function getTokenPosOfNode(sourceFile, node) {
|
|
11
11
|
if (nodeIsMissing(node))
|
|
12
12
|
return node.pos;
|
|
13
|
-
return (0,
|
|
13
|
+
return (0, scanner_js_1.skipTrivia)(sourceFile.content, node.pos);
|
|
14
14
|
}
|
|
15
15
|
function nodeIsMissing(node) {
|
|
16
16
|
return node === undefined
|
|
17
17
|
? true
|
|
18
|
-
: node.pos === node.end && node.pos >= 0 && node.kind !==
|
|
18
|
+
: node.pos === node.end && node.pos >= 0 && node.kind !== types_js_1.SyntaxKind.EndOfFileToken;
|
|
19
19
|
}
|
|
20
20
|
function syntaxNodesToRanges(doc, sourceFile, nodes) {
|
|
21
21
|
return nodes.map(node => syntaxNodeToRange(doc, sourceFile, node));
|
|
@@ -39,7 +39,7 @@ function escapeIdentifierText(text) {
|
|
|
39
39
|
return quote(esc);
|
|
40
40
|
}
|
|
41
41
|
const ch = text.charCodeAt(0);
|
|
42
|
-
if (!(0,
|
|
42
|
+
if (!(0, scanner_js_1.isIdentifierStart)(ch) || text.includes(" "))
|
|
43
43
|
return quote(text);
|
|
44
44
|
return text;
|
|
45
45
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as lst from "vscode-languageserver-types";
|
|
2
|
-
import { SourceFile } from "../types";
|
|
3
|
-
import { DocumentLike } from "../";
|
|
2
|
+
import { SourceFile } from "../types.js";
|
|
3
|
+
import { DocumentLike } from "../index.js";
|
|
4
4
|
export declare function validateDocument(doc: DocumentLike, sourceFile: SourceFile): lst.Diagnostic[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validateDocument = void 0;
|
|
4
|
-
const
|
|
4
|
+
const error_js_1 = require("../error.js");
|
|
5
5
|
function convertDiagnostic(document, source) {
|
|
6
6
|
return {
|
|
7
7
|
range: {
|
|
@@ -9,8 +9,8 @@ function convertDiagnostic(document, source) {
|
|
|
9
9
|
end: document.positionAt(source.end),
|
|
10
10
|
},
|
|
11
11
|
severity: source.category,
|
|
12
|
-
code: (0,
|
|
13
|
-
source:
|
|
12
|
+
code: (0, error_js_1.formatError)(source.code),
|
|
13
|
+
source: error_js_1.diagnosicSource,
|
|
14
14
|
message: source.message,
|
|
15
15
|
};
|
|
16
16
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|