d2oracle: don't modify classes

This commit is contained in:
Alexander Wang 2023-04-17 18:55:43 -07:00
parent 7f3c2c7121
commit e0b4c09df1
No known key found for this signature in database
GPG key ID: D89FA31966BDBECE
7 changed files with 1376 additions and 33 deletions

View file

@ -1177,3 +1177,27 @@ func (m *Map) Equal(n2 Node) bool {
return true
}
func (m *Map) InClass(key *d2ast.Key) bool {
classes := m.Map().GetField("classes")
if classes == nil || classes.Map() == nil {
return false
}
for _, class := range classes.Map().Fields {
if class.Map() == nil {
continue
}
classF := class.Map().GetField(key.Key.IDA()...)
if classF == nil {
continue
}
for _, ref := range classF.References {
if ref.Context.Key == key {
return true
}
}
}
return false
}

View file

@ -17,6 +17,7 @@ import (
"oss.terrastruct.com/d2/d2compiler"
"oss.terrastruct.com/d2/d2format"
"oss.terrastruct.com/d2/d2graph"
"oss.terrastruct.com/d2/d2ir"
"oss.terrastruct.com/d2/d2parser"
"oss.terrastruct.com/d2/d2target"
)
@ -180,6 +181,10 @@ func _set(g *d2graph.Graph, key string, tag, value *string) error {
}
}
ir, err := d2ir.Compile(g.AST)
if err != nil {
return err
}
attrs := obj.Attributes
var edge *d2graph.Edge
if len(mk.Edges) == 1 {
@ -273,6 +278,9 @@ func _set(g *d2graph.Graph, key string, tag, value *string) error {
}
if reserved {
inlined := func(s *d2graph.Scalar) bool {
return s != nil && s.MapKey != nil && !ir.InClass(s.MapKey)
}
reservedIndex := toSkip - 1
if mk.Key != nil && len(mk.Key.Path) > 0 {
if reservedKey == "" {
@ -280,62 +288,62 @@ func _set(g *d2graph.Graph, key string, tag, value *string) error {
}
switch reservedKey {
case "shape":
if attrs.Shape.MapKey != nil {
if inlined(&attrs.Shape) {
attrs.Shape.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "link":
if attrs.Link != nil && attrs.Link.MapKey != nil {
if inlined(attrs.Link) {
attrs.Link.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "tooltip":
if attrs.Tooltip != nil && attrs.Tooltip.MapKey != nil {
if inlined(attrs.Tooltip) {
attrs.Tooltip.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "width":
if attrs.WidthAttr != nil && attrs.WidthAttr.MapKey != nil {
if inlined(attrs.WidthAttr) {
attrs.WidthAttr.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "height":
if attrs.HeightAttr != nil && attrs.HeightAttr.MapKey != nil {
if inlined(attrs.HeightAttr) {
attrs.HeightAttr.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "top":
if attrs.Top != nil && attrs.Top.MapKey != nil {
if inlined(attrs.Top) {
attrs.Top.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "left":
if attrs.Left != nil && attrs.Left.MapKey != nil {
if inlined(attrs.Left) {
attrs.Left.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "grid-rows":
if attrs.GridRows != nil && attrs.GridRows.MapKey != nil {
if inlined(attrs.GridRows) {
attrs.GridRows.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "grid-columns":
if attrs.GridColumns != nil && attrs.GridColumns.MapKey != nil {
if inlined(attrs.GridColumns) {
attrs.GridColumns.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "grid-gap":
if attrs.GridGap != nil && attrs.GridGap.MapKey != nil {
if inlined(attrs.GridGap) {
attrs.GridGap.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "vertical-gap":
if attrs.VerticalGap != nil && attrs.VerticalGap.MapKey != nil {
if inlined(attrs.VerticalGap) {
attrs.VerticalGap.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "horizontal-gap":
if attrs.HorizontalGap != nil && attrs.HorizontalGap.MapKey != nil {
if inlined(attrs.HorizontalGap) {
attrs.HorizontalGap.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
@ -355,12 +363,12 @@ func _set(g *d2graph.Graph, key string, tag, value *string) error {
}
switch reservedTargetKey {
case "shape":
if arrowhead.Shape.MapKey != nil {
if inlined(&arrowhead.Shape) {
arrowhead.Shape.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "label":
if arrowhead.Label.MapKey != nil {
if inlined(&arrowhead.Label) {
arrowhead.Label.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
@ -375,98 +383,98 @@ func _set(g *d2graph.Graph, key string, tag, value *string) error {
}
switch reservedTargetKey {
case "opacity":
if attrs.Style.Opacity != nil {
if inlined(attrs.Style.Opacity) {
attrs.Style.Opacity.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "stroke":
if attrs.Style.Stroke != nil {
if inlined(attrs.Style.Stroke) {
attrs.Style.Stroke.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "fill":
if attrs.Style.Fill != nil {
if inlined(attrs.Style.Fill) {
attrs.Style.Fill.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "stroke-width":
if attrs.Style.StrokeWidth != nil {
if inlined(attrs.Style.StrokeWidth) {
attrs.Style.StrokeWidth.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "stroke-dash":
if attrs.Style.StrokeDash != nil {
if inlined(attrs.Style.StrokeDash) {
attrs.Style.StrokeDash.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "border-radius":
if attrs.Style.BorderRadius != nil {
if inlined(attrs.Style.BorderRadius) {
attrs.Style.BorderRadius.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "shadow":
if attrs.Style.Shadow != nil {
if inlined(attrs.Style.Shadow) {
attrs.Style.Shadow.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "3d":
if attrs.Style.ThreeDee != nil {
if inlined(attrs.Style.ThreeDee) {
attrs.Style.ThreeDee.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "multiple":
if attrs.Style.Multiple != nil {
if inlined(attrs.Style.Multiple) {
attrs.Style.Multiple.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "double-border":
if attrs.Style.DoubleBorder != nil {
if inlined(attrs.Style.DoubleBorder) {
attrs.Style.DoubleBorder.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "font":
if attrs.Style.Font != nil {
if inlined(attrs.Style.Font) {
attrs.Style.Font.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "font-size":
if attrs.Style.FontSize != nil {
if inlined(attrs.Style.FontSize) {
attrs.Style.FontSize.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "font-color":
if attrs.Style.FontColor != nil {
if inlined(attrs.Style.FontColor) {
attrs.Style.FontColor.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "animated":
if attrs.Style.Animated != nil {
if inlined(attrs.Style.Animated) {
attrs.Style.Animated.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "bold":
if attrs.Style.Bold != nil {
if inlined(attrs.Style.Bold) {
attrs.Style.Bold.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "italic":
if attrs.Style.Italic != nil {
if inlined(attrs.Style.Italic) {
attrs.Style.Italic.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "underline":
if attrs.Style.Underline != nil {
if inlined(attrs.Style.Underline) {
attrs.Style.Underline.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "fill-pattern":
if attrs.Style.FillPattern != nil {
if inlined(attrs.Style.FillPattern) {
attrs.Style.FillPattern.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
}
case "label":
if attrs.Label.MapKey != nil {
if inlined(&attrs.Label) {
attrs.Label.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}

View file

@ -859,6 +859,85 @@ square.style.opacity: 0.2
exp: `square: {
style.fill-pattern: grain
}
`,
},
{
name: "classes-style",
text: `classes: {
a: {
style.fill: red
}
}
b.class: a
`,
key: `b.style.fill`,
value: go2.Pointer(`green`),
exp: `classes: {
a: {
style.fill: red
}
}
b.class: a
b.style.fill: green
`,
},
{
name: "dupe-classes-style",
text: `classes: {
a: {
style.fill: red
}
}
b.class: a
b.style.fill: red
`,
key: `b.style.fill`,
value: go2.Pointer(`green`),
exp: `classes: {
a: {
style.fill: red
}
}
b.class: a
b.style.fill: green
`,
},
{
name: "unapplied-classes-style",
text: `classes: {
a: {
style.fill: red
}
}
b.style.fill: red
`,
key: `b.style.fill`,
value: go2.Pointer(`green`),
exp: `classes: {
a: {
style.fill: red
}
}
b.style.fill: green
`,
},
{
name: "unapplied-classes-style-2",
text: `classes: {
a: {
style.fill: red
}
}
b
`,
key: `b.style.fill`,
value: go2.Pointer(`green`),
exp: `classes: {
a: {
style.fill: red
}
}
b: {style.fill: green}
`,
},
{

348
testdata/d2oracle/TestSet/classes-style.exp.json generated vendored Normal file
View file

@ -0,0 +1,348 @@
{
"graph": {
"name": "",
"isFolderOnly": false,
"ast": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,0:0:0-7:0:75",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,0:0:0-4:1:43",
"key": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,0:0:0-0:7:7",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,0:0:0-0:7:7",
"value": [
{
"string": "classes",
"raw_string": "classes"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,0:9:9-4:0:42",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,1:2:13-3:3:41",
"key": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,1:2:13-1:3:14",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,1:2:13-1:3:14",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,1:5:16-3:2:40",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,2:4:22-2:19:37",
"key": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,2:4:22-2:14:32",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,2:4:22-2:9:27",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,2:10:28-2:14:32",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,2:16:34-2:19:37",
"value": [
{
"string": "red",
"raw_string": "red"
}
]
}
}
}
}
]
}
}
}
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,5:0:44-5:10:54",
"key": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,5:0:44-5:7:51",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,5:0:44-5:1:45",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,5:2:46-5:7:51",
"value": [
{
"string": "class",
"raw_string": "class"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,5:9:53-5:10:54",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,6:0:55-6:19:74",
"key": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,6:0:55-6:12:67",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,6:0:55-6:1:56",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,6:2:57-6:7:62",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,6:8:63-6:12:67",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,6:14:69-6:19:74",
"value": [
{
"string": "green",
"raw_string": "green"
}
]
}
}
}
}
]
},
"root": {
"id": "",
"id_val": "",
"attributes": {
"label": {
"value": ""
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": ""
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
},
"edges": null,
"objects": [
{
"id": "b",
"id_val": "b",
"references": [
{
"key": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,5:0:44-5:7:51",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,5:0:44-5:1:45",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,5:2:46-5:7:51",
"value": [
{
"string": "class",
"raw_string": "class"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
},
{
"key": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,6:0:55-6:12:67",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,6:0:55-6:1:56",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,6:2:57-6:7:62",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/classes-style.d2,6:8:63-6:12:67",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "b"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {
"fill": {
"value": "green"
}
},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
},
"classes": [
"a"
]
},
"zIndex": 0
}
]
},
"err": "<nil>"
}

348
testdata/d2oracle/TestSet/dupe-classes-style.exp.json generated vendored Normal file
View file

@ -0,0 +1,348 @@
{
"graph": {
"name": "",
"isFolderOnly": false,
"ast": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,0:0:0-7:0:75",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,0:0:0-4:1:43",
"key": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,0:0:0-0:7:7",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,0:0:0-0:7:7",
"value": [
{
"string": "classes",
"raw_string": "classes"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,0:9:9-4:0:42",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,1:2:13-3:3:41",
"key": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,1:2:13-1:3:14",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,1:2:13-1:3:14",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,1:5:16-3:2:40",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,2:4:22-2:19:37",
"key": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,2:4:22-2:14:32",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,2:4:22-2:9:27",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,2:10:28-2:14:32",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,2:16:34-2:19:37",
"value": [
{
"string": "red",
"raw_string": "red"
}
]
}
}
}
}
]
}
}
}
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,5:0:44-5:10:54",
"key": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,5:0:44-5:7:51",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,5:0:44-5:1:45",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,5:2:46-5:7:51",
"value": [
{
"string": "class",
"raw_string": "class"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,5:9:53-5:10:54",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,6:0:55-6:19:74",
"key": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,6:0:55-6:12:67",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,6:0:55-6:1:56",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,6:2:57-6:7:62",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,6:8:63-6:12:67",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,6:14:69-6:19:74",
"value": [
{
"string": "green",
"raw_string": "green"
}
]
}
}
}
}
]
},
"root": {
"id": "",
"id_val": "",
"attributes": {
"label": {
"value": ""
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": ""
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
},
"edges": null,
"objects": [
{
"id": "b",
"id_val": "b",
"references": [
{
"key": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,5:0:44-5:7:51",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,5:0:44-5:1:45",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,5:2:46-5:7:51",
"value": [
{
"string": "class",
"raw_string": "class"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
},
{
"key": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,6:0:55-6:12:67",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,6:0:55-6:1:56",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,6:2:57-6:7:62",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/dupe-classes-style.d2,6:8:63-6:12:67",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "b"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {
"fill": {
"value": "green"
}
},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
},
"classes": [
"a"
]
},
"zIndex": 0
}
]
},
"err": "<nil>"
}

View file

@ -0,0 +1,266 @@
{
"graph": {
"name": "",
"isFolderOnly": false,
"ast": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style-2.d2,0:0:0-6:0:67",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style-2.d2,0:0:0-4:1:43",
"key": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style-2.d2,0:0:0-0:7:7",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style-2.d2,0:0:0-0:7:7",
"value": [
{
"string": "classes",
"raw_string": "classes"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style-2.d2,0:9:9-4:0:42",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style-2.d2,1:2:13-3:3:41",
"key": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style-2.d2,1:2:13-1:3:14",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style-2.d2,1:2:13-1:3:14",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style-2.d2,1:5:16-3:2:40",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style-2.d2,2:4:22-2:19:37",
"key": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style-2.d2,2:4:22-2:14:32",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style-2.d2,2:4:22-2:9:27",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style-2.d2,2:10:28-2:14:32",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style-2.d2,2:16:34-2:19:37",
"value": [
{
"string": "red",
"raw_string": "red"
}
]
}
}
}
}
]
}
}
}
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style-2.d2,5:0:44-5:22:66",
"key": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style-2.d2,5:0:44-5:1:45",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style-2.d2,5:0:44-5:1:45",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style-2.d2,5:3:47-5:21:65",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style-2.d2,5:4:48-5:21:65",
"key": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style-2.d2,5:4:48-5:14:58",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style-2.d2,5:4:48-5:9:53",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style-2.d2,5:10:54-5:14:58",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style-2.d2,5:16:60-5:21:65",
"value": [
{
"string": "green",
"raw_string": "green"
}
]
}
}
}
}
]
}
}
}
}
]
},
"root": {
"id": "",
"id_val": "",
"attributes": {
"label": {
"value": ""
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": ""
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
},
"edges": null,
"objects": [
{
"id": "b",
"id_val": "b",
"references": [
{
"key": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style-2.d2,5:0:44-5:1:45",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style-2.d2,5:0:44-5:1:45",
"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": {
"fill": {
"value": "green"
}
},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
}
]
},
"err": "<nil>"
}

View file

@ -0,0 +1,270 @@
{
"graph": {
"name": "",
"isFolderOnly": false,
"ast": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style.d2,0:0:0-6:0:64",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style.d2,0:0:0-4:1:43",
"key": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style.d2,0:0:0-0:7:7",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style.d2,0:0:0-0:7:7",
"value": [
{
"string": "classes",
"raw_string": "classes"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style.d2,0:9:9-4:0:42",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style.d2,1:2:13-3:3:41",
"key": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style.d2,1:2:13-1:3:14",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style.d2,1:2:13-1:3:14",
"value": [
{
"string": "a",
"raw_string": "a"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style.d2,1:5:16-3:2:40",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style.d2,2:4:22-2:19:37",
"key": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style.d2,2:4:22-2:14:32",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style.d2,2:4:22-2:9:27",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style.d2,2:10:28-2:14:32",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style.d2,2:16:34-2:19:37",
"value": [
{
"string": "red",
"raw_string": "red"
}
]
}
}
}
}
]
}
}
}
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style.d2,5:0:44-5:19:63",
"key": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style.d2,5:0:44-5:12:56",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style.d2,5:0:44-5:1:45",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style.d2,5:2:46-5:7:51",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style.d2,5:8:52-5:12:56",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style.d2,5:14:58-5:19:63",
"value": [
{
"string": "green",
"raw_string": "green"
}
]
}
}
}
}
]
},
"root": {
"id": "",
"id_val": "",
"attributes": {
"label": {
"value": ""
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": ""
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
},
"edges": null,
"objects": [
{
"id": "b",
"id_val": "b",
"references": [
{
"key": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style.d2,5:0:44-5:12:56",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style.d2,5:0:44-5:1:45",
"value": [
{
"string": "b",
"raw_string": "b"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style.d2,5:2:46-5:7:51",
"value": [
{
"string": "style",
"raw_string": "style"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/unapplied-classes-style.d2,5:8:52-5:12:56",
"value": [
{
"string": "fill",
"raw_string": "fill"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "b"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {
"fill": {
"value": "green"
}
},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
}
]
},
"err": "<nil>"
}