This commit is contained in:
Alexander Wang 2023-03-01 14:53:58 -08:00
parent 9fd773bbb7
commit 3a9745974c
No known key found for this signature in database
GPG key ID: D89FA31966BDBECE
13 changed files with 712 additions and 145 deletions

View file

@ -56,7 +56,7 @@ func compileIR(ast *d2ast.Map, m *d2ir.Map) (*d2graph.Graph, error) {
if len(c.err.Errors) > 0 {
return nil, c.err
}
c.compileBoardLink(g)
c.validateBoardLinks(g)
if len(c.err.Errors) > 0 {
return nil, c.err
}
@ -722,7 +722,7 @@ func (c *compiler) validateNear(g *d2graph.Graph) {
}
}
func (c *compiler) compileBoardLink(g *d2graph.Graph) {
func (c *compiler) validateBoardLinks(g *d2graph.Graph) {
for _, obj := range g.Objects {
if obj.Attributes.Link == nil {
continue
@ -734,65 +734,55 @@ func (c *compiler) compileBoardLink(g *d2graph.Graph) {
continue
}
switch linkKey.Path[0].Unbox().ScalarString() {
// Starting a link with one of the following means it is targeting a board
case "layers", "scenarios", "steps", "_":
default:
if linkKey.Path[0].Unbox().ScalarString() != "root" {
continue
}
obj.LinkedBoard = c.findBoard(g, linkKey.IDA())
if obj.LinkedBoard == nil {
c.errorf(obj.Attributes.Link.MapKey, "link key %#v to board not found", obj.Attributes.Link.Value)
root := g
for root.Parent != nil {
root = root.Parent
}
if !hasBoard(root, linkKey.IDA()) {
c.errorf(obj.Attributes.Link.MapKey, "link key to board not found")
continue
}
}
for _, b := range append(append(g.Layers, g.Scenarios...), g.Steps...) {
c.compileBoardLink(b)
c.validateBoardLinks(b)
}
}
func (c *compiler) findBoard(g *d2graph.Graph, ida []string) *d2graph.Graph {
var currType string
for _, p := range ida {
if g == nil {
return nil
}
if p == "_" {
g = g.Parent
func hasBoard(root *d2graph.Graph, ida []string) bool {
for i := 0; i < len(ida); i += 2 {
id := ida[i]
if id == "root" {
continue
}
switch p {
case "layers", "scenarios", "steps":
currType = p
continue
if i == len(ida)-1 {
return root.Name == id
}
var boards []*d2graph.Graph
switch currType {
case "layers":
boards = g.Layers
case "scenarios":
boards = g.Scenarios
case "steps":
boards = g.Steps
default:
return nil
}
currType = ""
var board *d2graph.Graph
for i, b := range boards {
if b.Name == p {
board = boards[i]
break
nextID := ida[i+1]
if id == "layers" {
for _, b := range root.Layers {
if b.Name == nextID {
return hasBoard(b, ida[i:])
}
}
} else if id == "scenarios" {
for _, b := range root.Scenarios {
if b.Name == nextID {
return hasBoard(b, ida[i:])
}
}
} else if id == "steps" {
for _, b := range root.Steps {
if b.Name == nextID {
return hasBoard(b, ida[i:])
}
}
}
g = board
}
return g
return false
}
func init() {

View file

@ -2036,7 +2036,7 @@ layers: {
}
}`,
assertions: func(t *testing.T, g *d2graph.Graph) {
tassert.Equal(t, ".layers.x", g.Objects[0].LinkedBoard.AbsID())
tassert.Equal(t, "root.layers.x", g.Objects[0].Attributes.Link.Value)
},
},
{
@ -2056,7 +2056,7 @@ scenarios: {
}
}`,
assertions: func(t *testing.T, g *d2graph.Graph) {
tassert.Equal(t, ".layers.cat", g.Objects[0].LinkedBoard.AbsID())
tassert.Equal(t, "root.layers.cat", g.Objects[0].Attributes.Link.Value)
},
},
{
@ -2089,7 +2089,21 @@ layers: {
}
}`,
assertions: func(t *testing.T, g *d2graph.Graph) {
tassert.Equal(t, ".layers.x.layers.x", g.Objects[0].LinkedBoard.AbsID())
tassert.Equal(t, "root.layers.x.layers.x", g.Objects[0].Attributes.Link.Value)
},
},
{
name: "link-board-key-nested",
text: `x: {
y.link: layers.x
}
layers: {
x: {
yo
}
}`,
assertions: func(t *testing.T, g *d2graph.Graph) {
tassert.Equal(t, "root.layers.x", g.Objects[1].Attributes.Link.Value)
},
},
{
@ -2107,9 +2121,9 @@ layers: {
}
}`,
assertions: func(t *testing.T, g *d2graph.Graph) {
tassert.NotNil(t, g.Layers[0].Layers[0].Objects[0].LinkedBoard)
tassert.Equal(t, ".layers.x", g.Layers[0].Layers[0].Objects[0].LinkedBoard.AbsID())
tassert.Equal(t, ".layers.x", g.Layers[0].Layers[0].Objects[1].LinkedBoard.AbsID())
tassert.NotNil(t, g.Layers[0].Layers[0].Objects[0].Attributes.Link.Value)
tassert.Equal(t, "root.layers.x", g.Layers[0].Layers[0].Objects[0].Attributes.Link.Value)
tassert.Equal(t, "root.layers.x", g.Layers[0].Layers[0].Objects[1].Attributes.Link.Value)
},
},
{
@ -2125,7 +2139,7 @@ layers: {
}
}
}`,
expErr: `d2/testdata/d2compiler/TestCompile/link-board-underscore-not-found.d2:7:17: link key "_._._" to board not found`,
expErr: `d2/testdata/d2compiler/TestCompile/link-board-underscore-not-found.d2:7:5: board referenced by link not found`,
},
}

View file

@ -107,8 +107,6 @@ type Object struct {
LabelHeight *int `json:"labelHeight,omitempty"`
IconPosition *string `json:"iconPosition,omitempty"`
LinkedBoard *Graph `json:"-"`
Class *d2target.Class `json:"class,omitempty"`
SQLTable *d2target.SQLTable `json:"sql_table,omitempty"`

View file

@ -1,6 +1,8 @@
package d2ir
import (
"strings"
"oss.terrastruct.com/d2/d2ast"
"oss.terrastruct.com/d2/d2parser"
)
@ -127,6 +129,34 @@ func (c *compiler) compileField(dst *Map, kp *d2ast.KeyPath, refctx *RefContext)
}
c.compileMap(f.Map(), refctx.Key.Value.Map)
} else if refctx.Key.Value.ScalarBox().Unbox() != nil {
// If these are boards, we transform into absolute paths
if f.Name == "link" {
link, err := d2parser.ParseKey(refctx.Key.Value.ScalarBox().Unbox().ScalarString())
if err == nil {
scopeID, _ := d2parser.ParseKey(refctx.ScopeMap.AbsID())
scopeIDA := scopeID.IDA()
for i := len(scopeIDA) - 1; i > 0; i-- {
if scopeIDA[i-1] == "layers" || scopeIDA[i-1] == "scenarios" || scopeIDA[i-1] == "steps" || scopeIDA[i-1] == "root" {
scopeIDA = scopeIDA[:i+1]
break
}
}
linkIDA := link.IDA()
if len(linkIDA) > 0 {
for len(linkIDA) > 0 && linkIDA[0] == "_" {
if len(scopeIDA) <= 2 {
c.errorf(refctx.Key.Key, "board referenced by link not found")
return
}
// pop 2 off path per one underscore
scopeIDA = scopeIDA[:len(scopeIDA)-2]
linkIDA = linkIDA[1:]
}
scopeIDA = append(scopeIDA, linkIDA...)
refctx.Key.Value = d2ast.MakeValueBox(d2ast.RawString(strings.Join(scopeIDA, "."), true))
}
}
}
f.Primary_ = &Scalar{
parent: f,
Value: refctx.Key.Value.ScalarBox().Unbox(),

View file

@ -158,7 +158,7 @@ type Map struct {
func (m *Map) initRoot() {
m.parent = &Field{
Name: "",
Name: "root",
References: []*FieldReference{{
Context: &RefContext{
ScopeMap: m,
@ -221,6 +221,17 @@ func (m *Map) Root() bool {
return f.Root()
}
func (m *Map) AbsID() string {
f, ok := m.parent.(*Field)
if !ok {
return ""
}
if f.parent == nil {
return f.Name
}
return f.parent.(*Map).AbsID() + "." + f.Name
}
func (f *Field) Root() bool {
return f.parent == nil
}

View file

@ -0,0 +1,540 @@
{
"graph": {
"name": "",
"isFolderOnly": false,
"ast": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,0:0:0-7:1:54",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,0:0:0-2:1:25",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,0:0:0-0:1:1",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,0:0:0-0:1:1",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,0:3:3-2:0:24",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,1:2:7-1:8:13",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,1:2:7-1:3:8",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,1:4:9-1:8:13",
"value": [
{
"string": "link",
"raw_string": "link"
}
]
}
}
]
},
"primary": {},
"value": {
"double_quoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "root.x.layers.x"
}
]
}
}
}
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,3:0:26-7:1:54",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,3:0:26-3:6:32",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,3:0:26-3:6:32",
"value": [
{
"string": "layers",
"raw_string": "layers"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,3:8:34-7:0:53",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,4:1:37-6:3:52",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,4:1:37-4:2:38",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,4:1:37-4:2:38",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,4:4:40-6:2:51",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,5:4:46-5:6:48",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,5:4:46-5:6:48",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,5:4:46-5:6:48",
"value": [
{
"string": "yo",
"raw_string": "yo"
}
]
}
}
]
},
"primary": {},
"value": {}
}
}
]
}
}
}
}
]
}
}
}
}
]
},
"root": {
"id": "",
"id_val": "",
"label_dimensions": {
"width": 0,
"height": 0
},
"attributes": {
"label": {
"value": ""
},
"style": {},
"near_key": null,
"shape": {
"value": ""
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
},
"edges": null,
"objects": [
{
"id": "x",
"id_val": "x",
"label_dimensions": {
"width": 0,
"height": 0
},
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,0:0:0-0:1:1",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,0:0:0-0:1:1",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "x"
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
},
{
"id": "y",
"id_val": "y",
"label_dimensions": {
"width": 0,
"height": 0
},
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,1:2:7-1:8:13",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,1:2:7-1:3:8",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,1:4:9-1:8:13",
"value": [
{
"string": "link",
"raw_string": "link"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "y"
},
"style": {},
"link": {
"value": "root.x.layers.x"
},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
}
],
"layers": [
{
"name": "x",
"isFolderOnly": false,
"ast": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,0:0:0-7:1:54",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,0:0:0-2:1:25",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,0:0:0-0:1:1",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,0:0:0-0:1:1",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,0:3:3-2:0:24",
"nodes": [
{
"map_key": {
"range": ",0:0:0-0:0:0",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,1:2:7-1:8:13",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,1:2:7-1:3:8",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,1:4:9-1:8:13",
"value": [
{
"string": "link",
"raw_string": "link"
}
]
}
}
]
},
"primary": {},
"value": {
"double_quoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "root.x.layers.x"
}
]
}
}
}
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,3:0:26-7:1:54",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,3:0:26-3:6:32",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,3:0:26-3:6:32",
"value": [
{
"string": "layers",
"raw_string": "layers"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,3:8:34-7:0:53",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,4:1:37-6:3:52",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,4:1:37-4:2:38",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,4:1:37-4:2:38",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,4:4:40-6:2:51",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,5:4:46-5:6:48",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,5:4:46-5:6:48",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,5:4:46-5:6:48",
"value": [
{
"string": "yo",
"raw_string": "yo"
}
]
}
}
]
},
"primary": {},
"value": {}
}
}
]
}
}
}
}
]
}
}
}
}
]
},
"root": {
"id": "",
"id_val": "",
"label_dimensions": {
"width": 0,
"height": 0
},
"attributes": {
"label": {
"value": ""
},
"style": {},
"near_key": null,
"shape": {
"value": ""
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
},
"edges": null,
"objects": [
{
"id": "yo",
"id_val": "yo",
"label_dimensions": {
"width": 0,
"height": 0
},
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,5:4:46-5:6:48",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-key-nested.d2,5:4:46-5:6:48",
"value": [
{
"string": "yo",
"raw_string": "yo"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "yo"
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
}
]
}
]
},
"err": null
}

View file

@ -40,7 +40,7 @@
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-mixed.d2,1:15:46-1:25:56",
"range": ",0:0:0-0:0:0",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-mixed.d2,1:0:31-1:13:44",
"path": [
@ -70,12 +70,11 @@
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-mixed.d2,1:15:46-1:25:56",
"double_quoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "layers.cat",
"raw_string": "layers.cat"
"string": "root.layers.cat"
}
]
}
@ -404,7 +403,7 @@
},
"style": {},
"link": {
"value": "layers.cat"
"value": "root.layers.cat"
},
"near_key": null,
"shape": {
@ -462,7 +461,7 @@
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-mixed.d2,1:15:46-1:25:56",
"range": ",0:0:0-0:0:0",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-mixed.d2,1:0:31-1:13:44",
"path": [
@ -492,12 +491,11 @@
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-mixed.d2,1:15:46-1:25:56",
"double_quoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "layers.cat",
"raw_string": "layers.cat"
"string": "root.layers.cat"
}
]
}
@ -934,7 +932,7 @@
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-mixed.d2,1:15:46-1:25:56",
"range": ",0:0:0-0:0:0",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-mixed.d2,1:0:31-1:13:44",
"path": [
@ -964,12 +962,11 @@
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-mixed.d2,1:15:46-1:25:56",
"double_quoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "layers.cat",
"raw_string": "layers.cat"
"string": "root.layers.cat"
}
]
}
@ -1344,7 +1341,7 @@
}
},
"link": {
"value": "layers.cat"
"value": "root.layers.cat"
},
"near_key": null,
"shape": {

View file

@ -7,7 +7,7 @@
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-nested.d2,0:8:8-0:25:25",
"range": ",0:0:0-0:0:0",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-nested.d2,0:0:0-0:6:6",
"path": [
@ -37,12 +37,11 @@
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-nested.d2,0:8:8-0:25:25",
"double_quoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "layers.x.layers.x",
"raw_string": "layers.x.layers.x"
"string": "root.layers.x.layers.x"
}
]
}
@ -263,7 +262,7 @@
},
"style": {},
"link": {
"value": "layers.x.layers.x"
"value": "root.layers.x.layers.x"
},
"near_key": null,
"shape": {
@ -288,7 +287,7 @@
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-nested.d2,0:8:8-0:25:25",
"range": ",0:0:0-0:0:0",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-nested.d2,0:0:0-0:6:6",
"path": [
@ -318,12 +317,11 @@
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-nested.d2,0:8:8-0:25:25",
"double_quoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "layers.x.layers.x",
"raw_string": "layers.x.layers.x"
"string": "root.layers.x.layers.x"
}
]
}
@ -507,7 +505,7 @@
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-nested.d2,0:8:8-0:25:25",
"range": ",0:0:0-0:0:0",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-nested.d2,0:0:0-0:6:6",
"path": [
@ -537,12 +535,11 @@
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-nested.d2,0:8:8-0:25:25",
"double_quoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "layers.x.layers.x",
"raw_string": "layers.x.layers.x"
"string": "root.layers.x.layers.x"
}
]
}

View file

@ -7,7 +7,7 @@
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-ok.d2,0:8:8-0:16:16",
"range": ",0:0:0-0:0:0",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-ok.d2,0:0:0-0:6:6",
"path": [
@ -37,12 +37,11 @@
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-ok.d2,0:8:8-0:16:16",
"double_quoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "layers.x",
"raw_string": "layers.x"
"string": "root.layers.x"
}
]
}
@ -205,7 +204,7 @@
},
"style": {},
"link": {
"value": "layers.x"
"value": "root.layers.x"
},
"near_key": null,
"shape": {
@ -230,7 +229,7 @@
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-ok.d2,0:8:8-0:16:16",
"range": ",0:0:0-0:0:0",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-ok.d2,0:0:0-0:6:6",
"path": [
@ -260,12 +259,11 @@
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-ok.d2,0:8:8-0:16:16",
"double_quoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "layers.x",
"raw_string": "layers.x"
"string": "root.layers.x"
}
]
}

View file

@ -4,8 +4,8 @@
"ioerr": null,
"errs": [
{
"range": "d2/testdata/d2compiler/TestCompile/link-board-underscore-not-found.d2,6:16:62-6:21:67",
"errmsg": "d2/testdata/d2compiler/TestCompile/link-board-underscore-not-found.d2:7:17: link key \"_._._\" to board not found"
"range": "d2/testdata/d2compiler/TestCompile/link-board-underscore-not-found.d2,6:4:50-6:14:60",
"errmsg": "d2/testdata/d2compiler/TestCompile/link-board-underscore-not-found.d2:7:5: board referenced by link not found"
}
]
}

View file

@ -149,7 +149,7 @@
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-underscore.d2,6:16:62-6:28:74",
"range": ",0:0:0-0:0:0",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-underscore.d2,6:4:50-6:14:60",
"path": [
@ -179,12 +179,11 @@
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-underscore.d2,6:16:62-6:28:74",
"double_quoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "_._.layers.x",
"raw_string": "_._.layers.x"
"string": "root.layers.x"
}
]
}
@ -193,7 +192,7 @@
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-underscore.d2,7:14:89-7:15:90",
"range": ",0:0:0-0:0:0",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-underscore.d2,7:4:79-7:12:87",
"path": [
@ -223,12 +222,11 @@
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-underscore.d2,7:14:89-7:15:90",
"double_quoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "_",
"raw_string": "_"
"string": "root.layers.x"
}
]
}
@ -483,7 +481,7 @@
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-underscore.d2,6:16:62-6:28:74",
"range": ",0:0:0-0:0:0",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-underscore.d2,6:4:50-6:14:60",
"path": [
@ -513,12 +511,11 @@
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-underscore.d2,6:16:62-6:28:74",
"double_quoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "_._.layers.x",
"raw_string": "_._.layers.x"
"string": "root.layers.x"
}
]
}
@ -527,7 +524,7 @@
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-underscore.d2,7:14:89-7:15:90",
"range": ",0:0:0-0:0:0",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-underscore.d2,7:4:79-7:12:87",
"path": [
@ -557,12 +554,11 @@
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-underscore.d2,7:14:89-7:15:90",
"double_quoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "_",
"raw_string": "_"
"string": "root.layers.x"
}
]
}
@ -817,7 +813,7 @@
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-underscore.d2,6:16:62-6:28:74",
"range": ",0:0:0-0:0:0",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-underscore.d2,6:4:50-6:14:60",
"path": [
@ -847,12 +843,11 @@
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-underscore.d2,6:16:62-6:28:74",
"double_quoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "_._.layers.x",
"raw_string": "_._.layers.x"
"string": "root.layers.x"
}
]
}
@ -861,7 +856,7 @@
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-underscore.d2,7:14:89-7:15:90",
"range": ",0:0:0-0:0:0",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-underscore.d2,7:4:79-7:12:87",
"path": [
@ -891,12 +886,11 @@
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/link-board-underscore.d2,7:14:89-7:15:90",
"double_quoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "_",
"raw_string": "_"
"string": "root.layers.x"
}
]
}
@ -998,7 +992,7 @@
},
"style": {},
"link": {
"value": "_._.layers.x"
"value": "root.layers.x"
},
"near_key": null,
"shape": {
@ -1059,7 +1053,7 @@
},
"style": {},
"link": {
"value": "_"
"value": "root.layers.x"
},
"near_key": null,
"shape": {

View file

@ -31,7 +31,7 @@
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/path_link.d2,1:8:13-1:39:44",
"range": ",0:0:0-0:0:0",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/path_link.d2,1:2:7-1:6:11",
"path": [
@ -50,12 +50,11 @@
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/path_link.d2,1:8:13-1:39:44",
"double_quoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "Overview.Untitled board 7.zzzzz",
"raw_string": "Overview.Untitled board 7.zzzzz"
"string": "root.x.Overview.Untitled board 7.zzzzz"
}
]
}
@ -131,7 +130,7 @@
},
"style": {},
"link": {
"value": "Overview.Untitled board 7.zzzzz"
"value": "root.x.Overview.Untitled board 7.zzzzz"
},
"near_key": null,
"shape": {

View file

@ -31,7 +31,7 @@
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/url_link.d2,1:8:13-1:26:31",
"range": ",0:0:0-0:0:0",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/url_link.d2,1:2:7-1:6:11",
"path": [
@ -50,12 +50,11 @@
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/url_link.d2,1:8:13-1:26:31",
"double_quoted_string": {
"range": ",0:0:0-0:0:0",
"value": [
{
"string": "https://google.com",
"raw_string": "https://google.com"
"string": "root.x.https"
}
]
}
@ -131,7 +130,7 @@
},
"style": {},
"link": {
"value": "https://google.com"
"value": "root.x.https"
},
"near_key": null,
"shape": {