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.
Files changed (109) hide show
  1. package/dist/index.d.ts +497 -0
  2. package/dist/index.js +3853 -0
  3. package/package.json +10 -11
  4. package/.github/dependabot.yml +0 -15
  5. package/.github/workflows/CD.yml +0 -37
  6. package/.github/workflows/CI.yml +0 -28
  7. package/.github/workflows/auto-merge.yaml +0 -26
  8. package/CITATION.cff +0 -14
  9. package/biome.json +0 -48
  10. package/lib/cjs/binder.d.ts +0 -2
  11. package/lib/cjs/binder.js +0 -297
  12. package/lib/cjs/checker.d.ts +0 -15
  13. package/lib/cjs/checker.js +0 -228
  14. package/lib/cjs/core.d.ts +0 -1
  15. package/lib/cjs/core.js +0 -13
  16. package/lib/cjs/error.d.ts +0 -3
  17. package/lib/cjs/error.js +0 -12
  18. package/lib/cjs/index.d.ts +0 -5
  19. package/lib/cjs/index.js +0 -22
  20. package/lib/cjs/parser.d.ts +0 -27
  21. package/lib/cjs/parser.js +0 -664
  22. package/lib/cjs/scanner.d.ts +0 -41
  23. package/lib/cjs/scanner.js +0 -578
  24. package/lib/cjs/service/codeAction.d.ts +0 -12
  25. package/lib/cjs/service/codeAction.js +0 -245
  26. package/lib/cjs/service/colorProvider.d.ts +0 -5
  27. package/lib/cjs/service/colorProvider.js +0 -91
  28. package/lib/cjs/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.d.ts +0 -10
  29. package/lib/cjs/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.js +0 -42
  30. package/lib/cjs/service/command/ChangeEdgeOpCommand.d.ts +0 -10
  31. package/lib/cjs/service/command/ChangeEdgeOpCommand.js +0 -67
  32. package/lib/cjs/service/command/ConsolidateDescendantsCommand.d.ts +0 -10
  33. package/lib/cjs/service/command/ConsolidateDescendantsCommand.js +0 -87
  34. package/lib/cjs/service/command/RemoveSemicolons.d.ts +0 -10
  35. package/lib/cjs/service/command/RemoveSemicolons.js +0 -39
  36. package/lib/cjs/service/command/common.d.ts +0 -31
  37. package/lib/cjs/service/command/common.js +0 -33
  38. package/lib/cjs/service/completion.d.ts +0 -4
  39. package/lib/cjs/service/completion.js +0 -173
  40. package/lib/cjs/service/hover.d.ts +0 -4
  41. package/lib/cjs/service/hover.js +0 -142
  42. package/lib/cjs/service/languageFacts.d.ts +0 -683
  43. package/lib/cjs/service/languageFacts.js +0 -996
  44. package/lib/cjs/service/reference.d.ts +0 -5
  45. package/lib/cjs/service/reference.js +0 -67
  46. package/lib/cjs/service/rename.d.ts +0 -4
  47. package/lib/cjs/service/rename.js +0 -51
  48. package/lib/cjs/service/service.d.ts +0 -28
  49. package/lib/cjs/service/service.js +0 -38
  50. package/lib/cjs/service/util.d.ts +0 -11
  51. package/lib/cjs/service/util.js +0 -49
  52. package/lib/cjs/service/validation.d.ts +0 -4
  53. package/lib/cjs/service/validation.js +0 -23
  54. package/lib/cjs/tester.d.ts +0 -1
  55. package/lib/cjs/tester.js +0 -23
  56. package/lib/cjs/types.d.ts +0 -397
  57. package/lib/cjs/types.js +0 -74
  58. package/lib/cjs/visitor.d.ts +0 -2
  59. package/lib/cjs/visitor.js +0 -76
  60. package/lib/esm/binder.d.ts +0 -2
  61. package/lib/esm/binder.js +0 -294
  62. package/lib/esm/checker.d.ts +0 -15
  63. package/lib/esm/checker.js +0 -212
  64. package/lib/esm/core.d.ts +0 -1
  65. package/lib/esm/core.js +0 -10
  66. package/lib/esm/error.d.ts +0 -3
  67. package/lib/esm/error.js +0 -8
  68. package/lib/esm/index.d.ts +0 -5
  69. package/lib/esm/index.js +0 -6
  70. package/lib/esm/parser.d.ts +0 -27
  71. package/lib/esm/parser.js +0 -714
  72. package/lib/esm/scanner.d.ts +0 -41
  73. package/lib/esm/scanner.js +0 -581
  74. package/lib/esm/service/codeAction.d.ts +0 -12
  75. package/lib/esm/service/codeAction.js +0 -207
  76. package/lib/esm/service/colorProvider.d.ts +0 -5
  77. package/lib/esm/service/colorProvider.js +0 -54
  78. package/lib/esm/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.d.ts +0 -10
  79. package/lib/esm/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.js +0 -38
  80. package/lib/esm/service/command/ChangeEdgeOpCommand.d.ts +0 -10
  81. package/lib/esm/service/command/ChangeEdgeOpCommand.js +0 -30
  82. package/lib/esm/service/command/ConsolidateDescendantsCommand.d.ts +0 -10
  83. package/lib/esm/service/command/ConsolidateDescendantsCommand.js +0 -83
  84. package/lib/esm/service/command/RemoveSemicolons.d.ts +0 -10
  85. package/lib/esm/service/command/RemoveSemicolons.js +0 -35
  86. package/lib/esm/service/command/common.d.ts +0 -31
  87. package/lib/esm/service/command/common.js +0 -25
  88. package/lib/esm/service/completion.d.ts +0 -4
  89. package/lib/esm/service/completion.js +0 -137
  90. package/lib/esm/service/hover.d.ts +0 -4
  91. package/lib/esm/service/hover.js +0 -135
  92. package/lib/esm/service/languageFacts.d.ts +0 -683
  93. package/lib/esm/service/languageFacts.js +0 -993
  94. package/lib/esm/service/reference.d.ts +0 -5
  95. package/lib/esm/service/reference.js +0 -63
  96. package/lib/esm/service/rename.d.ts +0 -4
  97. package/lib/esm/service/rename.js +0 -48
  98. package/lib/esm/service/service.d.ts +0 -28
  99. package/lib/esm/service/service.js +0 -35
  100. package/lib/esm/service/util.d.ts +0 -11
  101. package/lib/esm/service/util.js +0 -42
  102. package/lib/esm/service/validation.d.ts +0 -4
  103. package/lib/esm/service/validation.js +0 -20
  104. package/lib/esm/tester.d.ts +0 -1
  105. package/lib/esm/tester.js +0 -21
  106. package/lib/esm/types.d.ts +0 -397
  107. package/lib/esm/types.js +0 -71
  108. package/lib/esm/visitor.d.ts +0 -2
  109. package/lib/esm/visitor.js +0 -73
