(sql string, start int)
| 298 | } |
| 299 | |
| 300 | func scanBalancedParenthesizedSQL(sql string, start int) (string, int, bool) { |
| 301 | if start >= len(sql) || sql[start] != '(' { |
| 302 | return "", start, false |
| 303 | } |
| 304 | |
| 305 | depth := 0 |
| 306 | for i := start; i < len(sql); { |
| 307 | switch { |
| 308 | case hasLineCommentPrefix(sql, i): |
| 309 | i = scanLineComment(sql, i) |
| 310 | case hasBlockCommentPrefix(sql, i): |
| 311 | i = scanBlockComment(sql, i) |
| 312 | case sql[i] == '\'': |
| 313 | i = scanSingleQuotedString(sql, i) |
| 314 | case sql[i] == '"': |
| 315 | i = scanDoubleQuotedString(sql, i) |
| 316 | case sql[i] == '[': |
| 317 | i = scanBracketIdentifier(sql, i) |
| 318 | case sql[i] == '(': |
| 319 | depth++ |
| 320 | i++ |
| 321 | case sql[i] == ')': |
| 322 | depth-- |
| 323 | i++ |
| 324 | if depth == 0 { |
| 325 | return sql[start:i], i, true |
| 326 | } |
| 327 | default: |
| 328 | i++ |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | return "", start, false |
| 333 | } |
| 334 | |
| 335 | func hasKeywordAt(sql string, pos int, keyword string) bool { |
| 336 | if pos < 0 || pos+len(keyword) > len(sql) { |
no test coverage detected