CollapsedString takes a node representing a URL and attempts to make it at least somewhat easily parseable. It's common to build URLs out of variables and function calls so we want to turn something like: './upload.php?profile='+res.id+'&show='+$('.participate_modal_container').attr('data-val') In
()
| 177 | // |
| 178 | // The value of ExpressionPlaceholder is used as a placeholder, defaulting to 'EXPR' |
| 179 | func (n *Node) CollapsedString() string { |
| 180 | if !n.IsValid() { |
| 181 | return "" |
| 182 | } |
| 183 | switch n.Type() { |
| 184 | case "binary_expression": |
| 185 | return fmt.Sprintf( |
| 186 | "%s%s", |
| 187 | n.ChildByFieldName("left").CollapsedString(), |
| 188 | n.ChildByFieldName("right").CollapsedString(), |
| 189 | ) |
| 190 | case "string": |
| 191 | return n.RawString() |
| 192 | default: |
| 193 | return ExpressionPlaceholder |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | // IsValid returns true if the *Node and the underlying |
| 198 | // tree-sitter node are both not nil. |