(result, message string, scopes []string)
| 395 | } |
| 396 | |
| 397 | func appendKnownFieldSuggestions(result, message string, scopes []string) string { |
| 398 | if len(scopes) == 0 { |
| 399 | return result |
| 400 | } |
| 401 | m := unknownPropertyPattern.FindStringSubmatch(message) |
| 402 | if len(m) != 2 { |
| 403 | return result |
| 404 | } |
| 405 | |
| 406 | unknownProps := strings.Split(m[1], ", ") |
| 407 | unique := uniqueClosestScopeSuggestions(unknownProps, scopes) |
| 408 | if len(unique) == 1 { |
| 409 | return fmt.Sprintf("%s. Did you mean '%s'?", result, unique[0]) |
| 410 | } |
| 411 | if len(unique) > 1 { |
| 412 | return fmt.Sprintf("%s. Did you mean: %s?", result, strings.Join(unique, ", ")) |
| 413 | } |
| 414 | return result |
| 415 | } |
| 416 | |
| 417 | func uniqueClosestScopeSuggestions(unknownProps []string, scopes []string) []string { |
| 418 | var allSuggestions []string |
no test coverage detected