@@ -1,5 +0,0 @@
1
- import type { Location, Position, ReferenceContext } from "vscode-languageserver-types";
2
- import { type DocumentLike } from "../index.js";
3
- import type { SourceFile } from "../types.js";
4
- export declare function findReferences(doc: DocumentLike, sourceFile: SourceFile, position: Position, context: ReferenceContext): Location[];
5
- export declare function findDefinition(doc: DocumentLike, sourceFile: SourceFile, position: Position): Location | undefined;
@@ -1,63 +0,0 @@
1
- import { findNodeAtOffset } from "../checker.js";
2
- import { isIdentifierNode } from "../index.js";
3
- import { syntaxNodesToRanges, syntaxNodeToRange } from "./util.js";
4
- export function findReferences(doc, sourceFile, position, context) {
5
- if (!sourceFile.symbols)
6
- throw "sourceFile is not bound";
7
- const g = sourceFile.graph;
8
- if (!g)
9
- return [];
10
- const offset = doc.offsetAt(position);
11
- const node = findNodeAtOffset(g, offset);
12
- if (!node)
13
- return [];
14
- if (isIdentifierNode(node)) {
15
- const nodeSymbol = node.symbol;
16
- if (!nodeSymbol)
17
- throw "node.symbol is not bound";
18
- const refs = nodeSymbol.references || [];
19
- let symbolRefs;
20
- if (context.includeDeclaration) {
21
- symbolRefs = [nodeSymbol.firstMention, ...refs];
22
- }
23
- else {
24
- if (nodeSymbol.firstMention === node) {
25
- symbolRefs = refs;
26
- }
27
- else {
28
- symbolRefs = [nodeSymbol.firstMention, ...refs.filter(r => r !== node)];
29
- }
30
- }
31
- const ranges = syntaxNodesToRanges(doc, sourceFile, symbolRefs);
32
- const uri = doc.uri;
33
- return ranges.map(range => {
34
- return { uri, range };
35
- });
36
- }
37
- debugger;
38
- return [];
39
- }
40
- export function findDefinition(doc, sourceFile, position) {
41
- if (!sourceFile.symbols)
42
- throw "sourceFile is not bound";
43
- const g = sourceFile.graph;
44
- if (!g)
45
- return undefined;
46
- const offset = doc.offsetAt(position);
47
- const node = findNodeAtOffset(g, offset);
48
- if (!node)
49
- return undefined;
50
- if (isIdentifierNode(node)) {
51
- const nodeSymbol = node.symbol;
52
- if (!nodeSymbol)
53
- throw "node.symbol is not bound";
54
- const firstMention = nodeSymbol.firstMention;
55
- if (!firstMention)
56
- return undefined;
57
- const range = syntaxNodeToRange(doc, sourceFile, firstMention);
58
- return { uri: doc.uri, range };
59
- }
60
- debugger;
61
- return undefined;
62
- }
63
- //# sourceMappingURL=reference.js.map
@@ -1,4 +0,0 @@
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
- export declare function renameSymbol(doc: DocumentLike, sourceFile: SourceFile, position: Position, newName: string): WorkspaceEdit | undefined;
@@ -1,48 +0,0 @@
1
- import { TextEdit } from "vscode-languageserver-types";
2
- import { findNodeAtOffset } from "../checker.js";
3
- import { isIdentifierNode } from "../index.js";
4
- import { SyntaxKind } from "../types.js";
5
- import { syntaxNodesToRanges } from "./util.js";
6
- export function renameSymbol(doc, sourceFile, position, newName) {
7
- if (!sourceFile.symbols)
8
- throw "sourceFile is not bound";
9
- if (!newName)
10
- return undefined;
11
- const g = sourceFile.graph;
12
- if (!g)
13
- return undefined;
14
- const offset = doc.offsetAt(position);
15
- const node = findNodeAtOffset(g, offset);
16
- if (!node)
17
- return undefined;
18
- const parent = node.parent;
19
- if (isIdentifierNode(node) &&
20
- isRenamableIdentifier(node) &&
21
- !!parent &&
22
- isRenameableNode(parent)) {
23
- const nodeSymbol = node.symbol;
24
- if (!nodeSymbol)
25
- throw "node.symbol is not bound";
26
- const r = nodeSymbol.references;
27
- const refs = r ? [nodeSymbol.firstMention, ...r] : [nodeSymbol.firstMention];
28
- const ranges = syntaxNodesToRanges(doc, sourceFile, refs);
29
- const uri = doc.uri;
30
- const res = {
31
- changes: {
32
- [uri]: ranges.map(r => TextEdit.replace(r, newName)),
33
- },
34
- };
35
- return res;
36
- }
37
- debugger;
38
- return undefined;
39
- }
40
- function isRenameableNode(node) {
41
- return (node.kind === SyntaxKind.NodeId ||
42
- node.kind === SyntaxKind.DirectedGraph ||
43
- node.kind === SyntaxKind.UndirectedGraph);
44
- }
45
- function isRenamableIdentifier(node) {
46
- return node.kind !== SyntaxKind.QuotedTextIdentifier;
47
- }
48
- //# sourceMappingURL=rename.js.map
@@ -1,28 +0,0 @@
1
- import type { TextDocument } from "vscode-languageserver-textdocument";
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
- export interface DocumentLike {
6
- positionAt(offset: number): lst.Position;
7
- offsetAt(position: lst.Position): number;
8
- readonly uri: string;
9
- }
10
- export interface CommandApplication {
11
- label?: string;
12
- edit: lst.WorkspaceEdit;
13
- }
14
- export interface LanguageService {
15
- parseDocument(doc: TextDocument | string): SourceFile;
16
- validateDocument(doc: DocumentLike, sourceFile: SourceFile): lst.Diagnostic[];
17
- hover(doc: DocumentLike, sourceFile: SourceFile, position: lst.Position): lst.Hover | undefined;
18
- findReferences(doc: DocumentLike, sourceFile: SourceFile, position: lst.Position, context: lst.ReferenceContext): lst.Location[];
19
- findDefinition(doc: DocumentLike, sourceFile: SourceFile, position: lst.Position): lst.Location | undefined;
20
- renameSymbol(doc: DocumentLike, sourceFile: SourceFile, position: lst.Position, newName: string): lst.WorkspaceEdit | undefined;
21
- getCompletions(doc: DocumentLike, sourceFile: SourceFile, position: lst.Position): lst.CompletionItem[];
22
- getDocumentColors(doc: DocumentLike, sourceFile: SourceFile): ColorInformation[] | undefined;
23
- getColorRepresentations(doc: DocumentLike, sourceFile: SourceFile, color: Color, range: lst.Range): ColorPresentation[] | undefined;
24
- getCodeActions(doc: DocumentLike, sourceFile: SourceFile, range: lst.Range, context: lst.CodeActionContext): lst.Command[] | undefined;
25
- executeCommand(doc: DocumentLike, sourceFile: SourceFile, command: Omit<lst.Command, "title">): CommandApplication | undefined;
26
- getAvailableCommands(): string[];
27
- }
28
- export declare function createService(): LanguageService;
@@ -1,35 +0,0 @@
1
- import { bindSourceFile } from "../binder.js";
2
- import { checkSourceFile } from "../checker.js";
3
- import { Parser } from "../index.js";
4
- import { executeCommand, getAvailableCommands, getCodeActions } from "./codeAction.js";
5
- import { getColorRepresentations, getDocumentColors } from "./colorProvider.js";
6
- import { getCompletions } from "./completion.js";
7
- import { hover } from "./hover.js";
8
- import { findDefinition, findReferences } from "./reference.js";
9
- import { renameSymbol } from "./rename.js";
10
- import { validateDocument } from "./validation.js";
11
- function parseDocument(doc) {
12
- const parser = new Parser();
13
- const content = typeof doc === "string" ? doc : doc.getText();
14
- const sourceFile = parser.parse(content);
15
- bindSourceFile(sourceFile);
16
- checkSourceFile(sourceFile);
17
- return sourceFile;
18
- }
19
- export function createService() {
20
- return {
21
- parseDocument,
22
- validateDocument,
23
- hover,
24
- findReferences,
25
- findDefinition,
26
- renameSymbol,
27
- getCompletions,
28
- getDocumentColors,
29
- getColorRepresentations,
30
- getCodeActions,
31
- executeCommand,
32
- getAvailableCommands,
33
- };
34
- }
35
- //# sourceMappingURL=service.js.map
@@ -1,11 +0,0 @@
1
- import type { Range } from "vscode-languageserver-types";
2
- import type { DocumentLike } from "../index.js";
3
- import { type SourceFile, type SyntaxNode } from "../types.js";
4
- export declare function getStart(sourceFile: SourceFile, node: SyntaxNode): number;
5
- export declare function syntaxNodesToRanges(doc: DocumentLike, sourceFile: SourceFile, nodes: SyntaxNode[]): Range[];
6
- export declare function syntaxNodeToRange(doc: DocumentLike, sourceFile: SourceFile, node: SyntaxNode): {
7
- start: import("vscode-languageserver-types").Position;
8
- end: import("vscode-languageserver-types").Position;
9
- };
10
- export declare function escapeIdentifierText(text: string): string;
11
- export declare function assertNever(v: never): never;
@@ -1,42 +0,0 @@
1
- import { isIdentifierStart, skipTrivia } from "../scanner.js";
2
- import { SyntaxKind } from "../types.js";
3
- export function getStart(sourceFile, node) {
4
- return getTokenPosOfNode(sourceFile, node);
5
- }
6
- function getTokenPosOfNode(sourceFile, node) {
7
- if (nodeIsMissing(node))
8
- return node.pos;
9
- return skipTrivia(sourceFile.content, node.pos);
10
- }
11
- function nodeIsMissing(node) {
12
- return node === undefined
13
- ? true
14
- : node.pos === node.end && node.pos >= 0 && node.kind !== SyntaxKind.EndOfFileToken;
15
- }
16
- export function syntaxNodesToRanges(doc, sourceFile, nodes) {
17
- return nodes.map(node => syntaxNodeToRange(doc, sourceFile, node));
18
- }
19
- export function syntaxNodeToRange(doc, sourceFile, node) {
20
- const start = getStart(sourceFile, node);
21
- return {
22
- start: doc.positionAt(start),
23
- end: doc.positionAt(node.end),
24
- };
25
- }
26
- export function escapeIdentifierText(text) {
27
- if (text === "")
28
- return quote("");
29
- if (text.includes('"') || text.includes("\n")) {
30
- const esc = text.replace(/"/, '\\"').replace(/\n/, "\\\n");
31
- return quote(esc);
32
- }
33
- const ch = text.charCodeAt(0);
34
- if (!isIdentifierStart(ch) || text.includes(" "))
35
- return quote(text);
36
- return text;
37
- }
38
- const quote = (s) => `"${s}"`;
39
- export function assertNever(v) {
40
- throw new Error(`Should not have reached this. Value: ${v ?? ""}`);
41
- }
42
- //# sourceMappingURL=util.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 validateDocument(doc: DocumentLike, sourceFile: SourceFile): lst.Diagnostic[];
@@ -1,20 +0,0 @@
1
- import { diagnosicSource, formatError } from "../error.js";
2
- function convertDiagnostic(document, source) {
3
- return {
4
- range: {
5
- start: document.positionAt(source.start),
6
- end: document.positionAt(source.end),
7
- },
8
- severity: source.category,
9
- code: formatError(source.code),
10
- source: diagnosicSource,
11
- message: source.message,
12
- };
13
- }
14
- export function validateDocument(doc, sourceFile) {
15
- const diagnostics = sourceFile.diagnostics;
16
- if (!diagnostics || diagnostics.length <= 0)
17
- return [];
18
- return diagnostics.map(d => convertDiagnostic(doc, d));
19
- }
20
- //# sourceMappingURL=validation.js.map
@@ -1 +0,0 @@
1
- export {};
package/lib/esm/tester.js DELETED
@@ -1,21 +0,0 @@
1
- import { TextDocument } from "vscode-languageserver-textdocument";
2
- import { bindSourceFile } from "./binder.js";
3
- import { checkSourceFile } from "./checker.js";
4
- import { Parser } from "./parser.js";
5
- import { getCompletions } from "./service/completion.js";
6
- const text = `graph {
7
- node_name_a -- node_name_b [color=blue,
8
- ];
9
- }`;
10
- function main() {
11
- const parser = new Parser();
12
- const sf = parser.parse(text);
13
- bindSourceFile(sf);
14
- checkSourceFile(sf);
15
- const doc = TextDocument.create("inmemory://model.json", "DOT", 0, text);
16
- const requestOffset = text.indexOf("color=blue,\n\t") + "color=blue,\n\t".length;
17
- const completions = getCompletions(doc, sf, doc.positionAt(requestOffset));
18
- console.dir(completions);
19
- }
20
- main();
21
- //# sourceMappingURL=tester.js.map
@@ -1,397 +0,0 @@
1
- export declare const enum ErrorSource {
2
- Scan = 1,
3
- Parse = 2,
4
- Check = 4
5
- }
6
- export type ErrorCode = ParseErrorCode | ScanErrorCode | CheckErrorCode;
7
- export interface ParseErrorCode {
8
- source: ErrorSource.Parse;
9
- sub: ParseError;
10
- }
11
- export interface ScanErrorCode {
12
- source: ErrorSource.Scan;
13
- sub: ScanError;
14
- }
15
- export interface CheckErrorCode {
16
- source: ErrorSource.Check;
17
- sub: CheckError;
18
- }
19
- export declare const enum ParseError {
20
- ExpectationFailed = 0,
21
- TrailingData = 1,
22
- FailedListParsing = 2
23
- }
24
- export declare const enum ScanError {
25
- ExpectationFailed = 0,
26
- Unterminated = 1
27
- }
28
- export declare const enum CheckError {
29
- InvalidEdgeOperation = 0,
30
- InvalidShapeName = 1
31
- }
32
- export interface DiagnosticMessage {
33
- message: string;
34
- code: ErrorCode;
35
- category: DiagnosticCategory;
36
- start: number;
37
- end: number;
38
- }
39
- export declare enum DiagnosticCategory {
40
- Error = 1,
41
- Warning = 2,
42
- Message = 3,
43
- Suggestion = 4
44
- }
45
- export type ID = string;
46
- export interface SourceFile {
47
- content: string;
48
- graph?: Graph;
49
- identifiers: Set<ID>;
50
- diagnostics: DiagnosticMessage[];
51
- symbols?: SymbolTable;
52
- colors?: ColorTable;
53
- }
54
- export interface HtmlIdentifier extends SyntaxNode {
55
- kind: SyntaxKind.HtmlIdentifier;
56
- htmlContent: string;
57
- }
58
- export interface TextIdentifier extends SyntaxNode {
59
- kind: SyntaxKind.TextIdentifier;
60
- text: string;
61
- }
62
- export interface QuotedTextIdentifier extends SyntaxNode {
63
- kind: SyntaxKind.QuotedTextIdentifier;
64
- values: SyntaxNodeArray<StringLiteral>;
65
- concatenation?: string;
66
- }
67
- export interface StringLiteral extends SyntaxNode {
68
- kind: SyntaxKind.StringLiteral;
69
- text: string;
70
- }
71
- export interface NumericIdentifier extends SyntaxNode {
72
- kind: SyntaxKind.NumericIdentifier;
73
- text: string;
74
- value: number;
75
- }
76
- export type Identifier = TextIdentifier | QuotedTextIdentifier | HtmlIdentifier | NumericIdentifier;
77
- export interface Graph extends SyntaxNode {
78
- kind: SyntaxKind.DirectedGraph | SyntaxKind.UndirectedGraph;
79
- keyword: Token<SyntaxKind.GraphKeyword | SyntaxKind.DigraphKeyword>;
80
- strict?: Token<SyntaxKind.StrictKeyword>;
81
- id?: Identifier;
82
- statements: SyntaxNodeArray<Statement>;
83
- }
84
- export interface StatementBase {
85
- terminator?: StatementSeparator;
86
- }
87
- export type StatementSeparator = Token<SyntaxKind.SemicolonToken>;
88
- export type Statement = NodeStatement | EdgeStatement | AttributeStatement | IdEqualsIdStatement | SubGraphStatement;
89
- export interface NodeStatement extends SyntaxNode, StatementBase {
90
- kind: SyntaxKind.NodeStatement;
91
- id: NodeId;
92
- attributes: SyntaxNodeArray<AttributeContainer>;
93
- }
94
- export interface NodeId extends SyntaxNode {
95
- kind: SyntaxKind.NodeId;
96
- id: Identifier;
97
- port?: PortDeclaration;
98
- }
99
- export type EdgeSourceOrTarget = NodeId | SubGraph;
100
- export interface EdgeStatement extends SyntaxNode, StatementBase {
101
- kind: SyntaxKind.EdgeStatement;
102
- source: EdgeSourceOrTarget;
103
- rhs: SyntaxNodeArray<EdgeRhs>;
104
- attributes: SyntaxNodeArray<AttributeContainer>;
105
- }
106
- export interface AttributeStatement extends SyntaxNode, StatementBase {
107
- kind: SyntaxKind.AttributeStatement;
108
- subject: Token<SyntaxKind.GraphKeyword> | Token<SyntaxKind.NodeKeyword> | Token<SyntaxKind.EdgeKeyword>;
109
- attributes: SyntaxNodeArray<AttributeContainer>;
110
- }
111
- export interface IdEqualsIdStatement extends SyntaxNode, StatementBase {
112
- kind: SyntaxKind.IdEqualsIdStatement;
113
- leftId: Identifier;
114
- rightId: Identifier;
115
- }
116
- export interface SubGraph extends SyntaxNode {
117
- kind: SyntaxKind.SubGraph;
118
- id?: Identifier;
119
- statements: SyntaxNodeArray<Statement>;
120
- }
121
- export interface SubGraphStatement extends SyntaxNode, StatementBase {
122
- kind: SyntaxKind.SubGraphStatement;
123
- subgraph: SubGraph;
124
- }
125
- export interface EdgeRhs extends SyntaxNode {
126
- kind: SyntaxKind.EdgeRhs;
127
- operation: EdgeOp;
128
- target: EdgeSourceOrTarget;
129
- }
130
- export interface AttributeContainer extends SyntaxNode {
131
- kind: SyntaxKind.AttributeContainer;
132
- openBracket: Token<SyntaxKind.OpenBracketToken>;
133
- assignments: SyntaxNodeArray<Assignment>;
134
- closeBracket: Token<SyntaxKind.CloseBracketToken>;
135
- }
136
- export interface Assignment extends SyntaxNode {
137
- kind: SyntaxKind.Assignment;
138
- leftId: Identifier;
139
- rightId: Identifier;
140
- terminator?: AssignmentSeparator;
141
- }
142
- export type AssignmentSeparator = Token<SyntaxKind.SemicolonToken> | Token<SyntaxKind.CommaToken>;
143
- export type PortDeclaration = NormalPortDeclaration | CompassPortDeclaration;
144
- export interface NormalPortDeclaration extends SyntaxNode {
145
- kind: SyntaxKind.NormalPortDeclaration;
146
- colon: Token<SyntaxKind.ColonToken>;
147
- id: Identifier;
148
- compassPt?: CompassPortDeclaration;
149
- }
150
- export interface CompassPortDeclaration extends SyntaxNode {
151
- kind: SyntaxKind.CompassPortDeclaration;
152
- colon: Token<SyntaxKind.ColonToken>;
153
- compassPt: CompassPort;
154
- }
155
- export type CompassPort = Token<SyntaxKind.CompassNorthToken> | Token<SyntaxKind.CompassNorthEastToken> | Token<SyntaxKind.CompassEastToken> | Token<SyntaxKind.CompassSouthEastToken> | Token<SyntaxKind.CompassSouthToken> | Token<SyntaxKind.CompassSouthWestToken> | Token<SyntaxKind.CompassWestToken> | Token<SyntaxKind.CompassNorthWestToken> | Token<SyntaxKind.CompassCenterToken> | Token<SyntaxKind.UnderscoreToken>;
156
- export type EdgeOp = Token<SyntaxKind.DirectedEdgeOp> | Token<SyntaxKind.UndirectedEdgeOp>;
157
- export interface TextRange {
158
- pos: number;
159
- end: number;
160
- }
161
- export declare enum SyntaxKind {
162
- Unknown = 0,
163
- EndOfFileToken = 1,
164
- NewLineTrivia = 2,
165
- WhitespaceTrivia = 3,
166
- HashCommentTrivia = 4,
167
- SingleLineCommentTrivia = 5,
168
- MultiLineCommentTrivia = 6,
169
- CommaToken = 7,
170
- SemicolonToken = 8,
171
- PlusToken = 9,
172
- OpenBraceToken = 10,
173
- CloseBraceToken = 11,
174
- OpenBracketToken = 12,
175
- CloseBracketToken = 13,
176
- ColonToken = 14,
177
- EqualsToken = 15,
178
- LessThan = 16,
179
- GreaterThan = 17,
180
- CompassNorthToken = 18,
181
- CompassNorthEastToken = 19,
182
- CompassEastToken = 20,
183
- CompassSouthEastToken = 21,
184
- CompassSouthToken = 22,
185
- CompassSouthWestToken = 23,
186
- CompassWestToken = 24,
187
- CompassNorthWestToken = 25,
188
- CompassCenterToken = 26,
189
- UnderscoreToken = 27,
190
- StringLiteral = 28,
191
- HtmlIdentifier = 29,
192
- TextIdentifier = 30,
193
- QuotedTextIdentifier = 31,
194
- NumericIdentifier = 32,
195
- GraphKeyword = 33,
196
- DigraphKeyword = 34,
197
- NodeKeyword = 35,
198
- EdgeKeyword = 36,
199
- SubgraphKeyword = 37,
200
- StrictKeyword = 38,
201
- DirectedEdgeOp = 39,
202
- UndirectedEdgeOp = 40,
203
- DirectedGraph = 41,
204
- UndirectedGraph = 42,
205
- NodeStatement = 43,
206
- EdgeStatement = 44,
207
- AttributeStatement = 45,
208
- IdEqualsIdStatement = 46,
209
- SubGraph = 47,
210
- SubGraphStatement = 48,
211
- EdgeRhs = 49,
212
- AttributeContainer = 50,
213
- Assignment = 51,
214
- NormalPortDeclaration = 52,
215
- CompassPortDeclaration = 53,
216
- NodeId = 54,
217
- Count = 55,
218
- FirstNode = 41,
219
- CompassBegin = 18,
220
- CompassEnd = 27,
221
- LastKeyword = 38
222
- }
223
- export interface SyntaxNode extends TextRange {
224
- kind: SyntaxKind;
225
- flags: SyntaxNodeFlags;
226
- graphContext?: GraphContext;
227
- parent?: SyntaxNode;
228
- symbol?: TypeSymbol;
229
- }
230
- export interface Token<TKind extends SyntaxKind> extends SyntaxNode {
231
- kind: TKind;
232
- }
233
- export interface SyntaxNodeArray<T extends SyntaxNode> extends ReadonlyArray<T>, TextRange {
234
- hasTrailingComma?: boolean;
235
- }
236
- export type MutableSyntaxNodeArray<T extends SyntaxNode> = SyntaxNodeArray<T> & T[];
237
- export declare const enum SyntaxNodeFlags {
238
- None = 0,
239
- ContainsErrors = 2,
240
- Synthesized = 4
241
- }
242
- export declare const enum GraphContext {
243
- None = 0,
244
- Strict = 2,
245
- Directed = 4,
246
- Undirected = 8
247
- }
248
- export declare const enum TokenFlags {
249
- None = 0,
250
- Unterminated = 2,
251
- PrecedingLineBreak = 4
252
- }
253
- export declare const enum CharacterCodes {
254
- nullCharacter = 0,
255
- maxAsciiCharacter = 127,
256
- lineFeed = 10,
257
- carriageReturn = 13,
258
- lineSeparator = 8232,
259
- paragraphSeparator = 8233,
260
- nextLine = 133,
261
- space = 32,
262
- nonBreakingSpace = 160,
263
- enQuad = 8192,
264
- emQuad = 8193,
265
- enSpace = 8194,
266
- emSpace = 8195,
267
- threePerEmSpace = 8196,
268
- fourPerEmSpace = 8197,
269
- sixPerEmSpace = 8198,
270
- figureSpace = 8199,
271
- punctuationSpace = 8200,
272
- thinSpace = 8201,
273
- hairSpace = 8202,
274
- zeroWidthSpace = 8203,
275
- narrowNoBreakSpace = 8239,
276
- ideographicSpace = 12288,
277
- mathematicalSpace = 8287,
278
- ogham = 5760,
279
- _ = 95,
280
- $ = 36,
281
- _0 = 48,
282
- _1 = 49,
283
- _2 = 50,
284
- _3 = 51,
285
- _4 = 52,
286
- _5 = 53,
287
- _6 = 54,
288
- _7 = 55,
289
- _8 = 56,
290
- _9 = 57,
291
- a = 97,
292
- b = 98,
293
- c = 99,
294
- d = 100,
295
- e = 101,
296
- f = 102,
297
- g = 103,
298
- h = 104,
299
- i = 105,
300
- j = 106,
301
- k = 107,
302
- l = 108,
303
- m = 109,
304
- n = 110,
305
- o = 111,
306
- p = 112,
307
- q = 113,
308
- r = 114,
309
- s = 115,
310
- t = 116,
311
- u = 117,
312
- v = 118,
313
- w = 119,
314
- x = 120,
315
- y = 121,
316
- z = 122,
317
- A = 65,
318
- B = 66,
319
- C = 67,
320
- D = 68,
321
- E = 69,
322
- F = 70,
323
- G = 71,
324
- H = 72,
325
- I = 73,
326
- J = 74,
327
- K = 75,
328
- L = 76,
329
- M = 77,
330
- N = 78,
331
- O = 79,
332
- P = 80,
333
- Q = 81,
334
- R = 82,
335
- S = 83,
336
- T = 84,
337
- U = 85,
338
- V = 86,
339
- W = 87,
340
- X = 88,
341
- Y = 89,
342
- Z = 90,
343
- ampersand = 38,
344
- asterisk = 42,
345
- at = 64,
346
- backslash = 92,
347
- backtick = 96,
348
- bar = 124,
349
- caret = 94,
350
- closeBrace = 125,
351
- closeBracket = 93,
352
- closeParen = 41,
353
- colon = 58,
354
- comma = 44,
355
- dot = 46,
356
- doubleQuote = 34,
357
- equals = 61,
358
- exclamation = 33,
359
- greaterThan = 62,
360
- hash = 35,
361
- lessThan = 60,
362
- minus = 45,
363
- openBrace = 123,
364
- openBracket = 91,
365
- openParen = 40,
366
- percent = 37,
367
- plus = 43,
368
- question = 63,
369
- semicolon = 59,
370
- singleQuote = 39,
371
- slash = 47,
372
- tilde = 126,
373
- backspace = 8,
374
- formFeed = 12,
375
- byteOrderMark = 65279,
376
- tab = 9,
377
- verticalTab = 11
378
- }
379
- export type SymbolTable = Map<string, TypeSymbol>;
380
- export type ColorTable = Map<string, ColorInfo>;
381
- export interface TypeSymbol {
382
- name: string;
383
- firstMention: SyntaxNode;
384
- references?: SyntaxNode[];
385
- members?: SymbolTable;
386
- }
387
- export interface ColorInfo {
388
- node: SyntaxNode;
389
- }
390
- export interface Color {
391
- readonly red: number;
392
- readonly green: number;
393
- readonly blue: number;
394
- readonly alpha: number;
395
- }
396
- export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
397
- export type StatementOf<T extends Statement["kind"]> = T extends SyntaxKind.SubGraphStatement ? SubGraphStatement : T extends SyntaxKind.AttributeStatement ? AttributeStatement : T extends SyntaxKind.EdgeStatement ? EdgeStatement : T extends SyntaxKind.IdEqualsIdStatement ? IdEqualsIdStatement : T extends SyntaxKind.NodeStatement ? NodeStatement : never;