This commit is contained in:
Alexander Wang 2025-03-25 09:01:46 -06:00
parent ce5da5214f
commit df4f9ca30b
No known key found for this signature in database
GPG key ID: BE3937D0D52D8927
4 changed files with 336 additions and 89 deletions

View file

@ -1735,7 +1735,7 @@ d -> c
{ {
name: "import-style-1", name: "import-style-1",
text: `c.style.fill: red text: `b.c.style.fill: red
b: @imp b: @imp
`, `,

View file

@ -207,6 +207,88 @@
"id": "b", "id": "b",
"id_val": "b", "id_val": "b",
"references": [ "references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:0:0-0:3:3",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:0:0-0:1:1",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:2:2-0:3:3",
"value": [
{
"string": "c",
"raw_string": "c"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
},
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:7:7-0:10:10",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:7:7-0:8:8",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:9:9-0:10:10",
"value": [
{
"string": "d",
"raw_string": "d"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
},
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,2:0:12-2:1:13",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,2:0:12-2:1:13",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
},
{ {
"key": { "key": {
"range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:0:0-0:3:3", "range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:0:0-0:3:3",
@ -353,6 +435,37 @@
}, },
"key_path_index": 0, "key_path_index": 0,
"map_key_edge_index": 0 "map_key_edge_index": 0
},
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:0:0-0:3:3",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:0:0-0:1:1",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:2:2-0:3:3",
"value": [
{
"string": "c",
"raw_string": "c"
}
]
}
}
]
},
"key_path_index": 1,
"map_key_edge_index": 0
} }
], ],
"attributes": { "attributes": {
@ -418,6 +531,37 @@
}, },
"key_path_index": 0, "key_path_index": 0,
"map_key_edge_index": 0 "map_key_edge_index": 0
},
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:7:7-0:10:10",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:7:7-0:8:8",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-connections.d2,0:9:9-0:10:10",
"value": [
{
"string": "d",
"raw_string": "d"
}
]
}
}
]
},
"key_path_index": 1,
"map_key_edge_index": 0
} }
], ],
"attributes": { "attributes": {

View file

@ -3,17 +3,28 @@
"name": "", "name": "",
"isFolderOnly": false, "isFolderOnly": false,
"ast": { "ast": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:0:0-3:0:27", "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:0:0-3:0:29",
"nodes": [ "nodes": [
{ {
"map_key": { "map_key": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:0:0-0:17:17", "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:0:0-0:19:19",
"key": { "key": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:0:0-0:12:12", "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:0:0-0:14:14",
"path": [ "path": [
{ {
"unquoted_string": { "unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:0:0-0:1:1", "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:0:0-0:1:1",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:2:2-0:3:3",
"value": [ "value": [
{ {
"string": "c", "string": "c",
@ -24,7 +35,7 @@
}, },
{ {
"unquoted_string": { "unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:2:2-0:7:7", "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:4:4-0:9:9",
"value": [ "value": [
{ {
"string": "style", "string": "style",
@ -35,7 +46,7 @@
}, },
{ {
"unquoted_string": { "unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:8:8-0:12:12", "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:10:10-0:14:14",
"value": [ "value": [
{ {
"string": "fill", "string": "fill",
@ -49,7 +60,7 @@
"primary": {}, "primary": {},
"value": { "value": {
"unquoted_string": { "unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:14:14-0:17:17", "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:16:16-0:19:19",
"value": [ "value": [
{ {
"string": "red", "string": "red",
@ -62,13 +73,13 @@
}, },
{ {
"map_key": { "map_key": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,2:0:19-2:7:26", "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,2:0:21-2:7:28",
"key": { "key": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,2:0:19-2:1:20", "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,2:0:21-2:1:22",
"path": [ "path": [
{ {
"unquoted_string": { "unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,2:0:19-2:1:20", "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,2:0:21-2:1:22",
"value": [ "value": [
{ {
"string": "b", "string": "b",
@ -82,13 +93,13 @@
"primary": {}, "primary": {},
"value": { "value": {
"import": { "import": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,2:3:22-2:7:26", "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,2:3:24-2:7:28",
"spread": false, "spread": false,
"pre": "", "pre": "",
"path": [ "path": [
{ {
"unquoted_string": { "unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,2:4:23-2:7:26", "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,2:4:25-2:7:28",
"value": [ "value": [
{ {
"string": "imp", "string": "imp",
@ -130,16 +141,27 @@
"edges": null, "edges": null,
"objects": [ "objects": [
{ {
"id": "c", "id": "b",
"id_val": "c", "id_val": "b",
"references": [ "references": [
{ {
"key": { "key": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:0:0-0:12:12", "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:0:0-0:14:14",
"path": [ "path": [
{ {
"unquoted_string": { "unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:0:0-0:1:1", "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:0:0-0:1:1",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:2:2-0:3:3",
"value": [ "value": [
{ {
"string": "c", "string": "c",
@ -150,7 +172,7 @@
}, },
{ {
"unquoted_string": { "unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:2:2-0:7:7", "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:4:4-0:9:9",
"value": [ "value": [
{ {
"string": "style", "string": "style",
@ -161,7 +183,7 @@
}, },
{ {
"unquoted_string": { "unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:8:8-0:12:12", "range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:10:10-0:14:14",
"value": [ "value": [
{ {
"string": "fill", "string": "fill",
@ -174,21 +196,110 @@
}, },
"key_path_index": 0, "key_path_index": 0,
"map_key_edge_index": -1 "map_key_edge_index": -1
},
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,2:0:21-2:1:22",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,2:0:21-2:1:22",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
},
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:0:0-0:14:14",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:0:0-0:1:1",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:2:2-0:3:3",
"value": [
{
"string": "c",
"raw_string": "c"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:4:4-0:9:9",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:10:10-0:14:14",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
},
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,2:0:21-2:1:22",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,2:0:21-2:1:22",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
} }
], ],
"attributes": { "attributes": {
"label": { "label": {
"value": "c" "value": "b"
}, },
"labelDimensions": { "labelDimensions": {
"width": 0, "width": 0,
"height": 0 "height": 0
}, },
"style": { "style": {},
"fill": {
"value": "red"
}
},
"near_key": null, "near_key": null,
"shape": { "shape": {
"value": "rectangle" "value": "rectangle"
@ -223,6 +334,59 @@
}, },
"key_path_index": 0, "key_path_index": 0,
"map_key_edge_index": -1 "map_key_edge_index": -1
},
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:0:0-0:14:14",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:0:0-0:1:1",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:2:2-0:3:3",
"value": [
{
"string": "c",
"raw_string": "c"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:4:4-0:9:9",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,0:10:10-0:14:14",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"key_path_index": 1,
"map_key_edge_index": -1
} }
], ],
"attributes": { "attributes": {
@ -233,72 +397,11 @@
"width": 0, "width": 0,
"height": 0 "height": 0
}, },
"style": {}, "style": {
"near_key": null, "fill": {
"shape": { "value": "red"
"value": "rectangle" }
}, },
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
},
{
"id": "b",
"id_val": "b",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,2:0:19-2:1:20",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,2:0:19-2:1:20",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
},
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,2:0:19-2:1:20",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/import-style-1.d2,2:0:19-2:1:20",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "b"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null, "near_key": null,
"shape": { "shape": {
"value": "rectangle" "value": "rectangle"

View file

@ -435,7 +435,7 @@
], ],
"attributes": { "attributes": {
"label": { "label": {
"value": "red" "value": "k"
}, },
"labelDimensions": { "labelDimensions": {
"width": 0, "width": 0,