dot-language-support 2.3.0 → 3.0.0
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/dist/index.d.ts +497 -0
- package/dist/index.js +3853 -0
- package/package.json +10 -11
- package/.github/dependabot.yml +0 -15
- package/.github/workflows/CD.yml +0 -37
- package/.github/workflows/CI.yml +0 -28
- package/.github/workflows/auto-merge.yaml +0 -26
- package/CITATION.cff +0 -14
- package/biome.json +0 -48
- package/lib/cjs/binder.d.ts +0 -2
- package/lib/cjs/binder.js +0 -297
- package/lib/cjs/checker.d.ts +0 -15
- package/lib/cjs/checker.js +0 -228
- package/lib/cjs/core.d.ts +0 -1
- package/lib/cjs/core.js +0 -13
- package/lib/cjs/error.d.ts +0 -3
- package/lib/cjs/error.js +0 -12
- package/lib/cjs/index.d.ts +0 -5
- package/lib/cjs/index.js +0 -22
- package/lib/cjs/parser.d.ts +0 -27
- package/lib/cjs/parser.js +0 -664
- package/lib/cjs/scanner.d.ts +0 -41
- package/lib/cjs/scanner.js +0 -578
- package/lib/cjs/service/codeAction.d.ts +0 -12
- package/lib/cjs/service/codeAction.js +0 -245
- package/lib/cjs/service/colorProvider.d.ts +0 -5
- package/lib/cjs/service/colorProvider.js +0 -91
- package/lib/cjs/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.d.ts +0 -10
- package/lib/cjs/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.js +0 -42
- package/lib/cjs/service/command/ChangeEdgeOpCommand.d.ts +0 -10
- package/lib/cjs/service/command/ChangeEdgeOpCommand.js +0 -67
- package/lib/cjs/service/command/ConsolidateDescendantsCommand.d.ts +0 -10
- package/lib/cjs/service/command/ConsolidateDescendantsCommand.js +0 -87
- package/lib/cjs/service/command/RemoveSemicolons.d.ts +0 -10
- package/lib/cjs/service/command/RemoveSemicolons.js +0 -39
- package/lib/cjs/service/command/common.d.ts +0 -31
- package/lib/cjs/service/command/common.js +0 -33
- package/lib/cjs/service/completion.d.ts +0 -4
- package/lib/cjs/service/completion.js +0 -173
- package/lib/cjs/service/hover.d.ts +0 -4
- package/lib/cjs/service/hover.js +0 -142
- package/lib/cjs/service/languageFacts.d.ts +0 -683
- package/lib/cjs/service/languageFacts.js +0 -996
- package/lib/cjs/service/reference.d.ts +0 -5
- package/lib/cjs/service/reference.js +0 -67
- package/lib/cjs/service/rename.d.ts +0 -4
- package/lib/cjs/service/rename.js +0 -51
- package/lib/cjs/service/service.d.ts +0 -28
- package/lib/cjs/service/service.js +0 -38
- package/lib/cjs/service/util.d.ts +0 -11
- package/lib/cjs/service/util.js +0 -49
- package/lib/cjs/service/validation.d.ts +0 -4
- package/lib/cjs/service/validation.js +0 -23
- package/lib/cjs/tester.d.ts +0 -1
- package/lib/cjs/tester.js +0 -23
- package/lib/cjs/types.d.ts +0 -397
- package/lib/cjs/types.js +0 -74
- package/lib/cjs/visitor.d.ts +0 -2
- package/lib/cjs/visitor.js +0 -76
- package/lib/esm/binder.d.ts +0 -2
- package/lib/esm/binder.js +0 -294
- package/lib/esm/checker.d.ts +0 -15
- package/lib/esm/checker.js +0 -212
- package/lib/esm/core.d.ts +0 -1
- package/lib/esm/core.js +0 -10
- package/lib/esm/error.d.ts +0 -3
- package/lib/esm/error.js +0 -8
- package/lib/esm/index.d.ts +0 -5
- package/lib/esm/index.js +0 -6
- package/lib/esm/parser.d.ts +0 -27
- package/lib/esm/parser.js +0 -714
- package/lib/esm/scanner.d.ts +0 -41
- package/lib/esm/scanner.js +0 -581
- package/lib/esm/service/codeAction.d.ts +0 -12
- package/lib/esm/service/codeAction.js +0 -207
- package/lib/esm/service/colorProvider.d.ts +0 -5
- package/lib/esm/service/colorProvider.js +0 -54
- package/lib/esm/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.d.ts +0 -10
- package/lib/esm/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.js +0 -38
- package/lib/esm/service/command/ChangeEdgeOpCommand.d.ts +0 -10
- package/lib/esm/service/command/ChangeEdgeOpCommand.js +0 -30
- package/lib/esm/service/command/ConsolidateDescendantsCommand.d.ts +0 -10
- package/lib/esm/service/command/ConsolidateDescendantsCommand.js +0 -83
- package/lib/esm/service/command/RemoveSemicolons.d.ts +0 -10
- package/lib/esm/service/command/RemoveSemicolons.js +0 -35
- package/lib/esm/service/command/common.d.ts +0 -31
- package/lib/esm/service/command/common.js +0 -25
- package/lib/esm/service/completion.d.ts +0 -4
- package/lib/esm/service/completion.js +0 -137
- package/lib/esm/service/hover.d.ts +0 -4
- package/lib/esm/service/hover.js +0 -135
- package/lib/esm/service/languageFacts.d.ts +0 -683
- package/lib/esm/service/languageFacts.js +0 -993
- package/lib/esm/service/reference.d.ts +0 -5
- package/lib/esm/service/reference.js +0 -63
- package/lib/esm/service/rename.d.ts +0 -4
- package/lib/esm/service/rename.js +0 -48
- package/lib/esm/service/service.d.ts +0 -28
- package/lib/esm/service/service.js +0 -35
- package/lib/esm/service/util.d.ts +0 -11
- package/lib/esm/service/util.js +0 -42
- package/lib/esm/service/validation.d.ts +0 -4
- package/lib/esm/service/validation.js +0 -20
- package/lib/esm/tester.d.ts +0 -1
- package/lib/esm/tester.js +0 -21
- package/lib/esm/types.d.ts +0 -397
- package/lib/esm/types.js +0 -71
- package/lib/esm/visitor.d.ts +0 -2
- package/lib/esm/visitor.js +0 -73
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import * as lst from "vscode-languageserver-types";
|
|
2
|
-
import { findNodeAtOffset, getIdentifierText, isEdgeStatement } from "../checker.js";
|
|
3
|
-
import { isIdentifierNode } from "../index.js";
|
|
4
|
-
import { SyntaxKind, } from "../types.js";
|
|
5
|
-
import * as languageFacts from "./languageFacts.js";
|
|
6
|
-
import { escapeIdentifierText } from "./util.js";
|
|
7
|
-
export function getCompletions(doc, sourceFile, position) {
|
|
8
|
-
const symbols = sourceFile.symbols;
|
|
9
|
-
if (!symbols)
|
|
10
|
-
throw "sourceFile is not bound";
|
|
11
|
-
const g = sourceFile.graph;
|
|
12
|
-
if (!g)
|
|
13
|
-
return [];
|
|
14
|
-
const offset = doc.offsetAt(position);
|
|
15
|
-
const node = findNodeAtOffset(g, offset, true);
|
|
16
|
-
if (!node)
|
|
17
|
-
return [];
|
|
18
|
-
const prevOffsetNode = findNodeAtOffset(g, offset - 1, true);
|
|
19
|
-
const parent = node.parent;
|
|
20
|
-
const prevOffsetNodeParent = prevOffsetNode?.parent;
|
|
21
|
-
if ((parent?.parent && isEdgeStatement(parent.parent)) ||
|
|
22
|
-
(prevOffsetNodeParent?.parent && isEdgeStatement(prevOffsetNodeParent.parent))) {
|
|
23
|
-
return getNodeCompletions(symbols);
|
|
24
|
-
}
|
|
25
|
-
if (node.kind === SyntaxKind.AttributeContainer) {
|
|
26
|
-
const openingBracket = node.openBracket;
|
|
27
|
-
if (openingBracket.end - 1 > offset - 1) {
|
|
28
|
-
const exclusions = prevOffsetNode?.kind === SyntaxKind.TextIdentifier && prevOffsetNode.symbol
|
|
29
|
-
? [prevOffsetNode.symbol.name]
|
|
30
|
-
: undefined;
|
|
31
|
-
return getNodeCompletions(symbols, exclusions);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (node.kind === SyntaxKind.TextIdentifier && parent?.kind === SyntaxKind.NodeId) {
|
|
35
|
-
const exclusions = node.symbol ? [node.symbol.name] : undefined;
|
|
36
|
-
return getNodeCompletions(symbols, exclusions);
|
|
37
|
-
}
|
|
38
|
-
if (node.kind === SyntaxKind.AttributeContainer ||
|
|
39
|
-
(node.kind === SyntaxKind.CommaToken && parent?.kind === SyntaxKind.Assignment)) {
|
|
40
|
-
return getAttributeCompletions(position);
|
|
41
|
-
}
|
|
42
|
-
const prevNode = findNodeAtOffset(g, node.pos - 1, true);
|
|
43
|
-
if (!prevNode)
|
|
44
|
-
return [];
|
|
45
|
-
if (isIdentifierNode(prevNode)) {
|
|
46
|
-
const p = prevNode.parent;
|
|
47
|
-
if (p) {
|
|
48
|
-
switch (p.kind) {
|
|
49
|
-
case SyntaxKind.NodeId: {
|
|
50
|
-
return getNodeCompletions(symbols);
|
|
51
|
-
}
|
|
52
|
-
case SyntaxKind.Assignment: {
|
|
53
|
-
return getAssignmentCompletion(p);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (node.flags & 2 || node.end === node.pos) {
|
|
59
|
-
const attribute = prevNode;
|
|
60
|
-
if (!attribute)
|
|
61
|
-
return [];
|
|
62
|
-
if (!attribute.parent)
|
|
63
|
-
throw "sourceFile is not bound";
|
|
64
|
-
const parent = attribute.parent;
|
|
65
|
-
if (parent.kind === SyntaxKind.Assignment) {
|
|
66
|
-
return getAssignmentCompletion(parent);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return [];
|
|
70
|
-
}
|
|
71
|
-
function getAssignmentCompletion(assignment) {
|
|
72
|
-
const property = getIdentifierText(assignment.leftId);
|
|
73
|
-
if (!property)
|
|
74
|
-
return [];
|
|
75
|
-
switch (property.toLowerCase()) {
|
|
76
|
-
case "shape":
|
|
77
|
-
return getShapeCompletions();
|
|
78
|
-
case "color":
|
|
79
|
-
return getColorCompletions();
|
|
80
|
-
default:
|
|
81
|
-
return [];
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
function getShapeCompletions() {
|
|
85
|
-
const kind = lst.CompletionItemKind.EnumMember;
|
|
86
|
-
return languageFacts.shapes.map(s => ({
|
|
87
|
-
kind,
|
|
88
|
-
label: escapeIdentifierText(s),
|
|
89
|
-
}));
|
|
90
|
-
}
|
|
91
|
-
function getColorCompletions() {
|
|
92
|
-
const kind = lst.CompletionItemKind.Color;
|
|
93
|
-
const colors = languageFacts.colors;
|
|
94
|
-
return Object.keys(colors).map(label => ({
|
|
95
|
-
kind,
|
|
96
|
-
label,
|
|
97
|
-
documentation: colors[label],
|
|
98
|
-
}));
|
|
99
|
-
}
|
|
100
|
-
function getAttributeCompletions(posistion) {
|
|
101
|
-
const kind = lst.CompletionItemKind.Property;
|
|
102
|
-
const range = {
|
|
103
|
-
start: posistion,
|
|
104
|
-
end: posistion,
|
|
105
|
-
};
|
|
106
|
-
return languageFacts.attributes.map(label => ({
|
|
107
|
-
kind,
|
|
108
|
-
label,
|
|
109
|
-
textEdit: {
|
|
110
|
-
range,
|
|
111
|
-
newText: `${escapeIdentifierText(label)}=`,
|
|
112
|
-
},
|
|
113
|
-
}));
|
|
114
|
-
}
|
|
115
|
-
function getNodeCompletions(symbols, exlucdedSymbols) {
|
|
116
|
-
const res = [];
|
|
117
|
-
for (const [key, value] of symbols) {
|
|
118
|
-
if (exlucdedSymbols?.includes(key))
|
|
119
|
-
continue;
|
|
120
|
-
let kind = lst.CompletionItemKind.Variable;
|
|
121
|
-
const a = value.firstMention.parent;
|
|
122
|
-
if (a) {
|
|
123
|
-
switch (a.kind) {
|
|
124
|
-
case SyntaxKind.DirectedGraph:
|
|
125
|
-
case SyntaxKind.UndirectedGraph:
|
|
126
|
-
kind = lst.CompletionItemKind.Class;
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
res.push({
|
|
131
|
-
label: escapeIdentifierText(key),
|
|
132
|
-
kind: kind,
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
return res;
|
|
136
|
-
}
|
|
137
|
-
//# sourceMappingURL=completion.js.map
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type * as lst from "vscode-languageserver-types";
|
|
2
|
-
import type { DocumentLike } from "../index.js";
|
|
3
|
-
import { type SourceFile } from "../types.js";
|
|
4
|
-
export declare function hover(doc: DocumentLike, sourceFile: SourceFile, position: lst.Position): lst.Hover | undefined;
|
package/lib/esm/service/hover.js
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { findNodeAtOffset, getIdentifierText } from "../checker.js";
|
|
2
|
-
import { isIdentifierNode } from "../parser.js";
|
|
3
|
-
import { SyntaxKind, } from "../types.js";
|
|
4
|
-
import { getEdgeStr } from "./command/common.js";
|
|
5
|
-
import { syntaxNodeToRange } from "./util.js";
|
|
6
|
-
export function hover(doc, sourceFile, position) {
|
|
7
|
-
const offset = doc.offsetAt(position);
|
|
8
|
-
const g = sourceFile.graph;
|
|
9
|
-
if (!g)
|
|
10
|
-
return undefined;
|
|
11
|
-
const node = findNodeAtOffset(g, offset);
|
|
12
|
-
if (node === undefined)
|
|
13
|
-
return undefined;
|
|
14
|
-
return getNodeHover(doc, sourceFile, node);
|
|
15
|
-
}
|
|
16
|
-
function getNodeHover(doc, sf, n) {
|
|
17
|
-
const contents = getHoverContents(n);
|
|
18
|
-
if (contents) {
|
|
19
|
-
return {
|
|
20
|
-
contents,
|
|
21
|
-
range: syntaxNodeToRange(doc, sf, n),
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
return undefined;
|
|
25
|
-
}
|
|
26
|
-
function getAssignedLabel(statement) {
|
|
27
|
-
const assignments = statement.attributes.flatMap(a => a.assignments);
|
|
28
|
-
const assignedLabel = assignments?.find(a => getIdentifierText(a.leftId) === "label");
|
|
29
|
-
return assignedLabel?.rightId ? getIdentifierText(assignedLabel.rightId) : undefined;
|
|
30
|
-
}
|
|
31
|
-
function getHoverContents(n) {
|
|
32
|
-
if (isIdentifierNode(n)) {
|
|
33
|
-
const parent = n.parent;
|
|
34
|
-
if (parent) {
|
|
35
|
-
switch (parent.kind) {
|
|
36
|
-
case SyntaxKind.NodeId: {
|
|
37
|
-
if (n.symbol?.references) {
|
|
38
|
-
const nodeIdentifierRefs = n.symbol?.references;
|
|
39
|
-
const labelMentions = nodeIdentifierRefs.map(e => e.symbol?.members?.get("label")?.firstMention.parent);
|
|
40
|
-
for (let i = labelMentions.length; i >= 0; i--) {
|
|
41
|
-
const s = labelMentions[i];
|
|
42
|
-
if (s?.rightId) {
|
|
43
|
-
return `(node) ${getIdentifierText(n)}: ${getIdentifierText(s.rightId)}`;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
else if (parent.parent?.kind === SyntaxKind.NodeStatement) {
|
|
48
|
-
const label = getAssignedLabel(parent.parent);
|
|
49
|
-
if (label) {
|
|
50
|
-
return `(node) ${getIdentifierText(n)}: ${label}`;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return `(node) ${getIdentifierText(n)}`;
|
|
54
|
-
}
|
|
55
|
-
case SyntaxKind.Assignment: {
|
|
56
|
-
const assignment = parent;
|
|
57
|
-
const left = getIdentifierText(assignment.leftId);
|
|
58
|
-
const right = getIdentifierText(assignment.rightId);
|
|
59
|
-
return `(assignment) \`${left}\` = \`${right}\``;
|
|
60
|
-
}
|
|
61
|
-
case SyntaxKind.DirectedGraph:
|
|
62
|
-
return getGraphHover(parent);
|
|
63
|
-
case SyntaxKind.UndirectedGraph:
|
|
64
|
-
return getGraphHover(parent);
|
|
65
|
-
case SyntaxKind.SubGraphStatement: {
|
|
66
|
-
const sgs = parent;
|
|
67
|
-
const sg = sgs.subgraph;
|
|
68
|
-
return sg.id ? `(sub graph) ${getIdentifierText(sg.id)}` : "(sub graph)";
|
|
69
|
-
}
|
|
70
|
-
case SyntaxKind.SubGraph: {
|
|
71
|
-
const sg = parent;
|
|
72
|
-
return sg.id ? `(sub graph) ${getIdentifierText(sg.id)}` : "(sub graph)";
|
|
73
|
-
}
|
|
74
|
-
case SyntaxKind.IdEqualsIdStatement: {
|
|
75
|
-
const idEqId = parent;
|
|
76
|
-
const left = getIdentifierText(idEqId.leftId);
|
|
77
|
-
const right = getIdentifierText(idEqId.rightId);
|
|
78
|
-
return `(graph property) \`${left}\` = \`${right}\``;
|
|
79
|
-
}
|
|
80
|
-
case SyntaxKind.EdgeRhs:
|
|
81
|
-
return getEdgeHover(parent);
|
|
82
|
-
}
|
|
83
|
-
return SyntaxKind[parent.kind];
|
|
84
|
-
}
|
|
85
|
-
const fallback = SyntaxKind[n.kind];
|
|
86
|
-
return fallback ? `(${fallback.toLowerCase()})` : undefined;
|
|
87
|
-
}
|
|
88
|
-
switch (n.kind) {
|
|
89
|
-
case SyntaxKind.GraphKeyword:
|
|
90
|
-
case SyntaxKind.DigraphKeyword:
|
|
91
|
-
case SyntaxKind.StrictKeyword:
|
|
92
|
-
return getGraphHover(n.parent);
|
|
93
|
-
case SyntaxKind.DirectedGraph:
|
|
94
|
-
case SyntaxKind.UndirectedGraph:
|
|
95
|
-
return getGraphHover(n);
|
|
96
|
-
case SyntaxKind.DirectedEdgeOp:
|
|
97
|
-
case SyntaxKind.UndirectedEdgeOp:
|
|
98
|
-
return getEdgeHover(n.parent);
|
|
99
|
-
default:
|
|
100
|
-
return undefined;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
function getGraphHover(g) {
|
|
104
|
-
const direction = g.kind === SyntaxKind.DirectedGraph ? "directed" : "undirected";
|
|
105
|
-
const graphId = g.id;
|
|
106
|
-
const strict = g.strict ? "strict " : "";
|
|
107
|
-
return graphId
|
|
108
|
-
? `(${strict}${direction} graph) ${getIdentifierText(graphId)}`
|
|
109
|
-
: `(${strict}${direction} graph)`;
|
|
110
|
-
}
|
|
111
|
-
function getEdgeHover(n) {
|
|
112
|
-
const p = n.parent;
|
|
113
|
-
if (!p || p.rhs.length === 0)
|
|
114
|
-
return undefined;
|
|
115
|
-
let source;
|
|
116
|
-
for (const curr of p.rhs) {
|
|
117
|
-
if (curr === n)
|
|
118
|
-
break;
|
|
119
|
-
source = curr.target;
|
|
120
|
-
}
|
|
121
|
-
if (source === undefined)
|
|
122
|
-
source = p.source;
|
|
123
|
-
const edgeOpStr = getEdgeStr(n.operation.kind);
|
|
124
|
-
return source === undefined
|
|
125
|
-
? undefined
|
|
126
|
-
: `(edge) ${getEdgeSourceOrTargetText(source)} ${edgeOpStr} ${getEdgeSourceOrTargetText(n.target)}`;
|
|
127
|
-
}
|
|
128
|
-
function getEdgeSourceOrTargetText(n) {
|
|
129
|
-
return n.kind === SyntaxKind.NodeId
|
|
130
|
-
? getIdentifierText(n.id)
|
|
131
|
-
: n.id !== undefined
|
|
132
|
-
? `${getIdentifierText(n.id)}`
|
|
133
|
-
: "sub graph";
|
|
134
|
-
}
|
|
135
|
-
//# sourceMappingURL=hover.js.map
|