| 140 | } |
| 141 | |
| 142 | func (n *MemberNode) String() string { |
| 143 | node := n.Node.String() |
| 144 | if _, ok := n.Node.(*BinaryNode); ok { |
| 145 | node = fmt.Sprintf("(%s)", node) |
| 146 | } |
| 147 | |
| 148 | if n.Optional { |
| 149 | if str, ok := n.Property.(*StringNode); ok && utils.IsValidIdentifier(str.Value) { |
| 150 | return fmt.Sprintf("%s?.%s", node, str.Value) |
| 151 | } else { |
| 152 | return fmt.Sprintf("%s?.[%s]", node, n.Property.String()) |
| 153 | } |
| 154 | } |
| 155 | if str, ok := n.Property.(*StringNode); ok && utils.IsValidIdentifier(str.Value) { |
| 156 | if _, ok := n.Node.(*PointerNode); ok { |
| 157 | return fmt.Sprintf(".%s", str.Value) |
| 158 | } |
| 159 | return fmt.Sprintf("%s.%s", node, str.Value) |
| 160 | } |
| 161 | return fmt.Sprintf("%s[%s]", node, n.Property.String()) |
| 162 | } |
| 163 | |
| 164 | func (n *SliceNode) String() string { |
| 165 | if n.From == nil && n.To == nil { |