IsStringy returns true if a Node is a string or is an expression starting with a string (e.g. a string concatenation expression).
()
| 468 | // or is an expression starting with a string |
| 469 | // (e.g. a string concatenation expression). |
| 470 | func (n *Node) IsStringy() bool { |
| 471 | if n.Type() == "string" { |
| 472 | return true |
| 473 | } |
| 474 | |
| 475 | c := n.Content() |
| 476 | if len(c) == 0 { |
| 477 | return false |
| 478 | } |
| 479 | |
| 480 | switch c[0:1] { |
| 481 | case `"`, "'", "`": |
| 482 | return true |
| 483 | default: |
| 484 | return false |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | // CaptureName returns the name given to a node in a |
| 489 | // query if one exists, and an empty string otherwise |
no test coverage detected