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
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dot-language-support",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Parser and language service for graphviz (dot) files",
|
|
5
5
|
"author": "Niklas Mollenhauer",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"main": "./
|
|
8
|
-
"module": "./
|
|
9
|
-
"types": "./
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"type": "module",
|
|
10
11
|
"scripts": {
|
|
11
12
|
"ci": "biome ci ./src",
|
|
12
13
|
"test": "tsc --noEmit && vitest run",
|
|
@@ -14,11 +15,8 @@
|
|
|
14
15
|
"format": "biome format --write ./src",
|
|
15
16
|
"lint": "biome lint ./src",
|
|
16
17
|
"lint:fix": "biome lint --write ./src",
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"build:cjs": "tsc --target es2017 --module commonjs --outDir lib/cjs",
|
|
20
|
-
"build": "npm run build:esm && npm run build:cjs",
|
|
21
|
-
"prepare": "npm run clean && npm run build"
|
|
18
|
+
"build": "tsup",
|
|
19
|
+
"prepare": "npm run build"
|
|
22
20
|
},
|
|
23
21
|
"keywords": [
|
|
24
22
|
"graphviz",
|
|
@@ -37,13 +35,14 @@
|
|
|
37
35
|
"vscode-languageserver-types": "^3.17.5"
|
|
38
36
|
},
|
|
39
37
|
"devDependencies": {
|
|
40
|
-
"@biomejs/biome": "^2.
|
|
38
|
+
"@biomejs/biome": "^2.1.1",
|
|
41
39
|
"@vitest/coverage-v8": "^3.2.4",
|
|
42
40
|
"rimraf": "^6.0.1",
|
|
41
|
+
"tsup": "^8.5.0",
|
|
43
42
|
"typescript": "^5.8.3",
|
|
44
43
|
"vitest": "^3.2.4"
|
|
45
44
|
},
|
|
46
45
|
"engines": {
|
|
47
|
-
"node": ">=
|
|
46
|
+
"node": ">=22"
|
|
48
47
|
}
|
|
49
48
|
}
|
package/.github/dependabot.yml
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
version: 2
|
|
2
|
-
updates:
|
|
3
|
-
- package-ecosystem: "npm"
|
|
4
|
-
directory: "/"
|
|
5
|
-
schedule:
|
|
6
|
-
interval: "weekly"
|
|
7
|
-
groups:
|
|
8
|
-
patch-dependencies:
|
|
9
|
-
update-types:
|
|
10
|
-
- "patch"
|
|
11
|
-
|
|
12
|
-
- package-ecosystem: "github-actions"
|
|
13
|
-
directory: "/"
|
|
14
|
-
schedule:
|
|
15
|
-
interval: "weekly"
|
package/.github/workflows/CD.yml
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
name: CD
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- "!*"
|
|
7
|
-
tags:
|
|
8
|
-
- "v*"
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
build:
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
|
|
14
|
-
permissions:
|
|
15
|
-
contents: read
|
|
16
|
-
id-token: write
|
|
17
|
-
|
|
18
|
-
steps:
|
|
19
|
-
- uses: actions/checkout@v4
|
|
20
|
-
with:
|
|
21
|
-
show-progress: false
|
|
22
|
-
|
|
23
|
-
- uses: actions/setup-node@v4
|
|
24
|
-
with:
|
|
25
|
-
node-version: 24
|
|
26
|
-
cache: npm
|
|
27
|
-
registry-url: https://registry.npmjs.org
|
|
28
|
-
|
|
29
|
-
- run: npm ci
|
|
30
|
-
- run: npm run ci
|
|
31
|
-
- run: npm run build
|
|
32
|
-
- run: npm test
|
|
33
|
-
env:
|
|
34
|
-
CI: true
|
|
35
|
-
- run: npm publish --provenance --access public
|
|
36
|
-
env:
|
|
37
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/.github/workflows/CI.yml
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
name: CI
|
|
2
|
-
|
|
3
|
-
on: [push]
|
|
4
|
-
|
|
5
|
-
jobs:
|
|
6
|
-
build:
|
|
7
|
-
runs-on: ubuntu-latest
|
|
8
|
-
|
|
9
|
-
strategy:
|
|
10
|
-
matrix:
|
|
11
|
-
node-version: [20.x, 22.x, 24.x]
|
|
12
|
-
|
|
13
|
-
steps:
|
|
14
|
-
- uses: actions/checkout@v4
|
|
15
|
-
with:
|
|
16
|
-
show-progress: false
|
|
17
|
-
|
|
18
|
-
- uses: actions/setup-node@v4
|
|
19
|
-
with:
|
|
20
|
-
node-version: ${{ matrix.node-version }}
|
|
21
|
-
cache: npm
|
|
22
|
-
|
|
23
|
-
- run: npm ci
|
|
24
|
-
- run: npm run ci
|
|
25
|
-
- run: npm run build
|
|
26
|
-
- run: npm test
|
|
27
|
-
env:
|
|
28
|
-
CI: true
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
name: Dependabot auto-merge
|
|
2
|
-
|
|
3
|
-
# Taken and adapted from:
|
|
4
|
-
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#enable-auto-merge-on-a-pull-request
|
|
5
|
-
|
|
6
|
-
on: pull_request
|
|
7
|
-
|
|
8
|
-
permissions:
|
|
9
|
-
contents: write
|
|
10
|
-
pull-requests: write
|
|
11
|
-
|
|
12
|
-
jobs:
|
|
13
|
-
dependabot:
|
|
14
|
-
runs-on: ubuntu-latest
|
|
15
|
-
if: ${{ github.actor == 'dependabot[bot]' }}
|
|
16
|
-
|
|
17
|
-
steps:
|
|
18
|
-
- id: metadata
|
|
19
|
-
uses: dependabot/fetch-metadata@v2
|
|
20
|
-
|
|
21
|
-
- name: Enable auto-merge for Dependabot PRs
|
|
22
|
-
if: ${{ steps.metadata.outputs.update-type == 'version-update:semver-patch' }}
|
|
23
|
-
run: gh pr merge --auto --merge "$PR_URL"
|
|
24
|
-
env:
|
|
25
|
-
PR_URL: ${{ github.event.pull_request.html_url }}
|
|
26
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
package/CITATION.cff
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
cff-version: 1.2.0
|
|
2
|
-
title: DOT Language Support
|
|
3
|
-
message: If you use this software, please cite it using the metadata from this file.
|
|
4
|
-
type: software
|
|
5
|
-
authors:
|
|
6
|
-
- given-names: Niklas
|
|
7
|
-
family-names: Mollenhauer
|
|
8
|
-
repository-code: 'https://github.com/nikeee/dot-language-support'
|
|
9
|
-
abstract: A language service library for the DOT language (graphviz). Used by dot-language-server and edotor.net.
|
|
10
|
-
keywords:
|
|
11
|
-
- dot
|
|
12
|
-
- graphviz
|
|
13
|
-
- language-server-protocol
|
|
14
|
-
license: MIT
|
package/biome.json
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://biomejs.dev/schemas/2.0.0/schema.json",
|
|
3
|
-
"formatter": {
|
|
4
|
-
"enabled": true,
|
|
5
|
-
"indentWidth": 4,
|
|
6
|
-
"indentStyle": "tab",
|
|
7
|
-
"lineWidth": 100
|
|
8
|
-
},
|
|
9
|
-
"vcs": {
|
|
10
|
-
"enabled": true,
|
|
11
|
-
"clientKind": "git",
|
|
12
|
-
"defaultBranch": "master",
|
|
13
|
-
"root": "."
|
|
14
|
-
},
|
|
15
|
-
"linter": {
|
|
16
|
-
"enabled": true,
|
|
17
|
-
"rules": {
|
|
18
|
-
"recommended": true,
|
|
19
|
-
"suspicious": {
|
|
20
|
-
"noConstEnum": "off",
|
|
21
|
-
"noDebugger": "off"
|
|
22
|
-
},
|
|
23
|
-
"correctness": {
|
|
24
|
-
"noVoidTypeReturn": "off"
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
"javascript": {
|
|
29
|
-
"formatter": {
|
|
30
|
-
"arrowParentheses": "asNeeded"
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
"overrides": [
|
|
34
|
-
{
|
|
35
|
-
"includes": ["**/src/scanner.ts"],
|
|
36
|
-
"linter": {
|
|
37
|
-
"rules": {
|
|
38
|
-
"suspicious": {
|
|
39
|
-
"noAssignInExpressions": "off"
|
|
40
|
-
},
|
|
41
|
-
"style": {
|
|
42
|
-
"noParameterAssign": "off"
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
]
|
|
48
|
-
}
|
package/lib/cjs/binder.d.ts
DELETED
package/lib/cjs/binder.js
DELETED
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.bindSourceFile = bindSourceFile;
|
|
4
|
-
const checker_js_1 = require("./checker.js");
|
|
5
|
-
const parser_js_1 = require("./parser.js");
|
|
6
|
-
const types_js_1 = require("./types.js");
|
|
7
|
-
const binder = createBinder();
|
|
8
|
-
function bindSourceFile(file) {
|
|
9
|
-
binder.bind(file);
|
|
10
|
-
}
|
|
11
|
-
function createBinder() {
|
|
12
|
-
let parent;
|
|
13
|
-
let symbolTable;
|
|
14
|
-
let colorTable;
|
|
15
|
-
let graphContext = 0;
|
|
16
|
-
function bind(node) {
|
|
17
|
-
if (!node)
|
|
18
|
-
return;
|
|
19
|
-
const saveParent = parent;
|
|
20
|
-
const saveContext = graphContext;
|
|
21
|
-
node.parent = saveParent;
|
|
22
|
-
node.graphContext = saveContext;
|
|
23
|
-
parent = node;
|
|
24
|
-
innerBind(node);
|
|
25
|
-
parent = saveParent;
|
|
26
|
-
graphContext = saveContext;
|
|
27
|
-
}
|
|
28
|
-
function innerBind(node) {
|
|
29
|
-
switch (node.kind) {
|
|
30
|
-
case types_js_1.SyntaxKind.DirectedGraph:
|
|
31
|
-
case types_js_1.SyntaxKind.UndirectedGraph:
|
|
32
|
-
return bindGraph(node);
|
|
33
|
-
case types_js_1.SyntaxKind.AttributeStatement:
|
|
34
|
-
return bindAttributeStatement(node);
|
|
35
|
-
case types_js_1.SyntaxKind.EdgeStatement:
|
|
36
|
-
return bindEdgeStatement(node);
|
|
37
|
-
case types_js_1.SyntaxKind.NodeStatement:
|
|
38
|
-
return bindNodeStatement(node);
|
|
39
|
-
case types_js_1.SyntaxKind.SubGraph:
|
|
40
|
-
return bindSubGraph(node);
|
|
41
|
-
case types_js_1.SyntaxKind.SubGraphStatement:
|
|
42
|
-
return bindSubGraphStatement(node);
|
|
43
|
-
case types_js_1.SyntaxKind.IdEqualsIdStatement:
|
|
44
|
-
return bindIdEqualsIdStatement(node);
|
|
45
|
-
case types_js_1.SyntaxKind.QuotedTextIdentifier:
|
|
46
|
-
return bindQuotedTextIdentifier(node);
|
|
47
|
-
case types_js_1.SyntaxKind.EdgeRhs:
|
|
48
|
-
return bindEdgeRhs(node);
|
|
49
|
-
case types_js_1.SyntaxKind.AttributeContainer:
|
|
50
|
-
return bindAttributeContainer(node);
|
|
51
|
-
case types_js_1.SyntaxKind.Assignment:
|
|
52
|
-
return bindAssignment(node);
|
|
53
|
-
case types_js_1.SyntaxKind.NormalPortDeclaration:
|
|
54
|
-
return bindNormalPortDeclaration(node);
|
|
55
|
-
case types_js_1.SyntaxKind.CompassPortDeclaration:
|
|
56
|
-
return bindCompassPortDeclaration(node);
|
|
57
|
-
case types_js_1.SyntaxKind.NodeId:
|
|
58
|
-
return bindNodeId(node);
|
|
59
|
-
default:
|
|
60
|
-
if (node.kind >= types_js_1.SyntaxKind.FirstNode)
|
|
61
|
-
throw "TODO";
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
function bindGraph(node) {
|
|
65
|
-
if (node.strict) {
|
|
66
|
-
graphContext |= 2;
|
|
67
|
-
}
|
|
68
|
-
switch (node.kind) {
|
|
69
|
-
case types_js_1.SyntaxKind.DirectedGraph:
|
|
70
|
-
graphContext |= 4;
|
|
71
|
-
break;
|
|
72
|
-
case types_js_1.SyntaxKind.UndirectedGraph:
|
|
73
|
-
graphContext |= 8;
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
if (node.id) {
|
|
77
|
-
ensureGlobalSymbol(node.id);
|
|
78
|
-
bind(node.id);
|
|
79
|
-
}
|
|
80
|
-
if (node.strict)
|
|
81
|
-
bind(node.strict);
|
|
82
|
-
bindChildren(node.statements);
|
|
83
|
-
}
|
|
84
|
-
function bindAttributeStatement(node) {
|
|
85
|
-
bind(node.subject);
|
|
86
|
-
bindChildren(node.attributes);
|
|
87
|
-
if (node.terminator)
|
|
88
|
-
bind(node.terminator);
|
|
89
|
-
}
|
|
90
|
-
function bindEdgeStatement(node) {
|
|
91
|
-
bindChildren(node.attributes);
|
|
92
|
-
bindChildren(node.rhs);
|
|
93
|
-
bind(node.source);
|
|
94
|
-
if (node.terminator)
|
|
95
|
-
bind(node.terminator);
|
|
96
|
-
}
|
|
97
|
-
function bindNodeStatement(node) {
|
|
98
|
-
bind(node.id);
|
|
99
|
-
bindChildren(node.attributes);
|
|
100
|
-
if (node.terminator)
|
|
101
|
-
bind(node.terminator);
|
|
102
|
-
}
|
|
103
|
-
function bindSubGraph(node) {
|
|
104
|
-
if (node.id) {
|
|
105
|
-
bind(node.id);
|
|
106
|
-
}
|
|
107
|
-
bindChildren(node.statements);
|
|
108
|
-
}
|
|
109
|
-
function bindSubGraphStatement(node) {
|
|
110
|
-
bind(node.subgraph);
|
|
111
|
-
if (node.terminator)
|
|
112
|
-
bind(node.terminator);
|
|
113
|
-
}
|
|
114
|
-
function bindIdEqualsIdStatement(node) {
|
|
115
|
-
bind(node.leftId);
|
|
116
|
-
bind(node.rightId);
|
|
117
|
-
if (node.rightId && !(0, checker_js_1.nodeContainsErrors)(node.rightId)) {
|
|
118
|
-
if (isAttributeName("color", node.leftId)) {
|
|
119
|
-
ensureGlobalColor(node.rightId);
|
|
120
|
-
}
|
|
121
|
-
else if (isAttributeName("fillcolor", node.leftId)) {
|
|
122
|
-
ensureGlobalColor(node.rightId);
|
|
123
|
-
}
|
|
124
|
-
else if (isAttributeName("bgcolor", node.leftId)) {
|
|
125
|
-
ensureGlobalColor(node.rightId);
|
|
126
|
-
}
|
|
127
|
-
else if (isAttributeName("fontcolor", node.leftId)) {
|
|
128
|
-
ensureGlobalColor(node.rightId);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
if (node.terminator)
|
|
132
|
-
bind(node.terminator);
|
|
133
|
-
}
|
|
134
|
-
function bindQuotedTextIdentifier(node) {
|
|
135
|
-
bindChildren(node.values);
|
|
136
|
-
node.concatenation = node.values.map(v => v.text).join("");
|
|
137
|
-
}
|
|
138
|
-
function bindEdgeRhs(node) {
|
|
139
|
-
bind(node.operation);
|
|
140
|
-
bind(node.target);
|
|
141
|
-
}
|
|
142
|
-
function bindAttributeContainer(node) {
|
|
143
|
-
bind(node.openBracket);
|
|
144
|
-
bindChildren(node.assignments);
|
|
145
|
-
bind(node.closeBracket);
|
|
146
|
-
}
|
|
147
|
-
function bindAssignment(node) {
|
|
148
|
-
const attrContainer = node.parent;
|
|
149
|
-
console.assert(!!attrContainer);
|
|
150
|
-
const superParentStatement = attrContainer.parent;
|
|
151
|
-
console.assert(!!superParentStatement);
|
|
152
|
-
bind(node.leftId);
|
|
153
|
-
let carrierIdentifier;
|
|
154
|
-
switch (superParentStatement.kind) {
|
|
155
|
-
case types_js_1.SyntaxKind.NodeStatement:
|
|
156
|
-
carrierIdentifier = superParentStatement.id.id;
|
|
157
|
-
break;
|
|
158
|
-
case types_js_1.SyntaxKind.EdgeStatement:
|
|
159
|
-
break;
|
|
160
|
-
case types_js_1.SyntaxKind.SubGraphStatement:
|
|
161
|
-
break;
|
|
162
|
-
case types_js_1.SyntaxKind.AttributeStatement:
|
|
163
|
-
break;
|
|
164
|
-
}
|
|
165
|
-
if (carrierIdentifier)
|
|
166
|
-
ensureMemberSymbol(node.leftId, carrierIdentifier);
|
|
167
|
-
bind(node.rightId);
|
|
168
|
-
if (node.rightId && !(0, checker_js_1.nodeContainsErrors)(node.rightId)) {
|
|
169
|
-
if (isAttributeName("color", node.leftId)) {
|
|
170
|
-
ensureGlobalColor(node.rightId);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
if (node.terminator)
|
|
174
|
-
bind(node.terminator);
|
|
175
|
-
}
|
|
176
|
-
function bindNormalPortDeclaration(node) {
|
|
177
|
-
bind(node.colon);
|
|
178
|
-
ensureGlobalSymbol(node.id);
|
|
179
|
-
bind(node.id);
|
|
180
|
-
if (node.compassPt)
|
|
181
|
-
bind(node.compassPt);
|
|
182
|
-
}
|
|
183
|
-
function bindCompassPortDeclaration(node) {
|
|
184
|
-
bind(node.colon);
|
|
185
|
-
if (node.compassPt)
|
|
186
|
-
bind(node.compassPt);
|
|
187
|
-
}
|
|
188
|
-
function bindNodeId(node) {
|
|
189
|
-
ensureGlobalSymbol(node.id);
|
|
190
|
-
bind(node.id);
|
|
191
|
-
if (node.port)
|
|
192
|
-
bind(node.port);
|
|
193
|
-
}
|
|
194
|
-
function bindChildren(nodes) {
|
|
195
|
-
for (const n of nodes)
|
|
196
|
-
bind(n);
|
|
197
|
-
}
|
|
198
|
-
function createSymbolTable() {
|
|
199
|
-
return new Map();
|
|
200
|
-
}
|
|
201
|
-
function createColorTable() {
|
|
202
|
-
return new Map();
|
|
203
|
-
}
|
|
204
|
-
function ensureMemberSymbol(node, carrier) {
|
|
205
|
-
if (node && carrier && (0, parser_js_1.isIdentifierNode)(node)) {
|
|
206
|
-
const name = (0, checker_js_1.getIdentifierText)(node);
|
|
207
|
-
if (name === undefined)
|
|
208
|
-
return;
|
|
209
|
-
const carrierSymbol = carrier.symbol;
|
|
210
|
-
if (carrierSymbol === undefined)
|
|
211
|
-
throw "carrierSymbol is undefined";
|
|
212
|
-
let symbols = carrierSymbol.members;
|
|
213
|
-
if (symbols === undefined)
|
|
214
|
-
carrierSymbol.members = symbols = createSymbolTable();
|
|
215
|
-
ensureSymbolOnTable(name, node, symbols);
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
console.warn("ensureSymbol called on non-identifier node");
|
|
219
|
-
debugger;
|
|
220
|
-
}
|
|
221
|
-
function ensureGlobalSymbol(node) {
|
|
222
|
-
if (node && (0, parser_js_1.isIdentifierNode)(node)) {
|
|
223
|
-
const symbols = symbolTable;
|
|
224
|
-
const name = (0, checker_js_1.getIdentifierText)(node);
|
|
225
|
-
if (name === undefined)
|
|
226
|
-
return;
|
|
227
|
-
if (symbols === undefined)
|
|
228
|
-
throw "symbolTable is undefined";
|
|
229
|
-
ensureSymbolOnTable(name, node, symbols);
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
console.warn("ensureSymbol called on non-identifier node");
|
|
233
|
-
debugger;
|
|
234
|
-
}
|
|
235
|
-
function ensureSymbolOnTable(name, node, symbols) {
|
|
236
|
-
if (!name)
|
|
237
|
-
return;
|
|
238
|
-
let sym = symbols.get(name);
|
|
239
|
-
if (sym === undefined) {
|
|
240
|
-
sym = createSymbol(name, node);
|
|
241
|
-
symbols.set(name, sym);
|
|
242
|
-
}
|
|
243
|
-
else {
|
|
244
|
-
if (!sym.references)
|
|
245
|
-
sym.references = [node];
|
|
246
|
-
else
|
|
247
|
-
sym.references.push(node);
|
|
248
|
-
}
|
|
249
|
-
node.symbol = sym;
|
|
250
|
-
}
|
|
251
|
-
function ensureGlobalColor(node) {
|
|
252
|
-
if (node && (0, parser_js_1.isIdentifierNode)(node)) {
|
|
253
|
-
const colors = colorTable;
|
|
254
|
-
const name = (0, checker_js_1.getIdentifierText)(node);
|
|
255
|
-
if (name === undefined)
|
|
256
|
-
return;
|
|
257
|
-
if (colors === undefined)
|
|
258
|
-
throw "symbolTable is undefined";
|
|
259
|
-
const color = createColor(node);
|
|
260
|
-
colors.set(name, color);
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
console.warn("ensureSymbol called on non-identifier node");
|
|
264
|
-
debugger;
|
|
265
|
-
}
|
|
266
|
-
function createSymbol(name, node) {
|
|
267
|
-
if (!name)
|
|
268
|
-
throw "name is falsy";
|
|
269
|
-
if (!node)
|
|
270
|
-
throw "node is undefined or null";
|
|
271
|
-
return {
|
|
272
|
-
name,
|
|
273
|
-
firstMention: node,
|
|
274
|
-
references: undefined,
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
function createColor(node) {
|
|
278
|
-
return {
|
|
279
|
-
node,
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
function isAttributeName(name, id) {
|
|
283
|
-
return id ? (0, checker_js_1.getIdentifierText)(id).trim().toLowerCase() === name : false;
|
|
284
|
-
}
|
|
285
|
-
return {
|
|
286
|
-
bind: file => {
|
|
287
|
-
symbolTable = createSymbolTable();
|
|
288
|
-
colorTable = createColorTable();
|
|
289
|
-
const { graph } = file;
|
|
290
|
-
if (graph)
|
|
291
|
-
bind(graph);
|
|
292
|
-
file.symbols = symbolTable;
|
|
293
|
-
file.colors = colorTable;
|
|
294
|
-
},
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
//# sourceMappingURL=binder.js.map
|
package/lib/cjs/checker.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
export declare function checkSourceFile(file: SourceFile): void;
|
|
3
|
-
export declare function findNodeAtOffset(root: SyntaxNode, offset: number, inclusiveEnd?: boolean): SyntaxNode | undefined;
|
|
4
|
-
export declare function getAllowedEdgeOperation(graph: Graph): SyntaxKind.DirectedEdgeOp | SyntaxKind.UndirectedEdgeOp;
|
|
5
|
-
export declare function findAllEdges(node: SyntaxNode): EdgeRhs[];
|
|
6
|
-
export declare function findOptionalSemicolons(node: SyntaxNode): Token<SyntaxKind.SemicolonToken>[];
|
|
7
|
-
export declare function findAllStatements<T extends Statement["kind"]>(node: SyntaxNode, kind?: T): StatementOf<T>[];
|
|
8
|
-
export declare function isAttrStatement(node: SyntaxNode): node is AttributeStatement;
|
|
9
|
-
export declare function isEdgeStatement(node: SyntaxNode): node is EdgeStatement;
|
|
10
|
-
export declare function isSubGraphStatement(node: SyntaxNode): node is SubGraphStatement;
|
|
11
|
-
export declare function isGraph(node: SyntaxNode): node is Graph;
|
|
12
|
-
export declare function isNodeId(node: SyntaxNode): node is NodeId;
|
|
13
|
-
export declare function edgeStatementHasAttributes(es: EdgeStatement): boolean;
|
|
14
|
-
export declare function getIdentifierText(n: Identifier): string;
|
|
15
|
-
export declare function nodeContainsErrors(node: SyntaxNode): boolean;
|